import Euler.PacketNestedHorizons import Euler.PacketSourceParameterScales import Euler.ParentPacketNeighborPolynomial import Euler.PacketSourceScaleActual /-! Fixed coefficient thresholds for the literal neighboring-label guard. The history reciprocal is derived from the initial geometric step, and the only parent size input is the already constructed parent's label bound. -/ /-! ## From `Euler/ParentHistoryFrequencyGuard.lean` The text of `Euler/ParentHistoryFrequencyGuard.lean`, folded into this file, which was its only importer. -/ section /-! Reciprocal history times fit the literal previous-frequency budget. Only the first geometric step needs coupling and tilt bounds. All later step lengths are nonnegative independently of any future frame invariant. -/ noncomputable section namespace EulerParentHistoryFrequency open Real EulerPacketSourceScaleChoice EulerPacketSourceScaleSequence EulerPacketSourceParameterScales EulerPacketSourceScaleActual EulerPacketNestedHorizons EulerPacketBaseGuardScales theorem frequency_monotone (J : ℕ) (hJ : 2 ≤ J) (X : ℝ) (hX : 0 ≤ X) : Monotone (frequency J X) := by apply monotone_nat_of_le_succ intro n let j : ℝ := (J+n : ℕ) have hj2 : (2 : ℝ) ≤ j := by dsimp [j] exact_mod_cast (show 2 ≤ J+n by omega) have hj0 : 0 < j := by linarith only [hj2] have hx : 0 ≤ scaleSequence J X n := hX.trans (sequence_initial_le J (by omega) X hX n) have hadd : ((J+(n+1) : ℕ) : ℝ)=j+1 := by dsimp [j] push_cast ring have hstep : j+1 ≤ j^2 := by linarith only [hj2,sq_nonneg (j-2)] have hsq : (j+1)^2 ≤ (j^2)^2 := pow_le_pow_left₀ (by positivity) hstep 2 apply exp_le_exp.mpr change scaleSequence J X n/j^2 ≤ scaleSequence J X (n+1)/((J+(n+1) : ℕ) : ℝ)^2 rw [scaleSequence_succ,hadd] apply (div_le_div_iff₀ (sq_pos_of_pos hj0) (sq_pos_of_pos (by positivity))).2 calc scaleSequence J X n*(j+1)^2 ≤ scaleSequence J X n*(j^2)^2 := mul_le_mul_of_nonneg_left hsq hx _ = (j^2*scaleSequence J X n)*j^2 := by ring theorem initial_frequency_le_first (J D : ℕ) (hJ : 3 ≤ J) (X : ℝ) (hX : 0 ≤ X) (hbase : X^D ≤ exp (X/((J-1 : ℕ) : ℝ)^4)) : X^D ≤ frequency J X 0 := by let j : ℝ := (J-1 : ℕ) have hj2 : (2 : ℝ) ≤ j := by dsimp [j] exact_mod_cast (show 2 ≤ J-1 by omega) have hJ0 : (0 : ℝ) < J := by exact_mod_cast (show 0 < J by omega) have hadd : (J : ℝ)=j+1 := by dsimp [j] exact_mod_cast (show J=J-1+1 by omega) have hstep : j+1 ≤ j^2 := by linarith only [hj2,sq_nonneg (j-2)] have hsq : (J : ℝ)^2 ≤ j^4 := by rw [hadd] simpa only [← pow_mul] using pow_le_pow_left₀ (by positivity) hstep 2 apply hbase.trans change exp (X/j^4) ≤ exp (X/(J : ℝ)^2) exact exp_le_exp.mpr (div_le_div_of_nonneg_left hX (sq_pos_of_pos hJ0) hsq) theorem initial_frequency_le_previous (J D : ℕ) (hJ : 3 ≤ J) (X : ℝ) (hX : 0 ≤ X) (hbase : X^D ≤ exp (X/((J-1 : ℕ) : ℝ)^4)) (n : ℕ) : X^D ≤ previousFrequency J D X n := by cases n with | zero => exact le_rfl | succ n => exact (initial_frequency_le_first J D hJ X hX hbase).trans (frequency_monotone J (by omega) X hX (Nat.zero_le n)) theorem previousFrequency_one_le (J D : ℕ) (hJ : 3 ≤ J) (X : ℝ) (hX : 1 ≤ X) (hbase : X^D ≤ exp (X/((J-1 : ℕ) : ℝ)^4)) (n : ℕ) : 1 ≤ previousFrequency J D X n := (one_le_pow₀ hX).trans (initial_frequency_le_previous J D hJ X (zero_le_one.trans hX) hbase n) theorem base_inverse_le_initial_frequency (J D : ℕ) (hJ : 1 ≤ J) (hD : 2000 ≤ D) (X : ℝ) (hX : 2 ≤ X) : 12/baseHorizon J X ≤ X^D := by have hx1 : 1 ≤ X := by linarith only [hX] have hx0 : 0 ≤ X := zero_le_one.trans hx1 have hxpow : 2 ≤ X^1000 := hX.trans (by simpa only [pow_one] using pow_le_pow_right₀ hx1 (by decide : 1 ≤ 1000)) calc 12/baseHorizon J X ≤ 2*X^1000 := base_inverse_time_le J hJ X hx1 _ ≤ X^1000*X^1000 := mul_le_mul_of_nonneg_right hxpow (pow_nonneg hx0 1000) _ = X^2000 := by rw [← pow_add] _ ≤ X^D := pow_le_pow_right₀ hx1 hD theorem base_inverse_le_previous_frequency (J D : ℕ) (hJ : 3 ≤ J) (hD : 2000 ≤ D) (X : ℝ) (hX : 2 ≤ X) (hbase : X^D ≤ exp (X/((J-1 : ℕ) : ℝ)^4)) (n : ℕ) : 12/baseHorizon J X ≤ previousFrequency J D X n := (base_inverse_le_initial_frequency J D (by omega) hD X hX).trans (initial_frequency_le_previous J D hJ X (by linarith only [hX]) hbase n) theorem base_inverse_le_previous_frequency_pow80 (J D : ℕ) (hJ : 3 ≤ J) (hD : 2000 ≤ D) (X : ℝ) (hX : 2 ≤ X) (hbase : X^D ≤ exp (X/((J-1 : ℕ) : ℝ)^4)) (n : ℕ) : 12/baseHorizon J X ≤ previousFrequency J D X n^80 := by have hk := previousFrequency_one_le J D hJ X (by linarith only [hX]) hbase n exact (base_inverse_le_previous_frequency J D hJ hD X hX hbase n).trans (by simpa only [pow_one] using pow_le_pow_right₀ hk (by decide : 1 ≤ 80)) end EulerParentHistoryFrequency end end /-! ## From `Euler/ParentPacketNeighborScaleGuard.lean` The text of `Euler/ParentPacketNeighborScaleGuard.lean`, folded into this file, which was its only importer. -/ section /-! The computed neighboring-label cost fits the source's monomial majorant under fixed degree and constant guards. Thus the small support scale discharges the literal neighbor comparison in the geometry step. -/ noncomputable section namespace EulerParentNeighborCost theorem polynomial_le_monomial (A K Ti H k h : ℝ) (n q c : ℕ) (hA : 0 ≤ A) (hK : 0 ≤ K) (hTi : 0 ≤ Ti) (hH : 0 ≤ H) (hk : 1 ≤ k) (hh : 1 ≤ h) (hKk : K ≤ k^q) (hTik : Ti ≤ k^q) (hHh : H ≤ h) (hcost : A*4^n ≤ k) (hc : q*n+1 ≤ c) (hn : n ≤ c) : A*(1+K+Ti+H)^n ≤ k^c*h^c := by have hk0 : 0 ≤ k := zero_le_one.trans hk have hh0 : 0 ≤ h := zero_le_one.trans hh have hkq : 1 ≤ k^q := one_le_pow₀ hk have hkq0 : 0 ≤ k^q := zero_le_one.trans hkq have hkh : 1 ≤ k^q*h := one_le_mul_of_one_le_of_one_le hkq hh have hkk : k^q ≤ k^q*h := le_mul_of_one_le_right hkq0 hh have hhh : h ≤ k^q*h := le_mul_of_one_le_left hh0 hkq have hb : 1+K+Ti+H ≤ 4*k^q*h := by linarith only [hkh,hKk.trans hkk,hTik.trans hkk,hHh.trans hhh] calc _ ≤ A*(4*k^q*h)^n := mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (by positivity) hb n) hA _ = (A*4^n)*(k^(q*n)*h^n) := by simp only [mul_pow]; ring _ ≤ k*(k^(q*n)*h^n) := mul_le_mul_of_nonneg_right hcost (by positivity) _ = k^(q*n+1)*h^n := by rw [pow_succ]; ring _ ≤ k^c*h^c := mul_le_mul (pow_le_pow_right₀ hk hc) (pow_le_pow_right₀ hh hn) (pow_nonneg hh0 n) (pow_nonneg hk0 c) end EulerParentNeighborCost namespace EulerParentPacketFrames.LabelData open Set EulerSmoothLimit EulerTransverseFrameCoordinates EulerTransversePacketProvider EulerPacketSourceGeometry EulerParentNeighborCost EulerPacketSourceScaleSequence EulerPacketSourceScaleActual variable {G : Parent} (L : LabelData G) {U : Type} [NormedAddCommGroup U] [InnerProductSpace ℝ U] (m : Space) (hm : ‖m‖=1) (R : U ≃ₗᵢ[ℝ] 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) τ) (Ti CM CH : ℝ) (hτ1 : τ ≤ 1) (hTi : τ⁻¹ ≤ Ti) (hCM : 0 ≤ CM) (hCH : 0 ≤ CH) (ha : 1/2 ≤ P.a) (hH : 1 ≤ P.shear) include hτ1 hTi hCM hCH ha hH in theorem neighborScaleCost_monomial (k : ℝ) (q c : ℕ) (hk : 1 ≤ k) (hKk : L.K ≤ k^q) (hTik : Ti ≤ k^q) (hcost : (EulerParentNeighborCost.constant*(2*(1+CM+CH))^degree)*4^degree ≤ k) (hc : q*degree+1 ≤ c) (hn : degree ≤ c) : L.neighborScaleCost m hm R S hS H τ hτ hτT P CM CH ≤ k^c*P.shear^c := by have hconst := EulerParentNeighborCost.constant_pos exact (L.neighborScaleCost_low_polynomial m hm R S hS H τ hτ hτT P Ti CM CH hτ1 hTi hCM hCH ha hH).trans (polynomial_le_monomial (EulerParentNeighborCost.constant*(2*(1+CM+CH))^degree) L.K Ti P.shear k P.shear degree q c (by positivity) (zero_le_one.trans L.K_one) ((inv_pos.mpr hτ).le.trans hTi) (zero_le_one.trans hH) hk hH hKk hTik le_rfl hcost hc hn) include hτ1 hTi hCM hCH ha hH in theorem neighbor_error_of_source_scales (J D : ℕ) (X ρ : ℝ) (j q c : ℕ) (hρ : 0 ≤ ρ) (hρ1 : ρ ≤ 1) (hshear : P.shear=previousShear J X j) (hk : 1 ≤ previousFrequency J D X j) (hKk : L.K ≤ previousFrequency J D X j^q) (hTik : Ti ≤ previousFrequency J D X j^q) (hcost : (EulerParentNeighborCost.constant*(2*(1+CM+CH))^degree)*4^degree ≤ previousFrequency J D X j) (hc : q*degree+1 ≤ c) (hn : degree ≤ c) (hscale : G.ell ≤ supportScale J X j) : L.neighborScaleCost m hm R S hS H τ hτ hτT P CM CH*G.ell*ρ ≤ neighborError J D X (c : ℝ) j := by have hbound := L.neighborScaleCost_monomial m hm R S hS H τ hτ hτT P Ti CM CH hτ1 hTi hCM hCH ha hH (previousFrequency J D X j) q c hk hKk hTik hcost hc hn have hmono : 0 ≤ previousFrequency J D X j^c*P.shear^c := mul_nonneg (pow_nonneg (zero_le_one.trans hk) c) (pow_nonneg (zero_le_one.trans hH) c) calc _ ≤ (previousFrequency J D X j^c*P.shear^c)*G.ell*ρ := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hbound G.ell_pos.le) hρ _ ≤ (previousFrequency J D X j^c*P.shear^c)*G.ell := by simpa only [mul_one] using mul_le_mul_of_nonneg_left hρ1 (mul_nonneg hmono G.ell_pos.le) _ ≤ (previousFrequency J D X j^c*P.shear^c)*supportScale J X j := mul_le_mul_of_nonneg_left hscale hmono _ = neighborError J D X (c : ℝ) j := by simp only [neighborError,Real.rpow_natCast,hshear] ring end EulerParentPacketFrames.LabelData end end noncomputable section namespace EulerParentNeighborThreshold open Real EulerParentNeighborCost EulerPacketSourceScaleSequence EulerParentHistoryFrequency def forwardThreshold : ℝ := constant*4^degree def joinedThreshold (CM CH : ℝ) : ℝ := (constant*(2*(1+CM+CH))^degree)*4^degree def commonThreshold (CM CH : ℝ) : ℝ := max forwardThreshold (joinedThreshold CM CH) def requiredExponent : ℕ := 80*degree+1 theorem degree_le_requiredExponent : degree ≤ requiredExponent := by unfold requiredExponent omega theorem forwardThreshold_le_common (CM CH : ℝ) : forwardThreshold ≤ commonThreshold CM CH := le_max_left _ _ theorem joinedThreshold_le_common (CM CH : ℝ) : joinedThreshold CM CH ≤ commonThreshold CM CH := le_max_right _ _ end EulerParentNeighborThreshold namespace EulerParentPacketFrames.LabelData open Set Real EulerSmoothLimit EulerTransverseFrameCoordinates EulerTransversePacketProvider EulerPacketSourceGeometry EulerParentNeighborCost EulerPacketSourceScaleSequence EulerPacketSourceScaleActual EulerParentNeighborThreshold EulerParentHistoryFrequency EulerPacketNestedHorizons EulerPacketBaseGuardScales variable {G : Parent} (L : LabelData G) theorem strainDifferenceCost_power : L.strainDifferenceCost ≤ constant*(1+L.K)^degree := by simpa only [envelope,formula,strainDifferenceCost,mul_zero,add_zero] using envelope_power L.K 0 0 0 0 0 (zero_le_one.trans L.K_one) le_rfl le_rfl le_rfl le_rfl le_rfl theorem strainDifferenceCost_monomial (k : ℝ) (c : ℕ) (hk : 1 ≤ k) (hKk : L.K ≤ k^80) (hcost : forwardThreshold ≤ k) (hc : requiredExponent ≤ c) : L.strainDifferenceCost ≤ k^c := by have hconst := constant_pos have hn : degree ≤ c := degree_le_requiredExponent.trans hc have he : 80*degree+1 ≤ c := hc have hb := polynomial_le_monomial constant L.K 0 0 k 1 degree 80 c hconst.le (zero_le_one.trans L.K_one) le_rfl le_rfl hk le_rfl hKk (pow_nonneg (zero_le_one.trans hk) 80) zero_le_one hcost he hn exact L.strainDifferenceCost_power.trans (by simpa only [add_zero,one_pow,mul_one] using hb) theorem forward_neighbor_error_of_source_scales (J D : ℕ) (hJ : 3 ≤ J) (X ρ : ℝ) (hX : 1 ≤ X) (hbase : X^D ≤ exp (X/((J-1 : ℕ) : ℝ)^4)) (n c : ℕ) (hρ : 0 ≤ ρ) (hρ1 : ρ ≤ 1) (hKk : L.K ≤ previousFrequency J D X n^80) (hcost : forwardThreshold ≤ previousFrequency J D X n) (hc : requiredExponent ≤ c) (hscale : G.ell ≤ supportScale J X n) : L.strainDifferenceCost*G.ell*ρ ≤ neighborError J D X (c : ℝ) n := by have hk := previousFrequency_one_le J D hJ X hX hbase n have hh : 1 ≤ previousShear J X n := by cases n with | zero => exact one_le_pow₀ hX | succ n => apply one_le_exp exact div_nonneg ((zero_le_one.trans hX).trans (EulerPacketSourceParameterScales.sequence_initial_le J (by omega) X (zero_le_one.trans hX) n)) (by positivity) have hb := L.strainDifferenceCost_monomial (previousFrequency J D X n) c hk hKk hcost hc have hkn : 0 ≤ previousFrequency J D X n^c := pow_nonneg (zero_le_one.trans hk) c have hhn : 0 ≤ previousShear J X n^c := pow_nonneg (zero_le_one.trans hh) c have hb' : L.strainDifferenceCost ≤ previousFrequency J D X n^c*previousShear J X n^c := hb.trans (le_mul_of_one_le_right hkn (one_le_pow₀ hh)) have hprod : 0 ≤ previousFrequency J D X n^c*previousShear J X n^c := mul_nonneg hkn hhn calc _ ≤ (previousFrequency J D X n^c*previousShear J X n^c)*G.ell*ρ := mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hb' G.ell_pos.le) hρ _ ≤ (previousFrequency J D X n^c*previousShear J X n^c)*G.ell := by simpa only [mul_one] using mul_le_mul_of_nonneg_left hρ1 (mul_nonneg hprod G.ell_pos.le) _ ≤ (previousFrequency J D X n^c*previousShear J X n^c)*supportScale J X n := mul_le_mul_of_nonneg_left hscale hprod _ = neighborError J D X (c : ℝ) n := by simp only [neighborError,rpow_natCast] ring variable {U : Type} [NormedAddCommGroup U] [InnerProductSpace ℝ U] (m : Space) (hm : ‖m‖=1) (R : U ≃ₗᵢ[ℝ] 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) τ) end EulerParentPacketFrames.LabelData