Boolean Satisfiability Problem (SAT)

GATE DA — High Importance

🎯 Learning Objectives

  • Define the SAT problem formally
  • Understand Cook's theorem and NP-completeness of SAT
  • Learn the DPLL algorithm for SAT solving
  • Distinguish between 2-SAT (polynomial) and 3-SAT (NP-complete)

1. The SAT Problem

Definition: Boolean Satisfiability Problem (SAT)

Given a propositional formula φ (typically in CNF), determine whether there exists a truth assignment to its variables that makes φ true (i.e., whether φ is satisfiable).

SAT: Given φ in CNF, does there exist v such that v(φ) = True?

Example

φ = (P ∨ Q) ∧ (¬P ∨ R) ∧ (¬Q ∨ ¬R)

Is φ satisfiable? Try v(P)=T, v(Q)=T, v(R)=T:

  • (T ∨ T) = T ✅
  • (F ∨ T) = T ✅
  • (F ∨ F) = F ❌

This assignment doesn't work. Try v(P)=T, v(Q)=F, v(R)=T:

  • (T ∨ F) = T ✅
  • (F ∨ T) = T ✅
  • (T ∨ F) = T ✅

This works! φ is satisfiable. ✅

2. Cook's Theorem: SAT is NP-Complete

Cook-Levin Theorem (1971)

The Boolean Satisfiability Problem (SAT) is NP-complete. This means:

  1. SAT ∈ NP: Given a truth assignment, we can verify in polynomial time whether it satisfies the formula.
  2. SAT is NP-hard: Every problem in NP can be reduced to SAT in polynomial time.

This was the first problem shown to be NP-complete and is a cornerstone of computational complexity theory.

📝 Implications

  • No known polynomial-time algorithm for SAT (unless P = NP).
  • A brute-force approach checks all 2n assignments → exponential time.
  • Despite NP-completeness, modern SAT solvers handle millions of variables using clever heuristics.

3. SAT Variants: k-SAT

Definition: k-SAT

k-SAT is the restriction of SAT where each clause has exactly k literals.

3.1 2-SAT — Polynomial Time!

Theorem: 2-SAT ∈ P

2-SAT (every clause has exactly 2 literals) can be solved in O(n + m) time, where n = number of variables and m = number of clauses. The algorithm uses implication graphs and strongly connected components (SCC).

2-SAT Example

φ = (P ∨ Q) ∧ (¬P ∨ R) ∧ (¬Q ∨ ¬R)

Each clause has 2 literals. A clause (a ∨ b) is equivalent to (¬a → b) ∧ (¬b → a).

Build implication graph: ¬P→Q, ¬Q→P, P→R, ¬R→¬P, Q→¬R, R→¬Q

Find SCCs and check consistent assignment: satisfiable with P=T, Q=F, R=T.

3.2 3-SAT — NP-Complete

Theorem: 3-SAT is NP-Complete

3-SAT (every clause has exactly 3 literals) is NP-complete. In fact, any SAT instance can be reduced to a 3-SAT instance in polynomial time. This makes 3-SAT the "standard" NP-complete problem for reductions.

📝 Complexity Summary for GATE

ProblemComplexity
1-SATO(n) — trivial
2-SATO(n + m) — polynomial
3-SATNP-complete
k-SAT (k ≥ 3)NP-complete
General SATNP-complete
Horn-SATO(n) — linear

4. DPLL Algorithm

The Davis-Putnam-Logemann-Loveland (DPLL) algorithm (1962) is the foundation of all modern SAT solvers. It's a systematic backtracking search with two key optimizations.

Algorithm: DPLL
function DPLL(clauses, assignment):
    // Unit Propagation
    while there exists a unit clause {l} in clauses:
        assignment ← assignment ∪ {l = True}
        clauses ← simplify(clauses, l)
    
    // Pure Literal Elimination
    for each literal l that appears only positive (or only negative):
        assignment ← assignment ∪ {l = True}  // (or ¬l if only negative)
        clauses ← simplify(clauses, l)
    
    // Success / Failure
    if clauses is empty:
        return TRUE (satisfiable)
    if empty clause □ ∈ clauses:
        return FALSE (conflict)
    
    // Choose a variable and branch
    P ← choose an unassigned variable
    return DPLL(clauses ∪ {{P}}, assignment) 
        OR DPLL(clauses ∪ {{¬P}}, assignment)

function simplify(clauses, l):
    // Remove all clauses containing l (they are satisfied)
    // Remove ¬l from all remaining clauses
    return modified clauses

📝 DPLL Key Ideas

  • Unit Propagation: If a clause has only one literal, that literal must be true. Propagate this assignment.
  • Pure Literal Elimination: If a variable always appears with the same polarity, assign it to satisfy those clauses.
  • Branching: Pick an unassigned variable and try both values recursively.
  • Worst case: Still exponential, but pruning makes it practical for many instances.

Example: DPLL on (P ∨ Q) ∧ (¬P ∨ R) ∧ (¬R)

  1. Unit propagation: {¬R} is a unit clause → set R = False
  2. Simplify: Remove {¬R} (satisfied). Remove R from {¬P ∨ R} → {¬P}
  3. Clauses now: {P ∨ Q}, {¬P}
  4. Unit propagation: {¬P} is unit → set P = False
  5. Simplify: Remove {¬P} (satisfied). Remove P from {P ∨ Q} → {Q}
  6. Unit propagation: {Q} is unit → set Q = True
  7. Simplify: Remove {Q} (satisfied). Clauses empty!
  8. Return TRUE. Assignment: P=F, Q=T, R=F ✅

5. GATE Exam Tips

🎯 Key Points

  • Know that SAT is NP-complete (Cook's theorem).
  • Remember 2-SAT ∈ P but 3-SAT is NP-complete. The boundary is sharp!
  • GATE may ask to trace DPLL on small instances — practice unit propagation.
  • Horn-SAT is solvable in linear time — special case to remember.
  • Understand that SAT is a decision problem (yes/no), not an optimization problem.