File size: 12,655 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 | import Mathlib.Algebra.MvPolynomial.Degrees
import Mathlib.Algebra.MvPolynomial.Eval
import Mathlib.Algebra.Polynomial.Eval.Coeff
import Mathlib.Algebra.BigOperators.Group.Finset.Powerset
import Mathlib.Data.Fintype.Powerset
/-! Boolean finite differences (ETH, Lemma `boolean-differences`).
The finite sets in this module specify sums; they are not operational enumerators. -/
namespace OAI.Algorithms.SubexponentialSAT.SqrtLogSpace.BooleanDifferences
open scoped BigOperators
/-- The original support counting envelope. -/
def supportFamily (n J : β) : Finset (Finset (Fin n)) :=
Finset.univ.filter (fun E => E.card < J)
/-- Valid correction pairs form a subset of the square of the support envelope. -/
def pairFamily (n J : β) : Finset (Finset (Fin n) Γ Finset (Fin n)) :=
(supportFamily n J ΓΛ’ supportFamily n J).filter (fun p => p.2 β p.1)
@[simp] theorem mem_supportFamily {n J : β} {E : Finset (Fin n)} :
E β supportFamily n J β E.card < J := by
simp [supportFamily]
@[simp] theorem mem_pairFamily {n J : β} {E U : Finset (Fin n)} :
(E, U) β pairFamily n J β E.card < J β§ U β E := by
simp only [pairFamily, Finset.mem_filter, Finset.mem_product, mem_supportFamily]
exact β¨fun h => β¨h.1.1, h.2β©,
fun h => β¨β¨h.1, (Finset.card_le_card h.2).trans_lt h.1β©, h.2β©β©
theorem pairFamily_card_le (n J : β) :
(pairFamily n J).card β€ (supportFamily n J).card ^ 2 := by
calc
_ β€ (supportFamily n J ΓΛ’ supportFamily n J).card := Finset.card_filter_le _ _
_ = _ := by simp [pow_two]
theorem pairFamily_eq_biUnion (n J : β) :
pairFamily n J = (supportFamily n J).biUnion
(fun E => E.powerset.image (fun U => (E, U))) := by
ext p
rcases p with β¨E, Uβ©
simp [Finset.mem_biUnion, Finset.mem_image]
/-- Coordinate transport preserves the exact support counting envelope. -/
theorem supportFamily_map_equiv {V : Type*} [Fintype V] [DecidableEq V]
{n : β} (e : Fin n β V) (J : β) :
(supportFamily n J).map e.finsetCongr.toEmbedding =
Finset.univ.filter (fun E : Finset V => E.card < J) := by
ext E
simp [Finset.mem_map_equiv, Equiv.finsetCongr]
/-- A coordinate equivalence transports the iterator's pairs exactly. This is
an internal indexing change, not a change of the ambient assignment universe. -/
theorem pairFamily_map_equiv {V : Type*} [Fintype V] [DecidableEq V]
{n : β} (e : Fin n β V) (J : β) :
(pairFamily n J).map (Equiv.prodCongr e.finsetCongr e.finsetCongr).toEmbedding =
Finset.univ.filter (fun p : Finset V Γ Finset V => p.1.card < J β§ p.2 β p.1) := by
ext p
rcases p with β¨E, Uβ©
simp [Finset.mem_map_equiv, Equiv.prodCongr, Equiv.finsetCongr]
variable {V R : Type*} [DecidableEq V] [CommRing R]
/-- Substitution of the Boolean characteristic vector of a set. -/
def evalAt (U : Finset V) : MvPolynomial V R β+* R :=
MvPolynomial.eval (fun v => if v β U then 1 else 0)
/-- The coefficient of the Boolean multilinearization indexed by `E`. -/
def difference (E : Finset V) (p : MvPolynomial V R) : R :=
β U β E.powerset, (-1 : R) ^ (E.card - U.card) * evalAt U p
private theorem subset_sign_sum (E T : Finset V) :
(β U β E.powerset, (-1 : R) ^ (E.card - U.card) *
(if T β U then 1 else 0)) = if T = E then 1 else 0 := by
induction E using Finset.induction_on generalizing T with
| empty => simp only [Finset.powerset_empty, Finset.sum_singleton,
Finset.card_empty, Nat.sub_self, pow_zero, one_mul, Finset.subset_empty]
| @insert a E ha ih =>
rw [Finset.sum_powerset_insert ha]
have hcard (U : Finset V) (hU : U β E.powerset) : U.card β€ E.card :=
Finset.card_le_card (Finset.mem_powerset.mp hU)
have hnot (U : Finset V) (hU : U β E.powerset) : a β U :=
fun h => ha (Finset.mem_powerset.mp hU h)
by_cases hat : a β T
Β· have hzero : (β U β E.powerset, (-1 : R) ^ ((insert a E).card - U.card) *
(if T β U then 1 else 0)) = 0 := by
apply Finset.sum_eq_zero
intro U hU
simp [show Β¬T β U from fun h => hnot U hU (h hat)]
rw [hzero, zero_add]
calc
_ = β U β E.powerset, (-1 : R) ^ (E.card - U.card) *
(if T.erase a β U then 1 else 0) := by
apply Finset.sum_congr rfl
intro U hU
rw [Finset.card_insert_of_notMem ha, Finset.card_insert_of_notMem (hnot U hU)]
have hsub : T β insert a U β T.erase a β U := by
constructor
Β· intro h v hv
exact (Finset.mem_insert.mp (h (Finset.mem_erase.mp hv).2)).resolve_left
(Finset.mem_erase.mp hv).1
Β· intro h v hv
by_cases hav : v = a
Β· simp [hav]
Β· exact Finset.mem_insert_of_mem (h (Finset.mem_erase.mpr β¨hav, hvβ©))
simp [hsub]
_ = if T.erase a = E then 1 else 0 := ih _
_ = _ := by
have heq : T.erase a = E β T = insert a E := by
constructor
Β· intro h; rw [β h, Finset.insert_erase hat]
Β· intro h; subst T; simp [ha]
simp only [heq]
Β· have hsub (U : Finset V) : T β insert a U β T β U := by
constructor
Β· intro h v hv
exact (Finset.mem_insert.mp (h hv)).resolve_left (fun h => hat (h βΈ hv))
Β· exact fun h => h.trans (Finset.subset_insert _ _)
have hfirst : (β U β E.powerset, (-1 : R) ^ ((insert a E).card - U.card) *
(if T β U then 1 else 0)) =
-(β U β E.powerset, (-1 : R) ^ (E.card - U.card) *
(if T β U then 1 else 0)) := by
rw [β Finset.sum_neg_distrib]
apply Finset.sum_congr rfl
intro U hU
rw [Finset.card_insert_of_notMem ha,
show E.card + 1 - U.card = E.card - U.card + 1 by
have := hcard U hU
omega, pow_succ]
split_ifs <;> simp
rw [hfirst]
have hsecond : (β U β E.powerset,
(-1 : R) ^ ((insert a E).card - (insert a U).card) *
(if T β insert a U then 1 else 0)) =
β U β E.powerset, (-1 : R) ^ (E.card - U.card) *
(if T β U then 1 else 0) := by
apply Finset.sum_congr rfl
intro U hU
simp [Finset.card_insert_of_notMem ha,
Finset.card_insert_of_notMem (hnot U hU), hsub]
rw [hsecond, neg_add_cancel]
simp [show T β insert a E from fun h => hat (h.symm βΈ Finset.mem_insert_self a E)]
@[simp] theorem evalAt_monomial (U : Finset V) (d : V ββ β) (c : R) :
evalAt U (MvPolynomial.monomial d c) = if d.support β U then c else 0 := by
classical
rw [evalAt, MvPolynomial.eval_monomial, Finsupp.prod]
by_cases h : d.support β U
Β· rw [ite_eq_left h, Finset.prod_eq_one (fun v hv => by simp [h hv]), mul_one]
Β· obtain β¨v, hv, hvUβ© := Finset.not_subset.mp h
have hd : d v β 0 := Finsupp.mem_support_iff.mp hv
rw [Finset.prod_eq_zero hv (by simp [hvU, hd]), mul_zero, ite_eq_right h]
theorem difference_monomial (E : Finset V) (d : V ββ β) (c : R) :
difference E (MvPolynomial.monomial d c) = if d.support = E then c else 0 := by
classical
simp only [difference, evalAt_monomial]
calc
_ = (β U β E.powerset, (-1 : R) ^ (E.card - U.card) *
(if d.support β U then 1 else 0)) * c := by
rw [Finset.sum_mul]
apply Finset.sum_congr rfl
intro U _
split_ifs <;> simp
_ = _ := by rw [subset_sign_sum]; split_ifs <;> simp
theorem difference_eq_sum_coeff (E : Finset V) (p : MvPolynomial V R) :
difference E p = β d β p.support,
if d.support = E then p.coeff d else 0 := by
classical
conv_lhs => rw [β MvPolynomial.support_sum_monomial_coeff p]
simp only [difference, map_sum, Finset.mul_sum]
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro d _
exact difference_monomial E d (p.coeff d)
omit [DecidableEq V] in
/-- Degree controls the number of distinct variables in every monomial. -/
theorem support_card_le_totalDegree (p : MvPolynomial V R) {d : V ββ β}
(hd : d β p.support) : d.support.card β€ p.totalDegree := by
calc
d.support.card = β v β d.support, 1 := by simp
_ β€ β v β d.support, d v := Finset.sum_le_sum (fun v hv =>
Nat.one_le_iff_ne_zero.mpr (Finsupp.mem_support_iff.mp hv))
_ β€ p.totalDegree := MvPolynomial.le_totalDegree hd
/-- Recovery at one Boolean point; high-degree supports do not contribute. -/
theorem evalAt_eq_sum_differences [Fintype V] {J : β} (X : Finset V)
(p : MvPolynomial V R) (hp : p.totalDegree < J) :
evalAt X p = β E β Finset.univ.filter (fun E : Finset V => E.card < J),
if E β X then difference E p else 0 := by
classical
simp only [difference_eq_sum_coeff]
simp_rw [Finset.ite_sum_zero]
rw [Finset.sum_comm]
conv_lhs => rw [β MvPolynomial.support_sum_monomial_coeff p]
rw [map_sum]
apply Finset.sum_congr rfl
intro d hd
have hcard : d.support.card < J := (support_card_le_totalDegree p hd).trans_lt hp
rw [evalAt_monomial]
by_cases hsub : d.support β X
Β· rw [ite_eq_left hsub]
symm
rw [Finset.sum_eq_single d.support]
Β· simp [hsub]
Β· intro E _ hE
simp [Ne.symm hE]
Β· simp [hcard]
Β· rw [ite_eq_right hsub]
symm
apply Finset.sum_eq_zero
intro E _
by_cases he : d.support = E
Β· subst E; simp [hsub]
Β· simp [he]
/-- Boolean assignments retain all ambient variables, including unused ones. -/
def trueSet [Fintype V] (x : V β Bool) : Finset V :=
Finset.univ.filter (fun i => x i = true)
omit [DecidableEq V] in
@[simp] theorem subset_trueSet [Fintype V] (E : Finset V) (x : V β Bool) :
E β trueSet x β β i β E, x i = true := by
simp [Finset.subset_iff, trueSet]
/-- ETH Boolean finite differences over an arbitrary commutative ring.
The polynomial is allowed to depend on the assignment being summed. -/
theorem sum_eval_eq_sum_differences [Fintype V] {J : β}
(p : (V β Bool) β MvPolynomial V R)
(hp : β x, (p x).totalDegree < J) :
(β x, evalAt (trueSet x) (p x)) =
β E β Finset.univ.filter (fun E : Finset V => E.card < J), β U β E.powerset,
(-1 : R) ^ (E.card - U.card) *
β x β Finset.univ.filter (fun x : V β Bool => β i β E, x i = true),
evalAt U (p x) := by
classical
conv_lhs =>
arg 2
ext x
rw [evalAt_eq_sum_differences _ _ (hp x)]
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro E _
simp only [difference, Finset.sum_filter, subset_trueSet]
simp_rw [Finset.ite_sum_zero]
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro U _
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro x _
split_ifs <;> simp
/-- Every retained Taylor coefficient is recovered using the same pair family.
The hypothesis is the precise degree cost: each formal correction variable carries Z. -/
theorem coeff_sum_eval_eq_sum_differences [Fintype V] {J j : β}
(P : (V β Bool) β Polynomial (MvPolynomial V R)) (hj : j < J)
(hP : β x, ((P x).coeff j).totalDegree β€ j) :
(β x, (P x).map (evalAt (trueSet x))).coeff j =
(β E β Finset.univ.filter (fun E : Finset V => E.card < J),
β U β E.powerset, Polynomial.C ((-1 : R) ^ (E.card - U.card)) *
β x β Finset.univ.filter (fun x : V β Bool => β i β E, x i = true),
(P x).map (evalAt U)).coeff j := by
classical
simp only [Polynomial.finsetSum_coeff, Polynomial.coeff_C_mul, Polynomial.coeff_map]
exact sum_eval_eq_sum_differences (fun x => (P x).coeff j)
(fun x => (hP x).trans_lt hj)
/-- The entire truncated Taylor polynomial, also for J = 0 and an empty variable type. -/
theorem truncated_sum_eval_eq_sum_differences [Fintype V] (J : β)
(P : (V β Bool) β Polynomial (MvPolynomial V R))
(hP : β x j, j < J β ((P x).coeff j).totalDegree β€ j) :
(β j β Finset.range J, Polynomial.monomial j
((β x, (P x).map (evalAt (trueSet x))).coeff j)) =
β j β Finset.range J, Polynomial.monomial j
((β E β Finset.univ.filter (fun E : Finset V => E.card < J),
β U β E.powerset, Polynomial.C ((-1 : R) ^ (E.card - U.card)) *
β x β Finset.univ.filter (fun x : V β Bool => β i β E, x i = true),
(P x).map (evalAt U)).coeff j) := by
classical
apply Finset.sum_congr rfl
intro j hj
rw [coeff_sum_eval_eq_sum_differences P (Finset.mem_range.mp hj)
(fun x => hP x j (Finset.mem_range.mp hj))]
end OAI.Algorithms.SubexponentialSAT.SqrtLogSpace.BooleanDifferences
|