CSC4510/6510 AUTOMATA
7.4 Combining Turing Machines 7.6 The Church-Turing Thesis 7.7 Nondeterministic Turing Machines 7.8 Universal Turing Machines
Combining Turing Machines If T1 and T2 are TMs, the composition T1T2: first execute T1, then execute T2 on the result States of T1T2: the union of the sets of states of T1 and T2 (relabeled if necessary) Initial state: the initial state of T1 The transitions of T1T2: all of those of T2 and all of those of T1 that don’t go to ha A transition in T1 that goes to ha is replaced by a similar transition that goes to the start state of T2 It is important that the output of T1 be a valid input configuration for T2 2
1
Combining Turing Machines (cont’d.)
Combining Turing Machines (cont’d.)
In state p, if the current symbol is a, then execute the TM T
We have the following TMs:
Execute T1, and if T1 halts in ha with current symbol a, then execute T2
Accepting the Language of Palindromes
Copy: copy a string NB/PB: find the next/previous blank R: reverse a string Equal: compare two strings
Copy
Reverse
T: Copy NB R PB Equal
a/a,R b/b,R
Copy 3
/,R
a/a,L b/b,L
Reverse
/,L
Equal 4
2
The Church‐Turing Thesis
The Church‐Turing Thesis (cont’d.)
“To say that the TM is a general model of computation implies that any algorithmic procedure that can be carried out at all, by a human computer or a team of humans or an electronic computer, can be carried out by a TM” The statement was formulated by Alonzo Church in the 30’s It is referred to as Church’s thesis or the Church‐ Turing thesis It isn’t a statement that can be proved, but there is a lot of evidence for it
1. The nature of the model makes it seem that a TM can execute any algorithm a human can 2. Enhancements to the TM have been shown not to increase its power 3. Other theoretical models of computation proposed have been shown to be equivalent to a TM 4. No one has ever suggested any kind of computation that cannot be implemented on a TM
5
6
3
Nondeterministic Turing Machines
Nondeterministic Turing Machines Let L be the subset of {1}* of all strings whose length is a composite number, i.e., an element of L is a string of the form 1n, where n=p*q for some integers p and q with p,q≥2.
There are multiple choices for each transition. For each input x, the NTM may have more than one computation paths.
G2
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.
7
NBG2NBG2PBMPBEqual Original: 111111111111111 After NB: 111111111111111 After G2: 111111111111111 11111 After NB: 11111111111111111111 After G2: 11111111111111111111 111 After PB: 11111111111111111111111 11111111 After M: 111111111111111 111111111111111 After PB: 111111111111111111111111111111 After Equal: Accept 8
4
Nondeterministic Turing Machines
Universal Turing Machines
Theorem 7.31: For every nondeterministic TM T there is an ordinary (deterministic) TM T1 with L(T1)=L(T) Proof: The idea is to use an algorithm that can test, if necessary, every possible sequence of moves of T on an input string x. See book for details
9
Definition 7.32: A universal Turing machine is a Turing machine Tu that works as follows Receive an input string of the form e(T)e(z), where T is an arbitrary TM, z is a string over the input alphabet of T, and e is an encoding function whose values are strings in {0, 1}* The computation performed by Tu on this input string satisfies 1. Tu accepts e(T)e(z) if and only if T accepts z 2. If T accepts z and produces output y, then Tu produces output e(y) 10
5
Universal Turing Machines (cont’d.)
Universal Turing Machines (cont’d.)
The encoding function has several crucial features: It is possible to decide algorithmically, for an arbitrary string w{0, 1}*, whether w is a legitimate value of e
State labels will be replaced by numbers, and we will base the encoding on these numbers In order to use numbers to encode symbols as well, we adopt this convention: there is an infinite set S={a1, a2, …} of symbols, including a1= , such that the tape alphabet of every TM T is a subset of S The idea of the encoding is to represent a TM as a set of moves and associate each move with a 5‐tuple of numbers Each number is in unary followed by a 0
A string w should represent at most one TM, or at most one string There should be an algorithm for decoding strings of the form e(T) or e(z) and reconstructing the TM or string it represents 11
12
6
Universal Turing Machines (cont’d.)
Universal Turing Machines (cont’d.)
Definition 7.33: If T=(Q, , , q0, ) is a TM and z is a string, define the strings e(T) and e(z) as follows First assign numbers to each state, tape symbol, and tape head direction of T: n(ha)=1, n(hr)=2, n(q0)=3 The other elements qQ get distinct numbers 4 n(R)=1, n(L)=2, n(S)=3 For each move m of the form (p, )=(q, , D), e(m)=1n(p)01n()01n(q)01n()01n(D)0 List the moves of T as m1, …, mk (the order is arbitrary), and e(T)=e(m1)0e(m2)0…0e(mk)0 If z=z1z2…zj is a string, where each ziS, e(z)=01n(z1)01n(z2) …01n(zj)0 13
Encoding Symbol: n()=1, n(a)=2, n(b)=3 State: n(ha)=1, n(hr)=2, n(q0)=3, n(p)=4, n(r)=5, Direction: n(R)=1, n(L)=2, n(S)=3
Move m: (q0, )=(p, , R) e(m)=130101401010=111010111101010 e(m): 5‐tuple (11*0)5 e(T) = 1110101111010100 111101110111101110100 1111011011111011101100 1111010111110101100 111110111011111011101100 11111010101011100 e(T): a concatenation of one or more (11*0)50 14
7
Universal Turing Machines (cont’d.)
Universal Turing Machines (cont’d.)
Theorem 7.36: Let E={e(T) | T is a TM}. Then for every x{0,1}*, xE if and only if: 1. x matches the regular expression (11*0)50((11*0)50)*, so that it is a sequence of 5‐tuples 2. No two substrings of x representing 5‐tuples have the same first two parts 3. None of the 5‐tuples have first part 1 or 11 4. The last part of each 5‐tuple must be 1, 11, or 111
Construct a universal TM Tu Tape 1: input and out, originally with e(T)e(z). Tape 2: working tape of T containing current symbol. Tape 3: T’s current state. 1110101110101001111011101111011101001111011011111011101100111101011… 10111011101101110110 1111
(p, a)= (r, b, L)
1110101110101001111011101111011101001111011011111011101100111101011… 101110111011101110110 11111
1. T’s computation on the input string z might never terminate 2. T might reject 3. T might accept 15
16
8