





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
State-transition diagrams, which describe deterministic finite automata (DFAs) and nondeterministic finite automata (NFAs). DFAs are used to specify sets of identifiers, while NFAs can recognize more complex languages. examples, definitions, and explanations of how to construct state diagrams for various languages. Students in a CISC223 course during the Winter 2014 semester would find this material useful for understanding state diagrams and their applications.
Typology: Study notes
1 / 9
This page cannot be seen from the preview
Don't miss anything!






This material is from Chapter 8 in the textbook.
Example. An identifier can be defined as a string of letters and digits that begins with a letter.
The set of identifiers is specified by the state-transition diagram in Figure 1.
Figure 1: A state-diagram for specifying identifiers.
Example. We design a “sequential lock” as described below. The lock has 1-bit sequential input. Initially, the lock is closed. If the lock is closed it will open when the last three input bits are “1”, “0”, “1”, and then remains open. In other words, the state-transition diagram should accept exactly all strings that contain substring 101. The state-transition diagram will be constructed in class. What is a regular expression that denotes the same language?
A state diagram describes a deterministic finite automaton (DFA), a machine that at any given time is in one of finitely many states, and whose state changes according to a predetermined way in response to a sequence of input symbols.
A formal definition is given below. Definition. A DFA is defined as a tuple
M = (Q, Σ, δ, s, F )
where the components are as follows:
Example. Consider the state diagram in Figure 2.
1
(^01)
0
1
0
1
q 1 q 2
q 4 q 3
0
Figure 2: A state-transition diagram. In a formal notation this automaton can be specified as M = (Q, Σ, δ, s, F )
Example. Construct a state diagram for recognizing comments that may go over several lines: /* ......*/
b
b
Figure 3: Nondeterministic transitions.
When dealing with nondeterministic state diagrams it is important to remember that now a given string may label more than one path beginning from the starting state and we have to be careful how the acceptance of a string is defined: Nondeterministic acceptance: a string is accepted if it appears on any path from the starting state to an accepting state.
Why nondeterminism?
Example. Consider the following nondeterministic state diagram with input alphabet { 0 , 1 }:
Figure 4: A nondeterministic state diagram.
Nondeterministic state diagrams are also called nondeterministic finite automata, NFA.
Example. Let Σ = { 0 , 1 } and define
S 1 = Σ∗01Σ∗ S 2 = {w ∈ Σ∗^ | w has an even number of 1’s } The following state diagram recognizes S 1 ∪ S 2 :
*
HHH HHH Hj
Figure 6: A state diagram for S 1 ∪ S 2.
A state diagram with ε-transitions is called an ε-NFA. Given an ε-NFA M we can construct an equivalent NFA without ε-transitions as follows (see page 183 in the textbook):
Figure 7: A chain of ε-transitions followed by a “real” transition.
we add to M′^ a transition from state q to state p that is labeled by x. Note that here q and p may be any states. For example, the above construction step is used also in the case where q = p.
Example. How does the construction work with the state diagram:
Figure 8: An ε-NFA.
Example. The below state diagram (Figure 9) recognizes unsigned decimal numbers:
& %
6
?
?
Figure 9: An ε-NFA for unsigned decimal numbers.
We construct an equivalent nondeterministic state diagram without ε-transitions (in class).
Note: By combining the above two transformations, that is, the elimination of ε-transitions and the subset construction, we can always convert a state diagram with ε-transitions to a deterministic state diagram.