Finite Automata

02-11-2026

Overview

Finite automata is a branch of automata used heavily in compilers. The idea is to formalize a representation for Recognizers in a way that can be programmed in then be used in the scanning process. Formally, FAs consist of a finite amount of states SS, an alphabet ∑\sum, a transition function δ(s,c)\delta(s,c), a start state s0s_0, and a set of accepting states SAS_A. The idea is that an FA accepts a string x if and only if, beginning at the start state, the sequence of characters in x terminate in an accepting state. Formally:

δ(δ(…δ(δ(δ(s0,x1),x2),x3)…,xn−1),xn)∈Sa\delta(\delta(\dots\delta(\delta(\delta(s_{0,}x_{1}),x_{2}),x_{3})\dots, x_{n-1}),x_{n}) \in S_{a}

Of course, input is not always meant to be expected. In the context of programming, a keyword may be misspelled, or there may be some other syntax error. In this case, the transition function would map to an error state SeS_e. From a programming perspective, the pseudocode here is relatively simple:

state <- S0
char <- NextChar()

while (state != SE and char != eof) do
	state <- transitionFunction(state, char)
	char <- NextChar()
end

if (state is an accepting state) then
	success
else
	failure

FA as Recognizer Specs

As stated at the beginning of the note, finite automata is typically leveraged as a specification tool for recognizers. However, what we have learned thus far is not necessarily enough to complete this mapping yet. We are missing a concrete way to specify structure of words. While conceptually we have everything we need, we are missing a tool: Regular Expressions.