Download presentation
Presentation is loading. Please wait.
Published byMarilyn Smith Modified over 8 years ago
1
P, NP, NP-completeness 2 Reductions 1 Thu, July 7 th 1
2
Formalizing Tractability: Class P 2 Given a computational (decision) problem C P: C is ∈ P (polynomial-time solvable) if ∃ an algorithm solving C with O(n k ) run-time, for some constant k. where n is the input length in bits k is some constant, say, 1, 2, 5, 1M, etc. Ex poly-times: O(n), O(nlog(n)), O(n 3 ), O(n 100000 ) Ex: Every problem we saw so far (except 0-1 knapsack)
3
Fact: Some Problems Seem Intractable Ex: TSP 3 TSP: Traveling Salesman Problem Input: Complete graph G(V, E) with non-negative edge costs Output: ∃ a tour with cost ≤ k [i.e., cycle visiting each v once]? D C B A 2 1 4 3 5 6
4
Making a Case For TSP’s Intractability 4 (So far) We have not been able to argue for TSP’s intractability in an absolute sense. Idea From Early 1970s: Instead show “relative” intractability (i.e. show TSP is as hard as bunch of other problems C.)
5
Reductions: Showing C 2 is as hard as C 1 5 What does it mean for problem C 2 to be as hard as C 1 ? Definition: C 1 reduces to C 2, (C 1 ≤ p C 2 ), if given a poly- time algorithm for C 2, we can solve C 1 in poly-time. If C 1 reduces to C 2 => C 2 is “as hard as” C 1 Poly-time Alg for C 2 Π 1 ∈ C 1 Poly-time C 1 -> C 2 Converter Poly-time C 1 -> C 2 Converter Π 2 ∈ C 2 Solution to Π 2 Poly-time C 2 Solution -> C 1 Solution Converter Poly-time C 2 Solution -> C 1 Solution Converter Solution to Π 1
6
C = NP: Brute-force Solvable Problems Option 2: Let C be all brute-force solvable problems Definition (NP or brute-force solvable problems): A problem C ∈ NP if: 1.Correct solutions have polynomial length. 2.Claimed solutions are verifiable in poly-time. Q: Why do these 2 imply that C is exp-time solvable? There are 2 poly(n) possible solutions. Just verify & see if one is a solution: O(poly(n)2 poly(n) ) Dfn: EXP-Time = 2 poly(n) for some polynomial
7
Example NP problems Every problem we have seen in CS 341. Every problem in P. (Most-likely) Every problem you will ever see in practice. Ex: Decision version of TSP: ∃ T of size ≤ k? 1.Each tour T is a cycle of size n, so poly-length. 2.We can verify length of T in poly-time: just sum each edge in T. Warning: NP does not stand for: Not Polynomial It stands for: Non-deterministic Polynomial
8
Definition: Completeness 8 Let C be a set of problems. Ci ∈ CCi ∈ C If ∀ C k ∈ C, C k ≤ p C i, then C i is C -complete. (i.e. C i is as hard as every other problem in C ) (i.e. C i is the hardest problem in C ) Goal: Argue TSP is NP-complete
9
What is an NP-complete Problem? 9 NP C1C1 C1C1 C*: NP- complete C3C3 C3C3 C4C4 C4C4 C5C5 C5C5 C6C6 C6C6 CkCk CkCk C2C2 C2C2 C* is as hard as any NP problem!
10
Solving an NP-complete Problem 10 NP C1C1 C1C1 C*: NP- complete C3C3 C3C3 C4C4 C4C4 C5C5 C5C5 C6C6 C6C6 CkCk CkCk C2C2 C2C2 If we can solve C* efficiently, we can solve every single NP problem (basically all problems in practice)!!!
11
Two Ways to Argue C* is NP-Complete (1) 11 1. Just argue every NP problem reduces to C* NP C1C1 C1C1 C* C3C3 C3C3 C4C4 C4C4 C5C5 C5C5 CkCk CkCk C6C6 C6C6 C2C2 C2C2 Done for SAT (& CIRCUIT-SAT) in 1970 by Cook & Levin
12
Leonid Levin 12 Soviet-American computer scientist Current at Boston University
13
Two Ways to Argue C* is NP-Complete (2) 13 2. Argue an NP-complete C** reduces to C* NP C1C1 C1C1 C* C3C3 C3C3 C4C4 C4C4 C5C5 C5C5 CkCk CkCk C6C6 C6C6 C** Done since 1971 for 1000s of problems C2C2 C2C2 B/c reductions are transitive => All NP problems reduce to C*
14
History of NP-completeness 14 NP C2C2 C2C2 SAT C3C3 C3C3 C4C4 C4C4 C5C5 C5C5 CkCk CkCk C6C6 C6C6 C1C1 C1C1 K1K1 K1K1 K2K2 K2K2 … … K 20 K 21 1971: Cook-Levin1972: Karp
15
History of NP-completeness 15 NP C2C2 C2C2 SAT C3C3 C3C3 C4C4 C4C4 C5C5 C5C5 CkCk CkCk C6C6 C6C6 C1C1 C1C1 K1K1 K1K1 K2K2 K2K2 … … K 20 K 21 NP-complete Since 1972
16
Method 1: Ex: CIRCUIT-SAT 16 Input: A circuit C of AND, OR, and NOT gates n inputs x 1, x 2, …, x n Output: Is C satisfiable, are there 0/1 values to x i that make C output 1? AND OR AND OR ANDNOTOR NOTAND NOT AND OR NOT AND OR AND x1x1 x2x2 x3x3 x4x4 x5x5
17
17 Method 1: Ex: CIRCUIT-SAT Idea for proving every NP problem C* reduces to CIRCUIT-SAT: Every NP problem by dfn has a poly-time verifier algorithm A. A takes poly-size inputs and runs poly-time. Represent the state of the machine at each time-step of A by a sub-circuit. Merge the sub-circuits into a circuit Z. (All poly-time operations) And argue that C* returns YES iff circuit Z has a satisfiable input.
18
Method 2: “Intractability” Argument for TSP 18 Show that TSP is NP-complete => i.e. TSP is as hard as any other NP problem By showing that another known NP-complete problem reduces to it.
19
Why is TSP NP-complete? 19 HAM-CYCLE Problem: Input: Undirected Graph G(V, E) Output: YES if G contains a Hamiltonian cycle/NO o.w Dfn: A Ham. Cycle is a simple cycle that contain each vertex of the graph once. Fact: Hamiltonian Cycle is NP-complete. SAT≤ p 3-SAT≤ p CLIQUE≤ p VERTEX-COVER≤ p HAM-CYCLE
20
Hamiltonian Cycle Example (1) 20 F CB A D E G
21
Hamiltonian Cycle Example 21 F CB A D E G Answer: YES.
22
Hamiltonian Cycle Example 22 F C B A E
23
Hamiltonian Cycle Example 23 F C B A E Answer: NO. Any complete cycle has to visit A twice
24
Observation: TSP vs Hamiltonian Cycle 24 D C B A 2 1 4 3 5 6 TSP is simply asking for the minimum weight HC. (or TSP-Decision is asking if a HC with weight < k exists?
25
HAM-CYCLE ≤ p TSP 25 Efficient Alg A for TSP Π 1 ∈ HC Efficient HC-TSP Converter Π 2 ∈ TSP Solution to TSP Efficient TSP-HC Solution Converter Efficient TSP-HC Solution Converter Solution to HC Need to show the two converters
26
HAM-CYCLE ≤ p TSP 26 Let G(V, E) be the input to HAM-CYCLE HC-TSP Converter: Let G*(V, E*) be a complete graph with edge weights: w((u, v)) = 0 if (u, v) ∈ E w((u,v)) = 1 if (u, v) ∉ E TSP-HC Solution Converter: ∃ a Hamiltonian Cycle in G ⇔ ∃ a TSP Tour with weight 0 Runtime: O(n 2 ) Runtime: O(1)
27
Proof of Claim 27 => If ∃ a Hamiltonian Cycle C in G, then since each edge of C has weight 0 in E*, then C is a tour in G* with weight 0 <= If ∃ a tour T with weight 0 in G*, then all of its edges must be of weight 0, and hence from E, so T is a hamiltonian cycle in G Q.E.D Therefore, if we can solve TSP efficiently, we can solve HAM-CYCLE efficiently.
28
Completing TSP’s NP-completeness Proof 28 If we can solve TSP efficiently, we can solve HAM- CYCLE efficiently (by just transforming the input G to G* in poly-time & transforming the solution of TSP to HC in poly-time) since HAM-CYCLE is NP-complete we can solve every single NP problem efficiently TSP is NP-complete Q.E.D
29
Does P = NP? 29 We know P ⊆ NP. Two possibilities: NP P P=NP Is every problem, whose solutions are efficiently verifiable, is also efficiently solvable? We don’t know. But most people believe P ≠ NP.
30
Why Do People Believe P ≠ NP? 30 1.There are 1000s of NP-complete problems and for none of them is there a poly-time algorithm. 2.Counter to General Human Experience 3.Also some weird mathematical consequences, such as polynomial hierarchy collapsing, and others… But We Simply Don’t Know (Yet)!
31
How could we resolve P vs NP? 31 NP P P=NP Prove an NP-complete problem is solvable in poly time. Prove an NP-complete problem is NOT solvable in poly time. We don’t know which world we live in.
32
Your Problem is NP-complete. Now What? 32 Option 1: Focus to special-case inputs. Ex: Independent Set is NP-complete. Focusing on line graphs, had a O(n) DP alg. Option 2: Find an approximate answer. Will show a very simple algorithm for 0-1 Knapsack. Option 3: Be exponential time but better than brute- force search. 0-1 Knapscak O(nW) runtime DP algorihm. Option 4: Heuristics: fast algorithms that are not always correct (or even approximate) Option 5: Mix some of these options
33
Overview of the next 2 Lectures 33 Indep. Set 3-(CNF)SAT SAT Vertex Cover CLIQUE Hamiltonian Cycle TSP Subset Sum 0/1 Knapscak
34
SAT: The First NP-Complete Problem 34 Input: A boolean formula φ consisting of: n boolean variables x 1, x 2, …, x n m boolean connectives: ∧ (AND), ∨ (OR), ¬ (NOT), (iff), → (implication), … (can be others) and parantheses Output: Is φ satisfiable? I.e., are there true/false values to x i that make φ true?
35
Example SAT Formulas 35 φ = (x 1 → x 2 ) ∧ ¬x 2 Q: Is this satisfiable? A: Yes x1x1 x2x2 (x 1 → x 2 ) ∧ ¬x 2 00 1 010 100 110
36
Example SAT Formulas 36 φ = (x 1 → x 2 ) ∧ ¬x 2 Q: Is this satisfiable? A: Yes x1x1 x2x2 (x 1 → x 2 ) ∧ ¬x 2 00 1 010 100 110
37
Example SAT Formulas 37 φ = (x 1 → ¬x 2 ) ∧ ¬x 2 Q: Is this satisfiable? A: Yes x1x1 x2x2 (x 1 → ¬x 2 ) ∧ ¬x 2 00 1 010 100 110
38
Example SAT Formula 38 φ = (x 1 → ¬x 2 ) ∧ ¬x 2 Q: Is this satisfiable? A: Yes x1x1 x2x2 (x 1 → ¬x 2 ) ∧ ¬x 2 00 1 010 100 110
39
Example SAT Formula 39 φ = ((x 1 ∧ x 2 ∧ x 3 ) (¬x 1 ∧ x 3 )) x1x1 x2x2 x3x3 φ 0000 0010 0100 0110 1000 1010 1100 1110 Q: Is this satisfiable? A: No
40
Recall 2 Criteria For NP-Completeness 40 1.C* has to be in NP. 2.Every other NP problem has to reduce to C*.
41
Criterion 1: Why is SAT in NP? 41 Can verify a solution X* = (x 1 = 0/1, …., x n = 0/1) is linear time! Just check if X* makes φ true!
42
Criterion 2: Why does every NP problem reduce to SAT? 42 Method 1: Cook-Levin Theorem Won’t show in class Method 2: Or can show CIRCUIT-SAT, which is NP- complete reduces to SAT
43
3-CNFSAT 43 Input: A boolean formula φ consisting of: n boolean variables x 1, x 2, …, x n m boolean connectives: ∧ (AND), ∨ (OR), ¬ (NOT) and parantheses s.t. (1) each clause has 3 distinct literals; AND (2) φ is in Conjunctive Normal Form Output: Is φ satisfiable?
44
Conjunctive Normal Form 44 φ = (x 1 ∨ ¬x 3 ∨ x 7 ) ∧ (x 2 ∨ ¬x 3 ∨ x 5 ) ∧ (¬x 1 ∨ x 2 ∨ ¬x 7 ) ∧ … Clauses φ is in CNF: if (1) each clause is an OR of literals or their negations & (2) φ is an AND of clauses φ is in 3-CNF: if (1) φ is in CNF & (2) clauses have 3 distinct literals x i are literals
45
Criterion 1: Why is 3-CNFSAT in NP? 45 Can verify a solution X* = (x 1 = 0/1, …., x n = 0/1) is linear time! Just check if X* makes φ true! Specifically check if X* makes each clause true!
46
Criterion 2: SAT ≤ p 3-CNFSAT 46 Efficient Alg A for 3-CNFSAT Efficient Alg A for 3-CNFSAT Π 1 ∈ SAT Efficient SAT- 3-CNFSAT Converter Π 2 ∈ 3-SAT Solution to 3-CNFSAT Efficient 3-CNFSAT-SAT Solution Converter Efficient 3-CNFSAT-SAT Solution Converter Solution to SAT Need to show the two converters
47
SAT ≤ p 3-CNFSAT Converter 47 Say φ = ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬ x 2 Goal: In poly-time convert φ to an equivalent 3CNF formula φ```
48
Parse Tree: ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 48 ∧ ∧ ¬x 2 (x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 )
49
Parse Tree: ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 49 ∧ ∧ ¬x 2 ∨ ∨ x 1 → x 2 ¬((¬ x 1 ↔ x 3 ) ∨ x 4 )
50
Parse Tree: ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 50 ∧ ∧ ¬x 2 ∨ ∨ → → x1x1 x2x2 ¬((¬ x 1 ↔ x 3 ) ∨ x 4 )
51
Parse Tree: ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 51 ∧ ∧ ¬x 2 ∨ ∨ ¬ ¬ → → x1x1 x2x2 (¬ x 1 ↔ x 3 ) ∨ x 4
52
Parse Tree: ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 52 ∧ ∧ ¬x 2 ∨ ∨ ¬ ¬ → → ∨ ∨ x1x1 x2x2 ¬x1↔x3¬x1↔x3 x4x4
53
Parse Tree: ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 53 ∧ ∧ ¬x 2 ∨ ∨ ¬ ¬ → → ∨ ∨ ↔ ↔ x1x1 x2x2 ¬x1¬x1 x3x3 x4x4
54
Parse Tree: ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 54 ∧ ∧ ¬x 2 ∨ ∨ ¬ ¬ → → ∨ ∨ ↔ ↔ x1x1 x2x2 ¬x1¬x1 x3x3 x4x4 Call the entire formula variable y 1
55
Parse Tree: ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 55 ∧ ∧ ¬x 2 ∨ ∨ ¬ ¬ → → ∨ ∨ ↔ ↔ x1x1 x2x2 ¬x1¬x1 x3x3 x4x4 Call this subformula variable y 2 y1y1
56
Parse Tree: ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 56 ∧ ∧ ¬x 2 ∨ ∨ ¬ ¬ → → ∨ ∨ ↔ ↔ x1x1 x2x2 ¬x1¬x1 x3x3 x4x4 Call this subformula variable y 3 y1y1 y2y2
57
Parse Tree: ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 57 ∧ ∧ ¬x 2 ∨ ∨ ¬ ¬ → → ∨ ∨ ↔ ↔ x1x1 x2x2 ¬x1¬x1 x3x3 x4x4 Call this subformula variable y 3 y1y1 y2y2 y3y3
58
Parse Tree: ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 58 ∧ ∧ ¬x 2 ∨ ∨ ¬ ¬ → → ∨ ∨ ↔ ↔ x1x1 x2x2 ¬x1¬x1 x3x3 x4x4 so and so forth y1y1 y2y2 y3y3 y4y4 y5y5 y6y6
59
Parse Tree: ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 59 ∧ ∧ ¬x 2 ∨ ∨ ¬ ¬ → → ∨ ∨ ↔ ↔ x1x1 x2x2 ¬x1¬x1 x3x3 x4x4 Then: y 1 is true iff y 2 ∧ ¬x 2 is true y1y1 y2y2 y3y3 y4y4 y5y5 y6y6
60
Parse Tree: ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 60 ∧ ∧ ¬x 2 ∨ ∨ ¬ ¬ → → ∨ ∨ ↔ ↔ x1x1 x2x2 ¬x1¬x1 x3x3 x4x4 In other words: y 1 ↔ (y 2 ∧ ¬x 2 ) y 2 ↔ (y 3 ∨ y 4 ) y 3 ↔ (x 1 → x 2 ) y 4 ↔ ¬y 5 y 5 ↔ y 6 ∨ x 4 y 6 ↔ ¬x 1 ↔ x 3 y1y1 y2y2 y3y3 y4y4 y5y5 y6y6
61
Parse Tree: ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 61 ∧ ∧ ¬x 2 ∨ ∨ ¬ ¬ → → ∨ ∨ ↔ ↔ x1x1 x2x2 ¬x1¬x1 x3x3 x4x4 φ` = y 1 ∧ (y 1 ↔ (y 2 ∧ ¬x 2 )) ∧ (y 2 ↔ (y 3 ∨ y 4 )) ∧ (y 3 ↔ (x 1 → x 2 )) ∧ (y 4 ↔ ¬y 5 ) ∧ (y 5 ↔ y 6 ∨ x 4 ) ∧ (y 6 ↔ ¬x 1 ↔ x 3 ) y1y1 y2y2 y3y3 y4y4 y5y5 y6y6
62
Getting closer to 3CNF 62 φ` = y 1 ∧ (y 1 ↔ (y 2 ∧ ¬x 2 )) ∧ (y 2 ↔ (y 3 ∨ y 4 )) ∧ (y 3 ↔ (x 1 → x 2 )) ∧ (y 4 ↔ ¬y 5 ) ∧ (y 5 ↔ y 6 ∨ x 4 ) ∧ (y 6 ↔ ¬x 1 ↔ x 3 ) φ = ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 Progress so far: 1.φ=φ` 2.φ` is the AND of clauses that contain ≤ 3 distinct literals But clauses: 1.contain bool connectives other than ∨, ∧, ¬. 2.don’t contain exactly 3 literals
63
Turning Arbitrary Connectives to CNF 63 φ` = y 1 ∧ (y 1 ↔ (y 2 ∧ ¬x 2 )) ∧ (y 2 ↔ (y 3 ∨ y 4 )) ∧ (y 3 ↔ (x 1 → x 2 )) ∧ (y 4 ↔ ¬y 5 ) ∧ (y 5 ↔ y 6 ∨ x 4 ) ∧ (y 6 ↔ ¬x 1 ↔ x 3 ) y1y1 y2y2 x2x2 (y 1 ↔ (y 2 ∧ ¬x 2 )) 0001 0011 0100 0111 1000 1010 1101 1110 F=(y 1 ↔ (y 2 ∧ ¬x 2 )) Q: When is F false? G=[(¬y 1 ∧ y 2 ∧ ¬x 2 ) ∨ (y 1 ∧ ¬y 2 ∧ ¬x 2 ) ∨ (y 1 ∧ ¬y 2 ∧ x 2 ) ∨ (y 1 ∧ y 2 ∧ x 2 )]
64
Turning Arbitrary Connectives to CNF 64 φ` = y 1 ∧ (y 1 ↔ (y 2 ∧ ¬x 2 )) ∧ (y 2 ↔ (y 3 ∨ y 4 )) ∧ (y 3 ↔ (x 1 → x 2 )) ∧ (y 4 ↔ ¬y 5 ) ∧ (y 5 ↔ y 6 ∨ x 4 ) ∧ (y 6 ↔ ¬x 1 ↔ x 3 ) y1y1 y2y2 x2x2 (y 1 ↔ (y 2 ∧ ¬x 2 )) 0001 0011 0100 0111 1000 1010 1101 1110 F=(y 1 ↔ (y 2 ∧ ¬x 2 )) Q: When is F true? ¬G So we can replace F with ¬G
65
DeMorgan’s Law 65 ¬(a ∨ b) = ¬a ∧ ¬b ¬(a ∧ b) = ¬a ∨ ¬b ¬G = ¬ [(¬y 1 ∧ y 2 ∧ ¬x 2 ) ∨ (y 1 ∧ ¬y 2 ∧ ¬x 2 ) ∨ (y 1 ∧ ¬y 2 ∧ x 2 ) ∨ (y 1 ∧ y 2 ∧ x 2 )] = [¬(¬y 1 ∧ y 2 ∧ ¬x 2 )] ∧ [¬(y 1 ∧ ¬y 2 ∧ ¬x 2 )] ∧ [¬(y 1 ∧ ¬y 2 ∧ x 2 )] ∧ [¬(y 1 ∧ y 2 ∧ x 2 )] = ¬G = [(y 1 ∨ ¬y 2 ∨ x 2 )] ∧ [(¬y 1 ∨ y 2 ∨ x 2 )] ∧ [ (¬y 1 ∨ y 2 ∨ ¬x 2 )] ∧ [(¬y 1 ∨ ¬y 2 ∨ ¬x 2 )]
66
Turning Arbitrary Connectives to CNF 66 Can replace (y 1 ↔ (y 2 ∧ ¬x 2 )) with [(y 1 ∨ ¬y 2 ∨ x 2 )] ∧ [(¬y 1 ∨ y 2 ∨ x 2 )] ∧ [ (¬y 1 ∨ y 2 ∨ ¬x 2 )] ∧ [(¬y 1 ∨ ¬y 2 ∨ ¬x 2 )], which is in CNF Do this for all clauses and get φ`` φ` = y 1 ∧ (y 1 ↔ (y 2 ∧ ¬x 2 )) ∧ (y 2 ↔ (y 3 ∨ y 4 )) ∧ (y 3 ↔ (x 1 → x 2 )) ∧ (y 4 ↔ ¬y 5 ) ∧ (y 5 ↔ y 6 ∨ x 4 ) ∧ (y 6 ↔ ¬x 1 ↔ x 3 )
67
Getting closer to 3CNF 67 φ`` = y 1 ∧ [(y 1 ∨ ¬y 2 ∨ x 2 )] ∧ [(¬y 1 ∨ y 2 ∨ x 2 )] ∧ [ (¬y 1 ∨ y 2 ∨ ¬x 2 )] ∧ [(¬y 1 ∨ ¬y 2 ∨ ¬x 2 )] … φ = ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 Progress so far: 1.φ=φ` 2.φ`` is in CNF with ≤ 3 distinct literals in each clause But clauses: 1.don’t contain exactly 3 literals
68
Completing Clauses to 3 Literals 68 φ`` = y 1 ∧ [(y 1 ∨ ¬y 2 ∨ x 2 )] ∧ [(¬y 1 ∨ y 2 ∨ x 2 )] ∧ [ (¬y 1 ∨ y 2 ∨ ¬x 2 )] ∧ [(¬y 1 ∨ ¬y 2 ∨ ¬x 2 )] … φ = ((x 1 → x 2 ) ∨ ¬((¬x 1 ↔ x 3 ) ∨ x 4 ))) ∧ ¬x 2 Add dummy variables p and q with tautologies to complete each clause to exactly 3 literals. Case 1: There is 1 variable in the clause, e.g., y 1 Change y 1 with: H = (y 1 ∨ p ∨ q) ∧ (y 1 ∨ p ∨ ¬q) ∧ (y 1 ∨ ¬p ∨ q) ∧ (y 1 ∨ ¬p ∨ ¬q) Note: H ↔ y 1
69
Completing Clauses to 3 Literals 69 Case 2: There are 2 variables in clause, e.g., (y 1 ∨ y 2 ) Change (y 1 ∨ y 2 ) with: T = (y 1 ∨ y 2 ∨ p) ∧ (y 1 ∨ y 2 ∨ ¬p) Note: T ↔ y 1 ∨ y 2 We are now done! We have an equivalent φ``` that is in 3CNF.
70
Runtime of our SAT->3-CNFSAT Converter? 70 φ φ`: added y i ; so O(m) time φ` φ``: expanded each clause by ≤ 8 clauses; so O(m) time as well φ`` φ```: (expanded each clause by ≤ 4 clauses; so O(m) time as well. Total Runtime: O(m) Converting the solutions is O(1) time b/c φ =φ```
71
Conclusion 71 3-CNFSAT is NP-complete!
72
Overview of the next 2 Lectures 72 Indep. Set Vertex Cover CLIQUE Hamiltonian Cycle TSP Subset Sum 0/1 Knapscak (CNF)-SAT 3-(CNF)SAT
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.