// lanbncn.tm // accept the language L = { a^n b^n c^n | n>0 } not a CFL // // method: scan left to right, on each pass convert // one "a" to "X", one "b" to "Y" and one "c" to "Z" // reject if any "b" or "c" is missing // accept if no more "a" "b" or "c" final q6 start q0 limit 100 q0 a q1 X R convert left most "a" to "X" q0 Y q4 Y R no more a's do check for only Y's and Z's q1 a q1 a R skip over a's and Y's q1 Y q1 Y R q1 b q2 Y R convert left most "b" to "Y" q2 b q2 b R skip over b's and Z's q2 Z q2 Z R q2 c q3 Z L convert left most "c" to "Z" q3 a q3 a L back up over a's, b's, Y's and Z's, stop on first "X" q3 b q3 b L q3 Y q3 Y L q3 Z q3 Z L q3 X q0 X R ready for next pass q4 Y q4 Y R skip over Y's, must find Z q4 Z q5 Z R q5 Z q5 Z R skip over Z's q5 #] q6 ## N end of input, no b's or c's left to get here, accept q6 #] q6 // done this is the final state enddef tape abc accept tape bac reject tape bb reject tape aa reject tape cc reject tape aabc reject tape abbc reject tape abcc reject tape aaabbbccc accept