Need To Show L Formalizing Computation:: 3SAT For All L

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Goal: show 3SAT is NP-complete

Need to show L0 ≤P 3SAT for all L0 ∈ NP


Formalizing computation:
• Define an idealized model of computation
• RAM: Random Access Machine
• Reads bits from an input tape
• Writes bits to an output tape
• Random access memory
• Simple instruction set

1
Random Access Machine (RAM)

Input Tape

Random
Control
Access
Unit
Memory

Output Tape

2
Instruction Set:
• add 17, 18, 20 # m[20] ← m[17] + m[18]
• sub 17, 18, 20 # m[20] ← m[17] − m[18]
• mul 17, 18, 20 # m[20] ← m[17] · m[18]
• div 17, 18, 20 # m[20] ← bm[17]/ m[18]c
• ldc 17, 20 # m[20] ← 17
• ldd 17, 20 # m[20] ← m[17]
• ldi 17, 20 # m[20] ← m[m[17]]
• sti 17, 20 # m[m[20]] ← m[17]
• b 100 # branch to 100
• bpos 17, 100 # branch to 100 if m[17] > 0
• bz 17, 100 # branch to 100 if m[17] = 0
• halt
• read 20 # m[20] ← read bit
• write 17 # write m[17]
3
Polynomial time:
• n = input length
• Requirement: Number of instructions executed
≤ nb + c for constants , b, c
• Requirement: Number in each memory cell
0
≤ 0 nb + c0 in absolute value for constants
0 , b0 , c0
• Implication: highest memory cell addressed is
0
≤ 0 nb + c00 for constant c00

4
Circuit Satisfiability (CSAT)
a first NP-complete problem
Instance:
• A Boolean circuit C:
◦ inputs 1 , . . . , m
◦ constant gates (0, 1)
◦ AND, OR, NOT gates
◦ AND, OR take 2 inputs
◦ unrestricted “fan out”
◦ A single bit output
Question:
• Is there an assignment to the inputs 1 , . . . , m
such that C(1 , . . . , m ) = 1?
5
3
OR

1
AND
2 AND

OR
1 NOT

Linearized representation:
4 ← 1 ∧ 2
5 ← 1
6 ← 3 ∨ 4
7 ← 4 ∨ 5
8 ← 6 ∧ 7
6
Proof that CSAT is NP-complete
• Clearly CSAT ∈ NP: a witness is just a
satisfying assignment
• Need to show that CSAT is NP-hard, i.e.,
L ≤P CSAT for all L ∈ NP
• Let L ∈ NP
• We know there is a language L0 ∈ P and
constants , b, c such that ∀ ∈ {0, 1}∗ :
b +c
 ∈ L ⇐⇒ ∃ ∈ {0, 1}|| : 〈, 〉 ∈ L0
• Let M0 be the polynomial time RAM that
recognizes L0

7
Proof (cont’d):
• The current configuration of M0 is
α = (m, p, r, y, z), where
◦ m: contents of all memory cells
◦ p: program counter
◦ r: position of input “read head”
◦ y: contents of input tape
◦ z: contents of output tape
• There is a function ƒnext that maps a
configuration α to the successor configuration
ƒnext (α)
• Configurations can be encoded as
polynomial-sized bit strings
• The function ƒnext can be realized by a
polynomial-sized circuit Cnext
8
input: 

``pairing circuit''
〈, ·〉 x is ``hardwired''

α0 m p r y z

Cnext

α1 m p r y z

Cnext

..
.

αt m p r y z

output
9
Satisfiability (SAT)
Instance:
• A Boolean formula ϕ:
◦ variables 1 , . . . , m
◦ constants 0, 1
◦ operators ∨, ∧, ·
◦ Parentheses
Question:
• Is there an assignment to the variables
1 , . . . , m such that ϕ(1 , . . . , m ) = 1?
Formulas are essentially circuits with fan-out
restricted to 1
10
A simple reduction: CSAT ≤P SAT
• Let “ϕ1 ⇔ ϕ2 ” be shorthand for
“(ϕ1 ∧ ϕ2 ) ∨ (ϕ̄1 ∧ ϕ̄2 )”
Circuit C: Formula ϕ:
4 ← 1 ∧ 2 (4 ⇔ (1 ∧ 2 ))∧
5 ← 1 (5 ⇔ (1 ))∧
6 ← 3 ∨ 4 (6 ⇔ (3 ∨ 4 ))∧
7 ← 4 ∨ 5 (7 ⇔ (4 ∨ 5 ))∧
8 ← 6 ∧ 7 (8 ⇔ (6 ∧ 7 ))∧
8
• It is clear that C is satisfiable ⇔ ϕ is satisfiable

11
3SAT: a special case of SAT
Conjunctive Normal Form:
• a conjunction (∧) of clauses
• each clause is a disjunction (∨) of literals
• each literal is a variable  or its complement 
Examples:
 ∧ y,  ∧ (y ∨ z), ( ∨ y ∨ z) ∧ ( ∨  ∨ z)
A special form: 3-CNF
• Each clause consists of 3 distinct literals
n o
• 3SAT := 〈ϕ〉 : ϕ is a satisfiable 3-CNF formula

12
Fact: every formula ψ in 1–3 variables can be
rewritten as a 3-CNF formula (with at most 8
clauses)
• Add extra variables to make # of variables = 3
• Write down truth table for ψ
• Read off disjunctive normal form formula from
truth table
• Negate this formula, using DeMorgan’s law to
get 3-CNF

13
Proof that 3SAT is NP-hard
• Reduction: CSAT ≤P 3SAT
• Let N(ψ) be a 3-CNF formula representing ψ
Circuit C: Formula ϕ:
4 ← 1 ∧ 2 N(4 ⇔ (1 ∧ 2 ))∧
5 ← 1 N(5 ⇔ (1 ))∧
6 ← 3 ∨ 4 N(6 ⇔ (3 ∨ 4 ))∧
7 ← 4 ∨ 5 N(7 ⇔ (4 ∨ 5 ))∧
8 ← 6 ∧ 7 N(8 ⇔ (6 ∧ 7 ))∧
N(8 )

14

You might also like