import Euler.PacketSourceScaleActual import Euler.PacketPressureScaleCosts import Euler.PacketUniformFrequencyScales /-! One starting index and one final base scale suffice for the actual geometric guards, pressure series, and any finite list of further packet frequency comparisons. No independently chosen index is substituted. -/ /-! ## From `Euler/PacketGeometryPressureCosts.lean` The text of `Euler/PacketGeometryPressureCosts.lean`, folded into this file, which was its only importer. -/ section /-! Actual geometric pressure increments are dominated by the literal summable scale costs. The physical parent-strain bound is CM times the previous shear, while the activation constants remain fixed low constants. -/ noncomputable section namespace EulerParentPacketFrames.LabelData open Set Real EulerSmoothLimit EulerPacketSourceGeometry EulerPacketGeometryLowBounds EulerPacketPressureScale EulerPacketSourceScaleSequence EulerPacketSourceScaleChoice EulerPacketSourceScales EulerScale EulerParentBadRatio variable {G : Parent} (L : LabelData G) {U : Type} [NormedAddCommGroup U] [InnerProductSpace ℝ U] [CompleteSpace U] (m : Space) (hm : ‖m‖=1) (R : U ≃ₗᵢ[ℝ] EulerTransverseFrameCoordinates.referencePlane m) (S : Set Space) (hS : IsCompact S) (H : LowBounds G) (τ : ℝ) (hτ : 0 < τ) (hτT : τ < G.T) (P : ParentFrame (G.transverseData m hm R S hS) τ) (A : Guards hτ hτT P (G.historyOn H m hm R S hS τ hτ hτT)) (Ti : ℝ) (hτ1 : τ ≤ 1) (hTi : τ⁻¹ ≤ Ti) (J D : ℕ) (hJ : 3 ≤ J) (X Cθ CM CMn CHn c : ℝ) (hX : 1 ≤ X) (hCθ : 1 ≤ Cθ) (hCM : 0 ≤ CM) (hCMn : 0 ≤ CMn) (hCHn : 0 ≤ CHn) (hc : 1 ≤ c) (hbaseH : X^1000 ≤ exp (X/((J-1 : ℕ) : ℝ)^7)) (hbaseK : X^D ≤ exp (X/((J-1 : ℕ) : ℝ)^4)) (n : ℕ) (M : ℝ) (hK : L.K ≤ previousFrequency J D X n^c) (hTib : Ti ≤ previousShear J X n) (hCMb : A.CM ≤ CMn) (hCHb : A.CH ≤ CHn) (hTheta : P.horizon ≤ sourceTheta J Cθ (scaleSequence J X) n) (hSigma : P.sigma*scaleSequence J X n ≤ 2) (hchild : A.hchild ≤ shear J X n) (hMb : M ≤ CM*previousShear J X n) include hτ1 hTi hJ hX hCθ hCM hCMn hCHn hc hbaseH hbaseK hK hTib hCMb hCHb hTheta hSigma hchild hMb theorem joined_bad_pressure_cost_bound : 2*M*A.hchild*A.badRatio ≤ badCost J Cθ CM CMn CHn c (scaleSequence J X) n := by have hx := quadratic_growth_one_le J (by omega) (scaleSequence J X) hX (scaleSequence_succ J X) have hs : 1 ≤ P.shear := by have hh := mul_le_mul_of_nonneg_left hτ1 A.shear_pos.le linarith only [hh,A.history_layer] have hi : P.shear⁻¹ ≤ 1 := (inv_le_one₀ A.shear_pos).2 hs have hQ := parameters_le_source_exponential J D hJ X c hX hc hbaseH hbaseK n L.K Ti P.shear⁻¹ A.CM A.CH CMn CHn hK hTib hi hCMb hCHb hCMn hCHn have ht0 := (inv_pos.mpr hτ).le.trans hTi have hQ0 : 0 ≤ 1+L.K+Ti+P.shear⁻¹+A.CM+A.CH := by positivity [L.K_one,A.shear_pos,A.CM_nonneg,A.CH_nonneg] have hM' := hMb.trans (mul_le_mul_of_nonneg_left (previousShear_le_normal J (by omega) X hbaseH n) hCM) exact badCost_bound J hJ Cθ CM CMn CHn c hCθ hCM hCMn hCHn (scaleSequence J X) hx n M A.hchild A.badRatio (1+L.K+Ti+P.shear⁻¹+A.CM+A.CH) P.horizon P.sigma A.child_nonneg A.badRatio_nonneg hQ0 (zero_le_one.trans A.horizon_lower) A.sigma_pos hM' hchild hQ hTheta hSigma (L.badRatio_polynomial m hm R S hS H τ hτ hτT P A Ti hτ1 hTi) theorem joined_upper_pressure_cost_bound (hdelta : A.δ ≤ spike J X n) : 2*M*A.hchild*(A.δ*goodRatio+A.badRatio) ≤ 2*CM*goodRatio*goodCost J (scaleSequence J X) n+ badCost J Cθ CM CMn CHn c (scaleSequence J X) n := by have hb := L.joined_bad_pressure_cost_bound m hm R S hS H τ hτ hτT P A Ti hτ1 hTi J D hJ X Cθ CM CMn CHn c hX hCθ hCM hCMn hCHn hc hbaseH hbaseK n M hK hTib hCMb hCHb hTheta hSigma hchild hMb have hg := goodCost_bound J (by omega) X CM M A.δ A.hchild hCM A.delta_nonneg A.child_nonneg hbaseH n hMb hdelta hchild calc _ = 2*M*A.hchild*(A.δ*goodRatio)+2*M*A.hchild*A.badRatio := by ring _ ≤ _ := add_le_add hg hb end EulerParentPacketFrames.LabelData namespace EulerPacketSourceGeometry.ForwardGuards open Real EulerSmoothLimit EulerPacketGeometryLowBounds EulerParentBadRatio EulerPacketPressureScale EulerPacketSourceScaleSequence EulerPacketSourceScaleChoice EulerPacketSourceScales EulerScale variable {U : Type} [NormedAddCommGroup U] [InnerProductSpace ℝ U] [CompleteSpace U] {D : EulerTransversePacketProvider.Data U} {P : ParentFrame D 0} (A : ForwardGuards P) omit [CompleteSpace U] in theorem earlyRatio_bound : A.earlyRatio ≤ badConstant*1^degree*P.horizon^5*exp (-(1/(4*P.sigma))) := by have hh : cutoffBound*(8232*exp 9*P.horizon^5) ≤ cutoffBound*(8232*exp 9*P.horizon^5+4*P.horizon*(constant*1^degree)) := by apply mul_le_mul_of_nonneg_left _ cutoffBound_pos.le exact le_add_of_nonneg_right (by positivity [A.horizon_lower,constant_pos]) rw [show A.earlyRatio=cutoffBound*(8232*exp 9*P.horizon^5)*exp (-(1/(4*P.sigma))) by unfold earlyRatio ring] apply (mul_le_mul_of_nonneg_right hh (exp_pos _).le).trans exact mul_le_mul_of_nonneg_right (prefactor_bound 1 P.horizon le_rfl A.horizon_lower) (exp_pos _).le variable (J : ℕ) (hJ : 3 ≤ J) (X Cθ CM CMn CHn c : ℝ) (hX : 1 ≤ X) (hCθ : 1 ≤ Cθ) (hCM : 0 ≤ CM) (hCMn : 0 ≤ CMn) (hCHn : 0 ≤ CHn) (hc : 0 ≤ c) (hbaseH : X^1000 ≤ exp (X/((J-1 : ℕ) : ℝ)^7)) (n : ℕ) (M : ℝ) (hTheta : P.horizon ≤ sourceTheta J Cθ (scaleSequence J X) n) (hSigma : P.sigma*scaleSequence J X n ≤ 2) (hchild : A.hchild ≤ shear J X n) (hMb : M ≤ CM*previousShear J X n) include hJ hX hCθ hCM hCMn hCHn hc hbaseH hTheta hSigma hchild hMb omit [CompleteSpace U] in theorem bad_pressure_cost_bound : 2*M*A.hchild*A.earlyRatio ≤ badCost J Cθ CM CMn CHn c (scaleSequence J X) n := by have hx := quadratic_growth_one_le J (by omega) (scaleSequence J X) hX (scaleSequence_succ J X) have hz : 0 ≤ c*(scaleSequence J X n/((J-1+n : ℕ) : ℝ)^4) := by positivity [hx n] have he := one_le_exp hz have hQ : 1 ≤ (4+CMn+CHn)*exp (c*(scaleSequence J X n/((J-1+n : ℕ) : ℝ)^4)) := by linarith only [he,mul_nonneg hCMn (zero_le_one.trans he),mul_nonneg hCHn (zero_le_one.trans he)] have hM' := hMb.trans (mul_le_mul_of_nonneg_left (previousShear_le_normal J (by omega) X hbaseH n) hCM) exact badCost_bound J hJ Cθ CM CMn CHn c hCθ hCM hCMn hCHn (scaleSequence J X) hx n M A.hchild A.earlyRatio 1 P.horizon P.sigma A.child_nonneg A.earlyRatio_nonneg zero_le_one (zero_le_one.trans A.horizon_lower) A.sigma_pos hM' hchild hQ hTheta hSigma A.earlyRatio_bound omit [CompleteSpace U] in theorem upper_pressure_cost_bound (hdelta : A.δ ≤ spike J X n) : 2*M*A.hchild*(A.δ*goodRatio+A.earlyRatio) ≤ 2*CM*goodRatio*goodCost J (scaleSequence J X) n+ badCost J Cθ CM CMn CHn c (scaleSequence J X) n := by have hb := A.bad_pressure_cost_bound J hJ X Cθ CM CMn CHn c hX hCθ hCM hCMn hCHn hc hbaseH n M hTheta hSigma hchild hMb have hg := goodCost_bound J (by omega) X CM M A.δ A.hchild hCM A.delta_nonneg A.child_nonneg hbaseH n hMb hdelta hchild calc _ = 2*M*A.hchild*(A.δ*goodRatio)+2*M*A.hchild*A.earlyRatio := by ring _ ≤ _ := add_le_add hg hb end EulerPacketSourceGeometry.ForwardGuards end end /-! ## From `Euler/PacketPressureSeries.lean` The text of `Euler/PacketPressureSeries.lean`, folded into this file, which was its only importer. -/ section /-! The pressure and initial-gradient costs allow one common scale choice with any finite collection of the other source costs. Their finite partial sums control the actual low-bound increments. -/ noncomputable section namespace EulerPacketPressureScale open Real Filter EulerScale EulerPacketSourceScales EulerPacketSourceScaleBounds EulerPacketSourceScaleChoice EulerPacketSourceScaleSequence EulerPacketGeometryLowBounds open scoped Topology def goodCostSpec (CM : ℝ) (hCM : 0 ≤ CM) : CostSpec where d := 1 B := 5 N := 3 a := 3 b := 1 c := 2 C := 1+2*CM*goodRatio 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 := zero_lt_one C_pos := by positivity [goodRatio_pos] theorem goodCost_le_spec (J : ℕ) (hJ : 3 ≤ J) (CM : ℝ) (hCM : 0 ≤ CM) (x : ℕ → ℝ) (n : ℕ) (hx : 0 ≤ x n) : 2*CM*goodRatio*goodCost J x n ≤ (goodCostSpec CM hCM).cost J x n := by have h := sourceGoodCost_bound J hJ x n hx have hg : 0 ≤ goodCost J x n := by unfold goodCost; positivity have hm := monomialCost_nonneg J 1 5 3 1 2 1 0 0 x n zero_le_one hx calc _ ≤ (1+2*CM*goodRatio)*monomialCost J 1 5 3 1 2 1 0 0 x n := by apply mul_le_mul (by linarith) h hg positivity [goodRatio_pos] _ = _ := by simp only [goodCostSpec,CostSpec.cost,monomialCost,pow_zero,mul_one,one_mul] theorem add_series {f g : ℕ → ℝ} {a b : ℝ} (hf : SmallSeries f a) (hg : SmallSeries g b) : SmallSeries (fun n => f n+g n) (a+b) := by refine ⟨fun n => add_nonneg (hf.nonneg n) (hg.nonneg n),hf.summable.add hg.summable,?_⟩ rw [hf.summable.tsum_add hg.summable] exact add_le_add hf.total_le hg.total_le theorem finite_sum_le {f : ℕ → ℝ} {a : ℝ} (hf : SmallSeries f a) (N : ℕ) : ∑ n ∈ Finset.range N, f n ≤ a := (hf.summable.sum_le_tsum (Finset.range N) (fun n _ => hf.nonneg n)).trans hf.total_le /-- The added pressure costs share the stage index and base scale with any finite list of the existing source costs. -/ theorem uniform_choice {ι : Type*} [Fintype ι] (s : ι → CostSpec) (Cθ CM CMn CHn c : ℝ) (hθ : 0 ≤ Cθ) (hM : 0 ≤ CM) (hMn : 0 ≤ CMn) (hHn : 0 ≤ CHn) : ∃ J : ℕ, 3 ≤ J ∧ ∀ η : ℝ, 0 < η → ∃ X₀ : ℝ, 8 ≤ X₀ ∧ ∀ x : ℕ → ℝ, X₀ ≤ x 0 → (∀ n, x (n+1)=((J+n : ℕ) : ℝ)^2*x n) → (∀ i, SmallSeries ((s i).cost J x) η) ∧ SmallSeries (badCost J Cθ CM CMn CHn c x) η ∧ SmallSeries (fun n => 2*CM*goodRatio*goodCost J x n) η := by let t : Sum ι Bool → CostSpec | .inl i => s i | .inr false => goodCostSpec CM hM | .inr true => badCostSpec Cθ CM CMn CHn c hθ hM hMn hHn obtain ⟨J,hJ,hchoice⟩ := finite_uniform_choice t refine ⟨J,hJ,?_⟩ intro η hη obtain ⟨X₀,hX₀,hX⟩ := hchoice η hη refine ⟨X₀,hX₀,?_⟩ intro x hx0 hx have hxp := quadratic_growth_one_le J (by omega) x (by linarith only [hX₀,hx0]) hx have hs (i : Sum ι Bool) : SmallSeries ((t i).cost J x) η := by have hi := hX x hx0 hx i refine ⟨?_,hi.1,hi.2.1⟩ intro n exact monomialCost_nonneg J (t i).d (t i).B (t i).a (t i).b (t i).c (t i).C (t i).p (t i).q x n (t i).C_pos.le (zero_le_one.trans (hxp n)) refine ⟨fun i => hs (.inl i),hs (.inr true),?_⟩ apply (hs (.inr false)).mono · intro n have hg := goodRatio_pos.le have hc : 0 ≤ goodCost J x n := by unfold goodCost; positivity positivity · intro n exact goodCost_le_spec J hJ CM hM x n (zero_le_one.trans (hxp n)) /-- The same choice covers the literal initial polynomial frequency and shear and every subsequent recursively constructed scale. -/ theorem literal_uniform_choice {ι : Type*} [Fintype ι] (s : ι → CostSpec) (D : ℕ) (Cθ CM CMn CHn c : ℝ) (hθ : 0 ≤ Cθ) (hM : 0 ≤ CM) (hMn : 0 ≤ CMn) (hHn : 0 ≤ CHn) : ∃ J : ℕ, 3 ≤ J ∧ ∀ η : ℝ, 0 < η → ∃ X₀ : ℝ, 8 ≤ X₀ ∧ ∀ X : ℝ, X₀ ≤ X → X^1000 ≤ exp (X/((J-1 : ℕ) : ℝ)^7) ∧ X^D ≤ exp (X/((J-1 : ℕ) : ℝ)^4) ∧ (∀ i, SmallSeries ((s i).cost J (scaleSequence J X)) η) ∧ SmallSeries (badCost J Cθ CM CMn CHn c (scaleSequence J X)) η ∧ SmallSeries (fun n => 2*CM*goodRatio*goodCost J (scaleSequence J X) n) η := by obtain ⟨J,hJ,hchoice⟩ := uniform_choice s Cθ CM CMn CHn c hθ hM hMn hHn refine ⟨J,hJ,?_⟩ intro η hη obtain ⟨Y,hY,hy⟩ := hchoice η hη have hp : (0 : ℝ) < (J-1 : ℕ) := by exact_mod_cast (show 0 < J-1 by omega) have hevent := (eventually_pow_le_exp 1000 (show 0 < ((J-1 : ℕ) : ℝ)^7 by positivity)).and (eventually_pow_le_exp D (show 0 < ((J-1 : ℕ) : ℝ)^4 by positivity)) obtain ⟨Z,hZ⟩ := eventually_atTop.1 hevent refine ⟨max Y Z,hY.trans (le_max_left _ _),?_⟩ intro X hX have hs := hy (scaleSequence J X) ((le_max_left Y Z).trans hX) (scaleSequence_succ J X) have hb := hZ X ((le_max_right Y Z).trans hX) exact ⟨hb.1,hb.2,hs.1,hs.2.1,hs.2.2⟩ end EulerPacketPressureScale end end /-! ## From `Euler/PacketSourceScaleFromCosts.lean` The text of `Euler/PacketSourceScaleFromCosts.lean`, folded into this file, which was its only importer. -/ section /-! Reconstruct the numerical source guards from a supplied common finite cost budget, without making a second choice of the starting stage. -/ noncomputable section namespace EulerPacketSourceScaleChoice open Real EulerScale EulerPacketSourceScales EulerPacketSourceTime EulerPacketSourceScaleBounds EulerPacketSourceScaleSequence EulerPacketSourceScaleActual theorem uniformBounds_of_costs (J : ℕ) (hJ : 3 ≤ J) (C c δ : ℝ) (hC : 1 ≤ C) (hc : 0 ≤ c) (hδ : 0 ≤ δ) (A : ℕ) (x : ℕ → ℝ) (hx1 : ∀ n, 1 ≤ x n) (hsmall : ∀ i : SourceCost, SmallSeries ((sourceCostSpec C c hC A i).cost J x) (δ/3)) : UniformBounds J C c A x δ := by have hJ1 : 1 ≤ J := by omega have hxp : ∀ n, 0 ≤ x n := fun n => zero_le_one.trans (hx1 n) let f := fun i : SourceCost => (sourceCostSpec C c hC A i).cost J x have hweak (i : SourceCost) : SmallSeries (f i) δ := (hsmall i).weaken (by linarith only [hδ]) have hsum : SmallSeries (fun n => f .shear n+f .prior n+f .neighbor n) δ := by have hs := ((hsmall .shear).summable.add (hsmall .prior).summable).add (hsmall .neighbor).summable refine ⟨fun n => add_nonneg (add_nonneg ((hsmall .shear).nonneg n) ((hsmall .prior).nonneg n)) ((hsmall .neighbor).nonneg n), hs, ?_⟩ rw [Summable.tsum_add ((hsmall .shear).summable.add (hsmall .prior).summable) (hsmall .neighbor).summable, Summable.tsum_add (hsmall .shear).summable (hsmall .prior).summable] linarith only [(hsmall .shear).total_le,(hsmall .prior).total_le,(hsmall .neighbor).total_le] refine ⟨hsum.mono ?_ ?_, ?_, (hweak .width).mono ?_ ?_, (hweak .parent).mono ?_ ?_,(hweak .good).mono ?_ ?_⟩ · intro n have hθ : 0 ≤ sourceTheta J C x n := zero_le_one.trans (sourceTheta_bounds hJ1 hC hx1 n).1 unfold coefficientCost sourceCoefficientError sourceEpsilon sourceOlderGradient sourcePriorError sourceNeighborError positivity · intro n exact sourceCoefficientError_bound J hJ C c hC hc A x hx1 n · intro a ha ha₂ apply (hweak .extra).mono · intro n have hθ : 0 ≤ sourceTheta J C x n := zero_le_one.trans (sourceTheta_bounds hJ1 hC hx1 n).1 unfold extraTimeCost sourceNextTimeWidth positivity · intro n exact sourceExtraTime_bound J hJ1 C hC A x hx1 n (a n) (ha n) (ha₂ n) · intro n unfold sourceTimeRatio positivity · intro n exact sourceTimeRatio_bound J hJ1 x n · intro n unfold parentSquareRatio positivity · intro n exact (sourceParentSquareRatio_eq J x n).le · intro n unfold goodCost positivity · intro n exact sourceGoodCost_bound J hJ x n (hxp n) theorem actualBounds_of_uniform (J D : ℕ) (hJ : 3 ≤ J) (C c X δ : ℝ) (hC : 1 ≤ C) (hc : 0 ≤ c) (hX : 1 ≤ X) (hδ : 0 ≤ δ) (hbaseH : X^1000 ≤ exp (X/((J-1 : ℕ) : ℝ)^7)) (hbaseK : X^D ≤ exp (X/((J-1 : ℕ) : ℝ)^4)) (hbase : baseErrorCost J D C X ≤ δ/2) (hn : UniformBounds J C c 60 (scaleSequence J X) (δ/32)) : ActualBounds J D C c X δ := by have hXp : 0 < X := zero_lt_one.trans_le hX have hw : δ/32 ≤ δ := by linarith only [hδ] refine ⟨⟨hn.coefficient.weaken hw,fun a ha ha₂ => (hn.extraTime a ha ha₂).weaken hw, hn.width.weaken hw,hn.parent.weaken hw,hn.good.weaken hw⟩,hbaseH,hbaseK,?_⟩ intro a ha ha₂ let f : ℕ → ℝ := fun n => 16*coefficientCost J C c 60 (scaleSequence J X) n let z : ℕ → ℝ := fun n => if n=0 then baseErrorCost J D C X else 0 have hf : SmallSeries f (δ/2) := by refine ⟨fun n => mul_nonneg (by norm_num) (hn.coefficient.nonneg n), hn.coefficient.summable.mul_left 16,?_⟩ change (∑' n,16*coefficientCost J C c 60 (scaleSequence J X) n) ≤ δ/2 rw [tsum_mul_left] linarith only [hn.coefficient.total_le] have hz : SmallSeries z (δ/2) := by refine ⟨?_,(hasSum_ite_eq 0 (baseErrorCost J D C X)).summable,?_⟩ · intro n exact ite_nonneg (baseErrorCost_nonneg J D C X (zero_le_one.trans hC) hXp.le) le_rfl · change (∑' n : ℕ,if n=0 then baseErrorCost J D C X else 0) ≤ δ/2 rw [tsum_ite_eq] exact hbase have hsum : SmallSeries (fun n => f n+z n) δ := by refine ⟨fun n => add_nonneg (hf.nonneg n) (hz.nonneg n),hf.summable.add hz.summable,?_⟩ rw [hf.summable.tsum_add hz.summable] linarith only [hf.total_le,hz.total_le] apply hsum.mono · intro n unfold geometryErrorCost exact mul_nonneg (geometryError_nonneg J D C c X a n (zero_le_one.trans hC) hXp) (pow_nonneg (by unfold sourceTheta; positivity) 60) · intro n exact geometryErrorCost_bound J D hJ C c X hC hX hc a ha ha₂ hbaseH hbaseK n end EulerPacketSourceScaleChoice end end noncomputable section namespace EulerPacketCommonScaleChoice open Real Filter EulerScale EulerPacketSourceScales EulerPacketSourceScaleChoice EulerPacketSourceScaleSequence EulerPacketSourceScaleActual EulerPacketSourceScaleGuards EulerPacketPressureScale EulerPacketGeometryLowBounds open scoped Topology theorem exists_common_guards {ι : Type*} [Fintype ι] (s : ι → CostSpec) (D : ℕ) (hD : 1000 ≤ D) (C c K CM CMn CHn cP : ℝ) (hC : 4 ≤ C) (hc : 0 ≤ c) (hK : 1 ≤ K) (hCM : 0 ≤ CM) (hCMn : 0 ≤ CMn) (hCHn : 0 ≤ CHn) : ∃ J : ℕ, 3 ≤ J ∧ ∀ η : ℝ, 0 < η → ∃ X₀ δ : ℝ, 8 ≤ X₀ ∧ 0 < δ ∧ δ ≤ η ∧ δ ≤ 1/2 ∧ ∀ X : ℝ, X₀ ≤ X → ActualBounds J D C c X δ ∧ (∀ i, SmallSeries ((s i).cost J (scaleSequence J X)) δ) ∧ SmallSeries (badCost J C CM CMn CHn cP (scaleSequence J X)) δ ∧ SmallSeries (fun n => 2*CM*goodRatio*goodCost J (scaleSequence J X) n) δ ∧ ∀ a β : ℕ → ℝ, (∀ n, 1/2 ≤ a n) → (∀ n, a n ≤ 2) → (∀ n, 1/2 ≤ β n*scaleSequence J X n^2) → (∀ n, β n*scaleSequence J X n^2 ≤ 2) → ∀ n, StageGuards J D C c X K a β n := by have hC1 : 1 ≤ C := by linarith only [hC] let specs : Sum SourceCost ι → CostSpec | .inl i => sourceCostSpec C c hC1 60 i | .inr i => s i obtain ⟨J,hJ,hchoice⟩ := literal_uniform_choice specs D C CM CMn CHn cP (zero_le_one.trans hC1) hCM hCMn hCHn refine ⟨J,hJ,?_⟩ intro η hη let δ : ℝ := min η (min (1/2) (1/(1000000*K))) have hδ : 0 < δ := by dsimp [δ]; positivity have hδη : δ ≤ η := min_le_left _ _ have hδhalf : δ ≤ 1/2 := (min_le_right _ _).trans (min_le_left _ _) have hδK : 1000000*K*δ ≤ 1 := by have hh : δ ≤ 1/(1000000*K) := (min_le_right _ _).trans (min_le_right _ _) have hm := (le_div_iff₀ (show 0 < 1000000*K by positivity)).mp hh linarith only [hm] obtain ⟨Y,hY,hbounds⟩ := hchoice (δ/96) (by positivity) obtain ⟨Z,hZ⟩ := eventually_atTop.mp ((baseErrorCost_tendsto_zero J D (by omega) hD C hC1).eventually_le_const (by positivity : 0 < δ/2)) refine ⟨max Y Z,δ,hY.trans (le_max_left _ _),hδ,hδη,hδhalf,?_⟩ intro X hX have hXY : Y ≤ X := (le_max_left _ _).trans hX have hXZ : Z ≤ X := (le_max_right _ _).trans hX have hX8 : 8 ≤ X := hY.trans hXY have hX1 : 1 ≤ X := by linarith only [hX8] have hb := hbounds X hXY have hx1 : ∀ n, 1 ≤ scaleSequence J X n := quadratic_growth_one_le J (by omega) (scaleSequence J X) hX1 (scaleSequence_succ J X) have hn : UniformBounds J C c 60 (scaleSequence J X) (δ/32) := by apply uniformBounds_of_costs J hJ C c (δ/32) hC1 hc (by positivity) 60 (scaleSequence J X) hx1 intro i have hi := hb.2.2.1 (Sum.inl i) convert hi using 1 ring have ha := actualBounds_of_uniform J D hJ C c X δ hC1 hc hX1 hδ.le hb.1 hb.2.1 (hZ X hXZ) hn have hweaken : δ/96 ≤ δ := by linarith only [hδ] refine ⟨ha,fun i => (hb.2.2.1 (Sum.inr i)).weaken hweaken, hb.2.2.2.1.weaken hweaken,hb.2.2.2.2.weaken hweaken,?_⟩ intro a β ha₁ ha₂ hβ₁ hβ₂ n exact stage_guards J D hJ C c X K δ hC hX8 hK hδhalf hδK ha a β ha₁ ha₂ hβ₁ hβ₂ n end EulerPacketCommonScaleChoice