Practice Discrete Math

Algorithms / Two Sat

Least You Need to Know: 2-SAT, Implication Graphs, and SCC-Based Solving

2-SAT is a special satisfiability problem where each clause has two literals. Unlike general SAT, 2-SAT is solvable in polynomial time using an implication graph and strongly connected components. The signature theorem is that a formula is unsatisfiable exactly when some variable and its negation lie in the same SCC.

The least you need to know

Key notation

2-SAT SAT where every clause has exactly two literals in the standard model
implication graph directed graph of literal implications
SCC strongly connected component

Tiny worked example

  • For a clause `(x or y)`, add edges `(not x -> y)` and `(not y -> x)`.
  • Build the implication graph for all clauses.
  • Compute strongly connected components.
  • If `x` and `not x` fall in the same SCC for some variable `x`, the formula is unsatisfiable.

Common mistakes

How to recognize this kind of problem

Start practice