Lec 07 Transition Graphs
Lec 07 Transition Graphs
Transition Graphs
• Looking at TGs
• Nondeterminism
2
Relaxing the Restriction on Inputs
Relaxing the restrictions on inputs
• Beginning at the start state, anything but the string baa will
drop down into the garbage collecting state and never be
seen again. Even the string baabb will fail.
• Hence the language accepted by this FA is L = {baa}
4
Relaxing restrictions on input
• Let us relax the restriction that an FA can only read one letter from the
input string at a time
• Suppose we now allow a machine to read either one or two letters of the
input string at a time. Then we may design a machine that accepts only
the word baa with fewer states as the one below:
5
Definition of A Transition Graph (NFA)
6
• We should note the following from the definition of a TG:
1. Clause 3 in the definition means that every edge is labeled by some string
or strings of letters, not necessarily only one letter.
7
Example
Consider the Language L , defined over Σ = {a, b} of all
strings including Λ. The language L may be accepted by the
following TG
8
Example
• Consider the Language L of strings, defined over Σ = {a, b},
containing double a.
9
Example
• Consider the language L of strings, defined over Σ={a, b},
having double a or double b.
• The language L can be expressed by RE (a+b)* (aa + bb)
(a+b)*.
• The above language may also be expressed by the following
TGs.
10
Example
• The path from state 1 to state 2 to state 3 back to state 1 and then to the
final state 4 corresponds to the string (abb)(Λ)(aa)(b) = abbaab.
• When an edge is labeled with Λ, it means that we can take the ride it
offers for free (without consuming any letter from the input string).
11
Example contd.
12
• Because we allow some edges to be traversed for free, it is
logical to allow for the possibility of more than one start
state, as illustrated below:
• These two machines are equivalent, in the sense that all the
strings accepted by the first are accepted by the second and
vise versa.
• Important Note: Every FA is also a TG. However, NOT every
TG satisfies the definition of an FA.
13
Looking at TGs
15
Example
16
Example
17
Example
• We can read all the input letters, one at a time, and stay in the left-side
state. When we read a b, if it is the very last letter of the input string, we
can use it to go to the final state. Note that this b must be the very last
letter, because once we are in the right-side state, if we try to read
another letter, we will crash.
• However, all words ending with a b can be accepted by some path. Hence,
the language accepted by this TG is (a + b)*b.
18
Example
• In this TG, every edge is labeled with a pair of letters. Thus, for a string to
be accepted, it must have an even number of letters.
• Let’s call the left state the balanced state, and the right state the
unbalanced state.
• If the first pair of letters that we read is a double (aa or bb), then we stay
in the balanced state. While in the balanced state, we have read an even
number of a’s and an even number of b’s.
19
EVEN-EVEN
• When a pair of unmatched letters is read (ab or ba), the machine flips over
to the unbalanced state, meaning that it has read an odd number of a’s
and an odd number of b’s.
• Recall that EVEN - EVEN is the language of all words containing an even
number of a’s and an even number of b’s, including the null string Λ.
20
Generalized Transition Graphs
(GTG)
Definition
22
Example
23
• Note that there is no difference between the Kleene star
closure for regular expressions and a loop in transition graphs,
as illustrated in the following figure:
24
NonDeterminism
NonDeterminism
26
NonDeterminism
27