File size: 4,624 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | import OAI.Probability.SATVariance.FirstFailure
namespace OAI
noncomputable section
open MeasureTheory ProbabilityTheory
namespace RandomKSAT
open scoped Classical ENNReal
def killRatio (u b s : β) : β := (b.choose s : β) / (2 ^ s * u.choose s)
lemma killRatio_nonneg (u b s : β) : 0 β€ killRatio u b s := by
unfold killRatio
positivity
lemma killRatio_zero (u b : β) : killRatio u b 0 = 1 := by
simp [killRatio]
lemma killRatio_eq_zero {u b s : β} (hbs : b < s) : killRatio u b s = 0 := by
simp [killRatio, Nat.choose_eq_zero_of_lt hbs]
lemma killRatio_succ {u b s : β} (hsu : s < u) (hsb : s β€ b) :
killRatio u b (s + 1) = killRatio u b s * ((b : β) - s) / (2 * (u - s)) := by
have hu : (0 : β) < u.choose s := by exact_mod_cast Nat.choose_pos hsu.le
have hu' : (0 : β) < u.choose (s+1) := by exact_mod_cast Nat.choose_pos hsu
have hus : (0 : β) < (u : β) - s := sub_pos.mpr (by exact_mod_cast hsu)
have hb := congrArg (fun x : β => (x : β)) (Nat.choose_succ_right_eq b s)
have hn := congrArg (fun x : β => (x : β)) (Nat.choose_succ_right_eq u s)
push_cast [Nat.cast_sub hsb] at hb
push_cast [Nat.cast_sub hsu.le] at hn
unfold killRatio
rw [pow_succ]
apply (div_eq_iff (by positivity : (2 : β)^s * 2 * u.choose (s+1) β 0)).2
field_simp
nlinarith [mul_pos hu hus]
lemma killRatio_le_density_pow {u b s : β} (hbu : b β€ u) (hsu : s β€ u) :
killRatio u b s β€ ((b : β) / (2 * u)) ^ s := by
induction s with
| zero => simp [killRatio_zero]
| succ s ih =>
by_cases hbs : b < s+1
Β· rw [killRatio_eq_zero hbs]
positivity
Β· have hsb : s β€ b := by omega
have hsu' : s < u := by omega
have hus : (0 : β) < (u : β) - s := sub_pos.mpr (by exact_mod_cast hsu')
have hu : (0 : β) < u := by exact_mod_cast (Nat.zero_le s).trans_lt hsu'
have hbu' : (b : β) β€ u := by exact_mod_cast hbu
have hs : (0 : β) β€ s := by positivity
have hfactor : ((b : β)-s) / (2 * (u-s)) β€ (b : β)/(2*u) := by
apply (div_le_div_iffβ (by positivity) (by positivity)).2
nlinarith
rw [killRatio_succ hsu' hsb, mul_div_assoc, pow_succ]
have hbsβ : (0 : β) β€ (b : β) - s := sub_nonneg.mpr (by exact_mod_cast hsb)
exact mul_le_mul (ih (by omega)) hfactor (by positivity) (by positivity)
lemma killRatio_le_half_pow {u b s : β} (hu : 0 < u) (hbu : b β€ u) (hsu : s β€ u) :
killRatio u b s β€ ((1 : β)/2)^s := by
apply (killRatio_le_density_pow hbu hsu).trans
apply pow_le_pow_leftβ (by positivity)
apply (div_le_iffβ (by positivity : (0 : β) < 2*u)).2
have hb : (b : β) β€ u := by exact_mod_cast hbu
nlinarith
lemma killRatio_pos {u b s : β} (hsb : s β€ b) (hsu : s β€ u) :
0 < killRatio u b s := by
unfold killRatio
have hb : (0 : β) < b.choose s := by exact_mod_cast Nat.choose_pos hsb
have hu : (0 : β) < u.choose s := by exact_mod_cast Nat.choose_pos hsu
positivity
lemma killRatio_root_le {u b r : β} (hr : 0 < r) (hbu : b β€ u) (hru : r β€ u) :
(killRatio u b r) ^ ((r : β)β»ΒΉ) β€ (b : β) / (2*u) := by
have hrβ : (r : β) β 0 := by positivity
have h := Real.rpow_le_rpow (killRatio_nonneg u b r)
(killRatio_le_density_pow hbu hru) (by positivity : (0 : β) β€ (r : β)β»ΒΉ)
rw [β Real.rpow_natCast_mul (by positivity), mul_inv_cancelβ hrβ,
Real.rpow_one] at h
exact h
lemma frozen_power {u b r : β} (hr : 1 β€ r) (hbu : b β€ u) (hrb : r+1 β€ b) :
(killRatio u b r) ^ (((r : β)+1)/r) / (r+1) β€ killRatio u b (r+1) := by
have hru : r < u := by omega
have hrβ : (0 : β) < r := by exact_mod_cast hr
have huβ : (0 : β) < u := by exact_mod_cast (Nat.zero_le r).trans_lt hru
have hus : (0 : β) < (u : β)-r := sub_pos.mpr (by exact_mod_cast hru)
have hrb' : (r : β)+1 β€ b := by exact_mod_cast hrb
have hbu' : (b : β) β€ u := by exact_mod_cast hbu
have hstep : (b : β)/(2*u)/(r+1) β€ ((b : β)-r)/(2*(u-r)) := by
rw [div_div]
apply (div_le_div_iffβ (by positivity) (by positivity)).2
nlinarith [mul_nonneg (sub_nonneg.mpr hrb') (le_of_lt hrβ)]
have he : ((r : β)+1)/r = 1+(r : β)β»ΒΉ := by field_simp
rw [he, Real.rpow_add_of_nonneg (killRatio_nonneg u b r) zero_le_one (by positivity),
Real.rpow_one, mul_div_assoc, killRatio_succ hru (by omega), mul_div_assoc]
apply mul_le_mul_of_nonneg_left _ (killRatio_nonneg u b r)
exact (div_le_div_of_nonneg_right (killRatio_root_le (by omega) hbu hru.le)
(by positivity)).trans hstep
end RandomKSAT
end
end OAI
|