; This TM decides the language { a^n b^n c^n }. ; It is based on the JFLAP example "anbncn-TM.jff" (simplified a bit). ; ; This is a decider: it should halt for every input string in {a,b,c}*. ; A computation accepts if it ends in the state "halt-accept". ; We do not use an explicit "halt-reject" state. Instead, computations ; reject with an implicit halt (no rule for current state and symbol). ; ; Example accepted inputs: '', abc, aabbcc, aaabbbccc ; Example rejected inputs: aabc, abbc, abcc, acb, cba ; First jump from 0 (start state) to q0 (start state of JFLAP example) 0 * * * q0 ; q0: start at left, either accept empty string, or erase first a q0 a _ r q1 q0 _ _ * halt-accept q0 # # r q7 ; q1: skip remaining a's and #'s, replace first b with # q1 a a r q1 q1 # # r q2 q1 b # r q3 ; q2: replace first b after skipping any #'s q2 # # r q2 q2 b # r q3 ; q3: skip remaining b's until first c q3 b b r q3 q3 c c r q4 ; q4: skip c's until first blank q4 c c r q4 q4 _ _ l q5 ; q5: erase the last c, step left and goto q6 q5 c _ l q6 ; q6 run left to first blank, then goto q0 for the next loop q6 # # l q6 q6 a a l q6 q6 b b l q6 q6 c c l q6 q6 _ _ r q0 ; q7: check the remaining string is entirely #'s, if so accept q7 # # r q7 q7 _ _ l halt-accept