import OAI.Analysis.BernoulliCone.BoundedCalibration namespace OAI section noncomputable section open Set Filter InnerProductSpace open scoped Topology ContDiff namespace Bernoulli.DeSilvaJerison lemma upperFamily_eq_cap {x:Space 7} {l:ℝ} (hl:0κ*z.2*smoothCap (z.2⁻¹ • z.1.1)-z.1.2 have hi:ContDiffAt ℝ ∞ (fun z:(Space 7×ℝ)×ℝ=>z.2⁻¹ • z.1.1) (p,l):= (contDiffAt_snd.inv hl.ne').smul (contDiffAt_fst.fst) have hF:ContDiffAt ℝ ∞ F (p,l):= ((contDiffAt_const.mul contDiffAt_snd).mul (hc.comp (p,l) hi)).sub contDiffAt_fst.snd let ρ:=κ*(smoothCap (l⁻¹ • p.1)-inner ℝ (l⁻¹ • p.1) (gradient smoothCap (l⁻¹ • p.1))) have hρ:0<ρ:=mul_pos κ_pos (smoothCap_radial_defect_pos hq hpc) have hd:HasDerivAt (fun s:ℝ=>F (p,s)) ρ l := by have hh:=((Foliation.hasDerivAt_dilate p.1 hl.ne' (hc.differentiableAt (by simp))).const_mul κ).sub_const p.2 simpa only [F,mul_assoc] using hh obtain ⟨ψ,hψ,hψ0,hψeq,huniq⟩:=Foliation.scalar_implicit_unique hF hd hρ.ne' refine ⟨ψ,hψ,hψ0,?_⟩ have hF0:F (p,l)=0:=by dsimp [F] rw [←upperFamily_eq_cap hl hpos hq,he,sub_self] have ht:Tendsto (fun z:Space 7×ℝ=>(z,upperParameter z.1 z.2)) (𝓝 p) (𝓝 (p,l)):= tendsto_id.prodMk_nhds (upperParameter_continuousAt hp) filter_upwards [ht.eventually huniq] with z hz hzp hzq apply hz.mp rw [hF0] dsimp [F] have hzpos:0κ • gradient smoothCap ((ψ z)⁻¹ • z.1) have hψp:ψ p≠0:=by rw [hψ0]; exact (upperParameter_spec hp).1.ne' have hn:ContDiffAt ℝ ∞ (fun z:Space 7×ℝ=>(ψ z)⁻¹ • z.1) p:= (hψ.inv hψp).smul contDiffAt_fst have hg:ContDiffAt ℝ ∞ (gradient smoothCap) ((ψ p)⁻¹ • p.1):=by rw [hψ0]; exact gradient_smoothCap_contDiffAt hq refine ⟨B,(hg.comp p hn).const_smul κ,?_,?_⟩ · simp only [B,hψ0,upperFlux,ite_eq_left hp,ite_eq_left hq] · filter_upwards [he] with z hz hzp hzq simp only [B,hz hzp hzq,upperFlux,ite_eq_left hzp,ite_eq_left hzq] end Bernoulli.DeSilvaJerison end end end OAI