The Timpson Lyceum seal

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

Finite automaton (formal definition)

A finite automaton is a 5-tuple M=(Q,Σ,δ,q0,F)M = (Q, \Sigma, \delta, q_0, F) where:

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 δ\delta 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 M=(Q,Σ,δ,q0,F)M = (Q, \Sigma, \delta, q_0, F) and let w=w1w2⋯wnw = w_1 w_2 \cdots w_n with each wi∈Σw_i \in \Sigma. Then MM accepts ww if there exists a sequence of states r0,r1,…,rn∈Qr_0, r_1, \dots, r_n \in Q such that:

  1. r0=q0r_0 = q_0 (start in the start state),
  2. δ(ri,wi+1)=ri+1\delta(r_i, w_{i+1}) = r_{i+1} for i=0,1,…,n−1i = 0, 1, \dots, n-1 (each step follows the transition function), and
  3. rn∈Fr_n \in F (end in an accept state).

Note there is one more state than symbols (n+1n+1 states for a string of length nn), 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 A={0n1n:n≥0}A = \{0^n 1^n : n \ge 0\} 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 AA and BB)

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 (3−10∉N3 - 10 \notin \mathbb{N}); 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 A1,A2A_1, A_2 recognized by M1=(Q1,Σ,δ1,q1,F1)M_1 = (Q_1, \Sigma, \delta_1, q_1, F_1) and M2=(Q2,Σ,δ2,q2,F2)M_2 = (Q_2, \Sigma, \delta_2, q_2, F_2), 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 M=(Q,Σ,δ,q0,F)M = (Q, \Sigma, \delta, q_0, F) is defined by:

Q=Q1×Q2δ((r1,r2), a)=(δ1(r1,a), δ2(r2,a))q0=(q1, q2)F={(s,t):s∈F1}  ∪  {(s,t):t∈F2}\begin{aligned} Q &= Q_1 \times Q_2 \\ \delta\bigl((r_1, r_2),\, a\bigr) &= \bigl(\delta_1(r_1, a),\, \delta_2(r_2, a)\bigr) \\ q_0 &= (q_1,\, q_2) \\ F &= \{(s, t) : s \in F_1\} \;\cup\; \{(s, t) : t \in F_2\} \end{aligned}

Then L(M)=A1∪A2L(M) = A_1 \cup A_2, so A1∪A2A_1 \cup A_2 is regular.

Concrete instance. Let M1M_1 recognize "even number of 00s" (states q0,q1q_0, q_1, start/accept q0q_0) and M2M_2 recognize "even number of 11s" (states q2,q3q_2, q_3, start/accept q2q_2). The product machine starts at (q0,q2)(q_0, q_2). Reading symbol 11 from that start state:

δ((q0,q2), 1)=(δ1(q0,1), δ2(q2,1))=(q0, q3)\begin{aligned} \delta\bigl((q_0, q_2),\, 1\bigr) &= \bigl(\delta_1(q_0, 1),\, \delta_2(q_2, 1)\bigr) \\ &= (q_0,\, q_3) \end{aligned}

Since the first component q0∈F1q_0 \in F_1, the pair (q0,q3)(q_0, q_3) is an accept state, so the machine accepts a string like 1001110011 (even number of 00s, odd number of 11s) — exactly because M1M_1 alone would accept it.

Why concatenation is harder. To recognize strings whose first part has an even number of 00s and whose second part has an even number of 11s, the tempting fix is to jump from M1M_1's accept state to M2M_2'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 00110010011001, splitting after the fourth symbol gives an even number of 00s then an even number of 11s (should accept), yet a deterministic machine has no way to guess that split point. This dead end motivates nondeterminism.

Summary