We've seen a method for constructing ε-NFAs from regular expressions. However, using an ε-NFA to recognize a string as part of a language is tricky. We will look at a method to convert ε-NFAs to NFAs to simplify the recognition process.
Example
Observe the following ε-NFA:
This recognizes the string "a". Because the ε transition doesn't consume an input symbol, it can be simplified to the following:
Note that we've done some state relabelling for readability after s1 was eliminated from the original machine.
Similarly, the following ε-NFA recognizes the same language:
When we are converting an ε-NFA into an NFA, we may encounter a sequence of ε transitions linking state s0 through sn - 2, followed by a transition with input symbol σ from state sn - 2 to state sn - 1. We can replace it with a two-state construction of state s0 transitioning to sn - 1 on input symbol σ.
This allows us to eliminate leading ε transitions and unnecessary states, simplifying our automaton without affecting the set of strings it accepts.
Example
Observe the following ε-NFA:
This recognizes the string "a". Because the ε transition doesn't consume an input symbol, it can be simplified to the following:
Similarly, the following ε-NFA recognizes the same language:
When we are converting an ε-NFA into an NFA, we may encounter a sequence of ε transitions linking state s1 through sn - 1 following a transition with input symbol σ from state s0 to state s1. We can replace it with a two-state construction of state s0 transitioning to sn - 1 with input symbol σ. If sn - 1 was accepting in the initial construction, it will be in the new construction.
This allows us to remove trailing states without affecting the set of strings accepted by the automaton.
Following the above rules, we can convert an ε-NFA into an NFA, removing all ε transitions. However, we may still have states with multiple transitions corresponding to the same symbol.
Example
Using the same rules as above, this can be reduced to the following NFA (which happens to, by chance, also be a DFA):
GitHub Repository: https://github.com/bprollinson/ripal
Copyright © 2017 Brendan Rollinson-Lorimer