1 Universal Turing Machines Here is an encoding to represent an arbitrary Turing machine over an arbitrary alphabet as a string over a fixed alphabet. state q followed by an i digit binary number symbol in Σ a followed by a j digit binary number a 0 j ⊔ a 0 j − 1 1 ⊲ ← a 0 j − 2 10 a 0 j − 2 11 → start state q 0 i Let encode ( M ) denote the encoding of a Turing machine M . The book uses “M” for this. It consists in a sequence of ( q, a, p, b ) strings, where δ ( q, a ) = ( p, b ) , thus representing the transition table. The 4-tuples ( q, a, p, b ) are represented by encoding q, a, p , and b as indicated above, and including left and right parentheses and commas. So a possible encoding of a 4-tuple would be ( q 00 , a 100 , q 01 , a 000) . Here • i would be 2, • j would be 3, • q 00 would be the start state, • a 100 would represent a symbol, • q 01 would be another state, and • a 000 would represent ⊔ , that is, blank. This encoding uses the symbols “(”, “)”, “q”, “a”, “0”, “1”, “,”, and blank, so it uses a fixed number of symbols to encode a Turing machine having an arbitrary number of symbols in its alphabet. 1
1.1 Encoding of an example Turing machine Here’s an example Turing machine from section 4.1, with the names of states changed, and its encoding: M = ( K, Σ , δ, s, { h } ), K = { s, q, h } ,Σ = { a, ⊔ , ⊲ } . δ ( q ′ , σ ) 4-tuple q ′ σ ( q, ⊔ ) ( s, a, q, ⊔ ) s a s ⊔ ( h, ⊔ ) ( s, ⊔ , h, ⊔ ) δ : ( s, → ) ( s, ⊲ , s, → ) s ⊲ q a ( s, a ) ( q, a, s, a ) q ⊔ ( s, → ) ( q, ⊔ , s, → ) ( q, → ) ( q, ⊲ , q, → ) q ⊲ Here is the encoding of states and symbols: Symbols States ⊔ a 000 0 for blank s q 00 (start state is 00) a 001 1 for end marker ⊲ q 01 ← a 010 2 for left arrow q h q 10 (book has q 11 here) → a 011 3 for right arrow a 100 another symbol a Then the Turing machine as a whole is encoded by concatenating the encoding of the 4-tuples in lexicographic order, according to their encodings, so • the states are in the order q 00, q 01, q 10 and • the symbols are in the order a 000, a 001, a 010, a 011, a 100. Thus the 4-tuples are in the order ( s, ⊔ , h, ⊔ ), ( s, ⊲ , s, → ), ( s, a, q, ⊔ ), ( q, ⊔ , s, → ), ( q, ⊲ , q, → ), ( q, a, s, a ). This gives the encoding ( q 00 , a 000 , q 10 , a 000) , ( q 00 , a 001 , q 00 , a 011) , ( q 00 , a 100 , q 01 , a 000) , . . . , ( q 01 , a 100 , q 00 , a 100) . (The book gives a different order.) From this encoding all the components of the Turing machine can be obtained. 2
• The states are the items that appear in the first and third components, • the halting states are the states that do not appear in the first compo- nents, • the start state, left end marker, et cetera are given by the encoding, • the input alphabet consists of the items appearing in the second com- ponent, and • the transition function is given by the 4-tuples. The encoding of a Turing machine M is denoted by encode ( M ). 1.2 Encoding of strings Strings are encoded by concatenating the encodings of their symbols. Thus the string ⊲ ⊔ aa would be represented by a 001 a 000 a 100 a 100 . The encoding of a string x is denoted by encode ( x ). 1.3 Encoding inputs to a universal Turing machine The input to a universal Turing machine U would be the concatenation of encode ( M ) and encode ( x ) for some M and x , which would be written as encode ( M ) encode ( x ) . Given such an encoding, U would halt if and only if M halts on input x . 1.4 Encoding in Binary Of course, the final encoding of a Turing machine can be converted to a binary string by converting each symbol to a binary sequence. This binary string can be seen as a binary integer, so each Turing machine can be represented by a nonnegative integer. 3
Recommend
More recommend