File size: 12,278 Bytes
a2ee19a | 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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | import OAI.Probability.RandomSAT.Variance
namespace OAI
/-!
Normalized capped centers and polynomial concentration of the proper-clause
satisfiability probability.
-/
namespace FixedClauseThreshold
open Finset
noncomputable section
attribute [local instance] Classical.propDecidable
def capMultiplier (k : ℕ) : ℕ := 2^(k + 1)
def mainCap (n k : ℕ) : ℕ := capMultiplier k * n
def center (n k : ℕ) : ℝ :=
lifetimeMean k (mainCap n k) (Finset.univ : Finset (Assignment n)) / n
def varianceConstant (k : ℕ) : ℝ :=
2 * (capMultiplier k : ℝ)^3 * k * (2 * k + capMultiplier k + 2)
theorem capMultiplier_pos (k : ℕ) : 0 < capMultiplier k := by
unfold capMultiplier
positivity
theorem replacementBlock_le {n k : ℕ} (hn : 1 ≤ n) :
(replacementBlock n k : ℝ) ≤ (2 * k + 1) * replacementScale n k := by
have ha := replacementScale_one_le (k := k) hn
have hc := Nat.ceil_lt_add_one (show 0 ≤ 2 * (k : ℝ) * replacementScale n k by positivity)
change (replacementBlock n k : ℝ) < 2 * k * replacementScale n k + 1 at hc
nlinarith
theorem replacementError_mul {n k : ℕ} (hn : 0 < n) (hk : 0 < k) :
(n : ℝ) * replacementError n k = replacementScale n k := by
have ha := replacementScale_pos (k := k) hn
have hp : replacementScale n k ^ (k - 1) * replacementScale n k = (n : ℝ) := by
rw [← pow_succ, Nat.sub_add_cancel hk, replacementScale_pow hn hk]
unfold replacementError
rw [inv_pow]
rw [mul_inv_eq_iff_eq_mul₀ (pow_ne_zero _ (ne_of_gt ha))]
nlinarith [hp]
theorem integrated_forcing_capped {n k L : ℕ} (hk : 3 ≤ k) (hn : k + 1 ≤ n) :
∑ j ∈ Finset.range (L * n), forcedFractionMean n k j ≤
((L : ℝ) * k * (2 * k + L + 2)) * replacementScale n k := by
have hn0 : 0 < n := by omega
have hn1 : (1 : ℝ) ≤ n := by exact_mod_cast hn0
have h := integrated_forcing_finite hk hn (L * n)
have hpartial : (∑ j ∈ Finset.range (L * n), forcedFractionMean n k j) ≤
∑ j ∈ Finset.range (L * n + 1), forcedFractionMean n k j := by
rw [Finset.sum_range_succ]
exact le_add_of_nonneg_right (uniformMean_nonneg (fun _ => by positivity))
have heps := replacementError_mul (k := k) hn0 (by omega)
have hg := replacementBlock_le (k := k) (by omega : 1 ≤ n)
have ha := replacementScale_pos (k := k) hn0
have he0 := replacementError_nonneg n k
have hclean : (replacementBlock n k : ℝ) * ((L * n : ℕ) : ℝ) * ((k : ℝ) / n) +
((L * n + 1 : ℕ) : ℝ) * ((L * n : ℕ) : ℝ) * ((k : ℝ) / n) * replacementError n k =
(L : ℝ) * k * replacementBlock n k +
((L : ℝ) * n + 1) * L * k * replacementError n k := by
simp only [Nat.cast_add, Nat.cast_mul, Nat.cast_one]
field_simp
rw [hclean] at h
have he : replacementError n k ≤ replacementScale n k := by
nlinarith [mul_nonneg (sub_nonneg.mpr hn1) he0]
have hg' := mul_le_mul_of_nonneg_left hg (by positivity : (0 : ℝ) ≤ L * k)
have he' := mul_le_mul_of_nonneg_left he (by positivity : (0 : ℝ) ≤ L * k)
have hp : ((L : ℝ) * n + 1) * L * k * replacementError n k =
(L : ℝ)^2 * k * replacementScale n k + L * k * replacementError n k := by
nlinarith [congrArg (fun x : ℝ => (L : ℝ)^2 * k * x) heps]
rw [hp] at h
nlinarith
theorem variance_capped {n k : ℕ} (hk : 3 ≤ k) (hn : k + 1 ≤ n) :
lifetimeVariance k (mainCap n k) (Finset.univ : Finset (Assignment n)) ≤
varianceConstant k * n * replacementScale n k ^ 2 := by
have hL : (1 : ℝ) ≤ capMultiplier k := by exact_mod_cast capMultiplier_pos k
have hv := lifetimeVariance_forcing_bound (n := n) (k := k) (M := mainCap n k)
(L := capMultiplier k) (by omega) (by omega) hL (by simp [mainCap])
have hf := integrated_forcing_capped (L := capMultiplier k) hk hn
have hmul := mul_le_mul_of_nonneg_left hf
(show 0 ≤ 2 * (mainCap n k : ℝ) * capMultiplier k * replacementScale n k by
have ha := replacementScale_pos (k := k) (by omega : 0 < n)
positivity)
apply hv.trans
exact hmul.trans_eq (by simp only [mainCap, Nat.cast_mul, varianceConstant]; ring)
theorem uniform_chebyshev {α : Type*} [Fintype α] [Nonempty α]
(f : α → ℝ) {t : ℝ} (ht : 0 < t) :
uniformProbability (fun a => t ≤ |f a - uniformMean f|) ≤ uniformVariance f / t^2 := by
rw [le_div_iff₀ (sq_pos_of_pos ht), uniformProbability_eq_mean, ← uniformMean_mul_const]
apply uniformMean_mono
intro a
by_cases h : t ≤ |f a - uniformMean f|
· simp only [ite_eq_left h, one_mul]
nlinarith [sq_abs (f a - uniformMean f)]
· simp only [ite_eq_right h, zero_mul]
exact sq_nonneg _
theorem alive_univ (n : ℕ) : alive (Finset.univ : Finset (Assignment n)) = 1 := by
simp [alive]
theorem uniformProbability_fin_succ {α : Type*} [Fintype α] {m : ℕ}
(p : (Fin (m + 1) → α) → Prop) :
uniformProbability p = uniformMean (fun C : α => uniformProbability
(fun F : Fin m → α => p (Fin.cons C F))) := by
rw [uniformProbability_eq_mean, uniformMean_fin_succ]
apply uniformMean_congr
intro C
exact (uniformProbability_eq_mean _).symm
theorem lifetime_tail_probability {n k m M : ℕ} (hkn : k ≤ n) (hm : m ≤ M)
(S : Finset (Assignment n)) :
uniformProbability (fun F : Formula n k M => S.Nonempty ∧ (m : ℝ) ≤ lifetime k M S F) =
survival k m S := by
let : Nonempty (ProperClause n k) := nonempty_properClause hkn
induction m generalizing M S with
| zero =>
rw [uniformProbability_eq_mean, survival_zero]
have he : (fun F : Formula n k M => if S.Nonempty ∧ (0 : ℝ) ≤ lifetime k M S F
then (1 : ℝ) else 0) = fun _ => alive S := by
funext F
simp only [and_iff_left (lifetime_nonneg S F), alive]
simp only [Nat.cast_zero, he, uniformMean_const]
| succ m ih =>
cases M with
| zero => omega
| succ M =>
rw [uniformProbability_fin_succ]
have he (C : ProperClause n k) (F : Formula n k M) :
(S.Nonempty ∧ ((m + 1 : ℕ) : ℝ) ≤ lifetime k (M + 1) S (Fin.cons C F)) ↔
(addClause S C).Nonempty ∧ (m : ℝ) ≤ lifetime k M (addClause S C) F := by
rw [lifetime_cons, Nat.cast_add, Nat.cast_one]
by_cases hC : (addClause S C).Nonempty
· have hS : S.Nonempty := hC.mono (addClause_subset S C)
simp only [hS, hC, alive, ite_true, true_and]
constructor <;> intro h <;> linarith
· have hempty : addClause S C = ∅ := Finset.not_nonempty_iff_eq_empty.mp hC
simp only [hempty, alive_empty, lifetime_empty, add_zero, Finset.not_nonempty_empty,
false_and]
have hm0 : (0 : ℝ) ≤ m := Nat.cast_nonneg _
constructor
· rintro ⟨_, hh⟩; linarith
· exact False.elim
rw [survival_succ]
apply uniformMean_congr
intro C
exact (uniformProbability_congr (he C)).trans (ih (M := M) (by omega) (addClause S C))
theorem properSATProbability_eq_lifetime_tail {n k m M : ℕ} (hkn : k ≤ n) (hm : m ≤ M) :
properSATProbability n k m = uniformProbability (fun F : Formula n k M =>
(m : ℝ) ≤ lifetime k M Finset.univ F) := by
rw [properSATProbability_eq_survival, ← lifetime_tail_probability hkn hm]
congr 1
funext F
simp
def delta (k : ℕ) : ℝ := ((k : ℝ) - 2) / (4 * k)
def eta (k : ℕ) : ℝ := ((k : ℝ) - 2) / (2 * k)
def fluctuationWindow (n k : ℕ) : ℝ := (n : ℝ) ^ (1 - delta k)
def concentrationError (n k : ℕ) : ℝ := varianceConstant k * (n : ℝ) ^ (-eta k)
theorem delta_pos {k : ℕ} (hk : 3 ≤ k) : 0 < delta k := by
have hk' : (3 : ℝ) ≤ k := by exact_mod_cast hk
unfold delta
exact div_pos (by linarith) (by positivity)
theorem delta_lt_half {k : ℕ} (hk : 3 ≤ k) : delta k < 1 / 2 := by
have hk' : (3 : ℝ) ≤ k := by exact_mod_cast hk
rw [delta, div_lt_iff₀ (by positivity : (0 : ℝ) < 4 * k)]
linarith
theorem eta_eq_twice_delta (k : ℕ) : eta k = 2 * delta k := by
unfold eta delta
ring
theorem varianceConstant_nonneg (k : ℕ) : 0 ≤ varianceConstant k := by
unfold varianceConstant
positivity
theorem fluctuationWindow_pos {n k : ℕ} (hn : 0 < n) : 0 < fluctuationWindow n k :=
Real.rpow_pos_of_pos (by exact_mod_cast hn) _
theorem concentrationError_nonneg (n k : ℕ) : 0 ≤ concentrationError n k :=
mul_nonneg (varianceConstant_nonneg k) (Real.rpow_nonneg (Nat.cast_nonneg _) _)
theorem variance_window_identity {n k : ℕ} (hn : 0 < n) (hk : 0 < k) :
(n : ℝ) * replacementScale n k ^ 2 =
fluctuationWindow n k ^ 2 * (n : ℝ)^(-eta k) := by
have hn' : (0 : ℝ) < n := by exact_mod_cast hn
have hk' : (k : ℝ) ≠ 0 := by exact_mod_cast Nat.ne_of_gt hk
have hexp : 1 + (1 / (k : ℝ)) * 2 = (1 - delta k) * 2 + -eta k := by
unfold delta eta
field_simp
ring
calc
_ = (n : ℝ)^(1 + (1 / (k : ℝ)) * 2) := by
rw [Real.rpow_add hn', Real.rpow_one, Real.rpow_mul hn'.le, Real.rpow_two]
rfl
_ = (n : ℝ)^((1 - delta k) * 2 + -eta k) := by rw [hexp]
_ = _ := by
rw [Real.rpow_add hn', Real.rpow_mul hn'.le, Real.rpow_two]
rfl
theorem concentration_capped {n k : ℕ} (hk : 3 ≤ k) (hn : k + 1 ≤ n) :
uniformProbability (fun F : Formula n k (mainCap n k) =>
fluctuationWindow n k ≤ |lifetime k (mainCap n k) Finset.univ F -
(n : ℝ) * center n k|) ≤ concentrationError n k := by
let : Nonempty (ProperClause n k) := nonempty_properClause (by omega)
have hn0 : 0 < n := by omega
have hn' : (n : ℝ) ≠ 0 := by exact_mod_cast Nat.ne_of_gt hn0
have hm : (n : ℝ) * center n k = lifetimeMean k (mainCap n k) (Finset.univ : Finset (Assignment n)) := by
unfold center
field_simp
rw [hm]
have h := uniform_chebyshev (lifetime k (mainCap n k) (Finset.univ : Finset (Assignment n)))
(fluctuationWindow_pos (k := k) hn0)
apply h.trans
have hv := div_le_div_of_nonneg_right (variance_capped hk hn)
(sq_nonneg (fluctuationWindow n k))
apply hv.trans_eq
have hid := variance_window_identity (k := k) hn0 (by omega)
unfold concentrationError
calc
_ = varianceConstant k * ((n : ℝ) * replacementScale n k^2) / fluctuationWindow n k^2 := by ring
_ = _ := by
rw [hid]
field_simp [ne_of_gt (fluctuationWindow_pos (k := k) hn0)]
theorem center_nonneg (n k : ℕ) : 0 ≤ center n k := by
unfold center lifetimeMean
exact div_nonneg (uniformMean_nonneg (fun F => lifetime_nonneg _ F)) (Nat.cast_nonneg _)
theorem center_le_capMultiplier {n k : ℕ} (hkn : k ≤ n) (hn : 0 < n) :
center n k ≤ capMultiplier k := by
let : Nonempty (ProperClause n k) := nonempty_properClause hkn
have h := uniformMean_mono (fun F : Formula n k (mainCap n k) => lifetime_le Finset.univ F)
rw [uniformMean_const] at h
unfold center lifetimeMean
rw [div_le_iff₀ (by exact_mod_cast hn : (0 : ℝ) < n)]
simpa [mainCap] using h
theorem properSATProbability_center_upper {n k m : ℕ} (hk : 3 ≤ k) (hn : k + 1 ≤ n)
(hm : m ≤ mainCap n k)
(hgap : (n : ℝ) * center n k + fluctuationWindow n k ≤ m) :
properSATProbability n k m ≤ concentrationError n k := by
rw [properSATProbability_eq_lifetime_tail (by omega) hm]
apply (uniformProbability_mono (fun F hF => ?_)).trans (concentration_capped hk hn)
exact le_trans (by linarith) (le_abs_self _)
theorem properSATProbability_center_lower {n k m : ℕ} (hk : 3 ≤ k) (hn : k + 1 ≤ n)
(hm : m ≤ mainCap n k)
(hgap : (m : ℝ) + fluctuationWindow n k ≤ (n : ℝ) * center n k) :
1 - concentrationError n k ≤ properSATProbability n k m := by
let : Nonempty (ProperClause n k) := nonempty_properClause (by omega)
rw [properSATProbability_eq_lifetime_tail (by omega) hm]
have h := uniformProbability_mono (p := fun F : Formula n k (mainCap n k) =>
¬ (m : ℝ) ≤ lifetime k (mainCap n k) Finset.univ F)
(q := fun F => fluctuationWindow n k ≤
|lifetime k (mainCap n k) Finset.univ F - (n : ℝ) * center n k|) (fun F hF => by
have hh : lifetime k (mainCap n k) Finset.univ F < m := lt_of_not_ge hF
exact le_trans (by linarith) (neg_le_abs _))
rw [uniformProbability_not] at h
linarith [concentration_capped hk hn]
end
end FixedClauseThreshold
end OAI
|