File size: 5,357 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 110 111 112 113 114 115 116 117 118 119 120 | import OAI.Probability.SATVariance.OmissionCompression
namespace OAI
noncomputable section
open MeasureTheory ProbabilityTheory
namespace RandomKSAT
open scoped Classical ENNReal
lemma deletion_square_density {n r M : β} (hr : 2 β€ r) (hn : 2*(r+1) β€ n)
(i : Fin (M+1)) {B : β} (hB : 0 β€ B) (hM : (M : β) β€ B*n) :
favg (fun cs : Fin (M+1) β Clause n (r+1) => (omittedTime i cs-finiteTime cs)^2) β€
deletionMomentC (r+1) (B*(r+1 : β)^2) (2*B^2*(r+1 : β)^4)*durationLog (r+1) M := by
let := clause_nonempty n (r+1) (by omega)
rw [favg_insertNth i]
apply le_trans (favg_mono fun c : Clause n (r+1) => ?_) (le_of_eq (favg_const _))
obtain β¨e,a,hcβ© := clause_root_presentation c
have he := favg_equiv (Equiv.piCongrRight fun _ : Fin M => splitClauseEquiv e)
(fun w : Fin M β Clause n (r+1) =>
(omittedTime i (i.insertNth c w)-finiteTime (i.insertNth c w))^2)
rw [β he]
have hb := favg_mono (fun ps : Fin M β RootData (n-(r+1)) (r+1) =>
pow_le_pow_leftβ (omittedTime_nonneg_diff i _) (deletion_difference_le_rewards e i c a hc ps) 2)
exact hb.trans (rootRewards_square_density hr (by omega) e a hB hM)
lemma ell_eq_of_three {n : β} (hn : 1 β€ n) : ell 3 n = 1+Real.log n := by
have hn0 : (n : β) β 0 := by exact_mod_cast (by omega : n β 0)
simp [ell, Real.log_mul (Real.exp_ne_zero _) hn0]
lemma ell_one_le (k n : β) (hn : 1 β€ n) : 1 β€ ell k n := by
by_cases hk : k = 3
Β· subst k
rw [ell_eq_of_three hn]
have hh := Real.log_nonneg (show (1 : β) β€ n by exact_mod_cast hn)
linarith
Β· simp [ell, hk]
lemma durationLog_density {k n M : β} (hn : 1 β€ n) {B : β} (hB : 0 β€ B)
(hM : (M+1 : β) β€ B*(n : β)) :
durationLog k M β€ (1+Real.log (B+1))*ell k n := by
have hn0 : (0 : β) < n := by exact_mod_cast (by omega : 0 < n)
have hB0 : 0 < B+1 := by linarith
have hlogB : 0 β€ Real.log (B+1) := Real.log_nonneg (by linarith)
have hlogn : 0 β€ Real.log n := Real.log_nonneg (by exact_mod_cast hn)
by_cases hk : k = 3
Β· subst k
rw [durationLog, ite_eq_left rfl, ell_eq_of_three hn]
have hm : (M : β)+1 β€ (B+1)*n := by push_cast at hM; nlinarith
have hl := Real.log_le_log (by positivity : 0 < (M : β)+1) hm
rw [Real.log_mul (ne_of_gt hB0) (ne_of_gt hn0)] at hl
nlinarith [mul_nonneg hlogB hlogn]
Β· simp only [durationLog, ell, ite_eq_right hk, mul_one]
linarith
lemma extend_upper_bound {f : β β β} (hf : β n, 0 β€ f n) {k N : β} (hk : 1 β€ k)
{C : β} (hC : 0 β€ C) (hlarge : β n, N β€ n β k β€ n β f n β€ C*n*ell k n) :
β D : β, 0 β€ D β§ β n, k β€ n β f n β€ D*n*ell k n := by
let S := β j β Finset.range N, f j
have hS : 0 β€ S := Finset.sum_nonneg (fun j _ => hf j)
refine β¨C+S,add_nonneg hC hS,fun n hkn => ?_β©
have hn : 1 β€ n := hk.trans hkn
have he := ell_one_le k n hn
have hn1 : (1 : β) β€ n := by exact_mod_cast hn
have hne : 1 β€ (n : β)*ell k n := by nlinarith
by_cases hN : N β€ n
Β· have hh := hlarge n hN hkn
nlinarith [mul_nonneg hS (show 0 β€ (n : β)*ell k n by positivity)]
Β· have hs : f n β€ S := Finset.single_le_sum (fun j _ => hf j) (Finset.mem_range.mpr (by omega))
nlinarith [mul_nonneg hC (show 0 β€ (n : β)*ell k n by positivity),
mul_le_mul_of_nonneg_left hne hS]
theorem capped_variance_upper (k : β) (hk : 3 β€ k) (B : β) (hB : 0 < B) :
β C : β, 0 β€ C β§ β n : β, k β€ n β
variance (T B : Stream n k β β) (streamLaw n k) β€ C*n*ell k n := by
cases k with
| zero => omega
| succ r =>
have hr : 2 β€ r := by omega
let K := deletionMomentC (r+1) (B*(r+1 : β)^2) (2*B^2*(r+1 : β)^4)
have hK : 0 β€ K := deletionMomentC_nonneg hr _ _ (by positivity)
let C := B*K*(1+Real.log (B+1))
have hlogB : 0 β€ Real.log (B+1) := Real.log_nonneg (by linarith)
have hC : 0 β€ C := by dsimp [C]; positivity
apply extend_upper_bound (fun n => variance_nonneg _ _) (by omega : 1 β€ r+1) hC
(N := 2*(r+1))
intro n hn _
have hn1 : 1 β€ n := by omega
have hcap : (cap n B : β) β€ B*n := Nat.floor_le (by positivity)
have hh := capped_coordinate_omission (by omega : r+1 β€ n) B
cases he : cap n B with
| zero =>
rw [he] at hh
simp only [Finset.univ_eq_empty, Finset.sum_empty] at hh
exact hh.trans (by have hh' := ell_one_le (r+1) n hn1; dsimp [C]; positivity)
| succ M =>
have hM : (M : β) β€ B*n := by rw [he] at hcap; push_cast at hcap; linarith
have hb := Finset.sum_le_sum (fun i (_ : i β (Finset.univ : Finset (Fin (M+1)))) =>
deletion_square_density hr hn i hB.le hM)
simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] at hb
rw [he] at hh hcap
have htime := durationLog_density (k := r+1) hn1 hB.le hcap
have ht := mul_le_mul_of_nonneg_left htime (mul_nonneg (Nat.cast_nonneg (M+1)) hK)
have hf := mul_le_mul_of_nonneg_right hcap
(show 0 β€ K*((1+Real.log (B+1))*ell (r+1) n) by
have he := ell_one_le (r+1) n hn1
positivity)
change _ β€ C*n*ell (r+1) n
change _ β€ ((M+1 : β) : β)*(K*durationLog (r+1) M) at hb
dsimp only [C]
nlinarith [hh.trans hb]
end RandomKSAT
end
end OAI
|