import YM.RG08.Gaussian.Turning import YM.RG08.Flat.KLimit /-! # Pre-block Gaussian ledger on the Wilson Chain -/ set_option autoImplicit false noncomputable section namespace YM.RG08 open Function Filter Lattice Wilson RG Precision Exterior Bloch Matrix Laurent open Next.Free Work.F08 Tree Stationary open scoped Topology BigOperators Classical variable {G : Gauge} {X : Chain} namespace Chain def trees (X : Chain) (i : ℕ) := Repeated.axisRule (X.patch i).L (X.patch i).odd_side def Wake (G : Gauge) (X : Chain) := ∀ i,(X.patch i).Branches X.kernel G lemma wake_actual (a : Levels G) : Wake G (actual a) := fun i => (a.blocks i 0).branches -- p implicit for some joins; set patch type fixed here def curve (G : Gauge) (X : Chain) (N i : ℕ) := conditionalCov G (P:=X.patch i) (X.trees i) X.kernel (X.history N (i+1)) def predict (G : Gauge) (X : Chain) (N i : ℕ) := coarseMean G (P:=X.patch i) (X.trees i) X.kernel (X.history N (i+1)) lemma predict_truth (G : Gauge) (h : Wake G X) (N i : ℕ) (hp : i H p hj hh _⟩ exact ⟨1,one_pos,fun P hp _ => (h (P.order_cut.trans_eq hp)).elim⟩ choose b hb H using hr let w (j) := min (b j) (b (j+1)) have hw j : 0 rw [← hl]; exact min_le_left ..; exact min_le_right ..) le_rfl have h₁ : V*D≤C := le_trans (le_max_right ..) (le_max_left ..) have h₂ : D ≤ C := le_trans (le_max_left ..) (le_max_left ..) refine ⟨C,hD.trans h₂,fun _ hK u v => ⟨strip_mono (hG _) le_rfl h₂, ?_,fun η B hp ht h => ?_⟩⟩ · apply strip_mono (mean_budget _ _ _ (hG _) Hm hs.le) le_rfl; refine le_trans (le_of_eq ?_) h₁ unfold V n; ring have hhV : (minusRows (conditionalCov G X K u) (conditionalCov G X K v)).strip σ (E*B) := by refine strip_mono (covariance_moves X hK (hG _) (hG _) (σ:=η) (C:=B) (strip_flip (α:=TypeFace 1) h) hs ht) le_rfl (le_of_eq ?_) unfold E n; ring constructor · exact strip_mono hhV le_rfl (mul_le_mul_of_nonneg_right ((le_max_left ..).trans (le_max_right ..)) hp) apply strip_mono (coarseMean_movement X hhV Hm hs) le_rfl apply Eq.trans_le _ (mul_le_mul_of_nonneg_right (show V*E≤C from (le_max_right ..).trans (le_max_right ..)) hp) unfold V n; ring exact ⟨0,le_rfl, fun hp hB => (hX ⟨hp,hB⟩).elim⟩ dsimp only at hg choose v hv hh using hg exact ⟨⟨w,hw,v,hv,fun j P => hh j P⟩⟩ variable (K : KernelChoices) lemma crossing {K : KernelChoices} {P : KPrices K} (g : KGate P) (Y : Lending G K) : ∃ b : ℕ→ℕ, ∀ i j, j=i ∨ j+1=i → ∀ L : Side, b i ≤ L.val → Y.w j≤L.val*g.w i := by choose h hh using fun i j : ℕ => exists_nat_gt (Y.w j/g.w i) refine ⟨fun i => max (h i i) (h i (i-1)),fun i j hj L hp => (div_le_iff₀ (g.pos _)).mp ?_⟩ apply le_trans (hh i j).le rcases hj with hx|hx <;> subst i · exact_mod_cast ((le_max_left ..).trans hp : h j j≤L.val) dsimp only at hp; rw [Nat.add_sub_cancel] at hp exact_mod_cast ((le_max_right ..).trans hp : h (j+1) j≤L.val) /-- `Wake` is patch branches for the gauge; exact specialization to any actual Levels. Stipulate the widths before imposing sized stage gates. -/ structure Clear (P : KPrices X.kernel) (g : KGate P) (Y : Lending G X.kernel) (ℓ : ℕ) : Prop where booked : KAllowed g ℓ large i : ℓ ≤ i → Y.w (X.J i) ≤ (X.S.block i).val * g.w (X.J (i+1)) trueStep : X.Wake G open Chain lemma report_funding {G : Gauge} (X : Chain) (h : X.Wake G) (Y : Lending G X.kernel) (i : ℕ) (N : ℕ) : (curve G X N i).strip (Y.w (X.J i)) (Y.bill (X.J i) (X.patch i)) ∧ (predict G X N i).strip (Y.w (X.J i)) (Y.bill (X.J i) (X.patch i)) := by have he : X.J i=(X.patch i).J ∨ X.J i+1=(X.patch i).J := by change X.J i=X.J (i+1) ∨ X.J i+1=X.J (i+1); have h := X.mono i; have hp := X.slow i; omega have hv := Y.serves _ _ he (h i) (X.history N (i+1)) (X.history N (i+1)) exact ⟨hv.1,hv.2.1⟩ theorem overlap (A B : ℝ) (ha : 0≤A) (hb : 0≤B) (p q : ℕ) : ∃ c : ℝ, 0 ≤ c ∧ ∀ (G : Gauge) (X : Chain) (P : KPrices X.kernel) (g : KGate P) (Y : Lending G X.kernel) (k ℓ : ℕ) (Z : ℝ), 0≤Z → Clear P g Y ℓ → (let a := age X.S Z k (∀ i, ℓ ≤ i → P.bill (X.J i) ≤ A*a i^p) → (∀ i, ℓ ≤ i → Y.bill (X.J i) (X.patch i) ≤ B*a (i+1)^q) → ∀ i N N', ℓ ≤ i → i