Download presentation
Presentation is loading. Please wait.
Published byBrian Jonah Cameron Modified over 9 years ago
1
Lecture 18 Various TMs
2
Allow the head not move Theorem. If the head is allowed to stay at the cell in each move, then every function computed by the DTM is still Turing- computable. Proof. Consider DTM M=(Q,Σ,Γ,δ,s) where δ: Q x Γ → Q x Γ x {R, L, H} and H means that the head stays at the current cell. We construct M’=(Q U Q’, Σ, Γ, δ’,s) as follows:
3
Q’ = {q’ | q ε Q} For q ε Q, δ’(q, a) = (p, b, R) if δ(q, a) = (p, b, R) δ’(q, a) = (p, b, L) if δ(q, a) = (p, b, L) δ’(q, a) = (p’, b, R) if δ(q, a) = (p, b, H) For p’ ε Q’, δ’(p’, a) = (p, a, L). M and M’ compute the same function.
4
Corollary. A language is accepted by a DTM, which allows the head not to move, iff it is Turing-acceptable. Why this is a corollary? Because every language accepted by a DTM is the definition domain of a function computable by a DTM of the same type. Corollary. A language is decided by a DTM, which allows the head not to move, iff it is Turing-decidable.
5
Two-way DTM 123ab
6
Theorem. Every function computed by a two- way DTM is Turing-computable. $ 123 ab
7
Consider a two-way DTM M=(Q, Σ, Γ, δ,s). Construct a DTM M’ = (Q U Q’,Σ’,Γ’,δ’,s) to simulate M as follows: Q’={q’ | q ε Q} Γ’ ={(a, b) | a, b ε Γ } U { (B, $) } Σ’ ={(a, B) | a ε Σ} For q ε Q, δ’(q, $) = (q’,$,R) δ’(q, (a, c)) = (p,(b,c),D) if δ(q,a)=(p,b,D)
8
For q’ ε Q’, δ’(q’, $) = (q, $, R) δ’(q’,(c,a)) = (p’,(c,b),R) if δ(q,a)=(p,b,L) δ’(q’,(c,a)) = (p’,(c,b),L) if δ(q,a)=(p,b,R) δ’(q’,(c,a)) = (p’,(c,b),H) if δ(q,a)=(p,b,H)
9
Multi-tape DTM Input tape (read only) Storage tapes Output tape (possibly, write only)
10
Theorem. A function can be computed by a multitape DTM iff it isTuring-computable. Proof. tape head tape head tape head X X X
11
To simulate a move of the multitape DTM, the one- tape DTM needs two trips: Trip 1: read all symbols at heads. Trip 2: erase and write at cells scaned by heads. Questions: How many moves does one-tape DTM needs to simulate t moves of a multitape DTM? How many states does one-tape DTM needs to simulate a multitape DTM?
12
Nondeterministic TM (NTM) There are multiple choices for each transition. For each input x, the NTM may have more than one computation paths. An input x is accepted if at least one computation path leads to the final state. L(M) is the set of all accepted inputs.
13
A function f(x) is computed by an NTM M if for every x ε L(M), M gives output f(x) whenever it reaches the final state. Theorem. A function can be computed by an NTM iff it is Turing-computable. Proof. Idea: Enumerate all possible computation paths of certain length from small to large. Implement: set a tape to do the enumeration.
14
Suppose for each transition, there are at most c choices. Then on the enumeration tape, the DTM enumerate all strings on alphabet {a 1, a 2, …, a c }: ε, a 1, a 2, …, a c, a 1 a 2, a 1 a 3, …. When a string a i 1 a i 2 ∙∙∙a i m is written on the enumeration tape, the DTM simulates the NTM by making the i j –th choice at the j-th move. DTM halts iff it found a computation path of NTM which halts.
15
Question: How many moves does a DMT needs to simulate t moves of a NTM? O(c ) t
16
Church-Turing Thesis Any reasonably computable function is a Turing-computable function.
17
Theorem. A language A is Turing-decidable iff both A and its complement A are Turing-acceptable. Proof. The forward direction is easy. For the backward direction, suppose one-tape DTMs M and M’ accept A and A respectively. Construct 4-tape DTM M* as follows: Use a storage tape to simulate M and another storage tape to simulate M’. M* halts iff M or M’ halts. If M halts, then M* outputs 1. If M’ halts, then M* outputs 0.
18
Lecture 19 Recursive Functions
19
Initial Functions Zero function ζ(n) = 0. Successor σ(n) = n+1, for n ε N. Projection π i (n 1,…,n k ) = n i. k
20
Composition Let m, k be two integers. Given functions g: N → N and h i : N → N for I = 1, 2, …, m, define f: N → by f(n 1,…,n k ) = g(h 1 (n 1,…,n k ),…,h m (n 1,…,n k ) f is called the composition of g and h 1, …, h m. f = g o (h 1,…,h m ) mk k
21
Primitive Recursion Let k > 0. Given g: N → N and h: N → N, (when k=0, g is a constant), define f : N → N by f(n 1,…n k,0) = g(n 1,…,n k ) f(n 1,…,n k,m+1) = h(n 1,…,n k,m,f(n 1,…n k,m) kk+2 k+1
22
Primitive Recursive Functions All initial functions are primitive recursive. If g and h 1, …, h m are primitive recursive, so is g o (h 1, …, h k ). If g and h are primitive recursive, so is f obtained from g and h by primitive recursion. Nothing else is primitive recursive.
23
Add(m, n) = m+n Add(m,0) = π 1 (m) Add(m, n+1) = σ( π 3 (m,n, add(m, n))) 1 3
24
mult(m, n) = mn mult(m, 0) = ζ(m) Mult(m, n+1) = add(π 1 (m,n,mult(m,n)), π 3 (m, n, mult(m,n)) 33
25
minus(m,n)= m-n if m > n; 0 if m<n pred(m) = minus(m,1) pred(0) = ζ(0) pred(m+1) = m = π 1 (m, pred(m)) minus(m,0) = π 1 (m) minus(m, n+1) = pred(π 3 (m,n,minus(m, n)) 2 1 3
26
Pairing Function A function f: N → N is a pairing function if it satisfies the following conditions: (1) f is 1-to-1 and onto; (2) f is primitive recursive; (3) f(i, j) < f(i+1, j), f(i, j) < f(i, j+1). For example, 2
27
Two “inverse” functions i = g(f(i,j)) and j = h(f(i, j)) are also primitive recursive. 01 2 3 4 5 6 7 8 9 10 11 12 13 14
28
Bounded minimization Given g: N → N, define f by f(n 1, …, n k, m) = min {i | g(n 1, …, n k, i)=1} if there exists i < m such that g(n 1, …, n k, i) =1; = 0, otherwise. If g is primitive recursive, so is f. K+1
29
Unbounded minimization Given g: N → N, define f by f(n 1, …, n k ) = min {i | g(n 1, …, n k, i)=1} if there exists i such that g(n 1, …, n k, i) =1; = ↑, otherwise. f may not be primitive recursive, even if g is. K+1
30
Partial Recursive Functions All initial functions are partial recursive. If g is a total recursive function, then f obtained from g by unbounded minimization is partial recursive. If g and h 1,…, h k are partial recursive, so is g o (h 1,…,h k ). If g and h are partial recursive, so is f obtained from g and h by primitive recursion.
31
Over Σ* Zero function ζ(x) = ε. Successor σ a (x) = xa for a in Σ. Projection (no change) Composition (no change) Primitive recursion (need a change, m+1 is replaced by ma) Unbounded minimization (need to give a linear ordering of Σ*)
32
From Σ* to Γ* for Σ* c Γ* Zero function ζ(x) = ε. Successor σ a (x) = xa for a in Γ. N can be considered as a subset of {0, 1}* if we represent n by 1…1 n
33
Theorem A function is partial recursive iff it is Turing-computable.
34
Theorem The following are equivalent: A is r.e. A is Turing-acceptable. A is the range of a primitive recursive function. A is the domain of a partial recursive function.
35
Pairing function on Σ* Let π(i, j) be a pairing function on N. Let φ be a 1-to-1 onto mapping from N to Σ*. Let μ be a 1-to-1 onto mapping from Σ* to N. Then p(x, y) = φ(π(μ(x), μ(y)) is a pairing function on Σ*.
36
Lecture 20 Universal TM
37
Code of a DTM Consider a one-tape DTM M = (Q, Σ, Γ, δ, s). It can be encoded as follows: First, encode each state, each direction, and each symbol into a natural number (code(B) = 0, code(R) =1, code(L) = 2, code(s)=3, code(h)=4,... ). Then encode each transition δ(q, a) = (p, b, D) into a string 0 10 10 10 10 qapbD
38
The code of M is obtained by combining all codes code i of transitions together: 111code 1 11code 2 11∙∙∙11code m 111. Remark: Each TM has many codes. All codes of TMs form a Turing-decidable language.
39
Universal DTM One can design a three-tape DTM M* which behaves as follows: On input, M* first decodes M on the second tape and then simulates M on the output tape. Clearly, L(M*) = { | x ε L(M)}. Thus, Theorem 1. { | x ε L(M)} is Turing- acceptable.
40
Next, we prove Theorem 2. { | x ε L(M)} isn't Turing-decidable. To do so, we consider A = { M | M accepts M} and prove Lemma. A isn't Turing-decidable.
41
Barber cuts his own hair Class 1: {Barber | he can cut his own hair} Class 2: {Barber | he cannot cut own hair} Question: Is there a barber who cuts hair of everybody in class 2, but not cut hair of anybody in class 1. Answer: No!!! Proof. Suppose such a barber exists. If he cuts his own hair, then he is in class 1 and hence he cannot cut his own hair, a contradiction.
42
If he cannot cut his own hair, then he belongs to class 2 and hence he can cut his own hair, a contradiction. This argument is called diagonalization. hair barber
43
Example. There exists an irrational number. Proof. Consider all rational numbers in (0,1). They are countable, a1, a2, …. Now, we construct a number such that its i-th digit is different from the i-th digit of ai. Then this number is not rational. a1 a2 digits
44
Proof. For contradiction, suppose that A is accepted by a one-tape DTM M’. We look at M’ on input M’. If M’ accepts M’, then M’ is in A, which means that M’ rejects M’, a contradiction. If M’ rejects M’, then M’ isn’t in A which means that M’ accepts M’, a contradiction.
45
Many-one reduction Consider two sets A ε Σ* and B ε Γ*. If there exists a Turing-computable total function f : Σ* → Γ* such that x ε A iff f(x) ε B, then we say that A is many-one reducible to B, and write A ≤ m B.
46
A = { M | M accepts M} B = { | M accepts x} Claim. A ≤ m B. Proof. Define f(M) =. M ε A iff M accepts M iff ε B
47
Theorem. A ≤ m B, B ≤ m C imply A ≤ m C. (This means that ≤ m is a partial ordering.) Theorem. If A ≤ m B and B is Turing- decidable, then A is Turing-decidable. By this theorem, { | M accepts x} isn’t Turing-decidable.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.