Lecture 22: Finite automata

Overview

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:

example automaton (click for LaTeX)

example automaton (click for LaTeX)

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:

Definitions

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.

With these definitions, we can say what it means for the machine to accept or reject a string:

Definition: If \(\hat{δ}(q_0,x) \in F\) then \(M\) accepts \(x\). Otherwise, \(M\) rejects \(x\).

Definition: A language is a set of strings, i.e. a subset of \(Σ^*\).

Definition: The language of \(M\), denoted \(L(M)\) is given by \[L(M) ::= \{x \in \Sigma^* \mid M\text{ accepts }x\} = \{x \in \Sigma^* \mid \hat{\delta}(q_0,x) \in F\}\]

Definition: We say a language \(L\) is recognized by \(M\) if \(L = L(M)\).

Definition: A language \(L\) is DFA-recognizable if there exists some DFA \(M\) that recognizes \(L\).

A bogus proof

Here is a mistake that students often make, and one that it is important not to make. We are primarily interested in whether entire languages are recognized by machines, rather than particular strings. It does not make sense to say that a string is recognized, or that a language is accepted, and just because all of the strings in the language \(L\) are accepted by \(M\), does not mean that \(L\) is recognized by \(M\).

This is important, because otherwise the whole theory of automata becomes trivial:

(False) claim: Every language \(L\) is recognizable.

(Bogus) proof: Let \(M\) be a machine with one final state \(q\); and a transition function that takes \(q\) back to \(q\) on every character of \(Σ\). Clearly \(M\) accepts every string in \(L\), so \(M\) recognizes \(L\), and therefore \(L\) is recognizable.

This is bogus, because it only proves that \(L \subseteq L(M)\), not that \(L = L(M)\). To show \(L = L(M)\), you must show both that every \(x \in L\) is in \(L(M)\) and that every \(x \notin L\) is not in \(L(M)\).