import Mathlib import OAI.Geometry.BallPacking.Toric.CubicRadialFamilyExtension namespace OAI noncomputable section namespace PackingSufficiencySupport.CubicModel open scoped BigOperators ContDiff Manifold Topology open Set Function Filter Manifold open DiagonalQuadrics DiagonalQuadrics.Explicit Hamiltonian FiniteMoment section variable {ι : Type*} [Fintype ι] theorem radialProbability_nonneg {k : ι → ℕ × ℕ} (h0 : ∃ i,k i=(0,0)) (D m : ι → ℕ) (p : Radial.Plane) (x : BaseCurve) (i : ι) : 0≤radialProbability k D m p x i := Radial.selected_nonneg (fun j => coefficientNorm_pos (D j) (m j) x) h0 p i theorem radialProbability_sum {k : ι → ℕ × ℕ} (h0 : ∃ i,k i=(0,0)) (D m : ι → ℕ) (p : Radial.Plane) (x : BaseCurve) : ∑ i,radialProbability k D m p x i=1 := Radial.selected_sum (fun j => coefficientNorm_pos (D j) (m j) x) h0 p theorem radialProbability_mean {A B : ℕ} (hAB : A≤B) (D m : TrapezoidWeight A B → ℕ) {p : Radial.Plane} (hp : p∈Radial.lowerTrapezoid A B) (x : BaseCurve) : ∑ i,radialProbability Radial.latticeIndex D m p x i • trapezoidWeight A B i= planeVector p.1 p.2 := Radial.trapezoid_selected_mean hAB (fun j => coefficientNorm_pos (D j) (m j) x) hp end section variable {ι : Type*} [Fintype ι] [Nonempty ι] theorem reducedEndRegularPrimitive_norm_le (w : ι → MomentPlane) (D m : ι → ℕ) (c : ℝ) (p : MomentPlane) (ε : EndIndex) (y : Plane) {M : ℝ} (hM : ∀ i,‖weightedRegularEndPrimitive (D i) (m i) ε c y‖≤M) : ‖reducedEndRegularPrimitive w D m c p ε y‖≤M := by apply (norm_sum_le _ _).trans have hq (i : ι) : 0 (reducedProbability_pos w D m p (infinityDiffeomorph (parameters 0) ε y) i).le) (reducedProbability_sum w D m p _) hM omit [Nonempty ι] in theorem exists_regularCoefficient_log_bound (D m : ι → ℕ) {R : ℝ} (hR : {s : ℂ | Complex.normSq s≤R}⊆endRegularRegion) : ∃ M : ℝ,0≤M ∧ ∀ (i : ι) (ε : EndIndex) y,y∈radialAnnulus 0 R → |Real.log (regularCoefficientNorm (D i) (m i) ε y)|≤M := by have hc : ContinuousOn (fun y : Plane => fun j : ι × EndIndex => Real.log (regularCoefficientNorm (D j.1) (m j.1) j.2 y)) (radialAnnulus 0 R) := by apply continuousOn_pi.mpr intro j y hy have hRy : Complex.equivRealProdCLM.symm y∈endRegularRegion := by apply hR change Complex.normSq (Complex.equivRealProdCLM.symm y)≤R rw [radiusSq_complex] exact hy.2 exact ((regularCoefficientNorm_contDiffAt (D j.1) (m j.1) j.2 hRy).continuousAt.log (regularCoefficientNorm_pos _ _ _ _).ne').continuousWithinAt obtain ⟨M,hM⟩ := (radialAnnulus_compact 0 R).exists_bound_of_continuousOn hc refine ⟨max 0 M,le_max_left _ _,?_⟩ intro i ε y hy exact (show |Real.log (regularCoefficientNorm (D i) (m i) ε y)|≤ ‖fun j : ι × EndIndex => Real.log (regularCoefficientNorm (D j.1) (m j.1) j.2 y)‖ from (norm_le_pi_norm (fun j : ι × EndIndex => Real.log (regularCoefficientNorm (D j.1) (m j.1) j.2 y)) (i,ε))).trans ((hM y hy).trans (le_max_right _ _)) omit [Nonempty ι] in theorem exists_regularPrimitive_bound (D m : ι → ℕ) (c : ℝ) {R : ℝ} (hR : {s : ℂ | Complex.normSq s≤R}⊆endRegularRegion) : ∃ M : ℝ,0≤M ∧ ∀ (i : ι) (ε : EndIndex) y,y∈radialAnnulus 0 R → ‖weightedRegularEndPrimitive (D i) (m i) ε c y‖≤M := by have hc : ContinuousOn (fun y : Plane => fun j : ι × EndIndex => weightedRegularEndPrimitive (D j.1) (m j.1) j.2 c y) (radialAnnulus 0 R) := by apply continuousOn_pi.mpr intro j y hy have hRy : Complex.equivRealProdCLM.symm y∈endRegularRegion := by apply hR change Complex.normSq (Complex.equivRealProdCLM.symm y)≤R rw [radiusSq_complex] exact hy.2 exact (weightedRegularEndPrimitive_contDiffAt _ _ _ _ hRy).continuousAt.continuousWithinAt obtain ⟨M,hM⟩ := (radialAnnulus_compact 0 R).exists_bound_of_continuousOn hc refine ⟨max 0 M,le_max_left _ _,?_⟩ intro i ε y hy exact (norm_le_pi_norm (fun j : ι × EndIndex => weightedRegularEndPrimitive (D j.1) (m j.1) j.2 c y) (i,ε)).trans ((hM y hy).trans (le_max_right _ _)) end section variable {ι : Type*} [Fintype ι] theorem radialEndRegularPrimitive_norm_le {k : ι → ℕ × ℕ} (h0 : ∃ i,k i=(0,0)) (D m : ι → ℕ) (c : ℝ) (p : Radial.Plane) (ε : EndIndex) (y : Plane) {M : ℝ} (hM : ∀ i,‖weightedRegularEndPrimitive (D i) (m i) ε c y‖≤M) : ‖radialEndRegularPrimitive k D m c p ε y‖≤M := by apply (norm_sum_le _ _).trans have hq (i : ι) : 0≤radialEndProbability k D m p ε y i := radialProbability_nonneg h0 D m p _ _ simp only [norm_smul,Real.norm_eq_abs,abs_of_nonneg (hq _)] exact probability_weighted_le (fun i => radialProbability_nonneg h0 D m p (infinityDiffeomorph (parameters 0) ε y) i) (radialProbability_sum h0 D m p _) hM end def limitingEndOrder (D S : ℝ) (p : MomentPlane) (ε : EndIndex) : ℝ := if ε 0 then (if ε 1 then D-3*(p 0+p 1) else D-3*(p 0+p 1)-markedHeight S p) else (if ε 1 then D-3*(p 0+p 1)-markedHeight S p else 0) theorem probability_affine_degree {ι : Type*} [Fintype ι] {w : ι → MomentPlane} {q : ι → ℝ} {p : MomentPlane} (hs : ∑ i,q i=1) (he : ∑ i,q i • w i=p) (D C : ℝ) : (∑ i,q i*(D-C*((w i) 0+(w i) 1)))=D-C*(p 0+p 1) := by have hcoord (j : Fin 2) : ∑ i,q i*(w i) j=p j := by simpa using congrArg (fun z : MomentPlane => z j) he simp only [mul_sub,mul_add,Finset.sum_sub_distrib,Finset.sum_add_distrib] simp_rw [mul_left_comm (q _) C] rw [←Finset.mul_sum,←Finset.mul_sum,←Finset.sum_mul,hs,one_mul,hcoord 0,hcoord 1] theorem reducedEndProbability_regularized {A B D S : ℕ} (hB : 3*B regularCoefficientNorm (cubicDegree D k) (cubicMarkedOrder S k) ε y/ (radiusSq y)^(weightedEndOrder (cubicDegree D k) (cubicMarkedOrder S k) ε)) p := by unfold reducedEndProbability reducedProbability have he : (fun k : TrapezoidWeight A B => coefficientNorm (cubicDegree D k) (cubicMarkedOrder S k) (infinityDiffeomorph (parameters 0) ε y))=(fun k => regularCoefficientNorm (cubicDegree D k) (cubicMarkedOrder S k) ε y/(radiusSq y)^(weightedEndOrder (cubicDegree D k) (cubicMarkedOrder S k) ε)) := by funext k exact coefficientNorm_eq_regular_div (cubicMarked_lt_degree hB hS k).le (cubicMarked_twice_complement hB hS k) ε hy hR rw [he] theorem reducedEndResidue_error {A B D S : ℕ} (hA : 0 regularCoefficientNorm_pos _ _ _ _) hlog ht ht1 hn hp cases h0 : ε 0 <;> cases h1 : ε 1 · simp only [limitingEndOrder,h0,h1,Bool.false_eq_true,↓reduceIte,weightedEndOrder,Nat.cast_zero,mul_zero,Finset.sum_const_zero,sub_self,abs_zero] exact hb · simpa only [limitingEndOrder,h0,h1,Bool.false_eq_true,↓reduceIte] using hmarked (fun k => by simpa only [h0,h1,Bool.false_eq_true,↓reduceIte] using cubicEndOrder_cast hB hS ε k) · simpa only [limitingEndOrder,h0,h1,Bool.false_eq_true,↓reduceIte] using hmarked (fun k => by simpa only [h0,h1,Bool.false_eq_true,↓reduceIte] using cubicEndOrder_cast hB hS ε k) · have hdeg (k : TrapezoidWeight A B) := cubicEndOrder_cast hB hS ε k simp only [h0,h1,↓reduceIte] at hdeg simp only [hdeg,limitingEndOrder,h0,h1,↓reduceIte] rw [probability_affine_degree (by exact hsum) (by exact hmean),sub_self,abs_zero] exact hb end PackingSufficiencySupport.CubicModel namespace PackingSufficiencySupport.FiniteMoment.Radial open scoped Topology open Set Filter open scoped BigOperators ContDiff open Function theorem lowerTrapezoid_interior_sequence {A B : ℝ} {p : Plane} (hp : p∈lowerTrapezoid A B) : ∃ q : ℕ → Plane,(∀ n,planeVector (q n).1 (q n).2∈openTrapezoid A B) ∧ Tendsto q atTop (𝓝 p) := by let e : ℝ := min (A-p.1) (B-(p.1+p.2))/4 have he : 0 e*(1/((n:ℝ)+1)) have hd (n : ℕ) : 0 (p.1+d n,p.2+d n),?_,?_⟩ · intro n change 0 selected latticeIndex a (q n) i) atTop (𝓝 (selected latticeIndex a p i)) := by have hf := (trapezoid_selected_contDiffWithinAt hA hAB ha hp i).continuousWithinAt have hm : Tendsto (fun n => (a,q n)) atTop (𝓝[{z : (TrapezoidWeight A B → ℝ) × Plane | (∀ j,0 ⟨ha,hq n⟩)⟩ exact hf.tendsto.comp hm theorem selected_marked_error_lower {A B S : ℕ} (hA : 0 a j/t^(n j)) p k*(n k:ℝ))- (D-C*(p.1+p.2)-markedHeight S (planeVector p.1 p.2))|≤ (2*M+Fintype.card (TrapezoidWeight A B))/(-Real.log t) := by let b : TrapezoidWeight A B → ℝ := fun j => a j/t^(n j) have hb (j : TrapezoidWeight A B) : 0 ∑ k,selected latticeIndex b (q j) k*(n k:ℝ)) atTop (𝓝 (∑ k,selected latticeIndex b p k*(n k:ℝ))) := tendsto_finsetSum _ (fun i _ => (trapezoid_selected_tendsto hA hAB hb hp hqlo hqlim i).mul_const _) have hh : Continuous (fun z : Plane => D-C*(z.1+z.2)-markedHeight S (planeVector z.1 z.2)) := by simp only [markedHeight,planeVector] fun_prop exact le_of_tendsto ((hsum.sub (hh.continuousAt.tendsto.comp hqlim)).abs) (Eventually.of_forall hs) end PackingSufficiencySupport.FiniteMoment.Radial namespace PackingSufficiencySupport.CubicModel open scoped BigOperators ContDiff Manifold Topology open Set Function Filter Manifold open DiagonalQuadrics DiagonalQuadrics.Explicit Hamiltonian FiniteMoment theorem radialEndProbability_regularized {A B D S : ℕ} (hB : 3*B regularCoefficientNorm (cubicDegree D k) (cubicMarkedOrder S k) ε y/ (radiusSq y)^(weightedEndOrder (cubicDegree D k) (cubicMarkedOrder S k) ε)) p := by unfold radialEndProbability radialProbability have he : (fun k : TrapezoidWeight A B => coefficientNorm (cubicDegree D k) (cubicMarkedOrder S k) (infinityDiffeomorph (parameters 0) ε y))=(fun k => regularCoefficientNorm (cubicDegree D k) (cubicMarkedOrder S k) ε y/(radiusSq y)^(weightedEndOrder (cubicDegree D k) (cubicMarkedOrder S k) ε)) := by funext k exact coefficientNorm_eq_regular_div (cubicMarked_lt_degree hB hS k).le (cubicMarked_twice_complement hB hS k) ε hy hR rw [he] theorem radialEndResidue_error {A B D S : ℕ} (hA : 0 regularCoefficientNorm_pos _ _ _ _) hlog ht ht1 hn hp cases h0 : ε 0 <;> cases h1 : ε 1 · simp only [limitingEndOrder,h0,h1,Bool.false_eq_true,↓reduceIte,weightedEndOrder,Nat.cast_zero,mul_zero,Finset.sum_const_zero,sub_self,abs_zero] exact hb · simpa [limitingEndOrder,h0,h1,planeVector] using hmarked (fun k => by simpa only [h0,h1,Bool.false_eq_true,↓reduceIte] using cubicEndOrder_cast hB hS ε k) · simpa [limitingEndOrder,h0,h1,planeVector] using hmarked (fun k => by simpa only [h0,h1,Bool.false_eq_true,↓reduceIte] using cubicEndOrder_cast hB hS ε k) · have hdeg (k : TrapezoidWeight A B) := cubicEndOrder_cast hB hS ε k simp only [h0,h1,↓reduceIte] at hdeg simp only [hdeg,limitingEndOrder,h0,h1,↓reduceIte] rw [probability_affine_degree (by exact hsum) (by exact hmean),sub_self,abs_zero] exact hb variable {ι : Type*} [Fintype ι] [Nonempty ι] theorem reducedEndProbability_contDiffAt {w : ι → MomentPlane} (D m : ι → ℕ) {p : MomentPlane} (hp : Surrounds w p) (ε : EndIndex) {y : Plane} (hy : y∈(infinityDiffeomorph (parameters 0) ε).source) (i : ι) : ContDiffAt ℝ ∞ (fun z => reducedEndProbability w D m p ε z i) y := ((reducedProbability_smooth D m hp i).contMDiffAt.comp y ((infinityDiffeomorph (parameters 0) ε).contMDiffOn.contMDiffAt ((infinityDiffeomorph (parameters 0) ε).open_source.mem_nhds hy))).contDiffAt theorem reducedEndRegularPrimitive_contDiffAt {w : ι → MomentPlane} (D m : ι → ℕ) (c : ℝ) {p : MomentPlane} (hp : Surrounds w p) (ε : EndIndex) {y : Plane} (hy : y∈(infinityDiffeomorph (parameters 0) ε).source) (hR : Complex.equivRealProdCLM.symm y∈endRegularRegion) : ContDiffAt ℝ ∞ (reducedEndRegularPrimitive w D m c p ε) y := ContDiffAt.sum (fun i _ => (reducedEndProbability_contDiffAt D m hp ε hy i).smul (weightedRegularEndPrimitive_contDiffAt (D i) (m i) ε c hR)) theorem reducedEndResidue_contDiffAt {w : ι → MomentPlane} (D m : ι → ℕ) (c : ℝ) {p : MomentPlane} (hp : Surrounds w p) (ε : EndIndex) {y : Plane} (hy : y∈(infinityDiffeomorph (parameters 0) ε).source) : ContDiffAt ℝ ∞ (reducedEndResidue w D m c p ε) y := ContDiffAt.sum (fun i _ => (reducedEndProbability_contDiffAt D m hp ε hy i).mul contDiffAt_const) end PackingSufficiencySupport.CubicModel end end OAI