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 #
Cslib.Logic.PL.QuadEquation: a quadratic equation, with repeated monomials allowed.Cslib.Logic.PL.QuadEquation.Holds,Cslib.Logic.PL.QuadSystem.Holds,Cslib.Logic.PL.QuadSystem.Satisfiable: semantics.Cslib.Logic.PL.QuadEquation.vars: the variables in order of occurrence.Cslib.Logic.PL.QuadEquation.relabel: rename the variables.Cslib.Logic.PL.QuadSystem.linearCombination: the sum of the equations a mask selects.Cslib.Logic.PL.QuadSystem.countViolated: the number of equations an assignment violates.Cslib.Logic.PL.CNF.toQuadSystem: the quadratic system of a formula.
Main results #
Cslib.Logic.PL.QuadSystem.holds_congr: satisfaction depends only on the occurring variables.Cslib.Logic.PL.QuadSystem.satisfiable_relabel: injective relabelling preserves satisfiability.Cslib.Logic.PL.QuadSystem.holds_linearCombination_iff: a linear combination holds exactly when it selects an even number of violated equations.Cslib.Logic.PL.CNF.satisfiable_toQuadSystem: a formula is satisfiable exactly when its quadratic system is.
References #
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.
The monomials summed, with repetitions; repeated monomials cancel in pairs.
- rhs : Bool
The right-hand side of the equation.
Instances For
A finite conjunction of quadratic equations over ๐ฝโ.
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.
Rename the variables of an equation.
Satisfaction depends only on the variables of the equation.
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.
Rename the variables of every equation.
Satisfaction of a system depends only on its variables.
Injective relabelling preserves satisfiability.
Linear combinations of equations #
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.
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 #
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.
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.