Cooks theorem and NPreductions Pasi Frnti 6 11






















- Slides: 22
Cook’s theorem and NP-reductions Pasi Fränti 6. 11. 2016
Cook’s theorem Theorem: Satisfiability problem (SAT) is NP-complete Proof: TM ≤p SAT
Satisfiability problem f 1 f 2 f 3 F=(X 1 X 2 X 3) ( X 1 X 2) (X 1 X 3) x 1 0 0 1 1 x 2 0 0 1 1 x 3 0 1 0 1 f 1 f 2 f 3 F
Non-deterministic algorithm Satisfiability(F) FOR i 1 TO n DO xi Choose{0, 1}; IF F(x)=1 THEN SUCCESS; ELSE FAIL; T(n)=O(n) SAT NP
Notations needed Implication Equivalence All are true Some is true Exactly one is true At least one is true At most one is true
Proof of Cook’s theorem Only valid Turing machine configurations can have value TRUE ai = tape position s has symbol ai qj = machine is at state qj and R/W head is at position s
Cook’s theorem Machine is at state q 0 Tape content is {ai 1, ai 2, …, ain}
Cook’s theorem If not at position s, then content does not change If at position s and content is ai, then change state and content
Cook’s theorem Can be in any position s but machine must be in final state qk
NP hard problems 1. 2. 3. 4. 5. Satisfiability problem (SAT) Coloring problem (Color) Exact cover problem (EC) Knapsack problem (KP) Traveling salesman problem (TSP)
Satisfiability to Coloring Complete k-clique False color c 1 c 2 c 3 … ck … xk c 0 Connect to all but ci Literals x 1 x 2 x 1 x 3 … xk Color fi xj fi fi Connect to all but those literals in fi xj
SP to Coloring example (X 1 X 2) ( X 1 X 3)
Additional example f 1 f 2 f 3 (X 2 X 3) ( X 1 X 3 ) (X 1 X 2) x 1 0 0 1 1 x 2 0 0 1 1 x 3 0 1 0 1 f 1 1 0 1 1 f 2 1 1 0 1 f 3 1 1 0 0 1 1 F 1 0 0 0 1
Knapsack to TSP
Knapsack problem • Input: knapsack instance {2, 3, 5, 7, 11} • Size of the knapsack S=15.
Step 1: Create one node for every item • Input: knapsack instance {2, 3, 5, 7, 11} • Create a node for every knapsack element. 2 7 5 3 11
Step 2: Add start and end points • Add node 0 as the home. • Add node n+1 as the turning point. 2 7 5 0 3 n+1 11 n+2 nodes needed to represent the knapsack instance
Step 3: Create forward links • Draw links from smaller to bigger with weights: – – w(i, j) w(i, n+1) 2 =j =0 7 2 7 7 5 5 0 5 5 3 3 3 11 11 11 0 0 0 n+1
Step 4: Create backward links • Draw backward links from bigger to smaller nodes. • Set weight of the link as w(j, i)=0. 0 2 7 0 0 0 5 0 0 3 0 0 0 11 n+1
KP TSP • All nodes have two incoming links with weights – w(i, j) – 0 if item j is taken into knapsack (xj=1) if item j not is taken (xj=0) • Visit nodes selected in KP using w>0 link 2 0 ct sele 0 7 0 5 lec ct n+1 t 5 sele 3 3 se 0 7 0 11
KP TSP = 0 -3 -5 -7 -(N+1)-11 -2 -0 KP = {3, 5, 7} (all nodes which arrival cost > 0) 2 0 lect se 0 7 0 5 lec ct n+1 t 5 sele 3 3 se 0 7 0 11
Empty space for notes






















