Tseitin transformation
A translation of a propositional formula into CNF that introduces a fresh variable for each subformula and adds the clauses of . The result is equisatisfiable with the input rather than equivalent, and its size is linear in the input's.
For a gate with inputs and , already replaced by the variables or literals standing for them, each definition is three clauses:
Negation needs no new variable, since is already a literal. The encoding of a formula is the conjunction of every gate's clauses and the unit clause asserting the root's variable.
It is equisatisfiable because the definitions determine every gate variable from the input variables. A satisfying assignment of the input extends to one of the encoding by evaluating each gate, and any satisfying assignment of the encoding restricts to one of the input, since the root is asserted and each gate variable equals its subformula. For the same reason the two have the same number of models.
One fresh variable per binary gate. Variables 1 to nvars are the input's.
let tseitin f nvars =let next = ref nvars and clauses = ref [] inlet emit c = clauses := c :: !clauses inlet rec go = function| Var v -> v| Not a -> - go a| And (a, b) ->let a = go a and b = go b inincr next; let g = !next inemit [ -g; a ]; emit [ -g; b ]; emit [ g; -a; -b ]; g| Or (a, b) ->let a = go a and b = go b inincr next; let g = !next inemit [ g; -a ]; emit [ g; -b ]; emit [ -g; a; b ]; ginlet root = go f inemit [ root ];(!next, List.rev !clauses)
For the disjunction of n conjunctions (x_i and y_i), with 2n input variables. The encoding has 3 clauses per gate and 1 for the root, so 3(2n - 1) + 1 = 6n - 2.
n distributed tseitin (clauses, variables)1 2 4, 32 4 10, 75 32 28, 1910 1024 58, 3915 32768 88, 59
When a subformula occurs with only one polarity, one direction of its definition is enough. Under an even number of negations it suffices to have , which drops the third clause of each gate above. This is the Plaisted–Greenbaum encoding.[2] It is still equisatisfiable, but no longer preserves the number of models, because a gate variable constrained in one direction can sometimes take either value.
see also
- CNFConjunctive normal form: a conjunction of clauses, each a disjunction of literals, where a literal is a variable or its negation. It is the input format of SAT solvers. Every formula has an equivalent CNF, but it can be exponentially larger; the Tseitin transformation gives an equisatisfiable one of linear size instead.
- SATThe Boolean satisfiability problem: given a propositional formula, decide whether some assignment of true and false to its variables makes it true. It is the canonical NP-complete problem, and also one that modern solvers routinely settle for instances with millions of variables.
- DIMACS CNFThe plain-text interchange format for CNF instances: a header giving the variable and clause counts, then one clause per line as space-separated nonzero integers terminated by a zero, with a negative integer meaning a negated variable. Every SAT solver reads it, which is what makes solvers comparable at all.
further reading
- [1]G. S. Tseitin, “On the complexity of derivation in propositional calculus”, in Studies in Constructive Mathematics and Mathematical Logic, Part II (1968).
- [2]D. A. Plaisted, S. Greenbaum, “A structure-preserving clause form translation”, Journal of Symbolic Computation 2 (1986).