TCSLib

91 Complexity — SAT To3 SAT

91.1 Overview

This module formalises the classical polynomial-time reduction from SAT to 3-SAT via a chain (Tseitin-style) encoding. Given a CNF formula \(f\) over variables \(V\), the function SATTo3SAT.to3SAT produces an equisatisfiable 3-CNF formula over an extended variable type SATTo3SAT.AuxVar \(V\); the main result SATTo3SAT.SAT_to_3SAT_equivalence states that \(f\) is satisfiable if and only if its 3-CNF encoding is satisfiable.

91.2 Declarations

Definition 91.1 Clause
✓
#

A clause over variable type \(V\) is a disjunction represented as a list of literals, i.e. \(\mathtt{Clause}\, V = \mathtt{List}\, (\mathtt{Literal}\, V)\).

Definition 91.2 CNF formula
✓
#

A CNF formula over \(V\) is a conjunction of clauses, represented as a list of clauses: \(\mathtt{CNFFormula}\, V = \mathtt{List}\, (\mathtt{Clause}\, V)\).

Definition 91.3 Literal evaluation
✓
#

Given an assignment \(\alpha : V \to \mathrm{Prop}\), SATTo3SAT.evalLiteral maps a literal to its truth value: a positive literal \(\mathtt{pos}\, v\) is true iff \(\alpha (v)\) holds, and a negative literal \(\mathtt{neg}\, v\) is true iff \(\alpha (v)\) does not hold.

Definition 91.4 Clause satisfaction
✓

A clause \(c\) is satisfied by assignment \(\alpha \) if at least one literal in \(c\) evaluates to true under \(\alpha \), i.e. \(\exists \, l \in c,\; \texttt{SATTo3SAT.evalLiteral}\, \alpha \, l\).

Definition 91.5 Formula satisfaction
✓

A CNF formula \(f\) is satisfied by assignment \(\alpha \) if every clause in \(f\) is satisfied by \(\alpha \).

Definition 91.6 Satisfiability of a CNF formula
✓
#

A CNF formula \(f\) is satisfiable if there exists an assignment \(\alpha \) such that \(\texttt{SATTo3SAT.formulaSatisfied}\, \alpha \, f\) holds.

Definition 91.7 3-clause
✓
#

A 3-clause over \(V\) is a structure carrying exactly three literals \(l_1, l_2, l_3 : \mathtt{Literal}\, V\); a 3-clause is satisfied when at least one of the three literals is true.

Definition 91.8 3-CNF formula
✓
#

A 3-CNF formula over \(V\) is a list of 3-clauses: \(\mathtt{Formula3}\, V = \mathtt{List}\, (\mathtt{Clause3}\, V)\).

Definition 91.9 3-clause satisfaction
✓

A 3-clause \(c\) is satisfied by assignment \(\alpha \) if at least one of its three literals \(c.l_1\), \(c.l_2\), \(c.l_3\) evaluates to true under \(\alpha \).

Definition 91.10 3-CNF formula satisfaction
✓

A 3-CNF formula \(f\) is satisfied by assignment \(\alpha \) if every 3-clause in \(f\) is satisfied by \(\alpha \).

Definition 91.11 3-SAT satisfiability
✓

A 3-CNF formula \(f\) is 3-satisfiable if there exists an assignment \(\alpha \) such that \(\texttt{SATTo3SAT.formula3Satisfied}\, \alpha \, f\) holds.

Definition 91.12 Auxiliary variable type
✓
#

The inductive type \(\mathtt{AuxVar}\, V\) extends a variable type \(V\) with two constructors: \(\mathtt{orig}\, v\) wraps an original variable \(v : V\), and \(\mathtt{extra}\, i\, j\) introduces a fresh auxiliary variable \(y_{i,j}\) used as a chain link when encoding clause \(i\) of length greater than three.

Definition 91.13 Lift a literal to the extended type
✓
#

SATTo3SAT.liftLit maps a literal over \(V\) to the corresponding literal over \(\mathtt{AuxVar}\, V\) by wrapping each variable with \(\mathtt{orig}\), preserving polarity.

Definition 91.14 Build chain clauses
✓
#

Given a clause index \(c\_ idx\), a lifting map \(ml\), a suffix list of literals \(\mathit{lits}\), and a chain counter \(j \ge 1\), SATTo3SAT.buildChain produces the middle and final 3-clauses of the chain encoding. Each middle step emits \(\langle \lnot y_{j-1},\, l_i,\, y_j\rangle \); the final step emits \(\langle \lnot y_{j-1},\, l_{n-1},\, l_n\rangle \) when only two literals remain.

