We started with a second example proof by structural induction; this has been added to the end of the notes for lecture 20
We defined deterministic finite automata, and the extended transition function
An automaton is an extremely simple model of a computer or a program. The automata we will study examine an input string character by character and either say "yes" (accept the string) or "no" (reject the string).
Automata are defined by state transition diagrams. Here is one example:
This automaton processes strings containing the characters 0 and 1. It contains 4 states, \(q_{ee}\), \(q_{eo}\), \(q_{oe}\) and \(q_{oo}\).
While processing a string \(x\), the machine starts at the beginning of \(x\), and in the start state \(q_{ee}\) (as indicated by the arrow pointing to \(q_{ee}\)). As it processes each character, it follows the corresponding transitions (arrows). When it has finished processing the string, if it is in a final state (\(q_{eo}\) in this case, as indicated by the double circle), it accepts \(x\); otherwise it rejects \(x\).
For example, while processing \(1000110\), the machine will start in state \(q_{ee}\), then transition in order to states \(q_{eo}\) (after processing the 1), \(q_{oo}\) (after the first 0), then \(q_{eo}\), \(q_{oo}\), \(q_{eo}\), \(q_{ee}\), and finally end up in \(q_{eo}\). Since \(q_{eo}\) is an accepting state, the string \(1000110\) is accepted.
Although this model of computation is very limited, it is sophisticated enough to demonstrate several kinds of analysis that apply to more sophisticated models:
we'll talk about translating "programs" (automata) from one representation to another, and proving that those translations are correct. This is analagous to building and verifying compilers
we'll show how to optimise automata, again proving that our optimizations don't change the behavior of the program
we'll show that there are specifications (sets of strings) that can't be recognized by any automaton. Similar results apply to fully general models of computation, and have important practical implications.
we'll talk about non-determinism, an important concept when reasoning about programs.
Before we do any of that, we need to formalize the informal definition of an automaton and its operation.
Definitions: A deterministic finite automaton \(M\) is a 5-tuple \(M = (Q,Σ,δ,q_0,F)\), where
In the example diagram above,
\(q\) | \(a\) | \(δ(q,a)\) |
---|---|---|
\(q_{ee}\) | 0 | \(q_{oe}\) |
\(q_{ee}\) | 1 | \(q_{eo}\) |
\(q_{eo}\) | 0 | \(q_{oo}\) |
\(q_{eo}\) | 1 | \(q_{ee}\) |
\(q_{oe}\) | 0 | \(q_{ee}\) |
\(q_{oe}\) | 1 | \(q_{oo}\) |
\(q_{oo}\) | 0 | \(q_{eo}\) |
\(q_{oo}\) | 1 | \(q_{oe}\) |
Given an automaton \(M\), we define the extended transition function \(\hat{δ} : Q \times \Sigma^{\bf *} → Q\). Informally, \(\hat{δ}(q,x)\) tells us where \(M\) ends up after processing the entire string \(x\); contrast the domain with that of \(δ\), which processes only a single character. This distinction is important: since \(δ\) only processes characters, its domain is finite, so the description of the machine is finite; but \(\hat{δ}\) (which is not part of the description of the machine) can process an infinite number of strings.
Definition: Formally, we define the extended transition function \(\hat{δ} : Q \times Σ^* → Q\) inductively by \(\hat{δ}(q,ε) = q\), and \(\hat{δ}(q,xa) = δ(\hat{δ}(q,x), a)\).
The first part of this definition says that processing the empty string doesn't move the machine; the second part says that to process \(xa\), you first process \(x\), and then take one more step using \(a\) from wherever \(x\) gets you.