Documentation

CslibFrontier.Logics.Propositional.TseitinCNF

The Tseitin transformation of a proposition #

Tseitin's transformation Tseitin turns a proposition into a formula in conjunctive normal form of linear size by naming subformulas. Here every subformula B of A that is not an atom gets the variable Sum.inr B of CNF (Atom ⊕ Proposition Atom), and an atom x is its own variable Sum.inl x (Proposition.tseitinVar). Equal subformulas share a variable. For every subformula B = op(C, D) the definitional clauses say that the variable of B carries op of the variables of C and D; for B = ⊥ they say that its variable is false (Proposition.tseitinDefs). The formula Proposition.tseitinCNF A adds the unit clause asserting the variable of A.

This is not the Tseitin formula of a graph (Cslib.Logic.PL.CNF.tseitinFormula), a parity formula from the same paper. Cslib.Circuits.Boolean.tseitinCNF is the same construction for De Morgan gate lists, where wires play the role of subformulas.

The two formulas have the same models up to the fresh variables (Proposition.eval_tseitinCNF_eq_true_iff): an assignment σ satisfies A.tseitinCNF exactly when its restriction σ ∘ Sum.inl to the atoms satisfies A and σ gives every fresh variable in the formula the value of its subformula, that is, σ agrees with the extension Proposition.tseitinExtend (σ ∘ Sum.inl) on the variables of the formula. So every model of A extends to a model of A.tseitinCNF (Proposition.eval_tseitinCNF_tseitinExtend), uniquely on the variables of the formula (Proposition.eq_of_eval_tseitinCNF), and the two are equisatisfiable (Proposition.satisfiable_tseitinCNF_iff).

Source and conventions. Tseitin [Tseitin1983, §1, p. 467] gives the three clauses defining the variable of a conjunction, a disjunction and an implication, and tests whether a formula is a tautology by adding the unit clause of the negated variable of the whole formula. Here the variable of the formula is asserted positively instead, so that the transformation is satisfiable exactly when the formula is; a tautology test applies it to ¬A. CSLib's propositions have no negation connective, ¬A being A → ⊥, so negation goes through the implication clauses, and ⊥ gets the unit clause making its variable false.

The fresh variables keep the formula short: A.tseitinCNF has at most 3 · A.size + 1 clauses (Proposition.length_tseitinCNF_le), each with at most three literals (Proposition.length_le_three_of_mem_tseitinCNF).

Main definitions #

Main results #

References #

The variable of a subformula in the Tseitin transformation: an atom is its own variable and any other subformula is a fresh variable.

The definitional clauses of the subformulas of a proposition: for B = op(C, D), three clauses saying that the variable of B is op of the variables of C and D, and for B = ⊥ the unit clause saying that its variable is false.

def Cslib.Logic.PL.Proposition.tseitinCNF {Atom : Type u_1} (A : Proposition Atom) :
CNF (Atom ⊕ Proposition Atom)

The Tseitin transformation Tseitin: the definitional clauses of the subformulas of A, and the unit clause asserting the variable of A.

def Cslib.Logic.PL.Proposition.tseitinExtend {Atom : Type u_1} (v : Atom → Bool) :
Atom ⊕ Proposition Atom → Bool

An assignment of the atoms, extended to the fresh variables by giving the variable of every subformula its value.

The number of nodes of a proposition: atoms and ⊥ have size one.

Semantics #

@[simp]

The definitional clauses hold under the extension of any assignment of the atoms.

Under an assignment satisfying the definitional clauses, the variable of A carries the value of A at the atoms.

theorem Cslib.Logic.PL.Proposition.eq_tseitinExtend_of_eval_tseitinDefs {Atom : Type u_1} {σ : Atom ⊕ Proposition Atom → Bool} {A : Proposition Atom} (h : CNF.eval σ A.tseitinDefs = true) {y : Atom ⊕ Proposition Atom} (hy : y = A.tseitinVar ∨ y ∈ A.tseitinDefs.vars) :

Under an assignment satisfying the definitional clauses of A, the variables of those clauses and the variable of A carry the values of the extension of the assignment's atoms.

The models of the Tseitin transformation: an assignment satisfies A.tseitinCNF exactly when its restriction to the atoms satisfies A and it agrees, on the variables of the formula, with the extension of that restriction.

Every model of A extends to a model of A.tseitinCNF: the value of the Tseitin transformation under the extension of an assignment is the value of A.

theorem Cslib.Logic.PL.Proposition.eq_of_eval_tseitinCNF {Atom : Type u_1} {σ τ : Atom ⊕ Proposition Atom → Bool} {A : Proposition Atom} (hσ : CNF.eval σ A.tseitinCNF = true) (hτ : CNF.eval τ A.tseitinCNF = true) (hatoms : σ ∘ Sum.inl = τ ∘ Sum.inl) {y : Atom ⊕ Proposition Atom} (hy : y ∈ A.tseitinCNF.vars) :
σ y = τ y

Models of the Tseitin transformation are determined by the atoms: two models that agree on the atoms agree on every variable of the formula.

The Tseitin transformation preserves satisfiability.

The definitional clauses of a list of propositions hold under the Tseitin extension of any atom assignment.

Under an assignment satisfying the definitional clauses of fs, every variable of those clauses carries the value of the extension of the assignment's atoms.

theorem Cslib.Logic.PL.Proposition.eq_of_eval_tseitinDefs_flatMap {Atom : Type u_1} {σ τ : Atom ⊕ Proposition Atom → Bool} {fs : List (Proposition Atom)} (hσ : CNF.eval σ (List.flatMap tseitinDefs fs) = true) (hτ : CNF.eval τ (List.flatMap tseitinDefs fs) = true) (hatoms : σ ∘ Sum.inl = τ ∘ Sum.inl) {y : Atom ⊕ Proposition Atom} (hy : y ∈ CNF.vars (List.flatMap tseitinDefs fs)) :
σ y = τ y

Two assignments that satisfy the definitional clauses of fs and agree on the atoms agree on every variable of those clauses.

Size #

The definitional clauses of a list of propositions have linearly many clauses in total.

The Tseitin transformation has linearly many clauses.

Every definitional clause of A has at most three literals.

Every clause of the Tseitin transformation has at most three literals.