Download presentation
Presentation is loading. Please wait.
Published byGordon Glenn Modified over 9 years ago
1
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011
2
TIME COMPLEXITY Definition: Let M be a TM that halts on all inputs. The running time or time-complexity of M is the function f : N N, where f(n) is the maximum number of steps that M uses on any input of length n. Definition: TIME(t(n)) = { L | L is a language decided by a O(t(n)) time Turing Machine }
3
P = TIME(n c ) c ℕ IMPORTANT COMPLEXITY CLASS P is the class of problems that can be solved in polynomial time: they are efficiently decidable
4
NON-DETERMINISTIC PROGRAMS …are just like standard programs, except: 1. There is a special instruction, guess(), that can return 0 or 1. 2. The program accepts an input if there exists a list of guesses that make it accept. 3. The running time of the program is the maximum number of steps that can be caused by calls to guess().
5
NP = NTIME(n c ) c ℕ { L | L is decided by a O(t(n))-time non-deterministic Turing machine } Definition: NTIME(t(n)) =
6
BOOLEAN FORMULAS ( x y) z = logical operations variables parentheses A satisfying assignment is a setting of the variables that makes the formula true x = 1, y = 1, z = 1 is a satisfying assignment for (x y) (z x) 0010 A Boolean formula is satisfiable if there exists a satisfying assignment for it SAT = { | is a satisfiable Boolean formula }
7
A 3cnf-formula is of the form: (x 1 x 2 x 3 ) (x 4 x 2 x 5 ) (x 3 x 2 x 1 ) clauses (x 1 x̅ 2 x 1 ) (x 3 x 1 ) (x 3 x̅ 2 x̅ 1 ) (x 1 x 2 x 3 ) (x̅ 4 x 2 x 1 ) (x 3 x 1 x̅ 1 ) (x 1 x̅ 2 x 3 ) (x 3 x̅ 2 x̅ 1 ) YES NO 3SAT = { | is a satisfiable 3cnf-formula }
8
Theorem: 3SAT NP 3SAT = { | is a satisfiable 3cnf-formula } 1. Check if the formula is in 3cnf On input : 2. For each variable x i : 3. Test if the assignment satisfies a. Set temp = guess(). b. Scan across , replacing x i with temp. Total running time = O(mn)
9
Theorem: L NP if and only if there exists a poly-time Turing machine V (for “Verifier”) with L = { x | y |y| = poly(|x|) and V(x,y) accepts } Proof: (1) If L = { x | y |y| = poly(|x|) and V(x,y) accepts } then L NP Because we can guess() y and then run V(x,y) (2) If L NP then L = { x | y |y| = poly(|x|) and V(x,y) accepts } Let N be a non-deterministic poly-time TM that decides L and define V(x,y) to accept if y is an accepting computation history of N on x
10
3SAT = { | y such that y is a satisfying assignment to and is in 3cnf } SAT = { | y such that y is a satisfying assignment to } V( ,y) = “Accept if is in 3cnf and (y) is true” V( ,y) = “Accept if is a formula and (y) is true”
11
A language is in NP if and only if there exist polynomial-length certificates for membership to the language SAT is in NP because a satisfying assignment is a polynomial-length certificate that a formula is satisfiable
12
HAMILTONIAN PATHS b a e c d f h i g
13
HAMPATH = { 〈 G,s,t 〉 | G is a directed graph with a Hamiltonian path from s to t } Theorem: HAMPATH NP The Hamiltonian path itself is a certificate
14
K- CLIQUES b a e c d f g
15
CLIQUE = { 〈 G,k 〉 | G is an undirected graph with a k-clique } Theorem: CLIQUE NP The k-clique itself is a certificate
16
SEARCHING FOR… A search problem is one where the “answer” is more than a single bit, for example: if 〈 B,G 〉 is a “stable marriage” problem, the “answer” is a stable matching between every boy and some girl. If 〈 C 〉 is a CIRCUIT-SAT problem, the “answer” is an input that makes the circuit output 1. We can think of these problems as “finding a right answer.”
17
NP = { search problems where it is easy to check if an answer is right. }
18
EXAMPLES FACTOR = { 〈 N,k 〉 | N has a prime factor ≥ k }. SUBSET-SUM = { 〈 y 1,…y n, t 〉 | there exist bits b 1 …b n so that Σ i b i y i = t }. FUSION = { 〈 SIM,1 k 〉 | SIM is a program that simulates nuclear fusion reactor designs and has an input of length at most k where energy output > energy input }
19
P = NP? $$$
20
P VS NP RecognitionvsGeneration Checking if a song sounds like Mozart Composing a song that sounds like Mozart Checking if a proof is correctFinding a correct proof Checking if a fusion generator is efficient Finding an efficient fusion generator Verifying that p q = NFinding prime factors of N Appreciating funny jokesWriting funny jokes If P=NP, especially by a fast algorithm, then the tasks on left and right are all equally difficult!
21
If P = NP… Cryptography as we know it would not be possible Mathematicians would be out of a job We could determine if cold fusion is possible We could determine if faster-than-light travel is possible.
22
If P = NP… We could find optimal circuits for any task: EQC = { 〈 C 1,C 2 〉 | ∀ x. C 1 (x) = C 2 (x) } ∈ coNP MIN-CIRCUIT = { 〈 C 〉 | ∀ C’, |C’|≤|C| or (C,C’) EQC} If P=NP, then EQC ∈ P, so MIN-CIRCUIT ∈ coNP = P.
23
If P = NP… Writing symphonies is as easy as listening to them. Being a chef is as easy as eating. Writing Shakespeare is as easy as recognizing Shakespeare. Generation is as easy as recognition: In 40+ years, no one has found a proof that P NP.
24
POLY-TIME REDUCIBILITY A language A is polynomial time reducible to language B, written A P B, if there is a polynomial time computable function ƒ : Σ* Σ*, where for every w, w A ƒ(w) B ƒ is called a polynomial time reduction of A to B
25
AB ƒ ƒ ∀ w. w A ƒ(w) B
26
Theorem. If A ≤ P B and B ∈ P, then A ∈ P. (so if A ≤ P B and A P, then B P.) Proof. B P ⇒ TIME COMPLEXITY = O(|w| ab ) |s| b -time program test_b(s) to decide B A ≤ P B ⇒ test_a(w): s = map(w) return test_b(s) |w| a -time function map s.t. map(w) B iff w A.
27
Definition: A language B is NP-complete if: 1. B NP 2. Every A in NP is poly-time reducible to B (i.e. B is NP-hard) HARDEST PROBLEMS IN NP
28
B is NP-Complete P NP B
29
Theorem. If B is NP-Complete, C ∈ NP, and B ≤ P C, then C is NP-Complete. P NP B C
30
Theorem. If B is NP-Complete and B ∈ P, then P=NP. Corollary. If B is NP-Complete, and P NP, there is no fast algorithm for B.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.