By Hopcroft John. Introduction to Automata Theory, Languages, and Computation.