Finite Automata (FAs) are the simplest model of computation we will study. They are essentially programs that solve certain decision problems without using any variables or complex memory. They process input in a single pass, from left to right, and the result is known immediately after reading the last symbol.
3.1 Aims
Our goal here is not to provide a comprehensive course on Automata Theory. Instead, we use FAs as a didactic tool, a laboratory for introducing and understanding fundamental concepts of computation in a simple, visual way. We will explore:
- Modeling Computation: How to formally describe a computation.
- Core Concepts: We will define and build intuition for key ideas like Configuration, Computation Step, Simulation, Determinism, and Nondeterminism.
- Proofs of Limitation: We will learn how to prove that a specific task is unsolvable by a given class of algorithms.
Grasping these concepts with FAs will make it much easier to understand them later in the more general and powerful context of Turing machines.
3.2 Representations of Finite Automata
To define a model of computation, we must answer a few basic questions:
- What elementary operations are available?
- How much memory is available, and how is it used?
- How is input provided and output determined?
For FAs, the answer is stark: there is no memory besides the program itself and a pointer to the current instruction. This means no variables. The only changing piece of information is the program counter, which we will come to know as the automaton’s state.
A Program-like Representation
Let’s imagine an FA as a simple program. If the input alphabet is , the only allowed operation is a multi-way branch based on the next input symbol. Each line of the program corresponds to a state.
Consider a program A
over with four lines (states 0, 1, 2, 3). The program starts at line 0. A set of lines are designated as “accepting” lines. If the program finishes on a line in , the input is accepted.
Example Program A:
- States:
- Accepting States:
- Program Logic:
0: if input = 1 then goto 1 else goto 2 1: if input = 1 then goto 0 else goto 3 2: if input = 0 then goto 0 else goto 3 3: if input = 0 then goto 1 else goto 2
On input 1011
, the execution trace is:
Start at 0
→ read 1
→ goto 1
→ read 0
→ goto 3
→ read 1
→ goto 2
→ read 1
→ goto 3
.
The program ends at line 3
. Since , the word 1011
is accepted.
Graphical Representation
This program-like structure can be visualized as a state transition diagram. Each state (line number) is a node. A directed edge from state i
to j
labeled with symbol a
means if input = a then goto j
when in state i
.
- The start state is marked with an incoming arrow.
- Accepting states are marked with a double circle.
The diagram for Program A is:
Formal Definition
While intuitive, diagrams and programs are not ideal for formal proofs. The standard, rigorous way to define an FA is as a mathematical object.
Definition 3.1: Deterministic Finite Automaton (DFA)
A Deterministic Finite Automaton (DFA) is a 5-tuple , where:
- is a finite set of states.
- is a finite set called the input alphabet.
- is the transition function.
- is the start state.
- is the set of accepting states (or final states).
To describe the dynamics of a DFA, we define:
- Configuration: A pair , representing that the DFA is in state with the remaining input to be read.
- Step: We write if the DFA takes a single step from configuration to . This happens if and only if .
- Computation: A sequence of configurations where for all . The computation on input is the sequence starting from the start configuration and ending in an end configuration .
- Acceptance: A DFA accepts a word if the computation on ends in a configuration where .
- Language of a DFA: The language accepted by , denoted , is the set of all words that accepts.
- Regular Languages: The class of all languages accepted by some DFA is called the class of regular languages, denoted .
For our example automaton , the computation on 1011
is:
.
Since , the word is accepted.
The Meaning of States
The key to designing and understanding DFAs is to realize that each state represents a property of the prefix of the input read so far. The automaton has finite memory, embodied by its states. It partitions the infinite set of all possible strings into a finite number of equivalence classes, where all strings in a class drive the automaton to the same state.
For our example automaton, the states represent the parity of 0s and 1s seen so far:
The accepted language is . This is equivalent to , i.e., all words of even length.
3.3 Simulations
A powerful technique in automata theory is to simulate multiple automata at once. This allows us to prove that the class of regular languages is closed under certain operations (union, intersection, complement).
Lemma 3.2: Closure Properties
If and are regular languages, then so are , , and .
Proof Idea (Product Construction)
Let and be DFAs for and . We can construct a new DFA that runs and in parallel.
- The states of are pairs where and .
- The start state of is .
- The transition function is .
The only difference for the various operations is the choice of accepting states :
- For Intersection (): . We accept if both and are in an accepting state.
- For Union (): . We accept if at least one of or is in an accepting state.
- For Complement (): We just flip the accepting and non-accepting states of . .
3.4 Proofs of Non-existence
How can we prove that a language is not regular? We must show that no DFA can accept it. The key is to exploit the DFA’s main weakness: its finite memory.
A DFA can only remember a finite amount of information about the input it has seen, because this information must be encoded in its current state, and there are only a finite number of states.
This leads to a crucial insight (the Pigeonhole Principle): if we feed a DFA an infinite number of different prefixes, it must eventually revisit a state.
Lemma 3.4: The Pumping Lemma for Regular Languages
For every regular language , there exists a constant (the pumping length) such that for any word with , can be decomposed into three parts, , satisfying:
- For all , the word is also in .
Intuition: Any sufficiently long word must cause the DFA to visit some state twice while reading the first symbols. The part of the string between these two visits is . Since we can traverse this loop () any number of times (including zero) and still end up in the same state, the resulting string must also be accepted.
How to use it: To prove a language is not regular, we use a proof by contradiction.
- Assume is regular. The Pumping Lemma gives us a pumping length .
- Choose a clever word such that .
- Show that for any possible decomposition that satisfies conditions (1) and (2), there is some for which .
- This contradicts condition (3) of the lemma, so our initial assumption must be false. is not regular.
Example: Prove is not regular.
- Assume is regular with pumping length .
- Choose . Clearly, and .
- By the lemma, with and . Because of the length constraint, must consist entirely of ‘s.
- Let’s “pump” with . The new word is .
- Since , this new word has more ‘s than ‘s or ‘s, so it is not in . This is a contradiction.
- Therefore, is not regular.
3.5 Nondeterminism
What if we relax the rules of our automata? A Nondeterministic Finite Automaton (NFA) can have multiple possible moves from a given state on a given input symbol.
Definition 3.3: Nondeterministic Finite Automaton (NFA)
An NFA is a 5-tuple , where everything is the same as a DFA except the transition function:
Here, is the power set of . The function maps a state and an input symbol (or ) to a set of possible next states.
How an NFA computes
An NFA accepts an input word if there exists at least one path of transitions from the start state to an accepting state that consumes the word . The computation can be seen as a tree of possibilities. If any branch of the tree leads to an accepting state, the word is accepted.
The Power of Nondeterminism
It might seem that NFAs are more powerful than DFAs. Surprisingly, they are not.
Satz 3.2: Equivalence of NFAs and DFAs
For every NFA, there exists an equivalent DFA (that accepts the same language).
Proof Idea (Subset Construction)
We can construct a DFA that simulates the NFA. The key idea is that the state of the DFA will correspond to the set of all possible states the NFA could be in at that moment.
- States of DFA: The power set of the NFA’s states, .
- Start State of DFA: The set containing the NFA’s start state, (and all states reachable from it via -transitions).
- Transition of DFA: If the NFA is in a set of states and reads symbol , the DFA transitions to the state corresponding to the set of all states reachable from any state in by reading .
- Accepting States of DFA: Any state (which is a set of NFA states) that contains at least one of the NFA’s original accepting states.
The Cost of Determinism
While NFAs and DFAs are equivalent in power, converting an NFA with states to a DFA can, in the worst case, result in a DFA with states. This exponential blow-up is a fundamental theme in complexity theory. Nondeterminism can sometimes offer a much more concise way to describe a language, even if it doesn’t increase the ultimate computational power.
3.6 Summary
- Finite Automata are a simple model of computation with finite memory, represented by their states.
- They are used to recognize regular languages.
- We can prove a language is not regular using the Pumping Lemma, which exploits the finite memory limitation.
- Nondeterministic Finite Automata (NFAs) allow for multiple computation paths.
- NFAs are computationally equivalent to DFAs, but converting an NFA to a DFA can lead to an exponential increase in the number of states. This highlights a fundamental trade-off between conciseness and determinism.