J. E. Hopcroft and J. D. Ullman.Introduction to Automata Theory, Languages, and Computation.