Nondeterministic Finite State Automata: Examples
CS390, Fall 2019
Abstract
Practice designing and working with NFAs.
1 JFLAP

Return to the Finite Automata_ section of the Tutorial. Read the subsection devoted to Nondeterministic Finite Automata, specifically the sections titled “Construct and Run”, “Manipulating Transitions”, and "“Add a Trap State to DFA”. Also read “Convert to DFA”.

The NFA shown to the right is intended to accept the language ${aa,aab}^{*}{b}$. Try creating it in JFlap and running it on each of the following inputs to see if it works as expected:
 b
 aa
 aab
 aabb
 aaab
 aaaab
 aaaabb
 aaaabbb
Save your NFA.

Try constructing the NFA in Figure 3.10 of your text. This one uses a lambda transition, unlike the previous one.
Note: JFLAP marks lambda transitions with a lowercase $\lambda$ instead of the uppercase $\Lambda$ used in your textbook. Both conventions are quite common. I actually prefer the lowercase myself because elsewhere we have been following the convention of using uppercase (Roman) letters to denote sets and lowercase letter to denote individual symbols from our alphabet.
Try running your NFA on each of the following inputs to see if it works as expected:
 a
 aa
 aab
 aba
 aaba
 aabaab
 aabaaba
 aababa
 abaaab
Save your NFA.

JFLAP can convert NFAs to DFAs. Try converting each of your saved NFAs. Notice that the process used is directly comparable to the process described in section 3.3 of your text.

Look back at the example I gave of an NFA for the union of two languages.
Here is the NFA for the union.
Note: By default, JFLAP marks instantaneous transitions with a $\lambda$ instead of the $\epsilon$ used in your textbook. Both conventions are quite common. But for the sake of consistency, change the option in the JFLAP settings to use $\epsilon$.
Run this NFA on the following inputs, “Step” by step, observing how transitions take us to multiple states at once. Take note of which inputs are accepted.
 a
 b
 ba
 aba
 babba
 aabba

Use JFlap to convert this to a DFA. Compare the results and the steps with what we went through in the lecture notes.

Run the same inputs as the previous step through this new DFA. Convince yourself that it does accept the inputs that the NFA did.

Revisit some of the DFA problems that you worked in the final step of the earlier JFLAP exercise. Try rewriting some of them as NFAs.

In many cases, an NFA will use fewer states and transitions than the corresponding DFA. Certainly, it should never need more states or transitions than a DFA (because every DFA is also an NFA that just happens to not use nondeterminism).

You can think of this simplification as the payoff for the slightly more complicated conceptual effort involved in understanding nondeterminism.


Exercise 2.3.4 at the end of section 2.3 2 of your text suggests drawing a number of NFAs. Pick one or two of these and create them in JFLAP. Run a handful of inputs through each one to convince yourself that you have done so correctly.
2 Sample Problems
Try to solve these on your own, first, then check my answer. If you don’t see where I got my answer from, the videos will walk you through my thought process. If you want to check my answer, my JFLAP files are provided.
2.1 Basic Patterns
Design an NFSA to recognize the language consisting of…

the string 101

all strings beginning with 101
Reveal 
all strings ending with 101
Reveal 
all strings containing 101
Reveal
2.2 Combining Smaller Machines into Larger Ones
2.2.1 Sequencing
Putting two NSAs together in a sequence is, roughly speaking, accomplished by “connecting” each final state of the first FSA to the starting state of the second one with an $\epsilon$ transition.
No merging is required.
Design an FSA to recognize the language consisting of…
2.2.2 Alternation (Choice)
Join the alternatives at initial and accepting states to a common start and end with $\epsilon$ transitions.
Design an FSA to recognize the language consisting of…
2.2.3 Repetition
Design an FSA to recognize the language consisting of…

All strings containing one or more instances of 101
Reveal 
All strings containing zero or more instances of 101
Reveal 
all strings composed of 1 or more (nonoverlapping) occurrences of 101
Reveal 
all strings composed of zero or more occurrences of 101 only
Reveal 
all strings that do not contain 101
Reveal
2.3 Converting An NFA to a DFA
 Convert the automaton below to a deterministic FA.
Reveal
^