Definition 91.15 Encode a single clause as 3-clauses
✓

SATTo3SAT.transformClause maps a single clause (at index \(c\_ idx\)) to a list of 3-clauses: the empty clause becomes two contradictory 3-clauses (unsatisfiable), a 1-literal clause becomes \(\langle l_1,l_1,l_1\rangle \), a 2-literal clause becomes \(\langle l_1,l_2,l_2\rangle \), a 3-literal clause is copied as-is, and any longer clause \(l_1 :: l_2 :: \mathit{rest}\) becomes \(\langle l_1, l_2, y_0\rangle \) followed by \(\texttt{SATTo3SAT.buildChain}\) on \(\mathit{rest}\).

Definition 91.16 Recursive SAT-to-3SAT worker
✓

The auxiliary recursive function SATTo3SAT.to3SATAux iterates SATTo3SAT.transformClause over a list of clauses, threading a clause index counter to ensure each clause uses distinct auxiliary variables.

Definition 91.17 SAT to 3-SAT encoding
✓

SATTo3SAT.to3SAT converts a CNF formula \(f\) over \(V\) into a 3-CNF formula over \(\mathtt{AuxVar}\, V\) by calling SATTo3SAT.to3SATAux starting at index \(0\).

Definition 91.18 Auxiliary variable valuation
✓
#

For a list of literals \(\mathit{lits}\) and index \(j\), \(\texttt{SATTo3SAT.extraVal}\, \alpha \, \mathit{lits}\, j\) holds iff every literal in \(\mathit{lits}.\mathtt{take}(j + 2)\) is false under \(\alpha \). This is the intended truth value of the auxiliary chain variable \(y_j\) in the encoding of \(\mathit{lits}\).

Lemma 91.19 Auxiliary variable valuation as an all-false prefix
✓

Fix an assignment \(\alpha \) and a list of literals \(\mathit{lits}\), and let \(j\) be an index with \(j + 2 \le |\mathit{lits}|\). Then the auxiliary variable valuation associated with \(\alpha \), \(\mathit{lits}\), and \(j\) holds if and only if every one of the first \(j + 2\) literals of \(\mathit{lits}\) evaluates to false under \(\alpha \).

Definition 91.20 Global assignment lift
✓

Given \(\alpha : \mathtt{Assignment}\, V\) and a formula \(f\), SATTo3SAT.globalAssignment \(\alpha \, f\) is the assignment on \(\mathtt{AuxVar}\, V\) that maps each original variable \(\mathtt{orig}\, v\) to \(\alpha (v)\) and each auxiliary variable \(\mathtt{extra}\, i\, j\) to \(\texttt{SATTo3SAT.extraVal}\, \alpha \, (f.\mathtt{get}\, i)\, j\), i.e. the chain invariant “the first \(j+2\) literals of clause \(i\) are all false.”

Lemma 91.21 Membership in the clause-by-clause 3-SAT encoding
✓

Let \(\mathit{cs} = (c_0,\dots ,c_{m-1})\) be a list of clauses over a variable type \(V\), let \(\mathit{idx} \in \mathbb {N}\) be a starting index, and let \(c_3\) be a 3-clause over the auxiliary variable type \(\mathtt{AuxVar}\, V\). Encode \(\mathit{cs}\) into 3-clauses by transforming each clause \(c_i\) at the shifted index \(\mathit{idx}+i\) and concatenating the outputs in order of increasing \(i\). Then \(c_3\) occurs in the resulting encoding of \(\mathit{cs}\) if and only if there is a position \(i \lt m\) for which \(c_3\) occurs among the 3-clauses produced by transforming the clause \(c_i\) at index \(\mathit{idx}+i\).

Lemma 91.22 Membership in the SAT-to-3-SAT encoding
✓

Let \(f = (C_0, \dots , C_{m-1})\) be a CNF formula over a variable type \(V\), and write \(\mathrm{Aux}(V)\) for the auxiliary variable type built from \(V\). For each index \(i\) with \(0 \le i \lt m\), let \(T_i\) be the list of \(3\)-clauses obtained by encoding the single clause \(C_i\) at index \(i\), and take the SAT-to-3-SAT encoding of \(f\) to be the \(3\)-CNF formula over \(\mathrm{Aux}(V)\) formed by concatenating \(T_0, T_1, \dots , T_{m-1}\) in order. Then a \(3\)-clause \(c\) over \(\mathrm{Aux}(V)\) occurs in the SAT-to-3-SAT encoding of \(f\) if and only if there exists an index \(i \lt m\) such that \(c\) occurs in \(T_i\).

Lemma 91.23 Extending a list prefix past a dropped head
✓
#

