import Mathlib import OAI.Probability.SKBarriers.Dynamics.ClockEndpoint import OAI.Probability.SKBarriers.Dynamics.GreedyEventual import OAI.Probability.SKBarriers.Dynamics.BankNumerics import OAI.Probability.SKBarriers.Dynamics.BankDynamics namespace OAI section noncomputable section open scoped BigOperators Topology open Classical MeasureTheory ProbabilityTheory Filter Set namespace SK.Analytic def bankEndpointError (n : ℕ) : ℝ := 4*(9*Real.exp (-2*levelLogScale n)+(n:ℝ)*Real.exp (-levelLogScale n)) theorem scheduled_bank_total {n p B : ℕ} (hB : 0 E x ∧ (gibbsFiniteLaw β J).prob (fun y => E y ∧ q≤|overlap x y|) Real.exp (-c (j.val%B)*levelLogScale n) let δ : Fin p → ℝ := fun j => Real.exp (-(bankPrefix c (j.val%B)+5)*levelLogScale n) let S := lockingUnion n μ t (levelRho n) q b b' have hK : ∀j,0 (Real.exp_pos _).le) S (fun j w => hcov (j.val%B) (Nat.mod_lt _ hB) (fun x => ∀i,|overlap (w i) x|≤3*t)) (3*Real.exp (-4*levelLogScale n)) (scheduled_bank_total hB c hc hL hp hdom (replicaGibbsMass_nonneg β J S) hv) hsmall let v := initialBankReference (natBankPool K z) (natBankDefault K hK z) B t q have HC : ∀m≤⌈Real.exp (2*levelLogScale n)⌉₊, (∑x,gibbs β J x*kernelEvent β J (fun y => overlap (v x) y≤0) m x)≤9*Real.exp (-2*levelLogScale n) := by intro m hm have HM := bank_stationary_crossing hn β J μ B H (greedyBlockCount B t n) m t (levelRho n) b b' q G (by simpa only [Nat.cast_mul] using hcount m hm) K hK z hz have HK : (m:ℝ)+1≤3*Real.exp (2*levelLogScale n) := by have hi : (m:ℝ)≤(⌈Real.exp (2*levelLogScale n)⌉₊:ℝ) := by exact_mod_cast hm exact (add_le_add hi (le_refl (1:ℝ))).trans (horizon_size_bound (by linarith only [hL])) change _≤((m:ℝ)+1)*(gibbsFiniteLaw β J).prob (fun x => bankCoverageBad K (blockPrior p B) t q z x ∨ bankVertexBad (fun i : BankIndex K => i.1.val) S z x) at HM refine HM.trans ?_ calc _ ≤ (3*Real.exp (2*levelLogScale n))*(3*Real.exp (-4*levelLogScale n)) := mul_le_mul HK hzmass ((gibbsFiniteLaw β J).prob_nonneg _) (by positivity) _ = _ := by rw [mul_mul_mul_comm,← Real.exp_add]; norm_num; ring have HH := mixedMass_bounds_of_crossing hn β J (levelLogScale n) (9*Real.exp (-2*levelLogScale n)) (by linarith only [hL]) (by positivity) v HC refine ⟨HH.1,HH.2.trans ?_⟩ dsimp only [bankEndpointError] have hp0 : 0≤(n:ℝ)*Real.exp (-levelLogScale n) := by positivity linarith only [hp0] end SK.Analytic end end end OAI