- #1

- 1,030

- 4

## Main Question or Discussion Point

Is there an algorithm for converting DFA (or NFA) into regular expressions?

- Thread starter Dragonfall
- Start date

- #1

- 1,030

- 4

Is there an algorithm for converting DFA (or NFA) into regular expressions?

- #2

- 52

- 0

A GNFA is simply a NFA that accepts regular expressions on arrows instead of just symbols. The general idea is as follows:

1. Take any NFA, and add two states we call start and end. Add an epsilon-arrow from start to the previous start state, and add an epsilon-arrow from all previous final states to the end state. Now start is the only start state, and end is the only end state.

2. If start and end are the only states then we take the regular expression on the arrow between them and are done, if not we go to 3.

3. We pick a state Q that is not start or end. Let R be the arrow from Q to itself. Now from every state A that has an arrow C to Q, for every state B that has an arrow D from Q we add an arrow from A to B with the label CR*D.

4. We remove the state Q and all arrows to it, since we have constructed replacements.

5. If there exist two states A and B such that there are several arrow from A to B, then we reduce them to one by taking the union of all the arrows.

6. Go to step 2.

- Replies
- 20

- Views
- 12K

- Last Post

- Replies
- 3

- Views
- 3K

- Last Post

- Replies
- 3

- Views
- 3K

- Replies
- 1

- Views
- 16K

- Last Post

- Replies
- 2

- Views
- 3K

- Last Post

- Replies
- 1

- Views
- 2K

- Last Post

- Replies
- 2

- Views
- 2K

- Last Post

- Replies
- 2

- Views
- 828

- Last Post

- Replies
- 5

- Views
- 920

- Last Post

- Replies
- 2

- Views
- 3K