Quiz 2

✅ SAT, CNF & Local Search

382 words
2 min read
Python Week 1: the first filter for runtime behavior
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):
(x1x2)(x2x3x4)(x1x4)(x_1 \lor \overline{x_2}) \land (x_2 \lor x_3 \lor \overline{x_4}) \land (\overline{x_1} \lor x_4)
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: (x1x2x3)(x1x2x3)(x1x2x3)(x_1 \lor x_2 \lor x_3) \land (\overline{x_1} \lor \overline{x_2} \lor x_3) \land (x_1 \lor \overline{x_2} \lor \overline{x_3})

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:
  1. Pick an unsatisfied clause randomly
  2. With probability p: flip a random variable in the clause
  3. 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 2n2^n possible assignments (exponential in number of variables).

4. 📝 Practice Questions

Q1: Convert (x1x2)(x3x4)(x_1 \land x_2) \lor (x_3 \land x_4) to CNF.
Answer: (x1x3)(x1x4)(x2x3)(x2x4)(x_1 \lor x_3) \land (x_1 \lor x_4) \land (x_2 \lor x_3) \land (x_2 \lor x_4) — distribution of AND over OR. Q2: Is the formula (xy)(xy)(xy)(x \lor y) \land (x \lor \overline{y}) \land (\overline{x} \lor y) satisfiable?
Answer: Yes: x=True, y=True makes all three clauses True. (TT)(TF)(FT)=TTT=T(T\lor T)\land(T\lor F)\land(F\lor T) = T\land T\land T = T. Join Discord PreviousLocal Search OverviewNextSimulated Annealing & Tabu
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.