Download presentation

Presentation is loading. Please wait.

Published byEleanor Deeks Modified over 5 years ago

1
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

2
A CIRCUIT … is a collection of gates and inputs connected by wires. ∧ ⋁ ¬ ⋁ x0x0 x1x1 x2x2 … is satisfiable if some setting of inputs makes it output 1. … can be encoded as a string CIRCUIT-SAT = { 〈 C 〉 : C is a satisfiable circuit }

3
CIRCUIT-SAT IS DECIDABLE is_satisfiable(C): for each x ∈ {0,1} n : if (circuitValue(C,x)==1): return True else: return False How long does the algorithm take on n-bit inputs? COMPLEXITY THEORY: What problems have efficient algorithms? CIRCUIT-SAT ∈ TIME(2 O(n) )

4
TIME COMPLEXITY Definition: Let M be a TM that halts on all inputs. The running time or time-complexity of M is the function ƒ : N N, where ƒ(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 }

5
FAST ALGORITHMS Idea: a problem A is efficiently decidable if A TIME( ) ?

6
Theorem: Let t(n) be a function such that t(n) n. Then every t(n)-time multi-tape TM has an equivalent O(t(n) 2 ) single tape TM COMPUTATIONAL MODELS A = { 0 k 1 k | k 0 } TIME(n log n) No (single-tape) TM decides A in time o(n log n) A is decidable in time O(n) with a two-tape TM

7
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

8
WHY P? Many t(n) time variants of TMs can be simulated in time O(t(n) c ) by a single-tape TM, including: TMs with double-unbounded tape: O(t(n)) Multi-tape TMs: O(t 2 (n)) RAM Machines: O(t 6 (n)) Polynomials are the simplest class of functions closed under composition, multiplication, etc… They “grow slowly” compared to exponentials

9
EXAMPLE: PATH A directed graph with n nodes… is a set of vertices V = {1,2,…,n} and a set of edges E ⊆ VV. 1 2 3 4 can be encoded as an adjacency matrix has a path from s to t if there are nodes i 1, …, i k such that { (s,i 1 ), (i 1, i 2 ),…, (i k, t) } ⊆ E. PATH = { 〈 G,s,t 〉 | G has a path from s to t } A ij = 1, if (i,j) ∈ E 0, otherwise

10
PATH IS IN P has_path(G,s,t): mark s and add it to the queue while the queue is not empty: take v i from the queue for each v j in {1,…, n}: if A ij = 1 and v j is not marked: mark v j and add it to the queue if t is marked: return True else: return False 1 2 3 4 Total RAM Complexity: O(n 2 ) 5 6 7 O(1) O(n)

11
EXAMPLES Show that the following are in P: 3PATH = { 〈 G,s,t 〉 | There is a path of length at most 3 from s to t} E DFA = { 〈 D 〉 | D is a DFA and L(D)=Ø } MEDIAN = { 〈 (y 1,…,y n ),k 〉 | median(y 1,…,y n ) is at least k }

12
STABLE MARRIAGES A High School has N boys and N girls. Each has a ranked list of dates for the 1951 Senior Prom. Albert BobCharlie Alice Betty Carol B,C,A A,C,B A,B,C B,A,CC,A,BC,B,A An unstable couple prefer each other to their current dates. STABLE = { 〈 B,G 〉 | There is a pairing with no unstable couple}

13
STABLE MARRIAGES in P Albert BobCharlie Alice Betty Carol B,C,A A,C,B A,B,C B,A,C C,A,B C,B,A 1. Each boy asks his “first choice” to the prom. 2. Each girl “accepts” her best offer – for now. 3. Repeat until everyone has a date: a. Each boy with no date asks the next girl on his list. b. Each girl “accepts” her new best offer – for now. Total Time = O(n 2 )

14
NON-DETERMINISTIC TMs …are just like standard TMs, except: 1. The machine may proceed according to several possibilities. Formally, the transition function outputs a set of zero or more (state,symbol,direction) choices. 2. The machine accepts a string if there exists a path from start configuration to an accepting configuration 3. The running time of the machine is the length of the longest path to q accept or q reject.

15
Deterministic Computation Non-Deterministic Computation accept or rejectaccept reject

16
{ L | L is decided by a O(t(n))-time non-deterministic Turing machine } Definition: NTIME(t(n)) = TIME(t(n)) NTIME(t(n)) NTIME(t(n)) ⊆ TIME(?)

17
Non-Deterministic Computation accept reject ntm_accepts(M,C): if (current_state(C) = q accept ): return True if (current_state(C) = q reject ): return False for each C’ ∈ M. (C): if ntm_accepts(M,C’): return True return False Deterministic Computation 2c2c t(n) NTIME(t(n)) ⊆ TIME(2 O(t(n)) )

18
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().

19
NP = NTIME(n c ) c ℕ

20
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

21
SAT = { | is a satisfiable Boolean formula } A Boolean formula is satisfiable if there exists a satisfying assignment for it (x y) x a b c d YES NO

22
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 }

23
Theorem: 3SAT NP 3SAT = { | is a satisfiable 3cnf-formula } 1. Check if the formula is in 3cnf On input : 2. For each variable, non-deterministically substitute it with 0 or 1 3. Test if the assignment satisfies (x y x) ( y )00 ( y ) 11 ( )000( )010

24
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)

Similar presentations

© 2021 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google