The Timpson Lyceum · Computation Theory
Lecture 4 (Computation Theory) Finite Automata
Overview
This lecture builds the foundations of finite automata. It first fixes the basic vocabulary of formal-language theory — alphabets, symbols, strings, string length, and languages — then motivates a finite-state machine with a concrete automatic-door example before giving the formal five-tuple definition of a finite automaton. It develops a precise mathematical definition of what it means for a machine to accept a string, defines a regular language as one recognized by some finite automaton, and introduces the three regular operations (union, concatenation, and star). It closes by proving that the regular languages are closed under union via an explicit product (cross-product) construction, and shows why naively chaining two machines fails to recognize a concatenation — the motivation for nondeterminism in the next lecture.
Key Concepts
Basic terminology
- Alphabet — a non-empty finite set, usually written (or ). Its members are just symbols, not numbers. Examples: , , . A multi-character symbol is written in angle brackets, e.g. , and treated as one symbol.
- Symbol — any member of an alphabet.
- String — a finite sequence of symbols, written with no separators, e.g. . In this setting a string of s and s is never read as a number.
- String length — the number of symbols in , written . For , .
- Language — a set of strings (over some alphabet).
- Empty string — written , the string with no symbols. It is not the empty set ; is the empty list, while is the empty language (a set containing no strings).
Finite automaton (formal definition)
A finite automaton is a 5-tuple where:
- — a finite set of states.
- — the alphabet (the input symbols).
- — the transition function. Given the current state and the next input symbol, it returns the next state. (Reading line 3 of this definition correctly is the heart of understanding automata.)
- — the start state (exactly one).
- — the set of accept states (possibly empty, possibly more than one).
A machine is drawn as a diagram: each state is a circle, the start state has an incoming external arrow, accept states are drawn with a double circle, and each transition is a labeled arrow. The diagram, the transition table, and the explicit set of ordered pairs for all carry the same information — you should be able to convert freely among them. (A finite automaton resembles a directed graph but is a different object: a graph is a 2-tuple, an automaton a 5-tuple.)
Acceptance (formal definition)
Let and let with each . Then accepts if there exists a sequence of states such that:
- (start in the start state),
- for (each step follows the transition function), and
- (end in an accept state).
Note there is one more state than symbols ( states for a string of length ), since the sequence includes the state before reading any symbol.
Regular language
A language is regular if some finite automaton recognizes it. If you can build a machine accepting exactly that language, the language is regular by definition; a single regular language can be recognized by many different machines (and has a unique minimal one). The language is not regular — no finite automaton can recognize it, because tracking an arbitrary count needs unboundedly many states (this requires a more powerful model, a pushdown automaton / context-free grammar).
Regular operations (for languages and )
- Union: .
- Concatenation: — every string of followed by every string of . Order matters: in general. This produces strings (a language), unlike the Cartesian product , which produces ordered pairs.
- Star (Kleene star): — any number (including zero) of strings from concatenated. Because is allowed, always; if is non-empty, is infinite.
Closure
An operation is closed on a set if applying it to members of the set always yields a member of the set. The natural numbers are closed under addition but not subtraction (); the integers are closed under multiplication but not division. A major goal of the chapter is to show the regular languages are closed under union, concatenation, and star.
Worked Example
Product construction for union. To show the regular languages are closed under union: given regular recognized by and , build a single machine that simulates both at once. Its states are all pairs of states (one from each machine); it accepts when either component is in an accept state.
The new machine is defined by:
Then , so is regular.
Concrete instance. Let recognize "even number of s" (states , start/accept ) and recognize "even number of s" (states , start/accept ). The product machine starts at . Reading symbol from that start state:
Since the first component , the pair is an accept state, so the machine accepts a string like (even number of s, odd number of s) — exactly because alone would accept it.
Why concatenation is harder. To recognize strings whose first part has an even number of s and whose second part has an even number of s, the tempting fix is to jump from 's accept state to 's start state. But the machine cannot know where to split the input — at which point the "first part" ends and the "second part" begins. On , splitting after the fourth symbol gives an even number of s then an even number of s (should accept), yet a deterministic machine has no way to guess that split point. This dead end motivates nondeterminism.
Summary
- An alphabet is a non-empty finite set; its members are symbols, a string is a finite sequence of symbols, and a language is a set of strings. (empty string) and (empty language) are different objects.
- A finite automaton is the 5-tuple ; its transition function maps a (state, symbol) pair to the next state.
- accepts when there is a state sequence starting at , following on each symbol, and ending in an accept state ().
- A language is regular iff some finite automaton recognizes it; many machines can recognize the same regular language, while is not regular.
- The three regular operations are union, concatenation (, order-sensitive), and star (, any number of concatenations, always containing ).
- The regular languages are closed under union, proved by the product construction that runs both machines simultaneously; deterministically combining machines for concatenation fails because the split point is unknown.