Let \(l\) be a list over a type \(\alpha \), let \(n\) be a natural number, and suppose that dropping the first \(n\) entries of \(l\) leaves a nonempty list whose head is \(a\) (so that \(l\) has more than \(n\) entries and its \((n+1)\)-st entry is \(a\)). Then the prefix consisting of the first \(n+1\) entries of \(l\) equals the prefix consisting of the first \(n\) entries with \(a\) appended: taking \(n+1\) entries of \(l\) gives (taking \(n\) entries of \(l\)) followed by \([a]\).

Lemma 91.24 Chain clauses satisfied by the completed assignment
✓

Fix a clause index \(i\) and a clause presented as a list of literals over a variable type \(V\), and let \(\alpha : V \to \mathrm{Prop}\) be an assignment that makes at least one literal of the clause true. Let \(ml\) be a map lifting each literal over \(V\) to a literal over the extended type \(\mathtt{AuxVar}\, V\), and let \(\alpha _3\) be an assignment on \(\mathtt{AuxVar}\, V\) such that: (i) for every \(k\) the auxiliary variable \(y_{i,k}\) is true under \(\alpha _3\) exactly when all of the first \(k+2\) literals of the clause are false under \(\alpha \); and (ii) for every literal \(\ell \), the lifted literal \(ml(\ell )\) is true under \(\alpha _3\) if and only if \(\ell \) is true under \(\alpha \). Then for every chain counter \(j \ge 1\), letting \(\mathit{lits}\) be the suffix of the clause obtained by dropping its first \(j+1\) literals, every 3-clause in the chain built for clause \(i\) from \(\mathit{lits}\) starting at counter \(j\) is satisfied by \(\alpha _3\).

Definition 91.25 Local literal predicate
✓
#

A literal \(l\) in \(\mathtt{Literal}\, (\mathtt{AuxVar}\, V)\) is local to index \(i\) if every auxiliary variable appearing in \(l\) carries index \(i\). Literals over original variables are always local.

Lemma 91.26 Local and global assignments agree on local literals
✓

