Documentation

CslibFrontier.Logics.Propositional.CSP.Quadratic

Quadratic equations over ๐”ฝโ‚‚ #

A quadratic equation $\sum_{i,j} a_{ij} u_i u_j = b$ over ๐”ฝโ‚‚ in 0/1 variables is stored sparsely, as the list of the monomials (i, j) with $a_{ij} = 1$, and its right-hand side. Evaluation sums the products in the existing Boolean ring, so a repeated monomial cancels in pairs, as repeated variables of Cslib.Logic.PL.AffineEquation do. Since u * u = u on 0/1 values, the diagonal monomials (i, i) are the linear terms.

The second half gives the gadget behind the NP-hardness of QUADEQ Arora and Barak, draft, Exercise 2ยง18. A clause $\ell_0 \lor \dots \lor \ell_{k-1}$ with index i gets auxiliary variables $z_{i,0},\dots,z_{i,k}$ and the equations

$$z_{i,0} = 1,\qquad z_{i,t+1} = z_{i,t}\cdot\lnot\ell_t\ (t < k),\qquad z_{i,k} = 0,$$

each quadratic because $\lnot\ell_t$ is affine in the variable of $\ell_t$. The middle equations force $z_{i,t}$ to say that the first t literals are false, so the system is satisfiable exactly when the formula is (CNF.satisfiable_toQuadSystem).

Main definitions #

Main results #

References #

structure Cslib.Logic.PL.QuadEquation (V : Type u_3) :
Type u_3

A quadratic equation $\sum_{i,j} a_{ij} u_i u_j = b$ over ๐”ฝโ‚‚: the monomials (i, j) with $a_{ij} = 1$, and the right-hand side b.

  • terms : List (V ร— V)

    The monomials summed, with repetitions; repeated monomials cancel in pairs.

  • rhs : Bool

    The right-hand side of the equation.

