✅ SAT, CNF & Local Search
382 words
2 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# ✅ SAT, CNF & Local Search ## 1. 🎯 Learning Objectives - Represent boolean formulas in Conjunctive Normal Form (CNF) - Explain SAT as a canonical configuration problem - Trace WalkSAT/local search for SAT - Understand SAT as the first NP-complete problem - Connect SAT to real-world constraint problems ## 2.

✅ SAT, CNF & Local Search
1. 🎯 Learning Objectives
- Represent boolean formulas in Conjunctive Normal Form (CNF)
- Explain SAT as a canonical configuration problem
- Trace WalkSAT/local search for SAT
- Understand SAT as the first NP-complete problem
- Connect SAT to real-world constraint problems
2. 📖 Core Content
3.1 What is SAT?
The Boolean Satisfiability Problem (SAT) asks: given a boolean formula, does there exist an assignment of True/False to its variables that makes the formula True?
SAT is NP-complete (Cook-Levin theorem, 1971) — every NP problem can be reduced to SAT in polynomial time.
3.2 Conjunctive Normal Form (CNF)
A CNF formula is a conjunction (AND) of clauses, where each clause is a disjunction (OR) of literals (variables or their negations):
The formula is satisfiable if there exists an assignment making all clauses True simultaneously.
3.3 3SAT
3SAT is a restricted version where each clause has exactly 3 literals. 3SAT is also NP-complete.
Example: (x1∨x2∨x3)∧(x1∨x2∨x3)∧(x1∨x2∨x3)
3.4 Local Search for SAT
GSAT (Greedy SAT): Start with random assignment. Flip variable that most improves number of satisfied clauses. Repeat.
WalkSAT: Like GSAT but with randomness to escape local optima:
- Pick an unsatisfied clause randomly
- With probability p: flip a random variable in the clause
- With probability 1-p: flip the variable that maximizes satisfied clauses
3.5 SAT as Configuration Problem
SAT is a configuration problem — we only need the final assignment, not the path to reach it. The state space is all 2n possible assignments (exponential in number of variables).
4. 📝 Practice Questions
Q1: Convert (x1∧x2)∨(x3∧x4) to CNF.Answer: (x1∨x3)∧(x1∨x4)∧(x2∨x3)∧(x2∨x4) — distribution of AND over OR. Q2: Is the formula (x∨y)∧(x∨y)∧(x∨y) satisfiable?Answer: Yes: x=True, y=True makes all three clauses True. (T∨T)∧(T∨F)∧(F∨T)=T∧T∧T=T. Join Discord PreviousLocal Search OverviewNextSimulated Annealing & Tabu