470 likes | 478 Views
This lecture discusses several theorems related to Turing Machines, including the properties of allowing the head to stay at a cell, two-way Turing Machines, multi-tape Turing Machines, and Nondeterministic Turing Machines.
E N D
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:
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.
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.
Two-way DTM b a 1 2 3
Theorem.Every function computed by a two-way DTM is Turing-computable. 1 2 3 $ a b
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)
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)
Multi-tape DTM Input tape (read only) Storage tapes Output tape (possibly, write only)
Theorem.A function can be computed by a multitape DTM iff it isTuring-computable. Proof. tape X head tape X head tape X head
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?
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.
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.
Suppose for each transition, there are at most c choices. Then on the enumeration tape, the DTM enumerate all strings on alphabet {a1, a2, …, ac}: ε, a1, a2, …, ac, a1a2, a1a3, …. • When a string ai1ai2∙∙∙aim is written on the enumeration tape, the DTM simulates the NTM by making the ij –th choice at the j-th move. • DTM halts iff it found a computation path of NTM which halts.
Question: How many moves does a DMT needs to simulate t moves of a NTM? • O(c ) t
Church-Turing Thesis Any reasonably computable function is a Turing-computable function.
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.
Initial Functions • Zero function ζ(n) = 0. • Successor σ(n) = n+1, for n ε N. • Projectionπi (n1,…,nk) = ni. k
Composition • Let m, k be two integers. • Given functions g: N → N and hi: N → N for I = 1, 2, …, m, define f: N → by f(n1,…,nk) = g(h1(n1,…,nk),…,hm(n1,…,nk) • f is called thecompositionof g and h1, …,hm. • f = go(h1,…,hm) m k k
Primitive Recursion k k+2 • Let k > 0. Given g: N → N and h: N → N, (when k=0, g is a constant), define f : N → N by f(n1,…nk,0) = g(n1,…,nk) f(n1,…,nk,m+1) = h(n1,…,nk,m,f(n1,…nk,m) k+1
Primitive Recursive Functions • All initial functions are primitive recursive. • If g and h1, …, hm are primitive recursive, so is go(h1, …, hk). • If g and h are primitive recursive, so is f obtained from g and h by primitive recursion. • Nothing else is primitive recursive.
Add(m, n) = m+n • Add(m,0) = π1 (m) • Add(m, n+1) = σ( π3 (m,n, add(m, n))) 1 3
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)) 3 3
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
Pairing Function 2 • 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,
Two “inverse” functions i = g(f(i,j)) and j = h(f(i, j)) are also primitive recursive. 14 13 9 8 5 12 2 4 7 11 0 1 3 6 10
Bounded minimization K+1 • Given g: N → N, define f by f(n1, …, nk, m) = min {i | g(n1, …, nk, i)=1} if there exists i < m such that g(n1, …, nk, i) =1; = 0, otherwise. • If g is primitive recursive, so is f.
Unbounded minimization K+1 • Given g: N → N, define f by f(n1, …, nk) = min {i | g(n1, …, nk, i)=1} if there exists i such that g(n1, …, nk, i) =1; = ↑, otherwise. • f may not be primitive recursive, even if g is.
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 h1,…, hk are partial recursive, so is go(h1,…,hk). • If g and h are partial recursive, so is f obtained from g and h by primitive recursion.
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 Σ*)
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
Theorem • A function is partial recursive iff it is Turing-computable.
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.
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 Σ*.
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 q a p b D
The code of M is obtained by combining all codes codei of transitions together: 111code111code211∙∙∙11codem111. Remark: • Each TM has many codes. • All codes of TMs form a Turing-decidable language.
Universal DTM • One can design a three-tape DTM M* which behaves as follows: On input <x, M>, M* first decodes M on the second tape and then simulates M on the output tape. • Clearly, L(M*) = { <x, M> | x ε L(M)}. Thus, Theorem 1.{ <x, M> | x ε L(M)} is Turing-acceptable.
Next, we prove Theorem 2.{ <x, M> | 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.
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.
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
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. digits a1 a2
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.
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.
A = { M | M accepts M} • B = {<x,M> | M accepts x} Claim. A ≤m B. Proof. Define f(M) = <M,M>. M ε A iff M accepts M iff <M, M> ε B
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, {<x, M> | M accepts x} isn’t Turing-decidable.