2-SAT and Max 2-SAT
Overview
Kent Quanrud contrasts 2-SAT with Max 2-SAT, showing how implication graphs and strongly connected components yield a linear-time algorithm for deciding 2-SAT and constructing a satisfying assignment. He then reduces 3-SAT to Max 2-SAT with a ten-clause gadget whose score is 6 or 7 depending on whether the original clause is satisfied, establishing that the optimization problem is NP-hard despite the simplicity of 2-SAT.
Key takeaways
- For each 2-SAT clause A ∨ B, adding edges ¬A → B and ¬B → A turns clause constraints into directed implications.
- A 2-SAT formula is satisfiable exactly when no variable and its negation share a strongly connected component; SCC contraction and topological processing produce a linear-time solution.
- The 2-SAT implication algorithm does not directly solve Max 2-SAT because an unsatisfied clause does not require its corresponding implication to hold.
- A ten-clause gadget for each 3-SAT clause scores at most 6 when the original clause is false and can score 7 when it is true, making 7m a decisive threshold for m clauses.
- Singleton clauses can be padded from A to (A ∨ Y) and (A ∨ ¬Y); each adds one guaranteed baseline point, which can be subtracted from the optimization result.
Chapters
- SAT asks whether any Boolean-variable assignment makes a formula true; brute-force search over n variables can require testing 2^n assignments.
- Kent Quanrud recalls that CNF-SAT and 3-SAT look more restricted than general SAT, yet polynomial-time algorithms for these special cases would also solve broader SAT problems through reductions.
- The lecture frames the central question as whether restricting clauses to two literals changes the computational difficulty.
- 2-SAT asks whether every clause, each containing two literals, can be satisfied simultaneously.
- Max 2-SAT uses the same kind of clauses but seeks an assignment satisfying as many clauses as possible.
- An exact Max 2-SAT solver can decide 2-SAT by checking whether the maximum equals the total number of clauses.
- A clause with two literals can force one literal when the other is false, creating chains of assignments rather than the branching choices common in 3-SAT.
- The earlier 3-SAT construction from general SAT used clauses with three literals, so it does not directly establish that 2-SAT is hard.
- The motivating example shows that choosing a value for one variable can force another variable and expose a contradiction.
- Create two vertices per variable: xᵢ represents true and ¬xᵢ represents false, for 2n vertices total.
- For each clause A ∨ B, add the implications ¬A → B and ¬B → A.
- Each clause contributes two directed edges, encoding the rule that if one literal is false, the other must be true.
- An assignment satisfies the encoded clauses exactly when no implication edge goes from a true vertex to a false vertex.
- In the lecture's small example, assigning x₁ false, x₂ true, x₃ true, and x₄ false avoids every true-to-false edge.
- The graph translates clause checking into a condition about the directions and truth labels of edges.
- If xᵢ and ¬xᵢ lie in the same strongly connected component, each can reach the other through implication paths.
- Setting either literal true then forces its complement true as well, contradicting the requirement that a variable and its negation have opposite truth values.
- This condition rules out unsatisfiable instances, but a construction is still needed to prove that every instance without such a contradiction is satisfiable.
- The key criterion is that a 2-SAT formula is satisfiable if and only if no variable xᵢ and its complement ¬xᵢ belong to the same strongly connected component.
- The necessity direction follows from implication propagation around a cycle.
- For the sufficiency direction, the algorithm assigns components while respecting the directed acyclic graph formed by contracting strongly connected components.
- For every implication edge a → b, the graph also contains the complementary reversed edge ¬b → ¬a.
- This symmetry pairs each strongly connected component with a complementary component containing the opposite literals.
- A source component can be assigned false with minimal consequences, while its complementary sink is assigned true; removing the pair preserves the same structure.
- Build the implication graph, compute strongly connected components, and reject if xᵢ and ¬xᵢ share a component.
- Process components in reverse topological order, assigning each unassigned component true and its complement false.
- Graph construction, strongly connected component computation, contradiction checking, and assignment take O(V + E), which is linear in the formula size.
- The 2-SAT algorithm depends on every clause being enforced: if one literal is false, the other must be true.
- In Max 2-SAT, an assignment may leave a clause unsatisfied, so its implication need not be enforced.
- This extra flexibility separates the optimization problem from ordinary 2-SAT, despite their similar inputs.
- To show Max 2-SAT is hard, start with a 3-SAT instance and transform it in polynomial time into an instance with at most two literals per clause.
- The reduction must preserve enough information for a Max 2-SAT solver to decide whether the original 3-SAT instance is satisfiable.
- The direction matters: solving the simpler-looking Max 2-SAT instance must provide a way to solve the known-hard 3-SAT instance.
- Replacing a three-literal clause with three two-literal clauses can award one, two, or three points when the original clause is satisfied.
- Across many clauses, the total score does not reveal whether every original clause was satisfied, since points can be concentrated on only a few clauses.
- The reduction therefore needs a gadget with a consistent score gap between satisfied and unsatisfied original clauses.
- Replace each clause A ∨ B ∨ C with ten clauses and one fresh variable Y: A, B, C; ¬A ∨ ¬B, ¬B ∨ ¬C, ¬A ∨ ¬C; and Y, A ∨ ¬Y, B ∨ ¬Y, C ∨ ¬Y.
- For each assignment to A, B, and C, optimize Y; the gadget's maximum score is 6 when A ∨ B ∨ C is false and 7 when it is true.
- For m original clauses, the transformed instance reaches 7m satisfied clauses if and only if the original 3-SAT formula is satisfiable.
- Convert a one-literal clause A into (A ∨ Y) and (A ∨ ¬Y), using a fresh Y; this yields two satisfied clauses when A is true and one when A is false.
- With k singleton clauses, padding adds a fixed baseline of k points, so subtract k from the Max 2-SAT score to recover the original optimum.
- The reductions combine to show Max 2-SAT is NP-hard, while ordinary 2-SAT has a linear-time algorithm.
Transcript excerpt
0:05 Okay. So, uh once upon a time uh before the midterm, we started talking about SAT, right? And so, we're going to and we Well, I'll go through it, but today we're going to talk about two more. Yeah. >> Is SAT an acronym? >> Yes. Well, is it an acronym? Because it's just short for like uh satisfiability. So, it's more like the first three letters. >> Yeah. people in hand now. >> No, I think uh yeah, I think it's just short for satis satisfiability. >> Um okay. So yeah, we were doing uh you know and that's just kind of boolean formulas like uh you've seen before and or not, right? And and the basic problem is I give you some boolean formula and I ask you is there some way to make it output
0:52 true? Okay. and and of course you can try all possible inputs because it's easy to evaluate a boolean formula but that would take exponential time to try all the inputs okay so the question is um can you do better right and I think a very key feature is that it's a search problem in the sense that if you do find the answer you can recognize it right because if you do find something that makes output true you could have just computed you know plugged into the formula and checked right so in that sense it's a search problem but it doesn't feel like it's as well structured as binary search where you could really like annihilate half the options with every guess. Right? So some kind of it seems to be much weaker structure but otherwise still a search problem. Um and the big question is can you solve this in polinomial time
1:41 and okay so we did something that's maybe very
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Kent Quanrud.