Premium Chapter

Automata: DFA, NFA, PDA, TM

Computer Science & Applications (Paper 2) (Code 87) · Unit 8 · ~26 min read · Original chapter

Free previewPremium full chapter

Free preview

An automaton is a simple abstract machine: it reads an input string symbol by symbol and decides whether to accept it. The set of strings it accepts is its language. Different machines accept different families of languages, and that hierarchy is the whole topic. A finite automaton has a finite number of states and no memory beyond its current state. A deterministic finite automaton (DFA) has exactly one transition per symbol from each state. A nondeterministic finite automaton (NFA) may have several transitions, or none, for a symbol, and may also move on empty input (epsilon transitions). Every NFA can be converted to an equivalent DFA by subset construction: each DFA state represents a set of NFA states. An NFA with n states needs at most 2^n DFA states, though the minimal DFA is often much smaller.

Languages accepted by finite automata are called regular languages. They are exactly the languages described by regular expressions, and they are closed under union, intersection, complement and concatenation. The pumping lemma for regular languages proves non-regularity: if a language were regular, every long enough string in it could be split into xyz with y pumped any number of times while staying in the language. The language {a^n b^n | n ≥ 0} fails this test, because pumping changes the balance between a's and b's, so it is not regular. It needs a memory — a stack — which is what a pushdown automaton adds.

Worked example — a minimal DFA for "even number of 0s". Over the alphabet {0, 1}, two states suffice: state EVEN (accepting, start) and state ODD. Reading 0 toggles between them; reading 1 stays in the same state. Any string ending in EVEN has an even number of 0s, including zero 0s. Two states are minimal: one state cannot remember parity, and no third state is needed. This is the pattern for counting-modulo languages: a DFA for "number of 0s divisible by 3" needs exactly 3 states.

Checking premium access…