Unreachable states
A finite automaton may have states that cannot be reached. We call such states unreachable states. We typically want to remove them, because they only make the whole automaton needlessly complicated.
Example of unreachable states
Take this automaton:
We can see that whatever we do, we never get to state q3, because no transition leads into it. We say that state q3 is unreachable. A question: would state q3 be reachable if a transition from another state led into it? If we drew an edge from one of the states q0, q1, q2, q5, it would be reachable. If we added another node and drew a transition from it…
…then of course both states q3 and q4 would be unreachable.
Definition of an unreachable state
First we define a reachable state. Take a finite automaton A = ⟨Q, Σ, δ, q0, F⟩. We say that a state q ∈ Q is reachable if there exists a string w ∈ Σ∗ such that
A state q ∈ Q is unreachable if it is not reachable.
How to remove unreachable states
If an automaton already has some unreachable states, it is a good idea to remove them. We construct an equivalent automaton A′ = ⟨Q′, Σ, δ′, q0, F′⟩ that has no unreachable states.
We build the set of reachable states iteratively. We start with the set S0 = {q0}, because the start state is certainly reachable. We build the next set like this:
In plain words, the set S0 is always given, and we build the set S1 by taking all the states in the set S0 and finding where the transitions for all the symbols of Σ lead. We take the union of these states and the original set of states S0. We find the set S2 and the following sets in the same way. Clearly Si − 1 ⊆ Si.
We can then obtain the set of reachable states like this:
It may look strange that we are trying to take the union of infinitely many sets Si, but the automaton has only a finite number of states. This means that at some point the sets Sj and Sj + 1 and all the following ones will be the same, so even after taking the union of infinitely many sets we can get a finite set of states.
Let’s go back to the automaton
and try to find the set of reachable states. We start by stating the basic equality
Now we work out the set S1. We have to find all the transitions from state q0 and add their target states to the set S0. Because q0 → a q1 and q0 → bq2, the set S1 will additionally contain the states q1 and q2:
Next we construct the set S2. We look at where we can get to from the states q0, q1, q2. The only new state is q5, which we can reach from state q1:
Next we build the set S3. Can we get to any new state from the states q0, q1, q2, q5? We cannot, so the set S3 will contain the same elements as S2:
Because S2 = S3, we also have S3 = S4 = S5 = … If we take the union of all the Si, we get the set S2, because no further element is added in any later set.
So the set of reachable states of the automaton is {q0, q1, q2, q5}. We get the unreachable states by a simple set difference:
The set of unreachable states of our automaton is {q3, q4}. We remove from the automaton A all the unreachable states and all the transitions that involved an unreachable state. That is, we define the equivalent automaton A′ = ⟨Q′, Σ, δ′, q0, F′⟩ without unreachable states for the automaton A = ⟨Q, Σ, δ, q0, F⟩ as:
- ∀q ∈ Q′, a ∈ Σ: δ′(q, a) = δ(q, a)
Sources
Chapters: Unreachable states, Redundant states, DFA minimisation