Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to Theory of Computation

Similar presentations


Presentation on theme: "Intro to Theory of Computation"β€” Presentation transcript:

1 Intro to Theory of Computation
LECTURE 20 Last time Computation history method Review, test. Today Recursion theorem Complexity theory CS 332 Sofya Raskhodnikova

2 Recursion Theorem Making TMs that can obtain their own descriptions
with applications to computer viruses 10/13/2019

3 A TM 𝑷 π’˜ that prints w There is a computable function q that on input w outputs 𝑃 𝑀 , where 𝑃 𝑀 is a TM that prints w. TM computing q: ``On input w, Print 〈 𝑃 𝑀 βŒͺ and halt.’’ 𝑃 𝑀 =``Erase input. Print w and halt.’’ 10/13/2019

4 TM S that prints βŒ©π‘ΊβŒͺ Theorem. There is a TM S that erases input, prints βŒ©π‘†βŒͺ and halts. Proof: π‘ž 𝑀 = βŒ©π‘ƒ 𝑀 βŒͺ A= 𝑃 〈𝐡βŒͺ B =``On input 𝑀 , where 𝑀 is a TM, Compute 𝑃 βŒ©π‘€βŒͺ =π‘ž( 𝑀 ). Construct TM 𝑆′: Output 〈 𝑆 β€² βŒͺ and halt.’’ S =``Erase input. Run TM A. Run TM B. Halt.’’ 𝑺′ =``Erase input. Run TM 𝑃 βŒ©π‘€βŒͺ . Run TM 𝑀. Halt.’’ 10/13/2019

5 In English Write this sentence.
Write two copies of the following, the second one in quotes: ``Write two copies of the following, the second one in quotes:’’ 10/13/2019

6 Recursion Theorem If there is a TM T that computes a function 𝑑 𝑀, 𝑀 then there is a TM R that computes π‘Ÿ 𝑀 =𝑑 𝑀, 𝑅 . Punchline: ``Obtain your own description’’ is a valid step in an algorithmic description of a TM. P’ is P modified to leave w# on the tape; R accepts if T accepts; rejects if it rejects R =``On input 𝑀, Place # after 𝑀. Run TM A. Run TM B. Run TM T.’’ A= 𝑃′ 〈𝐡,𝑇βŒͺ 10/13/2019

7 Recursion Theorem If there is a TM T that computes a function 𝑑 𝑀, 𝑀 then there is a TM R that computes π‘Ÿ 𝑀 =𝑑 𝑀, 𝑅 . B =``On input w# 𝑀 1, 𝑀 2 , where 𝑀 1 , 𝑀 2 are TMs, Compute 𝑃′ 〈 𝑀 1 , 𝑀 2 βŒͺ =π‘žβ€²( 𝑀 1 , 𝑀 2 ). Construct TM 𝑅′: Output w#〈 𝑅 β€² βŒͺ and halt.’’ 𝑹 =``On input 𝑀, Place # after 𝑀. Run TM A. Run TM B. Run TM T.’’ 𝑹′ =``On input 𝑀, Place # after 𝑀. Run TM 𝑃′ 〈 𝑀 1 , 𝑀 2 βŒͺ . Run TM 𝑀 1 . Run TM 𝑀 2 ’’ A= 𝑃′ 〈𝐡,𝑇βŒͺ 10/13/2019

8 Recursion Theorem Punchline: ``Obtain your own description’’ is a valid step in an algorithmic description of a TM. P’ is P modified to leave w# on the tape; R accepts if T accepts; rejects if it rejects 10/13/2019

9 Application of recursion theorem
Give an alternative proof that 𝐴 𝑇𝑀 is undecidable. (on the board) 10/13/2019

10 Application of recursion theorem
A TM M is minimal if there is no TM equivalent to M that has a shorter description than 𝑀 . 𝑀𝐼 𝑁 𝑇𝑀 ={ 𝑀 βˆ£π‘€ is minimal TM}. Show that 𝑀𝐼 𝑁 𝑇𝑀 is not Turing-recognizable. (on the board) 10/13/2019

11 Complexity Theory Already learned Automata theory Computability theory
Last unit: complexity theory First topic: time complexity Measuring complexity (as in Algorithms) Asymptotic notation (as in Algorithms) Relationships between models 10/13/2019

12 How much time/memory needed to decide a language?
Example: Consider 𝐴= 0 π‘š 1 π‘š π‘šβ‰₯0}. Time needed for 1-tape TM? 𝑀 1 =β€œ FINITE CONTROL .. 1 1 .. 1 Scan input and reject if it is not of the form 0 βˆ— 1 βˆ— . Repeat while both 0s and 1s remain on the tape: Cross off one 0 and one 1 Accept if no 0s and no 1s left; otherwise reject.” 10/13/2019

13 Running time analysis If M is a TM and 𝑓:β„•β†’β„• then
Focus on worst case: upper bound on running time for all inputs of given length Exact time depends on the computer instead measure asymptotic growth If M is a TM and 𝑓:β„•β†’β„• then β€œM runs in time 𝑓(𝑛)” means for every input π‘€βˆˆ Ξ£ βˆ— of length 𝑛, M on 𝑀 halts within 𝑓(𝑛) steps 10/13/2019

