
BU CS 332 – Theory of Computation Lecture 22: • NP-Completeness Example Reading: • Space Complexity Sipser Ch 8.1-8.2 • Savitch’s Theorem Mark Bun April 22, 2020 NP-completeness Definition: A language is NP-complete if 1) NP, and 2) Every language NP is poly-time reducible to ∈ , i.e., (“ is NP-hard”) ∈ ≤p Theorem: If NP and for some NP-complete language , then is also NP-complete ∈ ≤p 4/22/2020 CS332 - Theory of Computation 2 (3-CNF Satisfiability) 3Definition(s): • A literal either a variable of its negation , • A clause is a disjunction (OR) of literals Ex. 5 7 • A 3-CNF is a conjunction (AND) of clauses where5 each7 2 clause contains exactly 3 literals ∨ ∨ Ex. … = 1 ∧ 2 ∧ ∧ 5 7 2 3 4 1 1 1 1 = ∨ ∨isa satisfiable∧ ∨ 3∨ CNF∧ ⋯ ∧ ∨ ∨ Cook-Levin Theorem: is NP-complete 3 − 4/22/2020 CS332 - Theory of Computation 3 3 Some general reduction strategies • Reduction by simple equivalence Ex. and − ≤p − − ≤p − • Reduction from special case to general case Ex. − ≤p − • Gadget reductions Ex. 3 ≤p − 4/22/2020 CS332 - Theory of Computation 4 Independent Set An independent set in an undirected graph is a set of vertices that includes at most one endpoint of every edge. = , is an undirected graph containing an independent set with vertices} − ≥ • Is there an independent set of size ≥ 6? • Yes. independent set • Is there an independent set of size ≥ 7? • No. 4/22/2020 CS332 - Theory of Computation 5 Independent Set is NP-complete 1) NP 2) Reduce 3 − ∈ ≤p − Proof. “On input , where is a 3CNF formula, 1. Construct graph from • contains 3 vertices for each clause, one for each literal. • Connect 3 literals in a clause in a triangle. • Connect literal to each of its negations. 2. Output , , where is the number of clauses in .” 4/22/2020 CS332 - Theory of Computation 6 Example of the reduction = 1 ∨ 2 ∨ 3 ∧ 1 ∨ 2 ∨ 3 ∧ 1 ∨ 2 ∨ 4 4/22/2020 CS332 - Theory of Computation 7 Proof of correctness for reduction Let = # clauses and = # literals in Claim: is satisfiable iff has an ind. set of size Given a satisfying assignment, select one literal from each triangle. This is an ind. set of size ⟹ Let be an ind. set of size • must contain exactly one vertex in each triangle ⟸ • Set these literals to true, and set all other variables in an arbitrary way • Truth assignment is consistent and all clauses satisfied Runtime: ( + ) which is polynomial in input size 2 4/22/2020 CS332 - Theory of Computation 8 Space Complexity 4/22/2020 CS332 - Theory of Computation 9 Complexity measures we’ve studied so far • Deterministic time TIME • Nondeterministic time NTIME • Classes P, NP Many other resources of interest: Space (memory), randomness, parallel runtime / #processors, quantum entanglement, interaction, communication, … 4/22/2020 CS332 - Theory of Computation 10 Space analysis Space complexity of a TM (algorithm) = maximum number of tape cell it uses on a worst-case input Formally: Let . A TM runs in space ( ) if on every input , halts on using at most cells ∶ ℕ∗ → ℕ ∈ Σ For nondeterministic machines: Let . An NTM runs in space ( ) if on every input , halts on using at most cells on every computational ∶ ℕ →∗ ℕ branch ∈ Σ 4/22/2020 CS332 - Theory of Computation 11 Space complexity classes Let A language ∶ ℕ → ℕ SPACE( ( )) if there exists a basic single- tape (deterministic) TM that 1) Decides , ∈and 2) Runs in space ( ( )) A language NSPACE ( ( )) if there exists a single- tape nondeterministic TM that 1) Decides , ∈and 2) Runs in space ( ( )) 4/22/2020 CS332 - Theory of Computation 12 Example: Space complexity of SAT Theorem: SPACE( ) Proof: The following deterministic TM decides using linear space ∈ On input where is a Boolean formula: 1. For each truth assignment to the variables , … , of : 2. Evaluate on , … , 1 3. If any evaluation = 1, accept. Else, reject. 1 4/22/2020 CS332 - Theory of Computation 13 Example: NFA analysis Theorem: Let = is an NFA with = } Then NSPACE( ). ∗ Σ Proof: The following NTM decides in linear space ∈ On input where is an NTM: 1. Place a marker on the start state of . 2. Repeat 2 times where is the # of states of : 3. Nondeterministically select . 4. Adjust the markers to simulate all ways for to read . ∈ Σ 5. Accept if at any point none of the markers are on an accept state. Else, reject. 4/22/2020 CS332 - Theory of Computation 14 Example 0,1 ε 0 1 2 3 1 4/22/2020 CS332 - Theory of Computation 15 Space vs. Time 4/22/2020 CS332 - Theory of Computation 16 Space vs. Time ⊆ ⊆ How about the opposite direction? Can low-space algorithms be simulated by low-time algorithms? 4/22/2020 CS332 - Theory of Computation 17 Reminder: Configurations A configuration is a string where and , • Tape contents = (followed by blanks ) ∗ ∈ ∈ Γ • Current state = ⊔ • Tape head on first symbol of Example: 101 0111 5 Start configuration: Accepting configuration: = 0 Rejecting configuration: = accept 4/22/2020 CS332 - Theory ofrejec Computationt 18 Reminder: Configurations Consider a TM with • states • tape alphabet {0, 1} • space ( ) How many configurations are possible when this TM is run on an input 0,1 ? ∈ Observation: If a TM enters the same configuration twice when run on input , it loops forever Corollary: A TM running in space ( ) also runs in time 2 4/22/2020 CS332 - Theory of Computation 19 Savitch’s Theorem 4/22/2020 CS332 - Theory of Computation 20 Savitch’s Theorem: Deterministic vs. Nondeterministic Space Theorem: Let be a function with . Then . 2 ≥ Proof idea: ⊆ • Let be an NTM deciding in space ( ) • We construct a TM deciding in space 2 • Actually solve a more general problem: • Given configurations , of and natural number , decide whether can go from to in steps on some nondeterministic1 2 path. 1 2 • Procedure CANYIELD ( , , ) ≤ 1 2 4/22/2020 CS332 - Theory of Computation 21 Savitch’s Theorem Theorem: Let be a function with . Then . 2 ≥ Proof idea: ⊆ • Let be an NTM deciding in space ( ) = “On input : 1. Output the result of CANYIELD( , , 2 )” 1 2 Where CANYIELD( , , ) decides whether can go from configuration to in steps on some nondeterministic path 1 2 1 2 ≤ 4/22/2020 CS332 - Theory of Computation 22 Savitch’s Theorem CANYIELD( , , ) decides whether can go from configuration to in steps on some nondeterministic path: 1 2 1 2 ≤ CANYIELD( , , ) = 1. If = 1, accept if = or yields in one transition. 1 2 Else, reject. 1 2 1 2 2. If > 1, then for each config of with cells: 3. Run CANYIELD( , , /2 ). ≤ 4. Run CANYIELD( , , /2 ). 〈1 〉 5. If both runs accept, accept. 〈 2 〉 6. Reject. 4/22/2020 CS332 - Theory of Computation 23 Complexity class PSPACE Definition: PSPACE is the class of languages decidable in polynomial space on a basic single-tape (deterministic) TM PSPACE = SPACE( ) ∞ ⋃=1 Definition: NPSPACE is the class of languages decidable in polynomial space on a single-tape (nondeterministic) TM NPSPACE = NSPACE( ) ∞ ⋃=1 4/22/2020 CS332 - Theory of Computation 24 Relationships between complexity classes 1. P NP PSPACE EXP since (2 ( )) ⊆ ⊆ ⊆ ⊆ EXP 2. P EXP (Monday) PSPACE=NPSPACE Which containments NP ≠ in (1) are proper? P Unknown! 4/22/2020 CS332 - Theory of Computation 25.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages25 Page
-
File Size-