import YM.TraceExtension.Terrace.Lyre set_option autoImplicit false noncomputable section namespace YM.Trace.Terrace open Function Filter Set Lattice RG RG.Supply Wilson Push.PriceCompiler Push.GridApprox Vac Stock open scoped BigOperators Topology Classical Matrix.Norms.Frobenius ContDiff variable {G:Gauge}(A:Levels G) {i j k:ℕ} (h:G.Simple) (θ:PostT A) abbrev basin (K:Tabs A)(j:ℕ):= Tabs.chosen A 1 K j variable (K:Tabs A) lemma unwinds (i:ℕ): i ≤ basin A K i:= (Tabs.opened A 1 K i).1 lemma tracks (i:ℕ): Tabs.opens A 1 i (basin A K i):= Tabs.opened .. lemma bondB : Tendsto (basin A K) atTop atTop:= tendsto_atTop_mono (unwinds A K) tendsto_id lemma Bcharged(k:ℕ): ((A.clock.coverSize k):ℝ) ≤ Lyra A k^2 +1:=(Nat.ceil_lt_add_one (sq_nonneg (Lyra A k))).le lemma gate_flex (d:ℕ) {c:ℝ}(hd:d<48)(hc:0.const_mul_atTop hc).eventually_ge_atTop 1,eventually_gt_atTop (1:ℝ)] with x hx hi have hu:= Real.log_pos hi refine (le_mul_of_one_le_left (pow_nonneg hu.le d) hx).trans_eq ?_; simp only [comp_apply] at *;rw [mul_assoc,← pow_add,show 48-d+d=48 by omega];rfl lemma summer (H:i≤ j): A.S.a i ≥ A.S.a j:= A.S.strictAnti.antitone H lemma scale_p(j:ℕ) (hp:1≤Lyra A j): Lyra A j ≤ Gate (A.clock.hatBeta j):=by simpa only [Lyra,Gate,pow_one] using! pow_le_pow_right₀ hp (show 1 ≤ 48 by decide) lemma lip (i:ℕ) (hu:8 ≤ Lyra A i): ((A.clock.coverSize i):ℝ) ≤ Lyra A i^3:=by apply (Bcharged ..).trans set y:=Lyra A i; have hz:0≤y:=by positivity nlinarith only [hu, mul_le_mul_of_nonneg_left hu hz,mul_le_mul_of_nonneg_left hu (sq_nonneg y)] lemma expA (x:ℝ) : x ≤ Real.exp x:= le_trans (le_add_of_nonneg_right zero_le_one) (Real.add_one_le_exp _) include h θ lemma open_budget : ∀ᶠ i:ℕ in atTop,basin A K i < summit A i :=by filter_upwards [bond A h θ,(lrate A h).eventually_ge_atTop 8] with i hB hi let x:= A.clock.hatBeta i; let y:= Lyra A i; let w:= Gate x; let K':= summit A i; let j:= K'-1; let m:= basin A K i have hk : i ≤ j ∧ j+1=K':=by have hp:i.le) hm _)) let u:= A.S.a i/A.S.a k apply le_trans (mul_le_mul_of_nonneg_left hP (pow_nonneg (div_nonneg (A.S.a_pos _).le (A.S.a_pos _).le) (4:ℕ))); apply le_trans (mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (div_nonneg (A.S.a_pos _).le (A.S.a_pos _).le) hv.1 4) (sq_nonneg _)); have hp : 4 ≤ x:=by unfold x; linarith only [hx] linarith only [mul_le_mul_of_nonneg_left hp (pow_nonneg he 26)] lemma glacier : ∀ᶠ i:ℕ in atTop, Gate (A.clock.hatBeta i)/2 ≤ gap A (basin A K i) (summit A i):=by filter_upwards [Bgap A h θ K, (hrate A h).eventually (gate_flex 6 (c:=1/2) (by decide) (by norm_num))] with i hx ht have he:=gstar A i; rw [triangle A i (basin A K i)] at he have hv:= ht; change Lyra A i^6≤ _ at hv; linarith only [hv,hx.2,he] lemma wallK : ∀ᶠ i:ℕ in atTop, (↑(A.clock.J (summit A i)):ℝ) ≤ Lyra A (summit A i):=by refine (Sstar A).eventually (p:= fun i=>(↑(A.clock.J i):ℝ) ≤ Lyra A i) ?_; filter_upwards [eventually_gt_atTop (0:ℕ)] with i hi cases i with | zero=> omega | succ i=> have ht := θ.cropK i; unfold ctl at ht; exact (Nat.cast_le.mpr (show A.clock.J _ ≤ (A.S.block i).val from le_trans (by omega) ht)).trans ((θ.bloom _).trans (lypos A h (Nat.le_succ _))) -- any poly-x radius is okay. coarse bill for k lemma Kagura(d:ℕ): ∀ᶠ i in atTop,∀ l:ℕ,(l:ℝ)≤ (A.clock.hatBeta (summit A i))^d → Push.GridApprox.room A i (summit A i) l:=by let C:ℝ:= 10000*2^d; have hx:0.le) hi.1 _)).trans_eq (by ring) have hp : (l:ℝ)+30*((A.clock.J t:ℝ)+5)