Download presentation
Presentation is loading. Please wait.
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.