# The Turing Machine program below is designed to detect strings of A's followed by an equal number of B's # Assumption: the machine starts in state 1 looking at the first (leftmost) character of a string # Input: one string consisting of 0 or more A's and B's. No blanks can occur between characters (the # machine won't work in this case) # Ouput: if there is nothing on the tape, we count this as a "Yes" since it is 0 A's followed by 0 B's # so, the machine will write an 'Y' on the tape and halt # if the string on the tape contains some (non-zero) number of A's followed by the same number of B's # it will halt with 'Y' on the tape (and it will erase all the A's and B's in the process) # if the string on the tape contains something other than A's followed by an equal number of B's, # then the machine will halt and write 'N' on the tape (and may leave some of the # original string on the tape as well. # How to Use: Open this file in a text editor and select/highlight the TM rules below and then copy/paste # them into the "Programming" window of the simulator. After put the lines in there, click # on the "Install Program" button. If this works fine, you should see " Entering program... # Machine programmed successfully" in the "Message Box." If you see some kind of error message # in the Message Box, then you'll have to play around to see what's wrong. The simulator seems # to be fairly picky about format - so you might need to check if there are extra blank spaces or # other symbols. Let me know if you're having trouble. 1,B,H,N,> 1,A,2,_,> 1,_,H,Y,> 2,A,2,A,> 2,B,3,B,> 2,_,H,N,> 3,B,3,B,> 3,A,H,N,> 3,_,4,_,< 4,B,5,_,< 5,A,5,A,< 5,B,5,B,< 5,_,1,_,>