Theory of Computing Lecture 19 MAS 714 Hartmut Klauck.

Slides:



Advertisements
Similar presentations
NP-Hard Nattee Niparnan.
Advertisements

Lecture 3 Universal TM. Code of a DTM Consider a one-tape DTM M = (Q, Σ, Γ, δ, s). It can be encoded as follows: First, encode each state, each direction,
Theory of Computing Lecture 23 MAS 714 Hartmut Klauck.
Lecture 24 MAS 714 Hartmut Klauck
Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
Lecture 23. Subset Sum is NPC
 2004 SDU Lecture17-P,NP, NPC.  2004 SDU 2 1.Decision problem and language decision problem decision problem and language 2.P and NP Definitions of.
1 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Concept of Completeness and hardness for a complexity class Definition.
The Theory of NP-Completeness
Complexity 12-1 Complexity Andrei Bulatov Non-Deterministic Space.
Complexity 15-1 Complexity Andrei Bulatov Hierarchy Theorem.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture13: Mapping Reductions Prof. Amos Israeli.
Courtesy Costas Busch - RPI1 A Universal Turing Machine.
CS21 Decidability and Tractability
February 23, 2015CS21 Lecture 201 CS21 Decidability and Tractability Lecture 20 February 23, 2015.
CPSC 411, Fall 2008: Set 12 1 CPSC 411 Design and Analysis of Algorithms Set 12: Undecidability Prof. Jennifer Welch Fall 2008.
Computability and Complexity 15-1 Computability and Complexity Andrei Bulatov NP-Completeness.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
CHAPTER 4 Decidability Contents Decidable Languages
Computability and Complexity 20-1 Computability and Complexity Andrei Bulatov Class NL.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 23 Instructor: Paul Beame.
Fall 2004COMP 3351 A Universal Turing Machine. Fall 2004COMP 3352 Turing Machines are “hardwired” they execute only one program A limitation of Turing.
Theory of Computing Lecture 20 MAS 714 Hartmut Klauck.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture11: The Halting Problem Prof. Amos Israeli.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Theory of Computing Lecture 15 MAS 714 Hartmut Klauck.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
Lecture 22 More NPC problems
Computational Complexity Theory Lecture 2: Reductions, NP-completeness, Cook-Levin theorem Indian Institute of Science.
Theory of Computing Lecture 17 MAS 714 Hartmut Klauck.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
1 Undecidability Reading: Chapter 8 & 9. 2 Decidability vs. Undecidability There are two types of TMs (based on halting): (Recursive) TMs that always.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
Complexity 25-1 Complexity Andrei Bulatov Counting Problems.
Theory of Computing Lecture 21 MAS 714 Hartmut Klauck.
A Universal Turing Machine
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
1 P P := the class of decision problems (languages) decided by a Turing machine so that for some polynomial p and all x, the machine terminates after at.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata (LBAs) are the same as Turing Machines with one difference: The input string tape space is the.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
1 Design and Analysis of Algorithms Yoram Moses Lecture 13 June 17, 2010
1 A Universal Turing Machine. 2 Turing Machines are “hardwired” they execute only one program A limitation of Turing Machines: Real Computers are re-programmable.
The NP class. NP-completeness
The Acceptance Problem for TMs
NP-Completeness Yin Tat Lee
Intro to Theory of Computation
CSCE 411 Design and Analysis of Algorithms
Decidable Languages Costas Busch - LSU.
Proposed in Turing’s 1936 paper
Formal Languages, Automata and Models of Computation
CS21 Decidability and Tractability
NP-Completeness Yin Tat Lee
CS21 Decidability and Tractability
CS21 Decidability and Tractability
Instructor: Aaron Roth
Instructor: Aaron Roth
Presentation transcript:

Theory of Computing Lecture 19 MAS 714 Hartmut Klauck

Subset Sum Input: set S of natural numbers, target t Is there a subset S’ µ S such that the elements in S’ sum to t? Theorem: Subset Sum is NP-complete Reduction from 3-SAT

