Documentation

Complexity.Computability.PolyTime.CNF.SparsePolyCompile

Polynomial-time compilation of CNF parity checks to sparse ๐”ฝโ‚‚ monomial systems #

This module implements the executable sparse ๐”ฝโ‚‚ polynomial compilation and heavy-variable restriction algorithms from ยง5.5 (pp. 38โ€“39) and ยง6 / ยง6.2โ€“6.3 (pp. 39โ€“40, 42โ€“43) of OpenAI, The Exponential Time Hypothesis is False:

  1. Canonical monomial-list algebra over ๐”ฝโ‚‚: strictly increasing monomials (IsCanonicalMonomial), duplicate-free equations (IsCanonicalEquation), Boolean evaluation (evalMonomialList, evalSystem), and mod-2 symmetric difference (xorEquation).
  2. Clause falsification and parity-row compilation (ยง6 eq. (6.1), ยง6.2โ€“6.3): compileClause, compileParityRow, and compileParitySystem, plus width-k guarded polynomial-time variants (compileClauseBounded, compileParityRowBounded, compileParitySystemBounded).
  3. Heavy-variable detection and single-variable restriction (ยง5.5): equationVars, varDegree, findHeavyVar, restrictEquation, and restrictSystem, all certified by plain ComputableInPolyTime.

Main definitions #

Main results #

References #

1. Canonical Sparse ๐”ฝโ‚‚ Monomial-List Representation & Mod-2 Algebra #

A canonical multilinear monomial is a strictly increasing list of variable indices.