14 Asymptotic notation O-notation (upper bounds): f(n) = O(g(n)) means
there exist constants c > 0, n0 > 0 such that 0 ο‚£ f(n) ο‚£ cg(n) for all n ο‚³ n0. EXAMPLE: 2n2 = O(n3) (c = 2, n0 = 1) functions, not values 10/13/2019 L20.16

15 Asymptotic Notation One-sided equality: 𝑇(𝑛) = O(𝑓(𝑛)).
Not transitive: 𝑓(𝑛) = 5𝑛3; 𝑔(𝑛) = 3𝑛2 𝑓(𝑛) = O(𝑛3) and 𝑔(𝑛) = O(𝑛3) but 𝑓 𝑛 ≠𝑔(𝑛). Alternative notation: 𝑓(𝑛) οƒŽ O(𝑔(𝑛)). 10/13/2019

16 Examples 106 𝑛3+ 2𝑛2 βˆ’π‘› +10 = O(𝑛3) 𝑛 + log⁑𝑛 = 𝑛 (log⁑𝑛+ 𝑛 ) = O( 𝑛 )
also O(𝑛2) 10/13/2019

17 -notation (lower bounds)
O-notation is an upper-bound notation. It makes no sense to say f(n) is at least O(n2). f(n) = (g(n)) means there exist constants c > 0, n0 > 0 such that 0 ο‚£ cg(n) ο‚£ f(n) for all n ο‚³ n0. EXAMPLE: (c = 1, n0 = 16) 𝑛 =Ξ©( log 𝑛) 10/13/2019

18 -notation (lower bounds)
Be careful: β€œAny comparison-based sorting algorithm requires at least O(𝑛 log 𝑛) comparisons.” Meaningless! Use  for lower bounds. 10/13/2019

19 -notation (tight bounds)
(g(n)) means both O(g(n)) and (g(n)) EXAMPLE: Polynomials are simple: ad nd + ad–1nd–1 +  + a1n + a0 = (nd) 10/13/2019

20 o-notation and -notation
O-notation and -notation are like ο‚£ and ο‚³. o-notation and -notation are like < and >. f(n) = o(g(n)) means for every constant c > 0, there exists a constants n0 > such that 0 ο‚£ f(n) ο‚£ cg(n) for all n ο‚³ n0. EXAMPLE: 2n2 = o(n3) (n0 = 2/c) 10/13/2019

21 Overview Notation … means … Think… Example lim nβ†βˆž 𝑓(𝑛) 𝑔 𝑛
f(n)=O(g(n)) βˆƒ c>0, n0>0, βˆ€ n > n0 : 0 ≀f(n) < cg(n) Upper bound 100n2 = O(n3) If it exists, it is < 1 f(n)=(g(n)) βˆƒc>0, n0>0, βˆ€ n > n0 : 0 ≀ cg(n) < f(n) Lower bound n100 = (2n) If it exists, it is > 0 f(n)=(g(n)) both of the above: f=(g) and f = O(g) Tight bound log(n!) = (n log n) If it exists, it is > 0 and < 1 f(n)=o(g(n)) βˆ€ c>0, βˆƒ n0>0, βˆ€ n > n0 : 0 ≀ f(n) < cg(n) Strict upper bound n2 = o(2n) Limit exists, =0 f(n)=(g(n)) βˆ€ c>0, βˆƒn0>0, βˆ€ n > n0 : 0 ≀ cg(n) < f(n) Strict lower bound n2 = (log n) Limit exists, =1 10/13/2019

22 Common Functions: Asymptotic Bounds
Polynomials. a0 + a1n + … + adnd is (nd) if ad > 0. Logarithms. log a n = (log b n) for all constants a, b > 0. For every x > 0, log n = o(nx). Exponentials. For all r >1 and all d > 0, nd = o(rn). Factorial. 𝑛!=𝑛 π‘›βˆ’1 β‹―1. By Sterling’s formula, log grows slower than every polynomial can avoid specifying the base Every exponential grows faster than every polynomial 10/13/2019

23 Sort by asymptotic order of growth
n log n log n n2 2n n log log n n! n1,000,000 n1/log(n) log(n!) 𝑛 2 2 𝑛 2 2 2 𝑛 10/13/2019

24 Time complexity classes
TIME(𝒇(𝒏)) is a class of languages. π‘¨βˆˆ TIME(𝒇(𝒏)) means that some 1-tape TM M that runs in time O(𝑓(𝑛)) decides A. 10/13/2019

25 The class P P is the class of languages decidable in polynomial time on a deterministic 1-tape TM: 𝑷= π‘˜ 𝑇𝐼𝑀𝐸 𝑛 π‘˜ . The same class even if we substitute another reasonable deterministic model. Roughly the class of problems realistically solvable on a computer. 10/13/2019


Download ppt "Intro to Theory of Computation"

Similar presentations


Ads by Google