Subset Sum Given formula of m clauses and n variables – no variable is unused, x i and : x i not in same clause Create 2 numbers for each variable: v i, w i 2 numbers for each clause: r c, s c Numbers are base 10 and have n+m digits t: 1 in each variable digit and 4 in each clause digit v i : 1 at digit i and 1 for each clause digit with literal x i w i : 1 at digit i and 1 for each clause digit with literal : x i r c : 1 at clause digit c s c : 2 at clause digit c

Subset Sum Suppose sum of a subset of numbers equals t Clearly: cannot contain both v i and w i Set x i =1 iff v i is in the subset Claim: Satisfying for F r c and s c can contribute at most 3 to a clause digit, but the sum is 4, hence the v i or w i in the subset must have digit 1 for the clause-> clause in F is satisfied

Subset Sum Suppose there is a satisfying assignment to F If x i =1 take v i into the subset, else w i Sums all numbers, consider n most significant digits: all are 1 Consider the last m digits of the sum: – For each clause digit value is at least 1, and up to 3 Add appropriate numbers r c, s c to make the sum equal to t

3-Dimensional Matching X,Y,Z are sets of n elements each E is a subset of X £ Y £ Z A 3D-matching is a set of triples that do not share vertices Question: Is there a perfect matching, i.e., one that contains every vertex in exactly one edge? Recall: 2D-matching is in P

