Documentation

CslibFrontier.Logics.Propositional.Algebraic.CNF

CNF as polynomial equations #

A clause is represented by a polynomial that vanishes when the clause holds. The variables of the polynomial are literals, interpreted at their truth values by Cslib.Logic.PL.Literal.toPolyAssignment: for a Boolean assignment σ, the positive coordinate (v, true) receives σ v and the negative coordinate (v, false) its complement, viewed as 0 or 1 in a commutative semiring. Over a ring these values are a and 1 - a.

Cslib.Logic.PL.Clause.toPoly multiplies the variables for the negations of the clause's literals. Thus x ∨ ¬y becomes X (x, false) * X (y, true), with value (1 - a x) * a y over a ring. At the literal truth values of any fixed Boolean assignment, the polynomial is 0 for a satisfied clause and 1 otherwise. With nontrivial coefficients, a CNF is therefore satisfied exactly when all its clause polynomials vanish at that same assignment. This correspondence is pointwise at those Boolean and complementary coordinates; the encoding constructs only the clause polynomials.

This is the twin-variable clause encoding used in polynomial calculus resolution (PCR) [AlekhnovichBenSassonRazborovWigderson2002, §4.1, p. 1197]. Here the coordinates record literal truth values and clause polynomials multiply their complements. The Boolean and complementarity axioms of PCR are not adjoined; Literal.toPolyAssignment supplies their intended values directly.

Main definitions #

Main results #

References #

def Cslib.Logic.PL.Literal.toPolyAssignment {V : Type u_1} (R : Type u_2) [CommSemiring R] (σ : V → Bool) :
Literal V → R

Extend a Boolean assignment to the truth values of both polarities, interpreted as 0 or 1. The positive coordinate receives the original bit and the negative coordinate its complement.

noncomputable def Cslib.Logic.PL.Clause.toPoly {V : Type u_1} (c : Clause V) (R : Type u_2) [CommSemiring R] :

The polynomial of a clause: multiply the variables for the complements of its literals. Repeated literals contribute repeated factors.

@[simp]
theorem Cslib.Logic.PL.Literal.toPolyAssignment_pos {V : Type u_1} {R : Type u_2} [CommSemiring R] (σ : V → Bool) (v : V) :
toPolyAssignment R σ (v, true) = ↑(σ v).toNat

The positive coordinate is the original Boolean bit, interpreted in the coefficient semiring.

@[simp]
theorem Cslib.Logic.PL.Literal.toPolyAssignment_neg {V : Type u_1} {R : Type u_2} [CommSemiring R] (σ : V → Bool) (v : V) :

The negative coordinate is the complementary Boolean bit.

@[simp]
theorem Cslib.Logic.PL.Clause.toPoly_nil {V : Type u_1} {R : Type u_2} [CommSemiring R] :
toPoly [] R = 1

The empty clause has polynomial 1, expressing its falsity.

@[simp]

Adding a literal multiplies by its complementary variable.

theorem Cslib.Logic.PL.Clause.eval_toPoly {V : Type u_1} {R : Type u_2} [CommSemiring R] (c : Clause V) (σ : V → Bool) :

On a Boolean assignment, the clause polynomial is 0 if the clause holds and 1 otherwise.

A fixed Boolean assignment satisfies a clause exactly when its polynomial evaluates to zero at the corresponding literal truth values.

theorem Cslib.Logic.PL.CNF.eval_eq_true_iff_forall_eval_toPoly_eq_zero {V : Type u_1} {R : Type u_2} [CommSemiring R] [Nontrivial R] (φ : CNF V) (σ : V → Bool) :
eval σ φ = true ↔ ∀ c ∈ φ, (MvPolynomial.eval (Literal.toPolyAssignment R σ)) (c.toPoly R) = 0

A fixed Boolean assignment satisfies a CNF exactly when all its clause polynomials vanish at the same Boolean and complementary coordinates.

theorem Cslib.Logic.PL.Literal.toPolyAssignment_neg_eq_one_sub {V : Type u_1} {R : Type u_2} [CommRing R] (σ : V → Bool) (v : V) :
toPolyAssignment R σ (v, false) = 1 - ↑(σ v).toNat

Over a ring, the negative literal coordinate is 1 - a when the positive coordinate is a.