Instances For
    theorem Cslib.Complexity.IsCanonicalMonomial.eq_of_toFinset_eq {mโ‚ mโ‚‚ : List โ„•} (hmโ‚ : IsCanonicalMonomial mโ‚) (hmโ‚‚ : IsCanonicalMonomial mโ‚‚) (h : mโ‚.toFinset = mโ‚‚.toFinset) :
    mโ‚ = mโ‚‚

    A sparse ๐”ฝโ‚‚ polynomial equation is canonical when its monomial list is duplicate-free and every monomial is strictly increasing.

    Instances For

      Evaluate a sparse ๐”ฝโ‚‚ monomial list on a Boolean assignment ฯƒ : โ„• โ†’ Bool.

      Instances For
        def Cslib.Complexity.evalSystem (sys : List (List (List โ„•))) (ฯƒ : โ„• โ†’ Bool) :

        Evaluate a sparse ๐”ฝโ‚‚ polynomial system (true iff every equation evaluates to false).

        Instances For
          @[simp]
          theorem Cslib.Complexity.evalMonomialList_cons (m : List โ„•) (eq : List (List โ„•)) (ฯƒ : โ„• โ†’ Bool) :
          evalMonomialList (m :: eq) ฯƒ = (m.all ฯƒ ^^ evalMonomialList eq ฯƒ)
          theorem Cslib.Complexity.evalMonomialList_append (eq1 eq2 : List (List โ„•)) (ฯƒ : โ„• โ†’ Bool) :
          evalMonomialList (eq1 ++ eq2) ฯƒ = (evalMonomialList eq1 ฯƒ ^^ evalMonomialList eq2 ฯƒ)
          theorem Cslib.Complexity.evalSystem_eq_true_iff (sys : List (List (List โ„•))) (ฯƒ : โ„• โ†’ Bool) :
          evalSystem sys ฯƒ = true โ†” โˆ€ eq โˆˆ sys, evalMonomialList eq ฯƒ = false

          On a canonical equation eq, reading evalMonomialList eq ฯƒ in ZMod 2 equals the Finset sum of BitString.monomial (ZMod 2) over (eq.map List.toFinset).toFinset.

          theorem Cslib.Complexity.bitVal_evalMonomialList_mem_lowDegree {k : โ„•} {eq : List (List โ„•)} (hdeg : โˆ€ m โˆˆ eq, m.length โ‰ค k) :
          (fun (ฯƒ : โ„• โ†’ Bool) => BitString.bitVal (ZMod 2) (evalMonomialList eq ฯƒ)) โˆˆ BitString.lowDegree (ZMod 2) โ„• k

          Every sparse ๐”ฝโ‚‚ equation whose monomials have length at most k defines a Boolean-cube function of ZMod 2-degree at most k.

          Toggle the presence of monomial m in a duplicate-free list eq modulo 2.

          Instances For

            Cancel duplicate monomials in eq modulo 2 by folding toggleMonomial from [].

            Instances For

              Executable mod-2 symmetric difference of two sparse ๐”ฝโ‚‚ equations.

              Instances For

                xorEquation preserves canonical sorted monomials and Nodup.

                theorem Cslib.Complexity.evalMonomialList_xorEquation (eq1 eq2 : List (List โ„•)) (ฯƒ : โ„• โ†’ Bool) :
                evalMonomialList (xorEquation eq1 eq2) ฯƒ = (evalMonomialList eq1 ฯƒ ^^ evalMonomialList eq2 ฯƒ)

                xorEquation evaluates to the Boolean XOR of the two equations' evaluations.

                xorEquation outputs at most eq1.length + eq2.length monomials.

                2. Executable Clause Falsification & Parity-Row Compiler (ยง6 eq. (6.1) & ยง6.3) #

                Insert v into a strictly increasing monomial m, omitting duplicates.

                Instances For

                  Canonical strictly increasing deduplication of variable indices.

                  Instances For
                    theorem Cslib.Complexity.all_insertSorted (m : List โ„•) (v : โ„•) (ฯƒ : โ„• โ†’ Bool) :
                    (insertSorted m v).all ฯƒ = (m.all ฯƒ && ฯƒ v)

                    Check whether clause c contains both (v, true) and (v, false) for some v.

                    Instances For

                      Sorted distinct positive-literal variables of c.

                      Instances For

                        Sorted distinct negative-literal variables of c.

                        Instances For

                          Expand โˆ_{v โˆˆ vs} (1 โŠ• x_v) starting from a canonical base monomial base.

                          Instances For

                            Compile the falsification indicator v_c(x) = !c.eval x of a clause c : Clause โ„• into a canonical sparse ๐”ฝโ‚‚ polynomial (ยง6, p. 39). Tautological clauses compile to [] (0).

                            Instances For

                              compileClause c always produces a canonical sparse ๐”ฝโ‚‚ equation.

                              Every variable occurring in compileClause c is a variable of c.

                              Every monomial in compileClause c has length at most c.length.

                              Exact clause falsification semantics (ยง6, p. 39): compileClause c evaluates to !c.eval ฯƒ for every assignment ฯƒ.

                              Compile a parity-check row row : List Bool on ฯ† : CNF โ„• into a sparse ๐”ฝโ‚‚ polynomial equation by XORing compileClause ฯ†[e] over e < ฯ†.length with row.getD e false = true.

                              Instances For

                                Compile a list of parity-check rows on ฯ† : CNF โ„• into a sparse ๐”ฝโ‚‚ polynomial system.

                                Instances For
                                  theorem Cslib.Complexity.length_mem_compileParityRow_le {k : โ„•} {ฯ† : Logic.PL.CNF โ„•} (hฯ† : โˆ€ c โˆˆ ฯ†, List.length c โ‰ค k) (row : List Bool) {m : List โ„•} (hm : m โˆˆ compileParityRow ฯ† row) :

                                  When every clause of ฯ† has width at most k, every monomial in compileParityRow ฯ† row has degree at most k.

                                  theorem Cslib.Complexity.length_compileParityRow_le {k : โ„•} {ฯ† : Logic.PL.CNF โ„•} (hฯ† : โˆ€ c โˆˆ ฯ†, List.length c โ‰ค k) (row : List Bool) :

                                  Row sparsity bound (ยง6.2, p. 42): when every clause of ฯ† has width at most k, compileParityRow ฯ† row contains at most row.count true * 2 ^ k monomials.

                                  theorem Cslib.Complexity.evalMonomialList_compileParityRow_eq_dotProduct (ฯ† : Logic.PL.CNF โ„•) (row : List Bool) (ฯƒ : โ„• โ†’ Bool) :
                                  evalMonomialList (compileParityRow ฯ† row) ฯƒ = (fun (e : Fin (List.length ฯ†)) => row.getD (โ†‘e) false) โฌแตฅ ฯ†.violations ฯƒ

                                  Exact parity-row semantics (ยง6 eq. (6.1)): compileParityRow ฯ† row evaluates to the ๐”ฝโ‚‚ dot product of row with ฯ†.violations ฯƒ.

                                  theorem Cslib.Complexity.evalSystem_compileParitySystem_iff_passesTests (ฯ† : Logic.PL.CNF โ„•) (rows : List (List Bool)) (ฯƒ : โ„• โ†’ Bool) :
                                  evalSystem (compileParitySystem ฯ† rows) ฯƒ = true โ†” BitString.PassesTests ฯ†.violations (List.map (fun (row : List Bool) (e : Fin (List.length ฯ†)) => row.getD (โ†‘e) false) rows) ฯƒ

                                  System acceptance equivalence: ฯƒ is a common zero of compileParitySystem ฯ† rows over ๐”ฝโ‚‚ if and only if ฯƒ passes all parity tests represented by rows on ฯ†.violations.

                                  Width-k guarded clause compiler (agrees with compileClause on clauses of width โ‰ค k).

                                  Instances For

                                    Width-k guarded parity-row compiler.

                                    Instances For

                                      Width-k guarded parity-system compiler.

                                      Instances For

                                        3. Executable Heavy-Variable Finder & Variable Restriction (ยง5.5, pp. 38โ€“39) #

                                        Canonical duplicate-free variable scope of an equation eq.

                                        Instances For

                                          Incidence degree of variable v in sys: number of equation scopes containing v.

                                          Instances For

                                            First variable v < n with varDegree v sys > bโ‚€, or none if none exists (ยง5.5, p. 38).

                                            Instances For

                                              Substitute x_v = val into eq over ๐”ฝโ‚‚, dropping monomials containing v when val = false and erasing v then cancelling mod-2 duplicates when val = true (ยง5.5, p. 38).

                                              Instances For

                                                Substitute x_v = val across every equation of a sparse ๐”ฝโ‚‚ system.

                                                Instances For
                                                  @[simp]
                                                  theorem Cslib.Complexity.mem_equationVars {eq : List (List โ„•)} {v : โ„•} :
                                                  v โˆˆ equationVars eq โ†” โˆƒ m โˆˆ eq, v โˆˆ m
                                                  theorem Cslib.Complexity.findHeavyVar_eq_some_iff {n bโ‚€ : โ„•} {sys : List (List (List โ„•))} {v : โ„•} :
                                                  findHeavyVar n bโ‚€ sys = some v โ†” v < n โˆง bโ‚€ < varDegree v sys โˆง โˆ€ u < v, varDegree u sys โ‰ค bโ‚€

                                                  findHeavyVar n bโ‚€ sys = some v iff v < n is minimal with varDegree v sys > bโ‚€.

                                                  theorem Cslib.Complexity.findHeavyVar_eq_none_iff {n bโ‚€ : โ„•} {sys : List (List (List โ„•))} :
                                                  findHeavyVar n bโ‚€ sys = none โ†” โˆ€ v < n, varDegree v sys โ‰ค bโ‚€

                                                  findHeavyVar n bโ‚€ sys = none iff every v < n occurs in at most bโ‚€ equation scopes.

                                                  theorem Cslib.Complexity.exists_sublist_of_mem_restrictEquation {v : โ„•} {val : Bool} {eq : List (List โ„•)} {m' : List โ„•} (hm' : m' โˆˆ restrictEquation v val eq) :
                                                  โˆƒ m โˆˆ eq, m'.Sublist m
                                                  theorem Cslib.Complexity.length_mem_restrictEquation_le {k v : โ„•} {val : Bool} {eq : List (List โ„•)} (hdeg : โˆ€ m โˆˆ eq, m.length โ‰ค k) {m' : List โ„•} (hm' : m' โˆˆ restrictEquation v val eq) :

                                                  restrictEquation preserves any monomial degree bound โ‰ค k.

                                                  restrictEquation never increases the number of monomials.

                                                  theorem Cslib.Complexity.not_mem_of_mem_restrictEquation {v : โ„•} {val : Bool} {eq : List (List โ„•)} {m' : List โ„•} (hm' : m' โˆˆ restrictEquation v val eq) :
                                                  v โˆ‰ m'

                                                  restrictEquation v val eq eliminates v from all output monomials.

                                                  Exact variable-restriction semantics (ยง5.5, p. 38): evaluating restrictEquation v val eq on ฯƒ agrees with evaluating eq on Function.update ฯƒ v val.

                                                  4. Polynomial-Time Complexity Proofs (Plain ComputableInPolyTime) #

                                                  For any fixed width bound k : โ„•, compiling a parity-check row on ฯ† : CNF โ„• is polynomial-time (for any sized Boolean list encoding encRow, such as encBits or encList encBool).