- Regular languages play an important role in lexical analysis (the scanner) for a compiler.

The book requires GNFAs to have the following three properties:

- The start state has transition arrows going to every other state but no arrows coming in from any other state.
- There is only a single accept state, and it has arrows coming in from every other state but no arrows going to any other state. Furthermore, the accept state is not the start state.
- Except for the start and accept states, one arrow goes from every state to every other state and also from each state to itself.

A **generalized nondeterministic finite automaton (GNFA)** is a 5-tuple where

- Q is the finite set of states,
- Σ is the alphabet,
- δ(Q - {q
_{accept}}) × (Q - {q_{start}}) —> R is the transition function (R is a regular expression), - q
_{start}is the start state, and - q
_{accept}is the accept state.

A GNFA **accepts** a string *w* in Σ^{*} if
*w = w _{1}...w_{k}* where each w

- q
_{0}= q_{start}is the start state, - q
_{k}= q_{accept}is the accept state, and - for each i,
*w*∈ L(R_{i}_{i}) where R_{i}= δ(q_{i-1}, q_{i}).

- Create an n+2 state GNFA from an n state DFA as follows:
- Add a new start state with an ε transition to the DFA start state.
- Add a new accept state with ε transitions from the DFA accept states to the new accept state. (Change the DFA accept states to non-accept states.)
- A transition should contain the union of the DFA transition labels.
- Add the ∅ transition to pairs of states in the DFA that had no transition between them.

- Repeatedly rip out one of the former DFA states using the following
procedure until only the start state and accept state are left
- Call the state being removed q
_{rip} - Consider a pair of states q
_{j}and q_{k} - if q
_{j}goes to q_{rip}with R_{1}, q_{rip}goes to q_{rip}with R_{2}, q_{rip}goes to q_{k}with R_{3}, and q_{j}goes to q_{k}with R_{4}, then the transition from q_{j}to q_{k}in the machine with q_{rip}removed is now R_{1}(R_{2})^{*}R_{3}∪ R_{4}.

- Call the state being removed q
- The regular expression equivalent appears on the transition from the start state to the accept state.

- Construct a DFA that recognizes any string that starts with an a over Σ = {a, b}.
- Using the procedure above, find the equivalent regular expression.

- Construct a DFA that recognizes any string that starts with an a and ends with a b over Σ = {a, b}.
- Using the procedure above, find the equivalent regular expression.

- Understand Example 1.68 on page 76.