import Euler.EulerProof /-! A common choice of the starting stage and base scale for the concrete coefficient, time-width, and pressure costs in the outer construction. -/ /-! ## From `Euler/PacketSourceScaleBounds.lean` The text of `Euler/PacketSourceScaleBounds.lean`, folded into this file, which was its only importer. -/ section /-! Pointwise bounds for the literal scale expressions in (37)--(39). They exhibit a finite list of exponential costs to which the existing uniform scale-choice theorem applies. The estimates here contain no field data. -/ noncomputable section namespace EulerPacketSourceScaleBounds open Real EulerScale EulerPacketScaleGeometry EulerPacketSourceScales EulerPacketSourceTime def monomialCost (J d B : ℕ) (a b c C : ℝ) (p q : ℕ) (x : ℕ → ℝ) (n : ℕ) : ℝ := C * ((J + n : ℕ) : ℝ)^p * (x n)^q * exp (-b * (x n / ((J + n : ℕ) : ℝ)^a) + c * (x n / ((J - d + n : ℕ) : ℝ)^B)) theorem monomialCost_nonneg (J d B : ℕ) (a b c C : ℝ) (p q : ℕ) (x : ℕ → ℝ) (n : ℕ) (hC : 0 ≤ C) (hx : 0 ≤ x n) : 0 ≤ monomialCost J d B a b c C p q x n := by unfold monomialCost positivity theorem monomialCost_eq_exp (J d B : ℕ) (a b c C : ℝ) (p q : ℕ) (x : ℕ → ℝ) (n : ℕ) (hJ : 1 ≤ J) (hC : 0 < C) (hx : 0 < x n) : monomialCost J d B a b c C p q x n = exp (-b * (x n / ((J + n : ℕ) : ℝ)^a) + c * (x n / ((J - d + n : ℕ) : ℝ)^B) + log C + p * log ((J + n : ℕ) : ℝ) + q * log (x n)) := by have hj : (0 : ℝ) < (J + n : ℕ) := by exact_mod_cast (show 0 < J+n by omega) simp only [monomialCost, exp_add, exp_log hC, exp_nat_mul, exp_log hj, exp_log hx] ring theorem theta_weighted_monomial_bound (J d B : ℕ) (a b c D C : ℝ) (p q A : ℕ) (x : ℕ → ℝ) (n : ℕ) (hJ : 1 ≤ J) (hC : 1 ≤ C) (hD : 0 ≤ D) (hx : ∀ n, 1 ≤ x n) : monomialCost J d B a b c D p q x n * sourceTheta J C x n^A ≤ monomialCost J d B a b c (D*(2*C)^A) (p+2*A) (q+2*A) x n := by have hθ := pow_le_pow_left₀ (le_trans zero_le_one (sourceTheta_bounds hJ hC hx n).1) (sourceTheta_bounds hJ hC hx n).2 A have hh := mul_le_mul_of_nonneg_left hθ (monomialCost_nonneg J d B a b c D p q x n hD (le_trans zero_le_one (hx n))) convert! hh using 1 simp only [monomialCost, mul_pow, ← pow_mul] ring theorem sourcePriorError_bound (J : ℕ) (hJ : 3 ≤ J) (x : ℕ → ℝ) (n : ℕ) (hx : 0 ≤ x n) : sourcePriorError J x n ≤ exp (-(1/4)*(x n/((J+n : ℕ) : ℝ)^4)) := by have hp : (0 : ℝ) < (J-1+n : ℕ) := by exact_mod_cast (show 0 < J-1+n by omega) have hpj : ((J-1+n : ℕ) : ℝ) ≤ (J+n : ℕ) := by exact_mod_cast (show J-1+n ≤ J+n by omega) have hd := div_le_div_of_nonneg_left hx (show 0 < 4*((J-1+n : ℕ) : ℝ)^4 by positivity) (mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hp.le hpj 4) (by norm_num : (0:ℝ) ≤ 4)) apply exp_le_exp.mpr change -x n/(4*((J-1+n : ℕ) : ℝ)^4) ≤ _ convert! neg_le_neg hd using 1 <;> ring theorem sourceNeighborError_bound (J : ℕ) (hJ : 3 ≤ J) (c : ℝ) (hc : 0 ≤ c) (x : ℕ → ℝ) (n : ℕ) (hx : 0 ≤ x n) : sourceNeighborError J c x n ≤ exp (-(x n/((J+n : ℕ) : ℝ)^(7/2 : ℝ)) + (2*c)*(x n/((J-1+n : ℕ) : ℝ)^4)) := by have hp : (1 : ℝ) ≤ (J-1+n : ℕ) := by exact_mod_cast (show 1 ≤ J-1+n by omega) have hd := div_le_div_of_nonneg_left (mul_nonneg hc hx) (by positivity : 0 < ((J-1+n : ℕ) : ℝ)^4) (pow_le_pow_right₀ hp (by decide : 4 ≤ 7)) unfold sourceNeighborError apply exp_le_exp.mpr simp only [div_eq_mul_inv] at hd ⊢ linarith only [hd] /-- The complete coefficient error is controlled by three explicit costs, with exactly the preceding-stage powers and the real support exponent 7/2. -/ theorem sourceCoefficientError_bound (J : ℕ) (hJ : 3 ≤ J) (C c : ℝ) (hC : 1 ≤ C) (hc : 0 ≤ c) (A : ℕ) (x : ℕ → ℝ) (hx : ∀ n, 1 ≤ x n) (n : ℕ) : sourceCoefficientError J C c x n * sourceTheta J C x n^A ≤ monomialCost J 2 9 7 (1/2) 2 (128*(2*C)^(A+1)) (2*(A+1)) (2*(A+1)) x n + monomialCost J 0 5 4 (1/4) 0 (16*(2*C)^A) (2*A) (2*A) x n + monomialCost J 1 4 (7/2) 1 (2*c) (16*(2*C)^A) (2*A) (2*A) x n := by have hJ1 : 1 ≤ J := by omega have hθ : 0 ≤ sourceTheta J C x n := le_trans zero_le_one (sourceTheta_bounds hJ1 hC hx n).1 have hxp : ∀ n, 0 ≤ x n := fun n => le_trans zero_le_one (hx n) have hs := mul_le_mul_of_nonneg_right (source_shear_gradient_bound J hJ x hxp n) (pow_nonneg hθ (A+1)) have hs16 := mul_le_mul_of_nonneg_left hs (by norm_num : (0:ℝ) ≤ 16) have hsm := theta_weighted_monomial_bound J 2 9 7 (1/2) 2 128 C 0 0 (A+1) x n hJ1 hC (by norm_num) hx have hshear : 16*(sourceEpsilon J x n*sourceTheta J C x n*sourceOlderGradient J x n^2)* sourceTheta J C x n^A ≤ monomialCost J 2 9 7 (1/2) 2 (128*(2*C)^(A+1)) (2*(A+1)) (2*(A+1)) x n := by apply le_trans _ (by simpa only [Nat.zero_add] using hsm) convert! hs16 using 1 <;> simp only [monomialCost, rpow_ofNat, pow_zero, pow_succ] <;> ring have hp := mul_le_mul_of_nonneg_right (sourcePriorError_bound J hJ x n (hxp n)) (pow_nonneg hθ A) have hp16 := mul_le_mul_of_nonneg_left hp (by norm_num : (0:ℝ) ≤ 16) have hpm := theta_weighted_monomial_bound J 0 5 4 (1/4) 0 16 C 0 0 A x n hJ1 hC (by norm_num) hx have hprior : 16*sourcePriorError J x n*sourceTheta J C x n^A ≤ monomialCost J 0 5 4 (1/4) 0 (16*(2*C)^A) (2*A) (2*A) x n := by apply le_trans _ (by simpa only [Nat.zero_add] using hpm) simpa only [monomialCost, rpow_ofNat, zero_mul, add_zero, pow_zero, mul_one, mul_assoc] using hp16 have hn := mul_le_mul_of_nonneg_right (sourceNeighborError_bound J hJ c hc x n (hxp n)) (pow_nonneg hθ A) have hn16 := mul_le_mul_of_nonneg_left hn (by norm_num : (0:ℝ) ≤ 16) have hnm := theta_weighted_monomial_bound J 1 4 (7/2) 1 (2*c) 16 C 0 0 A x n hJ1 hC (by norm_num) hx have hneighbor : 16*sourceNeighborError J c x n*sourceTheta J C x n^A ≤ monomialCost J 1 4 (7/2) 1 (2*c) (16*(2*C)^A) (2*A) (2*A) x n := by apply le_trans _ (by simpa only [Nat.zero_add] using hnm) simpa only [monomialCost, neg_one_mul, pow_zero, mul_one, mul_assoc] using hn16 have hh := add_le_add (add_le_add hshear hprior) hneighbor convert! hh using 1 unfold sourceCoefficientError ring theorem sourceExtraTime_bound (J : ℕ) (hJ : 1 ≤ J) (C : ℝ) (hC : 1 ≤ C) (A : ℕ) (x : ℕ → ℝ) (hx : ∀ n, 1 ≤ x n) (n : ℕ) (a : ℝ) (ha : 0 ≤ a) (ha₂ : a ≤ 2) : 2*sqrt (a*exp (x n/((J-1+n : ℕ) : ℝ)^7))*sourceNextTimeWidth J x n* sourceTheta J C x n^A ≤ monomialCost J 1 7 5 (1/2) (1/2) (48*(2*C)^A) (6+2*A) (2+2*A) x n := by have hθ : 0 ≤ sourceTheta J C x n := le_trans zero_le_one (sourceTheta_bounds hJ hC hx n).1 have hh := mul_le_mul_of_nonneg_right (source_extra_time_bound J hJ x n ha ha₂) (pow_nonneg hθ A) have hm := theta_weighted_monomial_bound J 1 7 5 (1/2) (1/2) 48 C 6 2 A x n hJ hC (by norm_num) hx apply le_trans hh simpa only [monomialCost, rpow_ofNat] using hm theorem sourceTimeRatio_bound (J : ℕ) (hJ : 1 ≤ J) (x : ℕ → ℝ) (n : ℕ) : sourceTimeRatio J x n ≤ monomialCost J 1 7 5 (1/2) (1/2) 4 4 0 x n := by have hj : (1 : ℝ) ≤ (J+n : ℕ) := by exact_mod_cast (show 1 ≤ J+n by omega) have hp : (((J+n : ℕ) : ℝ)+1)^2 ≤ 4*((J+n : ℕ) : ℝ)^2 := by nlinarith only [hj] have hh := mul_le_mul_of_nonneg_right hp (sq_nonneg ((J+n : ℕ) : ℝ)) have he := mul_le_mul_of_nonneg_right hh (exp_pos (-x n/(2*((J+n : ℕ) : ℝ)^5)+x n/(2*((J-1+n : ℕ) : ℝ)^7))).le have hexp : exp (-x n/(2*((J+n : ℕ) : ℝ)^5)+x n/(2*((J-1+n : ℕ) : ℝ)^7)) = exp (-(1/2)*(x n/((J+n : ℕ) : ℝ)^5)+(1/2)*(x n/((J-1+n : ℕ) : ℝ)^7)) := by congr 1 ring rw [hexp] at he convert! he using 1 <;> simp only [sourceTimeRatio, monomialCost, rpow_ofNat, pow_zero, mul_one] · rw [hexp] · ring theorem sourceParentSquareRatio_eq (J : ℕ) (x : ℕ → ℝ) (n : ℕ) : exp (2*x n/((J-1+n : ℕ) : ℝ)^7)/exp (x n/((J+n : ℕ) : ℝ)^5) = monomialCost J 1 7 5 1 2 1 0 0 x n := by rw [← exp_sub] simp only [monomialCost, pow_zero, mul_one, one_mul, rpow_ofNat] congr 1 ring theorem sourceGoodCost_bound (J : ℕ) (hJ : 3 ≤ J) (x : ℕ → ℝ) (n : ℕ) (hx : 0 ≤ x n) : exp (-x n/((J+n : ℕ) : ℝ)^3)*exp (x n/((J+n : ℕ) : ℝ)^5)* exp (x n/((J-1+n : ℕ) : ℝ)^7) ≤ monomialCost J 1 5 3 1 2 1 0 0 x n := by have hp : (1 : ℝ) ≤ (J-1+n : ℕ) := by exact_mod_cast (show 1 ≤ J-1+n by omega) have hpj : ((J-1+n : ℕ) : ℝ) ≤ (J+n : ℕ) := by exact_mod_cast (show J-1+n ≤ J+n by omega) have hd₁ := div_le_div_of_nonneg_left hx (by positivity : 0 < ((J-1+n : ℕ) : ℝ)^5) (pow_le_pow_left₀ (le_trans zero_le_one hp) hpj 5) have hd₂ := div_le_div_of_nonneg_left hx (by positivity : 0 < ((J-1+n : ℕ) : ℝ)^5) (pow_le_pow_right₀ hp (by decide : 5 ≤ 7)) rw [← exp_add, ← exp_add] simp only [monomialCost, pow_zero, one_mul, neg_one_mul, rpow_ofNat] apply exp_le_exp.mpr simp only [div_eq_mul_inv] at hd₁ hd₂ ⊢ linarith only [hd₁, hd₂] end EulerPacketSourceScaleBounds end end noncomputable section namespace EulerPacketSourceScaleChoice open Real Filter EulerScale EulerPacketSourceScales EulerPacketSourceTime EulerPacketScaleGeometry EulerPacketFiniteScaleChoice EulerPacketSourceScaleBounds open scoped Topology structure CostSpec where d : ℕ B : ℕ N : ℕ a : ℝ b : ℝ c : ℝ C : ℝ p : ℕ q : ℕ d_le_two : d ≤ 2 a_nonneg : 0 ≤ a a_lt_B : a < B a_le_N : a ≤ N b_pos : 0 < b C_pos : 0 < C def CostSpec.cost (s : CostSpec) (J : ℕ) (x : ℕ → ℝ) : ℕ → ℝ := monomialCost J s.d s.B s.a s.b s.c s.C s.p s.q x /-- A finite list of literal exponential costs has summable, uniformly small terms and a small total, using one fixed stage and then one base scale. -/ theorem finite_uniform_choice {ι : Type*} [Fintype ι] (s : ι → CostSpec) : ∃ J : ℕ, 3 ≤ J ∧ ∀ δ : ℝ, 0 < δ → ∃ X₀ : ℝ, 8 ≤ X₀ ∧ ∀ x : ℕ → ℝ, X₀ ≤ x 0 → (∀ n, x (n+1) = ((J+n : ℕ) : ℝ)^2*x n) → ∀ i, Summable ((s i).cost J x) ∧ (∑' n, (s i).cost J x n) ≤ δ ∧ ∀ n, (s i).cost J x n ≤ δ := by obtain ⟨J, hJ, hchoice⟩ := finite_source_uniform_small_sum_choice (fun i => (s i).d) (fun i => (s i).B) (fun i => (s i).N) (fun i => (s i).a) (fun i => (s i).b) (fun i => (s i).c) (fun i => log (s i).C) (fun i => ((s i).p : ℝ)) (fun i => ((s i).q : ℝ)) (fun i => (s i).a_lt_B) (fun i => (s i).a_le_N) (fun i => (s i).b_pos) refine ⟨J, hJ, ?_⟩ intro δ hδ obtain ⟨X₀, hX₀, hX⟩ := hchoice δ hδ refine ⟨max 8 X₀, le_max_left _ _, ?_⟩ intro x hx0 hx i have hstart : X₀ ≤ x 0 := (le_max_right _ _).trans hx0 have hxp := quadratic_growth_pos J (by omega) x (lt_of_lt_of_le zero_lt_one (hX₀.trans hstart)) hx have hdJ : (s i).d < J := lt_of_le_of_lt (s i).d_le_two (by omega) have hsum : Summable ((s i).cost J x) := polynomial_source_scale_summable J (s i).d (s i).B hdJ x (hxp 0) hx (s i).a (s i).b (s i).c (s i).C (s i).p (s i).q (s i).a_nonneg (s i).a_lt_B (s i).b_pos (s i).C_pos have hbound : (∑' n, (s i).cost J x n) ≤ δ := by convert! hX x hstart hx i using 1 apply tsum_congr intro n exact monomialCost_eq_exp J (s i).d (s i).B (s i).a (s i).b (s i).c (s i).C (s i).p (s i).q x n (by omega) (s i).C_pos (hxp n) refine ⟨hsum, hbound, ?_⟩ intro n apply le_trans (hsum.le_tsum n ?_) hbound intro m hm exact monomialCost_nonneg J (s i).d (s i).B (s i).a (s i).b (s i).c (s i).C (s i).p (s i).q x m (s i).C_pos.le (hxp m).le inductive SourceCost | shear | prior | neighbor | extra | width | parent | good deriving DecidableEq instance : Fintype SourceCost where elems := {.shear, .prior, .neighbor, .extra, .width, .parent, .good} complete c := by cases c <;> simp def sourceCostSpec (C c : ℝ) (hC : 1 ≤ C) (A : ℕ) : SourceCost → CostSpec | .shear => { d := 2, B := 9, N := 7, a := 7, b := 1/2, c := 2, C := 128*(2*C)^(A+1), p := 2*(A+1), q := 2*(A+1), d_le_two := by norm_num, a_nonneg := by norm_num, a_lt_B := by norm_num, a_le_N := by norm_num, b_pos := by norm_num, C_pos := by positivity } | .prior => { d := 0, B := 5, N := 4, a := 4, b := 1/4, c := 0, C := 16*(2*C)^A, p := 2*A, q := 2*A, d_le_two := by norm_num, a_nonneg := by norm_num, a_lt_B := by norm_num, a_le_N := by norm_num, b_pos := by norm_num, C_pos := by positivity } | .neighbor => { d := 1, B := 4, N := 4, a := 7/2, b := 1, c := 2*c, C := 16*(2*C)^A, p := 2*A, q := 2*A, d_le_two := by norm_num, a_nonneg := by norm_num, a_lt_B := by norm_num, a_le_N := by norm_num, b_pos := by norm_num, C_pos := by positivity } | .extra => { d := 1, B := 7, N := 5, a := 5, b := 1/2, c := 1/2, C := 48*(2*C)^A, p := 6+2*A, q := 2+2*A, d_le_two := by norm_num, a_nonneg := by norm_num, a_lt_B := by norm_num, a_le_N := by norm_num, b_pos := by norm_num, C_pos := by positivity } | .width => { d := 1, B := 7, N := 5, a := 5, b := 1/2, c := 1/2, C := 4, p := 4, q := 0, d_le_two := by norm_num, a_nonneg := by norm_num, a_lt_B := by norm_num, a_le_N := by norm_num, b_pos := by norm_num, C_pos := by norm_num } | .parent => { d := 1, B := 7, N := 5, a := 5, b := 1, c := 2, C := 1, p := 0, q := 0, d_le_two := by norm_num, a_nonneg := by norm_num, a_lt_B := by norm_num, a_le_N := by norm_num, b_pos := by norm_num, C_pos := by norm_num } | .good => { d := 1, B := 5, N := 3, a := 3, b := 1, c := 2, C := 1, p := 0, q := 0, d_le_two := by norm_num, a_nonneg := by norm_num, a_lt_B := by norm_num, a_le_N := by norm_num, b_pos := by norm_num, C_pos := by norm_num } structure SmallSeries (f : ℕ → ℝ) (δ : ℝ) : Prop where nonneg : ∀ n, 0 ≤ f n summable : Summable f total_le : (∑' n, f n) ≤ δ theorem SmallSeries.term_le {f : ℕ → ℝ} {δ : ℝ} (h : SmallSeries f δ) (n : ℕ) : f n ≤ δ := (h.summable.le_tsum n (fun m _ => h.nonneg m)).trans h.total_le theorem SmallSeries.weaken {f : ℕ → ℝ} {δ η : ℝ} (h : SmallSeries f δ) (hle : δ ≤ η) : SmallSeries f η := ⟨h.nonneg, h.summable, h.total_le.trans hle⟩ theorem SmallSeries.mono {f g : ℕ → ℝ} {δ : ℝ} (h : SmallSeries f δ) (hg : ∀ n, 0 ≤ g n) (hle : ∀ n, g n ≤ f n) : SmallSeries g δ := by have hs := h.summable.of_nonneg_of_le hg hle exact ⟨hg, hs, (hs.tsum_le_tsum hle h.summable).trans h.total_le⟩ def coefficientCost (J : ℕ) (C c : ℝ) (A : ℕ) (x : ℕ → ℝ) (n : ℕ) : ℝ := sourceCoefficientError J C c x n * sourceTheta J C x n^A def extraTimeCost (J : ℕ) (C : ℝ) (A : ℕ) (x a : ℕ → ℝ) (n : ℕ) : ℝ := 2*sqrt (a n*exp (x n/((J-1+n : ℕ) : ℝ)^7))*sourceNextTimeWidth J x n* sourceTheta J C x n^A def parentSquareRatio (J : ℕ) (x : ℕ → ℝ) (n : ℕ) : ℝ := exp (2*x n/((J-1+n : ℕ) : ℝ)^7)/exp (x n/((J+n : ℕ) : ℝ)^5) def goodCost (J : ℕ) (x : ℕ → ℝ) (n : ℕ) : ℝ := exp (-x n/((J+n : ℕ) : ℝ)^3)*exp (x n/((J+n : ℕ) : ℝ)^5)* exp (x n/((J-1+n : ℕ) : ℝ)^7) structure UniformBounds (J : ℕ) (C c : ℝ) (A : ℕ) (x : ℕ → ℝ) (δ : ℝ) : Prop where coefficient : SmallSeries (coefficientCost J C c A x) δ extraTime : ∀ a : ℕ → ℝ, (∀ n, 0 ≤ a n) → (∀ n, a n ≤ 2) → SmallSeries (extraTimeCost J C A x a) δ width : SmallSeries (sourceTimeRatio J x) δ parent : SmallSeries (parentSquareRatio J x) δ good : SmallSeries (goodCost J x) δ /-- The sequence in (37), now constructed rather than supplied. -/ def scaleSequence (J : ℕ) (X : ℝ) : ℕ → ℝ | 0 => X | n+1 => ((J+n : ℕ) : ℝ)^2*scaleSequence J X n @[simp] theorem scaleSequence_zero (J : ℕ) (X : ℝ) : scaleSequence J X 0 = X := rfl theorem scaleSequence_succ (J : ℕ) (X : ℝ) (n : ℕ) : scaleSequence J X (n+1) = ((J+n : ℕ) : ℝ)^2*scaleSequence J X n := rfl end EulerPacketSourceScaleChoice