MAX 2-SAT is NP-complete #
MaxTwoSAT consists of instances x : MaxTwoSATInstance (Cslib.Complexity.encMaxTwoSAT) pairing
a formula x.formula in conjunctive normal form with at most two literals per clause and a target
x.target such that some assignment satisfies at least x.target clauses of x.formula, counted
with multiplicity. Garey, Johnson and Stockmeyer proved it NP-complete
Garey, Johnson and Stockmeyer (attribution from secondary sources;
the theorem number is not checked against the paper), although 2-satisfiability itself is in NL
(Cslib.Complexity.TwoSAT.mem_NL).
The reduction is their ten-clause gadget. For a clause a ∨ b ∨ c and a fresh variable w, the
formula MaxTwoSAT.gadget a b c w has the ten clauses
a, b, c, w, ¬a ∨ ¬b, ¬a ∨ ¬c, ¬b ∨ ¬c, a ∨ ¬w, b ∨ ¬w, c ∨ ¬w. Every assignment satisfies at
most seven of them; some value of w reaches seven exactly when the assignment satisfies
a ∨ b ∨ c, and otherwise at most six are satisfied (MaxTwoSAT.gadgetScore). The table depends
only on the truth values of a, b, c, so repeated literals are harmless. The reduction
toMaxTwoSAT starts from ExactThreeSAT, doubles the source variables so that the odd numbers
are fresh, puts one gadget on each clause, and asks for seven satisfied clauses per gadget; a
formula with a clause of another width becomes a fixed no-instance. Composed with the padding
toExactThreeSAT, which repeats a literal of every clause of one or two literals, this reduces
ThreeSAT to MaxTwoSAT.
Main definitions #
Cslib.Complexity.MaxTwoSATInstance,Cslib.Complexity.encMaxTwoSAT.Cslib.Complexity.MaxTwoSAT: the decision version of maximum 2-satisfiability.Cslib.Complexity.MaxTwoSAT.gadget: the ten-clause gadget of one clause.Cslib.Complexity.toMaxTwoSAT: the reduction fromExactThreeSAT.
Main results #
Cslib.Complexity.MaxTwoSAT.mem_NP:MaxTwoSAT ∈ NP encMaxTwoSAT.Cslib.Complexity.MaxTwoSAT.countP_gadget: the satisfied clauses of one gadget, counted byMaxTwoSAT.gadgetScore.Cslib.Complexity.MaxTwoSAT.gadgetScore_le,Cslib.Complexity.MaxTwoSAT.gadgetScore_majority,Cslib.Complexity.MaxTwoSAT.gadgetScore_false_le: at most seven, seven when the clause holds and the fresh variable is the majority, at most six when the clause fails.Cslib.Complexity.mem_MaxTwoSAT_toMaxTwoSAT_iff: correctness of the reduction.Cslib.Complexity.polyTimeReducible_ExactThreeSAT_MaxTwoSAT,Cslib.Complexity.polyTimeReducible_ThreeSAT_MaxTwoSAT:ExactThreeSATandThreeSATreduce toMaxTwoSAT.Cslib.Complexity.MaxTwoSAT_npComplete:MaxTwoSATisNP-complete.
References #
- M. R. Garey, D. S. Johnson, L. Stockmeyer, Some simplified NP-complete graph problems
- M. R. Garey, D. S. Johnson, Computers and Intractability, Problem LO5 (locator from secondary sources)
- C. H. Papadimitriou, Computational Complexity, Theorem 9.2 (locator from secondary sources)
An instance (formula, target) of MAX 2-SAT.
- formula : Logic.PL.CNF ℕ
The formula in conjunctive normal form, with at most two literals per clause.
- target : ℕ
The minimum number of clauses that must be satisfied.
Instances For
Instances For
Instances For
Encoding of MaxTwoSATInstance as (formula, target) with target in binary.
Instances For
Maximum 2-satisfiability: the instances x : MaxTwoSATInstance such that every clause of
x.formula has at most two literals and some assignment satisfies at least x.target clauses of
x.formula, counted with multiplicity.
Instances For
Membership in MaxTwoSAT, unfolded.
Membership in NP #
The verifier for MaxTwoSAT: check that every clause has at most two literals and count the
clauses satisfied by the certificate assignment of SAT.assignment.
Instances For
MaxTwoSAT.verifier verifies MaxTwoSAT with certificates as long as the encoded instance:
the certificate lists the values of the variables in order of first occurrence.
Checking the clause widths and counting the satisfied clauses is polynomial-time: the count is computed in unary and compared with the binary target.
MaxTwoSAT belongs to NP.
The gadget #
The ten-clause gadget of Garey, Johnson and Stockmeyer for the clause a ∨ b ∨ c, with the
variable w: the unit clauses a, b, c, w, the clauses ¬a ∨ ¬b, ¬a ∨ ¬c, ¬b ∨ ¬c, and
the clauses a ∨ ¬w, b ∨ ¬w, c ∨ ¬w.
Instances For
The number of satisfied clauses of a gadget whose literals take the values x, y, z and
whose variable takes the value q.
Instances For
The number of satisfied clauses of a gadget depends only on the values of its literals and of its variable.
A gadget never has more than seven satisfied clauses.
The majority of three truth values.
Instances For
If the clause fails, the gadget has at most six satisfied clauses.
The reduction #
Double the variable of a literal; the odd variables are then free for the gadgets.
Instances For
The gadget of the clause numbered i, whose first three literals are doubled, with the fresh
variable 2 i + 1.
Instances For
The reduction from ExactThreeSAT to MaxTwoSAT: a formula all of whose clauses have three
literals becomes the gadgets of its clauses, with target seven satisfied clauses per gadget. Any
other formula becomes the formula with one empty clause and target one, a fixed no-instance: no
assignment satisfies the empty clause.
Instances For
A formula is in ExactThreeSAT exactly when its image under toMaxTwoSAT is in
MaxTwoSAT.
Polynomial time #
The reduction toMaxTwoSAT is computable in polynomial time.
ExactThreeSAT reduces to MaxTwoSAT in polynomial time via toMaxTwoSAT.
ThreeSAT reduces to MaxTwoSAT in polynomial time: pad every clause to three literals by
repetition (toExactThreeSAT), then apply toMaxTwoSAT.
MAX 2-SAT is NP-complete Garey, Johnson and Stockmeyer
(attribution from secondary sources). The target K is in binary, and clauses of one literal are
allowed.