Let \(\alpha \) be a truth assignment of the variables \(V\), and let \(f\) be a CNF formula over \(V\) with clauses \(C_0, \dots , C_{m-1}\). Fix an index \(i\) with \(0 \le i \lt m\) and write \(C_i\) for the \(i\)-th clause. Let \(l\) be a literal over the auxiliary variable type \(\mathtt{AuxVar}\, V\) that is local to \(i\), meaning that every auxiliary variable \(y_{i',j}\) occurring in \(l\) satisfies \(i' = i\). Write \(\hat\alpha \) for the global assignment determined by \(\alpha \) and \(f\), which sends each original variable to its value under \(\alpha \) and each auxiliary variable \(y_{i',j}\) to the truth of the assertion that the first \(j+2\) literals of clause \(C_{i'}\) are all false under \(\alpha \); and write \(\alpha _i\) for the corresponding local assignment, built from clause \(C_i\) alone. Then \(l\) takes the same truth value under \(\hat\alpha \) as under \(\alpha _i\).

Lemma 91.27 Chain-encoding clauses stay local to their index
✓

Let \(i\) be a natural number and let \(ml\) be a lifting map sending each literal over a variable type \(V\) to a literal over \(\mathtt{AuxVar}\, V\), and suppose that \(ml(l)\) is local to index \(i\) for every literal \(l\). Then, for every list of literals \(\mathit{lits}\) over \(V\) and every chain counter \(j\), each \(3\)-clause occurring in the chain of clauses built from \(\mathit{lits}\) (with clause index \(i\), lifting map \(ml\), and counter \(j\)) has all three of its literals local to index \(i\).

Lemma 91.28 Locality of the 3-clause encoding of a single clause
✓

Fix a clause index \(i\) and let \(C\) be a clause over a variable type \(V\). If a 3-clause occurs in the list produced by encoding \(C\) at index \(i\), then each of its three literals is local to \(i\); that is, every auxiliary variable appearing in the 3-clause carries the index \(i\), while literals over original variables of \(V\) are local automatically.

Fix an assignment \(\alpha \) of truth values to the variables of a type \(V\), a CNF formula \(f\), and an index \(i\) with \(i \lt \mathrm{length}(f)\); let \(C\) be the \(i\)-th clause of \(f\), and let \(c_3\) be any of the 3-clauses produced by encoding \(C\) as clause number \(i\). Consider the global lifted assignment on \(\mathtt{AuxVar}\, V\), which sends each original variable \(v\) to \(\alpha (v)\) and each auxiliary chain variable \(y_{i',j}\) to the truth value of the assertion “the first \(j+2\) literals of the \(i'\)-th clause of \(f\) are all false under \(\alpha \)”, together with the local assignment that agrees with \(\alpha \) on original variables and sends \(y_{i,j}\) to the truth value of “the first \(j+2\) literals of \(C\) are all false under \(\alpha \)”. Then \(c_3\) is satisfied by the global assignment if and only if it is satisfied by the local assignment.

Lemma 91.30 Extended assignment satisfies the 3-clause encoding of a satisfied clause
✓

Let \(\alpha \) be a truth assignment on a variable set \(V\), and let \(C\) be a clause over \(V\) — a finite list of literals read as their disjunction — carrying the index \(i\). Assume \(\alpha \) satisfies \(C\), meaning at least one literal of \(C\) is true under \(\alpha \). Extend \(\alpha \) to an assignment \(\alpha _3\) on the enlarged variable set consisting of the original variables of \(V\) together with the auxiliary chain variables \(y_{i,j}\): leave each original variable at its value under \(\alpha \), and set \(y_{i,j}\) to true exactly when the first \(j+2\) literals of \(C\) are all false under \(\alpha \). Then every \(3\)-clause in the list obtained by encoding \(C\) at index \(i\) as \(3\)-clauses is satisfied by \(\alpha _3\).

Let \(f\) be a CNF formula over a variable type \(V\), and let \(\mathrm{to3SAT}(f)\) be the 3-CNF formula produced by the standard clause-splitting transformation, whose variables are those of \(V\) together with fresh auxiliary chain variables introduced to break each long clause into a chain of three-literal clauses. If \(f\) is satisfiable — that is, some assignment to \(V\) makes every clause of \(f\) true — then \(\mathrm{to3SAT}(f)\) is 3-satisfiable: there is an assignment to its variables under which every 3-clause is true.

Lemma 91.32 Contradiction from a satisfied chain of all-false literals
✓

Fix a clause index \(i\) and an assignment \(\alpha \) of truth values to the auxiliary variables. Let \(\ell \mapsto \widehat{\ell }\) be a map lifting each literal over the base variable type to a literal over the auxiliary-variable type, let \(j \ge 1\), and let \(L\) be a list of at least two literals over the base type such that the lifted literal \(\widehat{\ell }\) evaluates to false under \(\alpha \) for every \(\ell \) in \(L\). If every 3-clause of the chain encoding built from clause index \(i\), the lifting \(\ell \mapsto \widehat{\ell }\), the list \(L\), and the counter \(j\) is satisfied by \(\alpha \), then \(\alpha \) cannot also make the entry variable \(y_{i,\, j-1}\) true; these hypotheses taken together are contradictory.

Lemma 91.33 Soundness of the clause-to-3-clause encoding
✓

Fix a variable type \(V\), a clause index \(c \in \mathbb {N}\), and a clause \(C\) over \(V\) — a finite list of literals read as their disjunction. Let \(\alpha \) be a truth assignment to the auxiliary variables (the original variables of \(V\) together with the fresh chain variables), and suppose that every \(3\)-clause produced by encoding \(C\) at index \(c\) is satisfied by \(\alpha \). Then \(C\) has at least one literal that is true under the assignment obtained by reading each original variable \(v\) through its copy among the auxiliary variables, i.e. \(v \mapsto \alpha (\mathrm{orig}\, v)\).

Theorem 91.34 Soundness of the SAT-to-3-SAT encoding
✓

Let \(f\) be a CNF formula over a variable type \(V\), and let its SAT-to-3-SAT encoding be the 3-CNF formula over the extended variable type (the original variables together with the fresh auxiliary chain variables). If this encoded 3-CNF formula is 3-satisfiable — that is, some assignment of the extended variables satisfies all of its 3-clauses — then \(f\) itself is satisfiable.

Theorem 91.35 SAT-to-3-SAT preserves satisfiability
✓

Let \(f\) be a CNF formula over a variable type \(V\), and let \(\tau (f)\) denote its \(3\)-CNF encoding: the formula obtained by replacing each clause of \(f\) with an equisatisfiable chain of \(3\)-clauses over an enlarged variable type that adjoins to \(V\) a supply of fresh auxiliary variables (a clause of more than three literals is split into linked triples using these auxiliary variables, while shorter clauses are padded to three literals). Then \(f\) is satisfiable if and only if \(\tau (f)\) is \(3\)-satisfiable.

91.3 Additional declarations

Definition 91.36 Literal over a variable type
✓
#

A literal over a variable type \(V\) is either a positive or a negative occurrence of a variable: for each variable \(v \in V\) there is the positive literal \(v\) and the negated literal \(\lnot v\).