We describe a universal TM from the JFLAP book, by Rodger and Finley. File U.jff (their file ex9-universal.jff) is a 3-tape universal TM, with tape alphabet {0,1,_}, where _ is the blank. Tape T1 holds , a description of M, the TM to simulate. T2 holds an encoding of M's tape (with the T2 head on the encoding of the current symbol). So initially it is , the encoding of M's input string x. T3 holds M's internal state, which is initially 1 (see below). Here are more details about the encodings: * Number M's states 1,2,...,|Q|, where 1 is the start and 2 is the only accept state. (Like JFLAP, we use implicit rejection.) Encode state i as =1^i * Number M's tape alphabet 1,2,...,|Gamma|, where 1 is blank. Encode symbol j as =1^j * Encode the movement symbols as: =1, =11, =111 * Let A be a transition, delta(p,a)=(q,b,X), with X in {L,S,R}. Encode A as =

00000 * Suppose TM M has transition arcs A1, A2, ..., AN. Encode M (on tape T1) as = .... * Suppose the simulated tape contains string x = x_1...x_n, with head on x_i. Then tape T2 contains 0...0, with T2's head on the first symbol of * When the simulated state is j, T3 contains =1^j In particular, T3 initially contains 1 (the start state). For example, if M is simple.jff (copy of ../book/ex9-simple.jff) and we run it on the input x="aaa", then we would start U as follows: T1 = = 101101011101110101011010110 T2 = = 110110110 T3 = <1> = 1 Note we chose to encode 'a' as 11 and 'b' as 111. If we run U with those inputs, it eventually accepts (T3 holds 11), with T2 contents 1011101110111010 = <_bbb_>, and the tape head on the blank (10). Since blanks at the ends can be ignored, we may interpret this as the output string "bbb". Note this U does not check that its tape inputs are validly formed encodings , , . If the initial tape contents are malformed, then the behavior of this U is undefined. With "a little more work", we could make U check its input format, and following Sipser's construction, we could convert U to a single-tape universal Turing machine, with (M,x) encoded as a single string, for example we could encode as 0. Then U would be general enough to simulate itself! But we will not actually try this, it would be quite a challenge.