import Mathlib import OAI.Analysis.HardSphere.Geometry.EnnrealTsumFinset import OAI.Analysis.HardSphere.Geometry.NominalDrift namespace OAI noncomputable section open scoped BigOperators Classical open scoped BigOperators Classical open scoped BigOperators Classical open scoped ENNReal NNReal open scoped ENNReal namespace HardSphere.Lattice def endpointDanger {K : ℕ} [NeZero K] (B : Finset (DiscreteTorus K)) (x : DiscreteTorus K) : Prop := ∃ F∈candidateSets (torusRangeGraph K 1), F⊆B ∧ ∃ c∈F, torusNear K F.card x c lemma fill_endpoint_danger {K : ℕ} [NeZero K] (hK : 2 norm_num | succ m ih => rw [pow_succ] have hp := Nat.one_le_pow m 2 (by norm_num) omega calc _ ≤ (3*2^m)^3 := Nat.pow_le_pow_left (by nlinarith) 3 _ = _ := by rw [mul_pow,← pow_mul,Nat.mul_comm m 3,pow_mul]; norm_num lemma endpoint_series_le (q : ℝ≥0∞) (hq : q≤1/16) : (∑' m : ℕ, ((2*(m+1)+1)^3:ℕ)*q^(m+1))≤54*q := by have h8 : (8:ℝ≥0∞)*q≤1/2 := by calc _ ≤ 8*(1/16:ℝ≥0∞) := mul_le_mul' le_rfl hq _ = _ := by have h : (8:ℝ≥0)*(1/16)=1/2 := by norm_num have hh := congrArg (fun x : ℝ≥0 ↦ (x:ℝ≥0∞)) h simpa only [ENNReal.coe_mul,ENNReal.coe_div (show (16:ℝ≥0)≠0 by norm_num), ENNReal.coe_div (show (2:ℝ≥0)≠0 by norm_num),ENNReal.coe_ofNat,ENNReal.coe_one] using hh calc _ ≤ ∑' m : ℕ, 27*q*((1/2:ℝ≥0∞)^m) := by apply ENNReal.tsum_le_tsum intro m calc _ ≤ (27*8^m:ℝ≥0∞)*q^(m+1) := by apply mul_le_mul' _ le_rfl exact_mod_cast endpoint_polynomial_le m _ = 27*q*((8*q)^m) := by rw [pow_succ,mul_pow]; ring _ ≤ _ := mul_le_mul' le_rfl (pow_le_pow_left' h8 m) _ = _ := by rw [ENNReal.tsum_mul_left,ENNReal.tsum_geometric]; norm_num; ring lemma rejection_probability {K a : ℕ} [NeZero K] (hK : 2 simp [hx] have hn : (∑' x, if ¬E x then μ x else 0)≠∞ := ne_of_lt (h.trans_lt (by norm_num)) calc (1/2:ℝ≥0∞)=1-(1/2) := by norm_num _ ≤ 1-(∑' x, if ¬E x then μ x else 0) := tsub_le_tsub_left h 1 _ = _ := by rw [← he,ENNReal.add_sub_cancel_right hn] theorem acceptedEnvironment_mass (a : ℕ) (ha : 1≤a) : ∃ p₀ : ℝ, 0