Instances For
    def Cslib.Logic.PL.instDecidableEqQuadEquation.decEq {Vโœ : Type u_3} [DecidableEq Vโœ] (xโœ xโœยน : QuadEquation Vโœ) :
    Decidable (xโœ = xโœยน)
    @[instance_reducible]
    def Cslib.Logic.PL.instReprQuadEquation.repr {Vโœ : Type u_3} [Repr Vโœ] :
    QuadEquation Vโœ โ†’ โ„• โ†’ Std.Format
    @[instance_reducible]
    instance Cslib.Logic.PL.instReprQuadEquation {Vโœ : Type u_3} [Repr Vโœ] :
    Repr (QuadEquation Vโœ)
    @[reducible, inline]
    abbrev Cslib.Logic.PL.QuadSystem (V : Type u_3) :
    Type u_3

    A finite conjunction of quadratic equations over ๐”ฝโ‚‚.

    def Cslib.Logic.PL.QuadEquation.Holds {V : Type u_1} (e : QuadEquation V) (a : V โ†’ Bool) :

    The sum of the monomials under the 0/1 assignment a equals the right-hand side in the Boolean ring.

    Instances For

      The variables of an equation, in order of occurrence, with repetitions.

      def Cslib.Logic.PL.QuadEquation.relabel {V : Type u_1} {W : Type u_2} (f : V โ†’ W) (e : QuadEquation V) :

      Rename the variables of an equation.

      theorem Cslib.Logic.PL.QuadEquation.mem_vars {V : Type u_1} {e : QuadEquation V} {v : V} :
      v โˆˆ e.vars โ†” โˆƒ p โˆˆ e.terms, v = p.1 โˆจ v = p.2

      The variables of an equation are the components of its monomials.

      theorem Cslib.Logic.PL.QuadEquation.holds_congr {V : Type u_1} {e : QuadEquation V} {a b : V โ†’ Bool} (h : โˆ€ v โˆˆ e.vars, a v = b v) :

      Satisfaction depends only on the variables of the equation.

      @[simp]
      theorem Cslib.Logic.PL.QuadEquation.holds_relabel {V : Type u_1} {W : Type u_2} (f : V โ†’ W) (e : QuadEquation V) (a : W โ†’ Bool) :

      A relabelled equation holds exactly when the original holds under the composed assignment.

      def Cslib.Logic.PL.QuadSystem.Holds {V : Type u_1} (F : QuadSystem V) (a : V โ†’ Bool) :

      Every equation of the system holds.

      Some 0/1 assignment satisfies every equation of the system.

      The variables of a system, in order of occurrence, with repetitions.

      def Cslib.Logic.PL.QuadSystem.relabel {V : Type u_1} {W : Type u_2} (f : V โ†’ W) (F : QuadSystem V) :

      Rename the variables of every equation.

      theorem Cslib.Logic.PL.QuadSystem.holds_congr {V : Type u_1} {F : QuadSystem V} {a b : V โ†’ Bool} (h : โˆ€ v โˆˆ F.vars, a v = b v) :

      Satisfaction of a system depends only on its variables.

      theorem Cslib.Logic.PL.QuadSystem.holds_relabel {V : Type u_1} {W : Type u_2} (f : V โ†’ W) (F : QuadSystem V) (a : W โ†’ Bool) :

      A relabelled system holds exactly when the original holds under the composed assignment.

      theorem Cslib.Logic.PL.QuadSystem.satisfiable_relabel {V : Type u_1} {W : Type u_2} {f : V โ†’ W} (hf : Function.Injective f) (F : QuadSystem V) :

      Injective relabelling preserves satisfiability.

      Linear combinations of equations #

      @[instance_reducible]
      instance Cslib.Logic.PL.instDecidableHolds {V : Type u_1} (e : QuadEquation V) (a : V โ†’ Bool) :

      Whether an equation holds is decided by comparing two bits.

      The linear combination of the equations of F selected by the mask r: the sum over ๐”ฝโ‚‚ of the equations F[i] with r[i] = true, obtained by concatenating their monomials and adding their right-hand sides. Positions beyond the end of r are not selected.

      def Cslib.Logic.PL.QuadSystem.countViolated {V : Type u_1} (F : QuadSystem V) (a : V โ†’ Bool) :

      The number of equations of F, counted with multiplicity, that the assignment a violates.

      A linear combination holds exactly when it selects an even number of violated equations: over ๐”ฝโ‚‚, the combination's two sides differ by the sum of the selected equations' defects.

      Quadratic equations of a formula #

      @[reducible, inline]

      The auxiliary variable $z_{i,t}$: the first t literals of clause i are false.

      The equation $z_{i,t} = c$, written as the monomial $z_{i,t} z_{i,t}$.

      The equation $z_{i,t+1} = z_{i,t}\cdot\lnot\ell$ for the literal $\ell = (v, b)$. Since $\lnot\ell = u_v + b$, it reads $z_{i,t+1} + z_{i,t} u_v + b\, z_{i,t} z_{i,t} = 0$.

      The equations of the clause c with index i: $z_{i,0} = 1$, $z_{i,k} = 0$ for its length k, and $z_{i,t+1} = z_{i,t}\cdot\lnot\ell_t$ for each literal $\ell_t$.

      The quadratic system of a formula: the equations of its clauses, the variable v of the formula kept as inl v, and the auxiliary variables numbered by clause and position.

      @[simp]
      theorem Cslib.Logic.PL.CNF.holds_auxEq {V : Type u_1} (i t : โ„•) (c : Bool) (a : V โŠ• โ„• ร— โ„• โ†’ Bool) :
      (auxEq i t c).Holds a โ†” a (auxVar i t) = c

      The equation $z_{i,t}\,z_{i,t} = c$ says $z_{i,t} = c$.

      theorem Cslib.Logic.PL.CNF.holds_stepEq {V : Type u_1} (i t : โ„•) (l : Literal V) (a : V โŠ• โ„• ร— โ„• โ†’ Bool) :
      (stepEq i t l).Holds a โ†” a (auxVar i (t + 1)) = (a (auxVar i t) && !Literal.eval (a โˆ˜ Sum.inl) l)

      The step equation says $z_{i,t+1} = z_{i,t}\cdot\lnot\ell$.

      The equations of a clause force it to hold under the assignment of the formula variables.

      theorem Cslib.Logic.PL.CNF.holds_clauseQuadSystem {V : Type u_1} {i : โ„•} {c : Clause V} {a : V โŠ• โ„• ร— โ„• โ†’ Bool} (haux : โˆ€ (t : โ„•), a (auxVar i t) = !Clause.eval (a โˆ˜ Sum.inl) (List.take t c)) (hc : Clause.eval (a โˆ˜ Sum.inl) c = true) :

      If the auxiliary variables of a clause record its literal prefixes and the clause holds, then its equations hold.

      A formula is satisfiable exactly when its quadratic system is.