Documentation

Complexity.Logics.Propositional.CNF.PolynomialTests

Polynomial compilation of CNF parity tests over ๐”ฝโ‚‚ #

For a propositional clause c : Clause V, its violation bit !c.eval ฯƒ on an assignment ฯƒ : V โ†’ Bool expands over ๐”ฝโ‚‚ = ZMod 2 into a multilinear sum of monomials (Cslib.Logic.PL.Clause.falsifyMonomials): a tautological clause expands to โˆ… (0), the empty clause expands to {โˆ…} (1), and a nontautological clause with positive variables P and negative variables N expands to {S โˆช N | S โІ P}, using the identity โˆ_{v โˆˆ P} (1 + x_v) โˆ_{v โˆˆ N} x_v = โˆ‘_{S โІ P} โˆ_{v โˆˆ S โˆช N} x_v over ZMod 2. Repeated literals within c collapse automatically, so every monomial has support in (c.map Prod.fst).toFinset and degree at most c.length, and there are at most 2 ^ c.length monomials.

Given a formula ฯ† : CNF V with m = ฯ†.length clauses and a binary parity-check row r : Fin ฯ†.length โ†’ Bool, equation (6.1) of [OAI26c] specifies the ๐”ฝโ‚‚ polynomial equation P_r(ฯƒ) = โˆ‘_{e : r e = true} v_e(ฯƒ) = 0. Retaining the monomials that occur in an odd number of active clauses (Cslib.Logic.PL.CNF.parityRowMonomials) cancels duplicate monomials modulo 2: adding rows in the Boolean ring corresponds to taking the symmetric difference of their monomial sets (Cslib.Logic.PL.CNF.parityRowMonomials_add), evaluating the compiled monomial sum agrees with the parity check โˆ‘ e, r e * ฯ†.violations ฯƒ e (Cslib.Logic.PL.CNF.sum_parityRowMonomials), and when every clause has length at most k, each retained monomial has degree at most k and there are at most weight r * 2 ^ k monomials (โ‰ค P * 2 ^ k for r = testRow ฮณ of length P).

On a finite variable type V, the common zeros of {ฯ†.parityRowMonomials r | r โˆˆ rows} are therefore the assignments accepted by PassesTests ฯ†.violations rows, decomposing as numPassing ฯ†.violations rows = ฯ†.modelCountOn Finset.univ + D(rows) where D(rows) counts accepted nonsatisfying assignments, and equaling ฯ†.modelCountOn Finset.univ after the 3 * Fintype.card V greedy rounds of CNF.numPassing_greedy [OpenAI2026ETH, Lemma 6.2, ยง6.3].

Main definitions #

Main results #

References #

Clause-falsification monomials over ZMod 2 #

The canonical multilinear ๐”ฝโ‚‚ monomials whose sum evaluates to !c.eval ฯƒ over ZMod 2. If some variable occurs both positively and negatively in c, the clause is tautological and the set is empty; otherwise it consists of S โˆช neg as S ranges over subsets of the positive variables pos of c, expanding โˆ_{v โˆˆ pos} (1 + x_v) โˆ_{v โˆˆ neg} x_v modulo 2.

