File size: 16,831 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 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 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | import OAI.Algorithms.SubexponentialSAT.LeanCompat
import OAI.Algorithms.SubexponentialSAT.SparsificationConstants
namespace OAI.Algorithms
/-!
# Counting binary branch-tree paths
False labels an A edge and true labels a B edge. A word is encoded injectively
by its length and the finite set of positions occupied by B. This proves the
finite counting step in Appendix A.3 without any analytic hypotheses.
-/
namespace SubexponentialSAT.BranchTree
open Finset
open scoped BigOperators
/-- The zero-based positions of B edges in an actual binary path. -/
def bPositions (p : List Bool) : Finset β :=
(range p.length).filter fun i => p[i]? = some true
@[simp] theorem mem_bPositions (p : List Bool) (i : β) :
i β bPositions p β i < p.length β§ p[i]? = some true := by
simp [bPositions]
/-- The B-position set is contained in the range of the path length. -/
theorem bPositions_subset (p : List Bool) : bPositions p β range p.length :=
filter_subset _ _
/-- Depth and B positions determine every edge of a binary path. -/
theorem eq_of_length_bPositions_eq {p q : List Bool}
(hlen : p.length = q.length) (hpos : bPositions p = bPositions q) : p = q := by
apply List.ext_getElem hlen
intro i hp hq
have he : (p[i]'hp = true) β (q[i]'hq = true) := by
have hm : i β bPositions p β i β bPositions q := by rw [hpos]
simpa [mem_bPositions, hp, hq, List.getElem?_eq_getElem] using hm
cases hvp : p[i]'hp <;> cases hvq : q[i]'hq <;> simp_all
/-- The concrete code used in the manuscript. -/
def pathCode (p : List Bool) : β Γ Finset β := (p.length, bPositions p)
theorem pathCode_injective : Function.Injective pathCode := by
intro p q h
exact eq_of_length_bPositions_eq (congrArg Prod.fst h) (congrArg Prod.snd h)
/-- All possible B-position sets of size at most R in a D-position ambient set. -/
def positionSets (D R : β) : Finset (Finset β) :=
(range (R + 1)).biUnion fun r => (range D).powersetCard r
theorem mem_positionSets {D R : β} {s : Finset β} :
s β positionSets D R β s β range D β§ s.card β€ R := by
simp only [positionSets, mem_biUnion, mem_range, mem_powersetCard]
constructor
Β· rintro β¨r, hr, hs, heβ©
exact β¨hs, he βΈ Nat.le_of_lt_succ hrβ©
Β· rintro β¨hs, hcβ©
exact β¨s.card, Nat.lt_succ_of_le hc, hs, rflβ©
theorem card_positionSets_le (D R : β) :
(positionSets D R).card β€ β r β range (R + 1), D.choose r := by
calc
(positionSets D R).card β€
β r β range (R + 1), ((range D).powersetCard r).card := card_biUnion_le
_ = β r β range (R + 1), D.choose r := by simp
/-- Every finite collection of actual binary paths obeys the node-count bound.
Prefix closure is unnecessary for this stronger statement. -/
theorem card_paths_le (P : Finset (List Bool)) (D R : β)
(hdepth : β p β P, p.length β€ D)
(hB : β p β P, (bPositions p).card β€ R) :
P.card β€ (D + 1) * β r β range (R + 1), D.choose r := by
have hsub : P.image pathCode β range (D + 1) ΓΛ’ positionSets D R := by
intro c hc
obtain β¨p, hp, rflβ© := mem_image.mp hc
apply mem_product.mpr
refine β¨mem_range.mpr (Nat.lt_succ_of_le (hdepth p hp)), ?_β©
apply mem_positionSets.mpr
refine β¨?_, hB p hpβ©
exact (bPositions_subset p).trans (range_mono (hdepth p hp))
calc
P.card = (P.image pathCode).card := (card_image_of_injective P pathCode_injective).symm
_ β€ (range (D + 1) ΓΛ’ positionSets D R).card := card_le_card hsub
_ = (D + 1) * (positionSets D R).card := by simp
_ β€ (D + 1) * β r β range (R + 1), D.choose r :=
Nat.mul_le_mul_left _ (card_positionSets_le D R)
/-- A finite rooted binary tree, with A as its left edge and B as its right edge. -/
inductive Tree where
| leaf : Tree
| branch : Tree β Tree β Tree
/-- All root-to-node paths, including the empty path to the root. -/
def Tree.paths : Tree β Finset (List Bool)
| .leaf => {[]}
| .branch A B => insert []
((A.paths.image (List.cons false)) βͺ (B.paths.image (List.cons true)))
/-- The number of actual nodes of this finite tree. -/
def Tree.nodeCount : Tree β β
| .leaf => 1
| .branch A B => 1 + A.nodeCount + B.nodeCount
@[simp] theorem Tree.card_paths (t : Tree) : t.paths.card = t.nodeCount := by
induction t with
| leaf => simp [Tree.paths, Tree.nodeCount]
| branch A B ihA ihB =>
have hd : Disjoint (A.paths.image (List.cons false))
(B.paths.image (List.cons true)) := by
apply disjoint_left.mpr
intro p hpA hpB
obtain β¨a, ha, rflβ© := mem_image.mp hpA
obtain β¨b, hb, heβ© := mem_image.mp hpB
cases he
have hAinj : Function.Injective (List.cons false : List Bool β List Bool) := by
intro a b h
exact List.cons.inj h |>.2
have hBinj : Function.Injective (List.cons true : List Bool β List Bool) := by
intro a b h
exact List.cons.inj h |>.2
simp only [Tree.paths, Tree.nodeCount]
rw [Finset.card_insert_of_notMem (by simp), card_union_of_disjoint hd,
card_image_of_injective _ hAinj, card_image_of_injective _ hBinj, ihA, ihB]
omega
/-- Appendix A.3's finite-tree bound, with every internal node included. -/
theorem Tree.nodeCount_le (t : Tree) (D R : β)
(hdepth : β p β t.paths, p.length β€ D)
(hB : β p β t.paths, (bPositions p).card β€ R) :
t.nodeCount β€ (D + 1) * β r β range (R + 1), D.choose r := by
rw [β t.card_paths]
exact card_paths_le t.paths D R hdepth hB
/-- The paper's exact floor convention: natural division is floor division. -/
theorem Tree.nodeCount_le_sparsification (t : Tree) (C k n M : β)
(hdepth : β p β t.paths, p.length β€ C * n)
(hB : β p β t.paths, (bPositions p).card β€ k * n / M) :
t.nodeCount β€ (C * n + 1) * β r β range (k * n / M + 1), (C * n).choose r :=
t.nodeCount_le (C * n) (k * n / M) hdepth hB
/-- Any pointwise binomial estimate produces precisely this polynomial factor. -/
theorem card_paths_le_of_choose_le (P : Finset (List Bool)) (D R E : β)
(hdepth : β p β P, p.length β€ D)
(hB : β p β P, (bPositions p).card β€ R)
(hchoose : β r β€ R, D.choose r β€ E) :
P.card β€ (D + 1) * (R + 1) * E := by
calc
P.card β€ (D + 1) * β r β range (R + 1), D.choose r := card_paths_le P D R hdepth hB
_ β€ (D + 1) * β _r β range (R + 1), E := by
apply Nat.mul_le_mul_left
exact sum_le_sum fun r hr => hchoose r (Nat.le_of_lt_succ (mem_range.mp hr))
_ = (D + 1) * (R + 1) * E := by simp [Nat.mul_assoc]
end SubexponentialSAT.BranchTree
namespace SubexponentialSAT.BranchTree
/-- A uniform binomial estimate valid at a real, not necessarily integral, cutoff. -/
theorem choose_le_rpow_real (D r : β) {q : β} (hq : 0 < q)
(hD : q β€ D) (hr : (r : β) β€ q) :
(D.choose r : β) β€ (4 * (D : β) / q) ^ q := by
have hbase : 1 β€ (D : β) / q := (le_div_iffβ hq).2 (by simpa using hD)
have hbasenonneg : 0 β€ (D : β) / q := le_trans zero_le_one hbase
have hsplit : (D : β) ^ r / (r.factorial : β) =
((D : β) / q) ^ r * (q ^ r / (r.factorial : β)) := by
rw [div_pow]
field_simp
have hpow : ((D : β) / q) ^ r β€ ((D : β) / q) ^ q := by
simpa only [Real.rpow_natCast] using
(Real.rpow_le_rpow_of_exponent_le hbase hr)
have hexp : Real.exp q β€ (4 : β) ^ q := by
rw [β Real.exp_one_rpow]
exact Real.rpow_le_rpow (Real.exp_nonneg _) (by linarith [Real.exp_one_lt_d9]) hq.le
calc
(D.choose r : β) β€ (D : β) ^ r / (r.factorial : β) := Nat.choose_le_pow_div r D
_ = ((D : β) / q) ^ r * (q ^ r / (r.factorial : β)) := hsplit
_ β€ ((D : β) / q) ^ r * Real.exp q :=
mul_le_mul_of_nonneg_left (Real.pow_div_factorial_le_exp q hq.le r)
(pow_nonneg hbasenonneg r)
_ β€ ((D : β) / q) ^ q * Real.exp q :=
mul_le_mul_of_nonneg_right hpow (Real.exp_nonneg q)
_ β€ ((D : β) / q) ^ q * (4 : β) ^ q :=
mul_le_mul_of_nonneg_left hexp (Real.rpow_nonneg hbasenonneg _)
_ = (4 * (D : β) / q) ^ q := by
rw [β Real.mul_rpow hbasenonneg (by norm_num : (0 : β) β€ 4)]
congr 1
ring
end SubexponentialSAT.BranchTree
namespace SubexponentialSAT.BranchTree
open Finset
open scoped BigOperators
/-- The finite path bound with an arbitrary positive real cutoff. -/
theorem card_paths_le_rpow_real (P : Finset (List Bool)) (D R : β) {q : β}
(hq : 0 < q) (hD : q β€ D) (hR : (R : β) β€ q)
(hdepth : β p β P, p.length β€ D)
(hB : β p β P, (bPositions p).card β€ R) :
(P.card : β) β€ ((D : β) + 1) * ((R : β) + 1) * (4 * (D : β) / q) ^ q := by
have hcount : (P.card : β) β€ ((D : β) + 1) *
β r β range (R + 1), (D.choose r : β) := by
exact_mod_cast card_paths_le P D R hdepth hB
calc
(P.card : β) β€ ((D : β) + 1) *
β r β range (R + 1), (D.choose r : β) := hcount
_ β€ ((D : β) + 1) * β _r β range (R + 1), (4 * (D : β) / q) ^ q := by
apply mul_le_mul_of_nonneg_left _ (by positivity)
apply sum_le_sum
intro r hr
apply choose_le_rpow_real D r hq hD
exact (Nat.cast_le.mpr (Nat.le_of_lt_succ (mem_range.mp hr))).trans hR
_ = ((D : β) + 1) * ((R : β) + 1) * (4 * (D : β) / q) ^ q := by
simp [mul_assoc]
/-- The only budget used here is the explicit logarithmic exponent inequality. -/
theorem card_paths_le_two_rpow (P : Finset (List Bool)) (D R : β) {q e : β}
(hq : 0 < q) (hD : q β€ D) (hR : (R : β) β€ q)
(hdepth : β p β P, p.length β€ D)
(hB : β p β P, (bPositions p).card β€ R)
(hbudget : q * Real.log (4 * (D : β) / q) β€ Real.log 2 * e) :
(P.card : β) β€ ((D : β) + 1) * ((R : β) + 1) * (2 : β) ^ e := by
have hDpos : 0 < (D : β) := hq.trans_le hD
have hbpos : 0 < 4 * (D : β) / q := by positivity
have hexp : (4 * (D : β) / q) ^ q β€ (2 : β) ^ e := by
rw [Real.rpow_def_of_pos hbpos, Real.rpow_def_of_pos (by norm_num), Real.exp_le_exp]
simpa only [mul_comm] using hbudget
exact (card_paths_le_rpow_real P D R hq hD hR hdepth hB).trans
(mul_le_mul_of_nonneg_left hexp (by positivity))
/-- Appendix A.3, including floor division and the n=0 case, under its stated
fixed-parameter budget. This is an actual bound on finite path cardinality. -/
theorem card_paths_le_sparsification_exponential (P : Finset (List Bool))
(C k n M : β) (hk : 0 < k) (hM : 0 < M)
(hDim : (k : β) / M β€ C)
(hbudget : (k : β) / M * Real.log (4 * (C : β) * M / k) β€ Real.log 2 / 32)
(hdepth : β p β P, p.length β€ C * n)
(hB : β p β P, (bPositions p).card β€ k * n / M) :
(P.card : β) β€ ((C * n + 1 : β) : β) * ((k * n / M + 1 : β) : β) *
(2 : β) ^ ((n : β) / 32) := by
by_cases hn : n = 0
Β· subst n
have hcount := card_paths_le P (C * 0) (k * 0 / M) hdepth hB
have hone : P.card β€ 1 := by simpa using hcount
simpa using (show (P.card : β) β€ 1 by exact_mod_cast hone)
have hnpos : 0 < (n : β) := Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)
have hkpos : 0 < (k : β) := Nat.cast_pos.mpr hk
have hMpos : 0 < (M : β) := Nat.cast_pos.mpr hM
let q : β := (k : β) * n / M
have hq : 0 < q := by dsimp [q]; positivity
have hD : q β€ (C * n : β) := by
have h := mul_le_mul_of_nonneg_right hDim hnpos.le
simpa [q, Nat.cast_mul, div_mul_eq_mul_div] using h
have hR : ((k * n / M : β) : β) β€ q := by
simpa [q, Nat.cast_mul] using (Nat.cast_div_le (m := k * n) (n := M) (Ξ± := β))
have hbase : 4 * ((C * n : β) : β) / q = 4 * (C : β) * M / k := by
dsimp [q]
push_cast
field_simp
have hb : q * Real.log (4 * ((C * n : β) : β) / q) β€
Real.log 2 * ((n : β) / 32) := by
rw [hbase]
have h := mul_le_mul_of_nonneg_right hbudget hnpos.le
convert h using 1 <;> first | (dsimp [q]; ring) | ring
have h := card_paths_le_two_rpow P (C * n) (k * n / M) hq hD hR hdepth hB hb
simpa only [Nat.cast_add, Nat.cast_one] using h
end SubexponentialSAT.BranchTree
namespace SubexponentialSAT.BranchTree
/-- The exponential estimate applies to the actual number of tree nodes. -/
theorem Tree.nodeCount_le_sparsification_exponential (t : Tree)
(C k n M : β) (hk : 0 < k) (hM : 0 < M)
(hDim : (k : β) / M β€ C)
(hbudget : (k : β) / M * Real.log (4 * (C : β) * M / k) β€ Real.log 2 / 32)
(hdepth : β p β t.paths, p.length β€ C * n)
(hB : β p β t.paths, (bPositions p).card β€ k * n / M) :
(t.nodeCount : β) β€ ((C * n + 1 : β) : β) * ((k * n / M + 1 : β) : β) *
(2 : β) ^ ((n : β) / 32) := by
rw [β t.card_paths]
exact card_paths_le_sparsification_exponential t.paths C k n M hk hM
hDim hbudget hdepth hB
/-- No analytic hypothesis remains once the constants module supplies its
integer admissibility certificate. The remaining premises are the two
combinatorial path bounds to be established for the sunflower process. -/
theorem Tree.nodeCount_le_of_admissible (t : Tree) (k n M : β) (hk : 2 β€ k)
(hM : SparsificationConstants.Admissible k M)
(hdepth : β p β t.paths, p.length β€ SparsificationConstants.C M (k - 1) * n)
(hB : β p β t.paths, (bPositions p).card β€ k * n / M) :
(t.nodeCount : β) β€ ((SparsificationConstants.C M (k - 1) * n + 1 : β) : β) *
((k * n / M + 1 : β) : β) * (2 : β) ^ ((n : β) / 32) := by
exact t.nodeCount_le_sparsification_exponential
(SparsificationConstants.C M (k - 1)) k n M (by omega)
(by have := hM.1; omega) hM.ratio_le (hM.log_budget hk) hdepth hB
/-- The deterministic selected constants meet the exponent budget for every
input size. Their dependence on k is explicit; there is no n-dependent choice. -/
theorem Tree.nodeCount_le_chosen_parameters (t : Tree) (k n : β) (hk : 2 β€ k) :
let M := SparsificationConstants.chooseM k hk
let C := SparsificationConstants.C M (k - 1)
(β p β t.paths, p.length β€ C * n) β
(β p β t.paths, (bPositions p).card β€ k * n / M) β
(t.nodeCount : β) β€ ((C * n + 1 : β) : β) * ((k * n / M + 1 : β) : β) *
(2 : β) ^ ((n : β) / 32) := by
dsimp
intro hdepth hB
exact t.nodeCount_le_of_admissible k n (SparsificationConstants.chooseM k hk) hk
(SparsificationConstants.chooseM_spec k hk) hdepth hB
/-- The factor suppressed by `poly_k(n+1)` is at most a quadratic polynomial,
even without using M > 0. -/
theorem polynomial_prefactor_bound (C k n M : β) :
(C * n + 1) * (k * n / M + 1) β€ (C + 1) * (k + 1) * (n + 1) ^ 2 := by
have hdiv : k * n / M β€ k * n := Nat.div_le_self _ _
calc
(C * n + 1) * (k * n / M + 1) β€ (C * n + 1) * (k * n + 1) := by
gcongr
_ β€ ((C + 1) * (n + 1)) * ((k + 1) * (n + 1)) := by
apply Nat.mul_le_mul <;> nlinarith
_ = (C + 1) * (k + 1) * (n + 1) ^ 2 := by ring
end SubexponentialSAT.BranchTree
namespace SubexponentialSAT.BranchTree
open Finset
theorem bPositions_cons (b : Bool) (p : List Bool) :
bPositions (b :: p) = (if b then {0} else β
) βͺ (bPositions p).image Nat.succ := by
ext i
cases i with
| zero => cases b <;> simp [mem_bPositions]
| succ i => cases b <;> simp [mem_bPositions, mem_image]
theorem card_bPositions_cons (b : Bool) (p : List Bool) :
(bPositions (b :: p)).card = (if b then 1 else 0) + (bPositions p).card := by
rw [bPositions_cons]
cases b <;> simp [card_image_of_injective _ Nat.succ_injective, Nat.add_comm]
theorem card_bPositions_eq_count (p : List Bool) :
(bPositions p).card = p.count true := by
induction p with
| nil => simp [bPositions]
| cons b p ih =>
rw [card_bPositions_cons, ih]
cases b <;> simp [Nat.add_comm]
end SubexponentialSAT.BranchTree
namespace SubexponentialSAT.BranchTree
/-- A concrete quadratic polynomial dominates all of the node-count prefactors. -/
theorem Tree.nodeCount_le_quadratic_exponential (t : Tree) (k n M : β) (hk : 2 β€ k)
(hM : SparsificationConstants.Admissible k M)
(hdepth : β p β t.paths, p.length β€ SparsificationConstants.C M (k - 1) * n)
(hB : β p β t.paths, p.count true β€ k * n / M) :
(t.nodeCount : β) β€
(((SparsificationConstants.C M (k - 1) + 1) * (k + 1) * (n + 1) ^ 2 : β) : β) *
(2 : β) ^ ((n : β) / 32) := by
have hcount := t.nodeCount_le_of_admissible k n M hk hM hdepth
(fun p hp => by rw [card_bPositions_eq_count]; exact hB p hp)
refine hcount.trans (mul_le_mul_of_nonneg_right ?_ (Real.rpow_nonneg (by norm_num) _))
exact_mod_cast polynomial_prefactor_bound (SparsificationConstants.C M (k - 1)) k n M
end SubexponentialSAT.BranchTree
end OAI.Algorithms
|