NP-hardness We reduce from 3-SAT Formula F with n variables and m clauses Variable gadget for x i : Vertices: {a i,1,…,a i,2m } [ {b i,1,...,b i,2m } Edges: (a i,j, a i,j+1, b i,j ) In a perfect matching only b i,j for odd j or for even j can be present (else some a i,j covered twice) Covering even b i,j means x i =1

3DM Clause gadget: – Vertices {c j, d j } – Edges: connect clause gadget nodes with variable gadgets: literal x i : connect with b i,2j, else with b i,2j-1 Observation: Must choose exactly one edge per clause gadget. This covers an odd or even b i,j vertex. Can cover a-vertices only if either odd or even b i,j are used, not both. More details: Need some extra gadgets to cover unused b-vertices

3DM Suppose F is satisfiable. Choose the edges for the variable gadgets as in x Then for a clause (l 1 Ç l 2 Ç l 3 ) all true literals have un-covered b-vertices that can be covered using an edge that covers the clause gadget vertices Similarly, given a perfect matching we can find a satisfying assignment

co-NP co-NP is the class of complements of languages that are in NP It is widely believed that NP  co-NP This would imply that NP Å co-NP does not contain NP-complete problems – Example: IntegerFactorization (decision version) – We don’t know a polynomial time algorithm, but the problem is likely not NP-complete

Intermediate Problems Ladner’s Theorem – Unless P=NP, there exist problems in NP that are neither in P nor NP-complete Candidate problems (their decision versions): – Integer Factorization – Graph Isomorphism – Discrete Logarithm – Group Isomorphism – Finding approximate short vectors in lattices Some of these problems can be used to define public key cryptosystems – Such systems are hard to break if the underlying problems are hard (e.g. for factorization/discrete log)

Other completeness notions P-completeness – Reductions must be computed in logarithmic space – implies (probably) that a problem cannot be solved in space polylog n or parallel time polylog n EXP-completeness – Implies that the problem cannot be solved in polynomial time NEXP-completeness – Problem is not in NP PSPACE-completeness – Problem is likely not in NP – Many two-player games like generalized chess with time bound

New topic: Computability Question 1: Are all Boolean functions computable? Answer 1: yes, by Boolean circuit families – But those are not uniform, seems like cheating, circuit family is an infinite object Question 2: Are all languages L µ {0,1}* computable by Turing machines ? Answer 2: NO.

Argument number 1 A Turing machine can be described by a finite string – list the elements of the 8-tuple – Alternative: C++ program We can identify finite strings with natural numbers – treat each character as a digit Conclusion: there are infinitely many Turing machines, but the set of all Turing machines is countable – A set S is countable if there is an injective mapping from S to the natural numbers – An infinite, countable set has the same cardinality as the natural numbers – Example: the rational numbers are countable, the reals are not

Argument number 1 Theorem: the set of languages L µ {0,1}* is uncountable – Indeed has the same cardinality as the real numbers Conclusion: – Almost all languages are not computable by a TM No matter how much time the TM can spend computing

Proof of the theorem First we use Cantor’s method of diagonalization to show that there is a language that cannot be computed Let M 1, M 2,… denote an enumeration of all Turing machines Let x 1, x 2,… denotes an enumeration of all inputs in {0,1}* Consider the matrix A that has rows labeled by x i and columns labeled by M j and that contains 1 if M j accepts x i and 0 otherwise

Proof of the claim Each column j corresponds to the language of strings accepted by M j Consider the complement of the diagonal of A – 0 with 1 and vice versa Consider the language L that contains string x i iff the i- th diagonal element is 0 L is not equal to any of the languages computed by the M j ! Hence L is an un-computable language [For languages we use both terms computable/decidable to mean that the language can be decided by a TM that halts on all inputs]

Proof of the claim The same can be done if we replace the columns with any enumeration of languages Hence the set of all languages is not countable, i.e., there is no injective mapping from the set of all languages to the natural numbers Note: the set of all languages has the same cardinality as the reals – Find an injective mapping from the reals to the set of all languages This means that `almost all’ languages are not computable But what about an explicit example?

Universality To answer this question we need another property of Turing machine Universality means that there is a Turing machine that can simulate all other Turing machines Compare: actual computers are universal, we generally don’t buy/build a new computer for a new application

Universality Fix some way to encode Turing machines – Write for the encoding of TM M (as a string) Definition: A universal Turing machine is a TM that on input,x accepts if and only if M accepts on x Theorem: There is a universal TM U

Proof Note: Since U must be finite, we cannot simply read into the internal state of U – in fact we cannot even read a state of M into U’s internal state Copy input x to a second tape (we assume that M has 1 tape) A third tape contains the current state of M – w.l.o.g. this is 0 2 Q We need to show that one step of M can be simulated Idea: search the transition function table in to determine the new state given the tape symbol on tape 2 and the current state on tape 3, update both, move the head on tape 2 Each step tests if the current state is accepting/rejecting We have a machine U that can simulate any 1-tape TM using 3 tapes Running time: we are interested in the running time in terms of |x| Fact: a universal TM U with time O(C n log n) exist, where C depends on M, and U has the same number of tapes as M

Halting Problem On an input x, a machine M might not halt – Infinite loop It would be nice to be able to decide if this happens! HALT={,x: M halts on input x} Theorem: – HALT is not computable

Proof We try a similar argument to Cantor’s Consider a TM H that decides HALT – halts on all inputs and gives the correct output Consider inputs, – These belong to HALT, if M halts on its encoding We define a new machine M that does the following: – On input x, run H on x,x [use U, note that H halts] – If H reports that x halts on x, go into an infinite loop – Else halt

Proof What does M do on ? If M halts on, H will say so, and M will go into an infinite loop on If M does not halt on, then H will say it does not halt, and M will halt on Contradiction! Hence H does not exist!

Reductions Definition: L many-one reduces to S is there is a computable function f such that x 2 L, f(x) 2 S Notation: L · S Conclusion: if L is not decidable then S is not decidable More general notion of reductions: Turing reductions (using oracle Turing machine)

More uncomputable problems We are in a similar situation as in the theory of NP-completeness We have an uncomputable/undecidable problem, find more by reductions

Example H={ : M halts on some input x 2 {0,1}*} Theorem: H is not computable because HALT · H Reduction: given,x we construct a new TM M x – M x ignores its own input but writes x on the tape and then simulates M on x Clearly:,x 2 HALT, 2 H Note: The description of has to be computable from and x

Example L M denotes the language accepted by M – the set of strings that M accepts NEMPTY={ : L M  ; } Theorem: E is not decidable because HALT · NEMPTY Reduction: – Given,x we create a new machine M x – M x reads the input and compares it to x – If input is not equal to x, then M x rejects – If input is equal to x, then M x simulates M – If M halts, accept We have:,x 2 HALT, 2 NEMPTY