import Euler.PacketSourceScaleBounds /-! A common choice of the starting stage and base scale for the concrete coefficient, time-width, and pressure costs in the outer construction. -/ 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