import Mathlib import OAI.Geometry.BallPacking.SurfaceArea.BoundedPlanarResidue namespace OAI noncomputable section namespace PackingSufficiencySupport.CubicModel open scoped ContDiff Manifold Topology BigOperators open Set Function Filter Manifold open DiagonalQuadrics DiagonalQuadrics.Explicit Hamiltonian FiniteMoment open MeasureTheory theorem radialEndProbability_contDiffAt {A B : ℕ} (hA : 0 radialEndProbability Radial.latticeIndex D m p ε z i) y := ((radialProbability_smooth hA hAB D m hp i).contMDiffAt.comp y ((infinityDiffeomorph (parameters 0) ε).contMDiffOn.contMDiffAt ((infinityDiffeomorph (parameters 0) ε).open_source.mem_nhds hy))).contDiffAt theorem radialEndRegularPrimitive_contDiffAt {A B : ℕ} (hA : 0 (radialEndProbability_contDiffAt hA hAB D m hp ε hy i).smul (weightedRegularEndPrimitive_contDiffAt (D i) (m i) ε c hR)) theorem radialEndResidue_contDiffAt {A B : ℕ} (hA : 0 (radialEndProbability_contDiffAt hA hAB D m hp ε hy i).mul contDiffAt_const) local instance cubicRadialEndSmoothSigmaCompact : SigmaCompactSpace BaseCurve := curveSigmaCompact (parameters 0) theorem tendsto_radial_cubic_cutoff_mass {A B D S : ℕ} (hA : 0 surfaceCutoffMass (shrinking_curveEndCutoff_compact (parameters 0) hr h1 n) (radialForm (Radial.latticeIndex (A := A) (B := B)) (cubicDegree D) (cubicMarkedOrder S) c p)) atTop (𝓝 (c*(3*((D:ℝ)-3*(p.1+p.2))-2*markedHeight S (planeVector p.1 p.2))*Real.pi)) := by obtain ⟨Mlog,hMlog,hlog⟩ := exists_regularCoefficient_log_bound (cubicDegree D (A := A) (B := B)) (cubicMarkedOrder S) hR obtain ⟨M,hM,hbound⟩ := exists_regularPrimitive_bound (cubicDegree D (A := A) (B := B)) (cubicMarkedOrder S) c hR obtain ⟨K,hK⟩ := (hg.continuous_deriv (by simp)).bounded_above_of_compact_support hgc.deriv have hK0 : 0≤K := (norm_nonneg (deriv g 0)).trans (hK 0) have hKg (t : ℝ) : |deriv g t|≤K := by simpa only [Real.norm_eq_abs] using hK t have hpoint (ε : EndIndex) (n : ℕ) (y : Plane) (hy : y∈radialAnnulus (r/((n:ℝ)+1)) (R/((n:ℝ)+1))) : y∈(infinityDiffeomorph (parameters 0) ε).source ∧ Complex.equivRealProdCLM.symm y∈endRegularRegion ∧ y∈radialAnnulus 0 R ∧ 0 (hR (hs.trans (div_le_self hRp.le hn))).1 exact ⟨radialAnnulus_in_end (parameters 0) (div_pos hr (by positivity)) hRI ε hy, hxR,hys,(div_pos hr (by positivity)).trans_le hy.1,hys.2.trans_lt hR1⟩ have ht := tendsto_curveCutoff_bounded_residue (parameters 0) (radialPrimitive (Radial.latticeIndex (A := A) (B := B)) (cubicDegree D) (cubicMarkedOrder S) c p) (radialPrimitive_smooth hA hAB _ _ c hp) (radialForm (Radial.latticeIndex (A := A) (B := B)) (cubicDegree D) (cubicMarkedOrder S) c p) (radialForm_smooth hA hAB _ _ c hp) (radialForm_skew _ _ _ c p) rfl hg hgc hr hRp.le (fun s hs => (hR hs).1) h1 h0 hK0 hM hKg (fun ε => c*limitingEndOrder D S (planeVector p.1 p.2) ε) (logarithmicError (|c| * (2*Mlog+Fintype.card (TrapezoidWeight A B))) R) (fun n => logarithmicError_nonneg (by positivity) hRp hR1 n) (tendsto_logarithmicError hRp _) (radialEndRegularPrimitive (Radial.latticeIndex (A := A) (B := B)) (cubicDegree D) (cubicMarkedOrder S) c p) (radialEndResidue (Radial.latticeIndex (A := A) (B := B)) (cubicDegree D) (cubicMarkedOrder S) c p) (fun ε n y hy => (radialEndRegularPrimitive_contDiffAt hA hAB _ _ c hp ε (hpoint ε n y hy).1 (hpoint ε n y hy).2.1).continuousAt.continuousWithinAt) (fun ε n y hy => (radialEndResidue_contDiffAt hA hAB _ _ c hp ε (hpoint ε n y hy).1).continuousAt.continuousWithinAt) (fun ε n y hy => radialEndRegularPrimitive_norm_le (Radial.lattice_zero A B) _ _ c p ε y (fun k => hbound k ε y (hpoint ε n y hy).2.2.1)) (fun ε n y hy => by have hh := radialEndResidue_error hA hS0 hAB hSB hB hS hp ε (hpoint ε n y hy).1 (hpoint ε n y hy).2.1 (hpoint ε n y hy).2.2.2.1 (hpoint ε n y hy).2.2.2.2 hMlog (fun k => hlog k ε y (hpoint ε n y hy).2.2.1) c apply hh.trans rw [←mul_div_assoc] exact logarithmicError_bound (by positivity) hRp hR1 n (hpoint ε n y hy).2.2.2.1 hy.2) (fun ε n y hy => radialPrimitive_infinity (Radial.latticeIndex (A := A) (B := B)) (fun k => (cubicMarked_lt_degree hB hS k).le) (fun k => cubicMarked_twice_complement hB hS k) c p ε (hpoint ε n y hy).1 (hpoint ε n y hy).2.1) rw [←Finset.mul_sum] at ht rw [sum_limitingEndOrder] at ht exact ht end PackingSufficiencySupport.CubicModel namespace PackingSufficiencySupport.FiniteMoment.Radial open scoped BigOperators Topology ContDiff open Set Filter Function def latticeOrigin (A B : ℕ) : TrapezoidWeight A B := ⟨(⟨0,by omega⟩,⟨0,by omega⟩),by simp⟩ theorem latticeIndex_injective (A B : ℕ) : Injective (latticeIndex (A:=A) (B:=B)) := by intro i j h apply Subtype.ext apply Prod.ext · exact Fin.ext (congrArg Prod.fst h) · exact Fin.ext (congrArg Prod.snd h) theorem monomial_origin (k : ℕ × ℕ) : monomial k (0,0)=if k=(0,0) then 1 else 0 := by classical by_cases h0 : k.1=0 <;> by_cases h1 : k.2=0 · have hk : k=(0,0) := Prod.ext h0 h1 simp [hk,monomial] · have hk : k≠(0,0) := fun h => h1 (congrArg Prod.snd h) simp [monomial,h0,h1,hk] · have hk : k≠(0,0) := fun h => h0 (congrArg Prod.fst h) simp [monomial,h0,h1,hk] · have hk : k≠(0,0) := fun h => h0 (congrArg Prod.fst h) simp [monomial,h0,h1,hk] theorem lattice_monomial_origin {A B : ℕ} (i : TrapezoidWeight A B) : monomial (latticeIndex i) (0,0)=if i=latticeOrigin A B then 1 else 0 := by rw [monomial_origin] have he : latticeIndex i=(0,0) ↔ i=latticeOrigin A B := ⟨fun h => latticeIndex_injective A B h,fun h => by simp [h,latticeOrigin,latticeIndex]⟩ simp only [he] theorem lattice_polynomial_origin {A B : ℕ} (a : TrapezoidWeight A B → ℝ) : polynomial latticeIndex a (0,0)=a (latticeOrigin A B) := by classical simp [polynomial,lattice_monomial_origin] theorem lattice_probability_origin {A B : ℕ} {a : TrapezoidWeight A B → ℝ} (ha : 0 coefficientNorm (D j) (m j) x) r=p) : radialPrimitive (fun j => (k j).swap) D m c p.swap=radialPrimitive k D m c p := by funext x apply Finset.sum_congr rfl intro i _ rw [radialProbability,Radial.selected_swap (fun j => coefficientNorm_pos (D j) (m j) x) h0 he0 he1 (hp x)] rfl theorem radialPrimitive_origin {A B : ℕ} (hA : 0 coefficientNorm_pos (D j) (m j) x)] simp theorem radialForm_face_positive {k : ι → ℕ × ℕ} (h0 : ∃ i,k i=(0,0)) (he0 : ∃ i,k i=(1,0)) (he1 : ∃ i,k i=(0,1)) {D m : ι → ℕ} (hm : ∀ i,m i D i.val) (m := fun i : Radial.Face k => m i.val) (fun i => hm i.val) hc hp b hy exact hh theorem radialForm_positive {A B : ℕ} (hA : 0 Radial.trapezoid_radial_surjective hAB (fun j => coefficientNorm_pos (D j) (m j) x) hp)] have he : p.swap=(0,p.1) := Prod.ext hp1 rfl rw [he] exact radialForm_face_positive h0' he0' he1' hm hc (Radial.face_surrounds h0' hend ⟨hpos,hp.2.1⟩) b hy · let : Nonempty (TrapezoidWeight A B) := ⟨Radial.latticeOrigin A B⟩ have hs : Surrounds (Radial.weight Radial.latticeIndex) (planeVector p.1 p.2) := trapezoidWeight_surrounds hAB ⟨hpos,hp.2.1,lt_of_le_of_ne hp.2.2.1 (Ne.symm hp1),hp.2.2.2⟩ rw [radialForm,radialPrimitive_eq_reduced h0 he0 he1 D m c hs] exact reducedForm_positive hm hc hs b hy end def regularEndPhase (ε : EndIndex) (y : Plane) : PlanePhase HomogeneousIndex := complexCartesian (endRegular ε (Complex.equivRealProdCLM.symm y)) def regularEndPrimitive (ε : EndIndex) (c : ℝ) : Plane → Plane →L[ℝ] ℝ := staticPullbackOneForm (hopfPrimitive c) (regularEndPhase ε) def endResidue (ε : EndIndex) (c : ℝ) : ℝ := if ε=zeroEnd then 0 else c theorem regularEndPhase_contDiffAt (ε : EndIndex) {y : Plane} (hy : Complex.equivRealProdCLM.symm y∈endRegularRegion) : ContDiffAt ℝ ∞ (regularEndPhase ε) y := (complexCartesian (ι := HomogeneousIndex)).contDiff.contDiffAt.comp y (((endRegular_contDiffAt ε hy).restrict_scalars ℝ).comp y Complex.equivRealProdCLM.symm.contDiff.contDiffAt) theorem regularEndPrimitive_contDiffAt (ε : EndIndex) (c : ℝ) {y : Plane} (hy : Complex.equivRealProdCLM.symm y∈endRegularRegion) : ContDiffAt ℝ ∞ (regularEndPrimitive ε c) y := staticPullbackOneForm_smoothAt (hopfPrimitive_smoothAt c (endRegular_cartesian_ne_zero ε _)) (regularEndPhase_contDiffAt ε hy) theorem endRegular_scale {ε : EndIndex} (hε : ε≠zeroEnd) {s : ℂ} (hs : s≠0) : endRegular ε s=s•complexAffineLift (endQuotient ε s) := by rw [endQuotient_homogeneous hε hs,smul_smul,mul_inv_cancel₀ hs,one_smul] theorem endQuotientPrimitive_residue (ε : EndIndex) (c : ℝ) {y : Plane} (hy : Complex.equivRealProdCLM.symm y∈endRegularRegion) (h0 : Complex.equivRealProdCLM.symm y≠0) (v : Plane) : affineFSPrimitive c (complexCartesian (endQuotient ε (Complex.equivRealProdCLM.symm y))) (fderiv ℝ (fun z : Plane => complexCartesian (endQuotient ε (Complex.equivRealProdCLM.symm z))) y v)= regularEndPrimitive ε c y v-(endResidue ε c/2)*angularOneForm y v := by let Q : Plane → AffineIndex → ℂ := fun z => endQuotient ε (Complex.equivRealProdCLM.symm z) have hQ : DifferentiableAt ℝ Q y := (((endQuotient_contDiffAt ε ⟨h0,hy.1⟩).restrict_scalars ℝ).differentiableAt (by simp)).comp y Complex.equivRealProdCLM.symm.differentiableAt have hp := affineFSPrimitive_hopf_pullback hQ c v change _ =_ at hp have hN : complexCartesian (complexAffineLift (Q y))≠0 := by intro hz have hf : complexAffineLift (Q y)=0 := by apply (complexCartesian (ι := HomogeneousIndex)).injective simpa only [map_zero] using hz exact one_ne_zero (congrFun hf none) by_cases hε : ε=zeroEnd · have he : regularEndPhase ε=ᶠ[𝓝 y] fun z => complexCartesian (complexAffineLift (Q z)) := by have hR := endRegularRegion_open.preimage Complex.equivRealProdCLM.symm.continuous have hZ := (isOpen_ne_fun Complex.equivRealProdCLM.symm.continuous continuous_const).mem_nhds h0 filter_upwards [hR.mem_nhds hy,hZ] with z hz hz0 simp only [regularEndPhase,endRegular,ite_eq_left hε] congr 2 exact (endQuotient_zeroEnd hz0 hz).symm.trans (congrArg (fun ε => endQuotient ε _) hε.symm) change _=hopfPrimitive c (regularEndPhase ε y) (fderiv ℝ (regularEndPhase ε) y v)-_ rw [he.eq_of_nhds,he.fderiv_eq] rw [show endResidue ε c=0 from ite_eq_left hε] simpa only [zero_div,zero_mul,sub_zero] using hp.symm · have he : regularEndPhase ε=ᶠ[𝓝 y] fun z => complexCartesian ((Complex.equivRealProdCLM.symm z)•complexAffineLift (Q z)) := by filter_upwards [(isOpen_ne_fun Complex.equivRealProdCLM.symm.continuous continuous_const).mem_nhds h0] with z hz exact congrArg complexCartesian (endRegular_scale hε hz) have hG : DifferentiableAt ℝ (fun z => complexAffineLift (Q z)) y := (complexAffineLift_smooth.differentiable (by simp) _).comp y hQ have hg := hopfPrimitive_variable_gauge Complex.equivRealProdCLM.symm.differentiableAt hG h0 hN c v change _=hopfPrimitive c (regularEndPhase ε y) (fderiv ℝ (regularEndPhase ε) y v)-_ rw [he.eq_of_nhds,he.fderiv_eq,hg,hp,show endResidue ε c=c from ite_eq_right hε] rw [ContinuousLinearEquiv.fderiv] simp only [ContinuousLinearEquiv.coe_coe] have hns : Complex.normSq (Complex.equivRealProdCLM.symm y)=radiusSq y := by change y.1*y.1+y.2*y.2=y.1^2+y.2^2 ring have hca : complexArea (Complex.equivRealProdCLM.symm y) (Complex.equivRealProdCLM.symm v)=planarArea y v := by rw [complexArea_apply] rfl rw [hns,hca] simp only [angularOneForm,smul_apply,smul_eq_mul] ring theorem cubic_curveFSPrimitive_infinity (ε : EndIndex) (c : ℝ) {y : Plane} (hy : y∈(infinityDiffeomorph (parameters 0) ε).source) (hR : Complex.equivRealProdCLM.symm y∈endRegularRegion) : euclideanPullbackOneForm (fun _ => curveFSPrimitive c) (infinityDiffeomorph (parameters 0) ε) (0,y)= regularEndPrimitive ε c y-(endResidue ε c/2) • angularOneForm y := by have hD : Complex.equivRealProdCLM.symm y∈infinityDomain (parameters 0) := by simpa only [infinityDiffeomorph_source,mem_preimage] using hy have hg := cubic_infinityPhase_germ ε hy change euclideanPullbackOneForm (fun _ => manifoldPullbackOneForm (fun _ => affineFSPrimitive c) phaseInclusion 0) (infinityDiffeomorph (parameters 0) ε) (0,y)=_ rw [euclideanPullbackOneForm_comp (phaseInclusion_smooth.mdifferentiable (by simp) _) ((infinityDiffeomorph (parameters 0) ε).mdifferentiableAt (by simp) hy)] apply ContinuousLinearMap.ext intro v change affineFSPrimitive c ((phaseInclusion ∘ infinityDiffeomorph (parameters 0) ε) y) (manifoldMapDifferential (E := PlanePhase AffineIndex) (F := Plane) (phaseInclusion ∘ infinityDiffeomorph (parameters 0) ε) y v)=_ rw [manifoldMapDifferential,mfderiv_eq_fderiv,hg.eq_of_nhds,hg.fderiv_eq] exact endQuotientPrimitive_residue ε c hR hD.1 v theorem sum_endResidue (c : ℝ) : (∑ ε : EndIndex,endResidue ε c)=3*c := by have h (ε : EndIndex) : endResidue ε c=c-(if ε=zeroEnd then c else 0) := by by_cases he : ε=zeroEnd <;> simp [endResidue,he] simp_rw [h] rw [Finset.sum_sub_distrib] norm_num [EndIndex,Fintype.card_fun] ring theorem exists_regularEndPrimitive_extension {R : ℝ} (hR : {s : ℂ | Complex.normSq s≤R}⊆endRegularRegion) (ε : EndIndex) (c : ℝ) : ∃ β : Plane → Plane →L[ℝ] ℝ,ContDiff ℝ ∞ β ∧ HasCompactSupport β ∧ β=ᶠ[𝓝ˢ (radialAnnulus 0 R)] regularEndPrimitive ε c := by let U : Set Plane := Complex.equivRealProdCLM.symm ⁻¹' endRegularRegion have hU : IsOpen U := endRegularRegion_open.preimage Complex.equivRealProdCLM.symm.continuous have hKU : radialAnnulus 0 R⊆U := by intro y hy apply hR change Complex.normSq (Complex.equivRealProdCLM.symm y)≤R rw [radiusSq_complex] exact hy.2 have hf : ContDiffOn ℝ ∞ (regularEndPrimitive ε c) U := fun y hy => (regularEndPrimitive_contDiffAt ε c hy).contDiffWithinAt obtain ⟨χ,_hχ,_hχc,_hχU,_hr,_h1,hf,hc,he⟩ := exists_smooth_compact_extension (radialAnnulus_compact 0 R) hU hKU hf exact ⟨fun y => χ y • regularEndPrimitive ε c y,hf,hc,he⟩ theorem cubic_regular_extension_germ {R : ℝ} {ε : EndIndex} {c : ℝ} {β : Plane → Plane →L[ℝ] ℝ} (he : β=ᶠ[𝓝ˢ (radialAnnulus 0 R)] regularEndPrimitive ε c) {z : Plane} (hz : radiusSq z≤R) : β=ᶠ[𝓝 z] regularEndPrimitive ε c := he.filter_mono (nhds_le_nhdsSet ⟨radiusSq_nonneg z,hz⟩) end PackingSufficiencySupport.CubicModel end end OAI