Source: https://www3.cs.stonybrook.edu/~pramod.ganapathi/doc/theory-of-computation/FiniteAutomata.pdf