Instances For
    @[simp]

    The empty clause is always falsified, so its falsification polynomial is the constant 1 ({โˆ…}).

    A tautological clause containing both (v, true) and (v, false) has empty falsification monomial set.

    Every monomial in c.falsifyMonomials uses only variables occurring in c.

    Every monomial in c.falsifyMonomials has degree at most the number of distinct variables in c.

    Every monomial in c.falsifyMonomials has degree at most c.length.

    A clause on d distinct variables expands to at most 2 ^ d falsification monomials.

    A clause c expands to at most 2 ^ c.length falsification monomials.

    theorem Cslib.Logic.PL.Clause.sum_falsifyMonomials {V : Type u_1} [DecidableEq V] (c : Clause V) (ฯƒ : V โ†’ Bool) :
    โˆ‘ M โˆˆ c.falsifyMonomials, BitString.monomial (ZMod 2) M ฯƒ = BitString.bitVal (ZMod 2) !eval ฯƒ c

    Clause-falsification polynomial identity over ๐”ฝโ‚‚ [OpenAI2026ETH, ยง6]. For every clause c and truth assignment ฯƒ, the sum over c.falsifyMonomials in ZMod 2 equals the violation bit !c.eval ฯƒ read in ZMod 2.

    theorem Cslib.Logic.PL.Clause.sum_falsifyMonomials_eq_zero_iff {V : Type u_1} [DecidableEq V] (c : Clause V) (ฯƒ : V โ†’ Bool) :
    โˆ‘ M โˆˆ c.falsifyMonomials, BitString.monomial (ZMod 2) M ฯƒ = 0 โ†” eval ฯƒ c = true

    The falsification polynomial of c vanishes at ฯƒ over ZMod 2 if and only if ฯƒ satisfies c.

    theorem Cslib.Logic.PL.Clause.sum_falsifyMonomials_mem_lowDegree {V : Type u_1} [DecidableEq V] (c : Clause V) :
    (fun (ฯƒ : V โ†’ Bool) => โˆ‘ M โˆˆ c.falsifyMonomials, BitString.monomial (ZMod 2) M ฯƒ) โˆˆ BitString.lowDegree (ZMod 2) V (List.length c)

    The falsification polynomial of c has multilinear degree at most c.length over ZMod 2.

    Parity-check row compilation and mod-2 cancellation #

    def Cslib.Logic.PL.CNF.parityRowMonomials {V : Type u_1} [DecidableEq V] (ฯ† : CNF V) (r : Fin (List.length ฯ†) โ†’ Bool) :

    The canonical ๐”ฝโ‚‚ monomial set of the linear parity-check equation (6.1) for row r : Fin ฯ†.length โ†’ Bool on ฯ† : CNF V: a monomial M is retained precisely when it belongs to (ฯ†.get e).falsifyMonomials for an odd number of active clauses e (r e = true), cancelling duplicate monomials modulo 2.

    Instances For
      @[simp]
      theorem Cslib.Logic.PL.CNF.mem_parityRowMonomials {V : Type u_1} [DecidableEq V] {ฯ† : CNF V} {r : Fin (List.length ฯ†) โ†’ Bool} {M : Finset V} :

      A monomial belongs to ฯ†.parityRowMonomials r if and only if it appears in an odd number of active clauses e with r e = true.

      @[simp]

      The zero parity row compiles to the empty monomial set.

      A unit parity row selecting only clause e compiles to (ฯ†.get e).falsifyMonomials.

      theorem Cslib.Logic.PL.CNF.parityRowMonomials_add {V : Type u_1} [DecidableEq V] (ฯ† : CNF V) (rโ‚ rโ‚‚ : Fin (List.length ฯ†) โ†’ Bool) :
      ฯ†.parityRowMonomials (rโ‚ + rโ‚‚) = symmDiff (ฯ†.parityRowMonomials rโ‚) (ฯ†.parityRowMonomials rโ‚‚)

      Mod-2 monomial cancellation across rows. Adding two parity-check rows in the Boolean ring takes the symmetric difference of their compiled monomial sets.

      theorem Cslib.Logic.PL.CNF.subset_vars_of_mem_parityRowMonomials {V : Type u_1} [DecidableEq V] {ฯ† : CNF V} {r : Fin (List.length ฯ†) โ†’ Bool} {M : Finset V} (hM : M โˆˆ ฯ†.parityRowMonomials r) :
      M โІ ฯ†.vars.toFinset

      Every monomial in ฯ†.parityRowMonomials r is supported on the variables of ฯ†.

      theorem Cslib.Logic.PL.CNF.card_le_of_mem_parityRowMonomials {V : Type u_1} [DecidableEq V] {ฯ† : CNF V} {k : โ„•} (hk : โˆ€ c โˆˆ ฯ†, List.length c โ‰ค k) {r : Fin (List.length ฯ†) โ†’ Bool} {M : Finset V} (hM : M โˆˆ ฯ†.parityRowMonomials r) :

      When every clause of ฯ† has length at most k, every monomial in ฯ†.parityRowMonomials r has degree at most k.

      theorem Cslib.Logic.PL.CNF.sum_parityRowMonomials_mem_lowDegree {V : Type u_1} [DecidableEq V] {ฯ† : CNF V} {k : โ„•} (hk : โˆ€ c โˆˆ ฯ†, List.length c โ‰ค k) (r : Fin (List.length ฯ†) โ†’ Bool) :
      (fun (ฯƒ : V โ†’ Bool) => โˆ‘ M โˆˆ ฯ†.parityRowMonomials r, BitString.monomial (ZMod 2) M ฯƒ) โˆˆ BitString.lowDegree (ZMod 2) V k

      When every clause of ฯ† has length at most k, the compiled polynomial of row r has multilinear degree at most k over ZMod 2.

      theorem Cslib.Logic.PL.CNF.card_parityRowMonomials_le {V : Type u_1} [DecidableEq V] {ฯ† : CNF V} {k : โ„•} (hk : โˆ€ c โˆˆ ฯ†, List.length c โ‰ค k) (r : Fin (List.length ฯ†) โ†’ Bool) :

      Sparsity of a compiled parity row [OpenAI2026ETH, ยง6.2]. When every clause of ฯ† has length at most k, ฯ†.parityRowMonomials r contains at most weight r * 2 ^ k monomials.

      theorem Cslib.Logic.PL.CNF.card_parityRowMonomials_testRow_le {V : Type u_1} [DecidableEq V] {ฯ† : CNF V} {k P : โ„•} (hk : โˆ€ c โˆˆ ฯ†, List.length c โ‰ค k) (ฮณ : Fin P โ†’ Fin (List.length ฯ†) ร— Bool) :

      Sparsity of a compiled test-list row [OpenAI2026ETH, Lemma 6.2]. For any test list ฮณ : Fin P โ†’ Fin ฯ†.length ร— Bool on a k-CNF formula ฯ†, ฯ†.parityRowMonomials (testRow ฮณ) contains at most P * 2 ^ k monomials.

      theorem Cslib.Logic.PL.CNF.sum_parityRowMonomials {V : Type u_1} [DecidableEq V] (ฯ† : CNF V) (r : Fin (List.length ฯ†) โ†’ Bool) (ฯƒ : V โ†’ Bool) :
      โˆ‘ M โˆˆ ฯ†.parityRowMonomials r, BitString.monomial (ZMod 2) M ฯƒ = BitString.bitVal (ZMod 2) (โˆ‘ e : Fin (List.length ฯ†), r e * ฯ†.violations ฯƒ e)

      Compiled parity-row evaluation identity [OpenAI2026ETH, eq. (6.1)]. Evaluating the sum of ฯ†.parityRowMonomials r at ฯƒ over ZMod 2 equals the parity โˆ‘ e, r e * ฯ†.violations ฯƒ e read in ZMod 2.

      theorem Cslib.Logic.PL.CNF.sum_parityRowMonomials_eq_zero_iff {V : Type u_1} [DecidableEq V] (ฯ† : CNF V) (r : Fin (List.length ฯ†) โ†’ Bool) (ฯƒ : V โ†’ Bool) :
      โˆ‘ M โˆˆ ฯ†.parityRowMonomials r, BitString.monomial (ZMod 2) M ฯƒ = 0 โ†” โˆ‘ e : Fin (List.length ฯ†), r e * ฯ†.violations ฯƒ e = false

      Parity-row zero criterion [OpenAI2026ETH, eq. (6.1)]. An assignment ฯƒ is a zero of the compiled ZMod 2 polynomial of row r if and only if the violation parity โˆ‘ e, r e * ฯ†.violations ฯƒ e is false.

      theorem Cslib.Logic.PL.CNF.sum_parityRowMonomials_eq_zero_iff_dotProduct {V : Type u_1} [DecidableEq V] (ฯ† : CNF V) (r : Fin (List.length ฯ†) โ†’ Bool) (ฯƒ : V โ†’ Bool) :
      โˆ‘ M โˆˆ ฯ†.parityRowMonomials r, BitString.monomial (ZMod 2) M ฯƒ = 0 โ†” r โฌแตฅ ฯ†.violations ฯƒ = false

      Dot-product form of CNF.sum_parityRowMonomials_eq_zero_iff.

      theorem Cslib.Logic.PL.CNF.sum_parityRowMonomials_testRow_eq_zero_iff {V : Type u_1} [DecidableEq V] {P : โ„•} (ฯ† : CNF V) (ฮณ : Fin P โ†’ Fin (List.length ฯ†) ร— Bool) (ฯƒ : V โ†’ Bool) :
      โˆ‘ M โˆˆ ฯ†.parityRowMonomials (BitString.testRow ฮณ), BitString.monomial (ZMod 2) M ฯƒ = 0 โ†” BitString.testParity ฮณ (ฯ†.violations ฯƒ) = false

      For a test list ฮณ, the compiled ZMod 2 polynomial of testRow ฮณ vanishes at ฯƒ if and only if testParity ฮณ (ฯ†.violations ฯƒ) = false.

      theorem Cslib.Logic.PL.CNF.commonZero_parityRowMonomials_iff_passesTests {V : Type u_1} [DecidableEq V] (ฯ† : CNF V) (rows : List (Fin (List.length ฯ†) โ†’ Bool)) (ฯƒ : V โ†’ Bool) :
      (โˆ€ r โˆˆ rows, โˆ‘ M โˆˆ ฯ†.parityRowMonomials r, BitString.monomial (ZMod 2) M ฯƒ = 0) โ†” BitString.PassesTests ฯ†.violations rows ฯƒ

      Common-zero characterization. An assignment ฯƒ vanishes on every compiled equation in rows if and only if PassesTests ฯ†.violations rows ฯƒ.

      theorem Cslib.Logic.PL.CNF.commonZero_map_parityRowMonomials_iff_passesTests {V : Type u_1} [DecidableEq V] (ฯ† : CNF V) (rows : List (Fin (List.length ฯ†) โ†’ Bool)) (ฯƒ : V โ†’ Bool) :
      (โˆ€ eq โˆˆ List.map ฯ†.parityRowMonomials rows, โˆ‘ M โˆˆ eq, BitString.monomial (ZMod 2) M ฯƒ = 0) โ†” BitString.PassesTests ฯ†.violations rows ฯƒ

      Common-zero characterization phrased over the compiled equation list rows.map ฯ†.parityRowMonomials.

      Common-zero counts and exact bridge to CNF.modelCountOn #

      @[simp]
      theorem Cslib.Logic.PL.CNF.modelCountOn_univ {V : Type u_1} [Fintype V] [DecidableEq V] (ฯ† : CNF V) :
      ฯ†.modelCountOn Finset.univ = {ฯƒ : V โ†’ Bool | eval ฯƒ ฯ† = true}.card

      On a finite variable type V, ฯ†.modelCountOn Finset.univ counts all satisfying assignments ฯƒ : V โ†’ Bool.

      theorem Cslib.Logic.PL.CNF.card_commonZeros_parityRowMonomials {V : Type u_1} [Fintype V] [DecidableEq V] (ฯ† : CNF V) (rows : List (Fin (List.length ฯ†) โ†’ Bool)) :
      {ฯƒ : V โ†’ Bool | โˆ€ r โˆˆ rows, โˆ‘ M โˆˆ ฯ†.parityRowMonomials r, BitString.monomial (ZMod 2) M ฯƒ = 0}.card = BitString.numPassing ฯ†.violations rows

      The number of common zeros of {ฯ†.parityRowMonomials r | r โˆˆ rows} on V โ†’ Bool equals numPassing ฯ†.violations rows.

      theorem Cslib.Logic.PL.CNF.numPassing_violations_eq_modelCountOn_add {V : Type u_1} [Fintype V] [DecidableEq V] (ฯ† : CNF V) (rows : List (Fin (List.length ฯ†) โ†’ Bool)) :
      BitString.numPassing ฯ†.violations rows = ฯ†.modelCountOn Finset.univ + {ฯƒ : V โ†’ Bool | eval ฯƒ ฯ† = false โˆง BitString.PassesTests ฯ†.violations rows ฯƒ}.card

      N(A) = #F + D(A) decomposition [OpenAI2026ETH, ยง6, p. 40]. The number of assignments passing rows equals ฯ†.modelCountOn Finset.univ plus the number of nonsatisfying assignments still accepted by rows.

      theorem Cslib.Logic.PL.CNF.card_commonZeros_eq_modelCountOn_add {V : Type u_1} [Fintype V] [DecidableEq V] (ฯ† : CNF V) (rows : List (Fin (List.length ฯ†) โ†’ Bool)) :
      {ฯƒ : V โ†’ Bool | โˆ€ r โˆˆ rows, โˆ‘ M โˆˆ ฯ†.parityRowMonomials r, BitString.monomial (ZMod 2) M ฯƒ = 0}.card = ฯ†.modelCountOn Finset.univ + {ฯƒ : V โ†’ Bool | eval ฯƒ ฯ† = false โˆง BitString.PassesTests ฯ†.violations rows ฯƒ}.card

      N(P_A) = #F + D(A) for compiled ๐”ฝโ‚‚ equations [OpenAI2026ETH, ยง6, p. 40].

      theorem Cslib.Logic.PL.CNF.card_commonZeros_greedy {V : Type u_1} [Fintype V] [DecidableEq V] (ฯ† : CNF V) {P : โ„•} (hn : 1 โ‰ค Fintype.card V) (hP : 1 โ‰ค P) (A : โ„• โ†’ List (Fin (List.length ฯ†) โ†’ Bool)) (hinit : โˆ€ (ฯƒ : V โ†’ Bool), BitString.PassesTests ฯ†.violations (A 0) ฯƒ โ†’ eval ฯƒ ฯ† = false โ†’ List.length ฯ† โ‰ค P * BitString.weight (ฯ†.violations ฯƒ)) (ฮณ : โ„• โ†’ Fin P โ†’ Fin (List.length ฯ†) ร— Bool) (hA : โˆ€ (i : โ„•), A (i + 1) = A i ++ [BitString.testRow (ฮณ i)]) (hฮณ : โˆ€ (i : โ„•) (ฮณ' : Fin P โ†’ Fin (List.length ฯ†) ร— Bool), BitString.numPassing ฯ†.violations (A i ++ [BitString.testRow (ฮณ i)]) โ‰ค BitString.numPassing ฯ†.violations (A i ++ [BitString.testRow ฮณ'])) :
      {ฯƒ : V โ†’ Bool | โˆ€ r โˆˆ A (3 * Fintype.card V), โˆ‘ M โˆˆ ฯ†.parityRowMonomials r, BitString.monomial (ZMod 2) M ฯƒ = 0}.card = ฯ†.modelCountOn Finset.univ

      Exact common-zero count after 3 n greedy parity-test rounds [OpenAI2026ETH, Lemma 6.2 & ยง6.3]. Under the hypotheses of CNF.numPassing_greedy, the common zeros of the compiled ๐”ฝโ‚‚ polynomial system A (3 * Fintype.card V) number exactly ฯ†.modelCountOn Finset.univ (#F).

      theorem Cslib.Logic.PL.CNF.greedy_system_bounds {V : Type u_1} [Fintype V] [DecidableEq V] (ฯ† : CNF V) {k Dโ‚€ P : โ„•} (hk : โˆ€ c โˆˆ ฯ†, List.length c โ‰ค k) (A : โ„• โ†’ List (Fin (List.length ฯ†) โ†’ Bool)) (hAโ‚€_len : (A 0).length โ‰ค 3 * Fintype.card V) (hAโ‚€_wt : โˆ€ r โˆˆ A 0, BitString.weight r โ‰ค Dโ‚€) (ฮณ : โ„• โ†’ Fin P โ†’ Fin (List.length ฯ†) ร— Bool) (hA : โˆ€ (i : โ„•), A (i + 1) = A i ++ [BitString.testRow (ฮณ i)]) {i : โ„•} (hi : i โ‰ค 3 * Fintype.card V) :
      (List.map ฯ†.parityRowMonomials (A i)).length โ‰ค 6 * Fintype.card V โˆง โˆ€ eq โˆˆ List.map ฯ†.parityRowMonomials (A i), (โˆ€ M โˆˆ eq, M โІ ฯ†.vars.toFinset โˆง M.card โ‰ค k) โˆง eq.card โ‰ค max Dโ‚€ P * 2 ^ k

      Quantitative bounds on compiled greedy systems [OpenAI2026ETH, Lemma 6.2, p. 42]. If every clause of ฯ† has length at most k, the initial matrix A 0 has at most 3 n rows each of weight at most Dโ‚€, and each round appends testRow (ฮณ i) of list length P, then at any stage i โ‰ค 3 n the compiled system (A i).map ฯ†.parityRowMonomials has at most 3 n + i (โ‰ค 6 n) equations, each of degree at most k, supported on ฯ†.vars.toFinset, and containing at most max Dโ‚€ P * 2 ^ k monomials.