import Mathlib import OAI.Probability.BinarySweep.SparseBounds.SparseReduction namespace OAI noncomputable section namespace BinaryCoordinateSweeps.Sparse lemma few_eta_good (b : ℕ) {L : ℝ} (hb : b ≤ 16000) (hL : (10:ℝ)^26 ≤ L) : Real.exp (-L/160000) ≤ 1/4 ∧ 4*(b:ℝ)*Real.sqrt (Real.exp (-L/160000)) ≤ Real.exp (-L/640000) := by have hbR : (b:ℝ) ≤ 16000 := by exact_mod_cast hb constructor · have hc : (4:ℝ) ≤ Real.exp (L/160000) := by apply (show (4:ℝ) ≤ L/160000+1 from by linarith).trans (Real.add_one_le_exp _) rw [show -L/160000=-(L/160000) by ring,Real.exp_neg] simpa only [one_div] using inv_anti₀ (by norm_num : (0:ℝ)<4) hc · have hc : 4*(b:ℝ) ≤ Real.exp (L/640000) := by apply (show 4*(b:ℝ) ≤ L/640000+1 from by linarith).trans (Real.add_one_le_exp _) have hs : Real.sqrt (Real.exp (-L/160000))=Real.exp (-L/320000) := by apply (Real.sqrt_eq_iff_mul_self_eq_of_pos (Real.exp_pos _)).mpr rw [←Real.exp_add] congr 1 ring rw [hs] refine (mul_le_mul_of_nonneg_right hc (Real.exp_pos _).le).trans_eq ?_ rw [←Real.exp_add] congr 1 ring lemma few_vertex_base (b h k : ℕ) {s : ℝ} (hs : 0 (hd j).2) have hux := mul_le_mul_of_nonneg_right hbR hr have hj := mul_le_mul_of_nonneg_right (show (r:ℝ) ≤ bits j by exact_mod_cast (hd j).1) (Real.log_nonneg (by norm_num : (1:ℝ) ≤ 2)) calc _ ≤ Real.log (gridSize bits)/40000+1 := by linarith _ ≤ Real.exp (Real.log (gridSize bits)/40000) := Real.add_one_le_exp _ _ ≤ _ := by rw [←Real.exp_log (by positivity : (0:ℝ)<((2^bits j:ℕ):ℝ)),←Real.exp_add] apply Real.exp_le_exp.mpr simp only [Nat.cast_pow,Nat.cast_ofNat,Real.log_pow] linarith lemma outside_card_add_one_le {b : ℕ} (bits : Fin b → ℕ) (j : Fin b) : (Fintype.card (GridOutside bits j)+1:ℝ) ≤ 2*(gridSize bits:ℝ) := by have he := outside_card_mul_axis bits j have hp : 1 ≤ 2^bits j := Nat.one_le_pow _ _ (by omega) have hle : Fintype.card (GridOutside bits j) ≤ gridSize bits := by nlinarith have hg : 1 ≤ gridSize bits := gridSize_pos bits exact_mod_cast (show Fintype.card (GridOutside bits j)+1 ≤ 2*gridSize bits from by omega) lemma few_cutoff_bounds (b k : ℕ) (hb : 1 ≤ b) (hbB : b ≤ 16000) : 2*((k/4+1)-1+2*b*((k/(8*b)+1)-1)) ≤ k ∧ (k:ℝ) ≤ 8*(((k/4+1+1)/2:ℕ):ℝ) ∧ (k:ℝ) ≤ 128000*(k/(8*b)+1:ℕ) := by have h1 := Nat.div_mul_le_self k 4 have h2 := Nat.div_mul_le_self k (8*b) have hmod := Nat.mod_lt k (by omega : 0<8*b) have he := Nat.mod_add_div k (8*b) constructor · simp only [Nat.add_sub_cancel] nlinarith constructor · exact_mod_cast (show k ≤ 8*((k/4+1+1)/2) from by omega) · have ht : k ≤ (8*b)*(k/(8*b)+1) := by nlinarith have hh := ht.trans (Nat.mul_le_mul_right _ (show 8*b ≤ 128000 from by omega)) exact_mod_cast hh end BinaryCoordinateSweeps end end OAI