0% found this document useful (0 votes)
102 views13 pages

Automata Unit2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views13 pages

Automata Unit2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

0

q3/0
1 1 0
Moore and Mealy Machines: Finite automata 0
with output: The finite automata which we were q0/0 q2/0
considered in the earlier have binary output i.e. 1 1
either they accept the string or they do not accept q1/1
the string. This acceptability was decided on the 0
basis of the reachability of final state by the Transition graph
initial state. Now, we remove this restriction and input string ⟶ 0111
consider the model where the outputs can be
chosen from some other alphabets. q0 0 q3 1 q0 1 q1 1 q2
The value of the output function Z(t) in the most output ⟶ 00010
general case is a function of the present state q(t)
and present input x(t), i.e. Definition: A Mealy machine has 6-tuple
Z(t) = λ(q(t), x(t) ) (Q, Σ, Δ,δ, λ,q0), where
Where λ is called the output function. This I. Q is a finite set of states.
generalized model is usually called the mealy II. Δ is the output alphabet,
machine. III. Σ is the input alphabet,
if the output function Z(t) depends only on the IV. δ is the transition function Σ × Q into Q.
present state and is independent of the current V. λ is the output function mapping Σ × Q into Δ.
input, the output function may be written as VI. q0 is initial state.
Z(T) = λ(q(t))
this restricted model is called the Moore machine. Example: Mealy Machine

Definition: A Moore machine has 6-tuple Present Next State


State a=0 a=1
(Q, Σ, Δ,δ, λ,q0), where state output state output
I. Q is a finite set of states. ⟶q1 q3 0 q2 0
II. Σ is the input alphabet, q2 q1 1 q4 0
q3 q2 1 q1 1
III. Δ is the output alphabet,
q4 q4 1 q3 0
IV. δ is the transition function Σ × Q into Q.
V. λ is the output function mapping Q into Δ. q3
VI. q0 is initial state.
0/1
Example: Moore Machine 0/1
Present Next State Output q1 q4
state a=0 a=1 (λ )
⟶q0 q3 q1 0
q1 q1 q2 1 q2
q2 q2 q3 0
Transition graph
q3 q3 q0 0
Input string : 0011

q1 0 q3 0 q2 1 q4 1 q3
Output String = 0100
Note: for a Moore machine, if the input string is Present a=0 a=1
of length n, the output string is of length n+1. The State Next O/p Next O/p
first output is λ(q0) for all output strings. In the ⟶q1 q3 0 q20 0
case of a Mealy machine if the input string is of q20 q1 1 q40 0
q21 q1 1 q41 1
length n, the output string is also same length. q3 q21 1 q1 1
q40 q41 1 q3 0
Convert the Following Moore Machine to Mealy
q41 q41 1 q3 0
Machine.

Present Next State Output Present Next State Output


State a=0 a=1 (λ) State a=0 a=1 (λ)
⟶q0 q3 q1 0 ⟶q1 q3 q20 1
q1 q1 q2 1 q20 q1 q40 0
q2 q2 q3 0 q21 q1 q41 1
q3 q3 q0 0 q3 q21 q1 0
q40 q41 q3 0
q41 q41 q3 1
Present a=0 a=1
State Next O/p Next O/p
⟶q0 q3 0 q1 1
q1 q1 1 q2 0
q2 q2 0 q3= 0 Convert the Following Mealy Machine to Moore
q3 q3 0 q0 0 Machine.
Convert the Following Moore Machine to Mealy
Machine. Present a=0 a=1
State Next O/p Next O/p
Present Next State Output ⟶q1 q2 z1 q3 z1
State a=0 a=1 (λ) q2 q2 z2 q3 z1
⟶q1 q1 q2 0 q3 q2 z1 q3 z2
q2 q1 q3 0
q3 q1 q3 1
Present a=0 a=1
State Next O/p Next O/p
Present a=0 a=1 ⟶q1 q21 z1 q31 z1
State Next O/p Next O/p q21 q22 z2 q31 z1
⟶q1 q1 0 q2 0 q22 q22 z2 q31 z1
q2 q2 0 q3 1 q3 q21 z1 q32 z2
q3 q3 0 q0 1 q3 q21 z1 q32 z2

Convert the Following Mealy Machine to Moore Present Next State Output
Machine. State a=0 a=1 (λ)
⟶q1 q21 q31 ∧
Present a=0 a=1 q21 q22 q31 z1
State Next O/p Next O/p q22 q22 q31 z2
⟶q1 q3 0 q2 0 q3 q21 q32 z1
q2 q1 1 q4 0 q3 q21 q32 z2
q3 q2 1 q1 1
q4 q4 1 q3 0
Question: Design a Moore machine which counts By the analyzing mealy machine transition
the occurrence of substring aab in input string. diagram, we can easily notice that it is also finite
Solution: Let the Moore machine be automata without any final state and output is
M0 = (Q, Σ, Δ, δ, λ,q0) there for input-symbol on corresponding
Q = { q0, q1, q2, q3 } transition. Output for every input symbol is
Σ = { a, b} represented as level on each transition
We will design this machine in such a way that corresponding output. For e.q. in between q1 and
machine prints out the character 0 except for q3, q2 is labeled by 0/1, 0 is input symbol and 1 is the
which prints a 1. To get q3, we must come from output symbol.
state q2 and have 1st read b. To get state q2, we
Question: Design a mealy machine, which prints
must read atleast two a’s in a row, having started
1’s complement of input bit string over alphabet
in any state.
Σ = { 0, 1}.
Δ={0,1}
Solution: If input string is 101110 then 1’s
λ’(q0) = 0, λ’(q1) = 0, λ’(q2) = 0, λ’(q3) = 1 complements of 101110 will be 010001, so we
The following machine will counts aab have to design a mealy machine which will print
occurrence for us. output 010001 for the input string 10110.
a
M0 = (Q, Σ, Δ, δ, λ,q0)
a
Q = { q0 }
a
q0/0 q0/1 q0/0 b q0/1 Σ = { 0, 1}
b Δ={0,1}
a
b b q0 is the initial state.

Question: Construct a mealy machine which 0/1


calculates the residue mod-4 for each binary q0
string treated as binary integer.
Solution: When we divide any number by 4 then 1/0
remainder can be 0, 1, 2, &3. so clearly mealy
machine will have four states. Question: Construct a mealy machine which
Let the Mealy machine be calculate residue mod-4 for each binary string
M0 = (Q, Σ, Δ, δ, λ,q0) treated as binary integer.
Q = { q1, q2, q3, q4 } Solution:
Σ = { a, b} M0 = (Q, Σ, Δ, δ, λ,q0)
Δ={0,1} Q = { q0, q1, q2, q3 }
q1 is the initial state & δ is transition function. Σ = { 0, 1}
λ’( q1, 0 ) = 0 λ’ ( q1, 1 ) = 0 Δ = { 0, 1, 2, 3}
λ’( q2, 0 ) = 1 λ’ ( q2, 1 ) = 0
λ’( q3, 0 ) = 1 λ’ ( q3, 1 ) = 1 0/0 1/3
λ’( q4, 0 ) = 1 λ’ ( q4, 1 ) = 0 1/1 1/3
Transition Diagram for M0 is as follows: q0 q1 q3
0/1
1/1 0/2
q1 1/0 q2 0/0 0/2

0/0 1/0 q2

1/0 0/1
Arden’s Theorem: let P and Q be two regular Conversion of FA to Regular Expression.
expressions over Σ. If P does not contain ∧, then
Example: The transition system is given in figure.
the following equation in R, is
R = Q + RP ---(i) a a b a

has a unique solution QP*---(ii) q1 q2 q3


b a
Proof: let us First check if QP* is a solution to Prove that the strings recognized are
(i). To check this, let us substitute R by QP* on ( a + a ( b + aa)* b )* a ( b + aa ) * a
both sides of (i)
we can directly apply the method since the graph
R = Q + RP = Q + QP*P = Q (∧ + P*P) = QP* does not contain any ∧-move and there is only
Hence eqn(i) is satisfied when R = QP*. This one initial state.
means R = QP* is a solution of eqn(i). q1 = q1a + q2b + ∧
Let us check if it is the only solution. To do this, q2 = q1a + q2b + q3a
replace R by Q + RP on the Right Hand Side. of q3 = q2a
eqn(ii), we get reduce the number of unknowns by repeated
substitution.
R = Q + RP = Q + ( Q + RP )P
q2 = q1a + q2b + q3a
= Q + QP + RP2
q2 = q1a + q2b + q2aa
= Q + QP + ( Q + RP )P2
q2 = q1a + q2( b + aa )
= Q + QP + QP2 + RP3
R= Q+R P ⟷ QP*
...
2 i i+1 q2 = q1a( b + aa )*
= Q + QP + QP + … + QP + RP
Now substitute q2 in q1
= Q ( ∧ + P + P2 + … + Pi) + RPi+1
q1 = q1a + q2b + ∧
We now show that any solution of equation (i) is
equivalent to QP*. q1 = q1a + q1a ( b + aa )*b + ∧
q1 = q1( a + a(b + aa )* + ∧
Let w be the string of length I in the set R. then w
R = R P + Q ⟷ QP*
belongs to the set Q ( ∧ + P + P2 + … + Pi) +
q1 = ∧.( a + a(b + aa )*)*
RPi+1. As P does not contain ∧, RPi+1 has no
string less than i+1. This means that w belongs to = ( a + a(b + aa )*)*
the set RPi+1. This means that w belongs to the set q2 = ( a + a ( b + aa )*)*a( b + aa )*
Q ( ∧ + P + P2 + … + Pi) and hence to QP*. q3 = ( a + a ( b + aa )*)*a( b + aa )*a
Rules for using Arden’s Theorem: Since q3 is a final state, the set of strings
recognized by the graph.
1. The transition graph does n’t have ∧- moves. Example: a
2. It has only one initial state.
q1 q2
3. Vi the regular expression ( of final state) b
represents the set of strings accepted by the a
system ( Vi is final state). b a
4. q = Σ qi (incoming edge) alphabets + ∧ (only
for initial state). q3
b
q4
We can directly apply the method since the graph Pumping Leema for regular
does not contain any ∧-move and there is only Languages/Regular Sets:
one initial state. Pumping Lemma: let M = (Q, Σ, δ, q0, F ) be a
q1 = q2b + q3a + ∧ finite automaton with n states. let L be the regular
set accepted by M. let x ∈ L and |x|≥ n, then there
q2 = q1a
exists μνω such that x = μνω, ν ≠ ∧ and μνmω ∈ L
q3 = q1b
for each m ≥ 0.
q4 = q2a + q3b + q4a + q4b
Proof: suppose that the set Q has n elements. for
q1 = q2b + q3b + ∧ any string x in L with length atleast n. of we write
q1 = q1ab + q1ba + ∧ x = a1a2…an;
q1 = q1 (ab + ba ) + ∧ then the sequence of n+1 states.
R =R P + Q ⟷ QP* q0 = δ * ( q 0 , ∧ )
q1 = ∧ .(ab + ba )* q1 = δ* ( q0 , a1 )
q1 = (ab + ba )* q2 = δ* ( q0 , a1a2 )
q3 = δ* ( q0 , a1a2a3 )
. . .
Example:-
1 0, 1 qn = δ* ( q0 , a1a2. . . an )
0 ν
1 0 µ ω
q1 q2 q3
q0 qi qf
We can directly apply the method since the graph
suppose qi = qi + p
does not contain any ∧-move and there is only
0≤i≤i+p≤n
one initial state.
then
q1 = q10 + ∧
δ* ( q0 , a1a2. . . ai ) = qi
q2 = q11 + q21
δ* ( qi , ai+1ai+2. . . ai+p ) = qi+p = qi
q3 = q20 + q3( 0 + 1 )
δ* ( qi , ai+p+1ai+p+2. . . an ) = qf ∈ F
q1 = q10 + ∧
To simplify the notation,
R = RP + Q ⟷ QP*
let μ = a1a2. . . ai
q1 = ∧.(0)* = 0 *
ν = ai+1ai+2. . . ai+p
q2 = q11 + q21
ω = ai+p+1ai+p+2. . . an
q2 = 0*1 + q21
R = Q + RP ⟷ QP* if i  0  will be  
if i + p  0  will be  
q2 = 0*11*  
As the final states are q1 and q2, we need not since δ* ( qi , ν ) = qi , have δ* ( qi , νm ) = qi for
solve q3. every m ≥ 0 and it follows that
q1 + q2 δ* ( q0 , μνmω ) = qf for every m ≥ 0 since p > 0
0* + 0*11* and i + p ≤ n.
0* (∧ + 11*) = 0*1* Note: The decomposition is valid only for strings
of length greater than or equal to the number of
states. for such a string x = μνω as many times as Hence, | μν2ω | strictly lies between n 2 and ( n +
we like and get strings of the form μνmω which 1)2, but is not equal to any one of them. thus, |
are longer than μνω and are in L. by considering μν2ω | is not a perfect square and so μν2ω ∉ L. but
the path from q0 to qi and then the path from qi to by pumping lemma, μν2ω ∈ L. this is
qf ( without going through the loop), we get a contradiction. thus L is not regular.
path ending in a final state with path value μω (
this corresponds to the case when m = 0). Example: Show that L = { aQ | Q is a prime} is
not a regular.
Application of Pumping Lemma:
Solution: Step 1: We suppose L is a regular. let n
This problem can be used to prove that certain
be the number of states in the finite automaton
sets are not regular. we now give the steps needed
accepting L.
for proving that a given set is not regular.
Step 2: Let Q be a prime number greater than n.
Step 1: Assume that L is regular. Let n be the
let x = aQ. by pumping lemma, x be written as x =
number of states in the corresponding FA.
μνω, with |μν|≤ n and |ν| > 0. μ , ν, ω are simply
Step 2: Choose a string x such that |x| ≥ n, use strings of a’s. so ν = ap for some p ≥ 1 (and ≤ n).
pumping lemma to write x = μνω with |μν|≤ n and
Step 3: let m = Q+1, the |μνmω|
|ν| > 0.
= |μνω| + | νm-1| = Q + (m-1)p = Q + QP =
m
Step 3: Find a suitable integer m such that μν ω Q(1+p).
∈ L. this contradicts our assumption Hence L is
by pumping lemma, μνmω ∈ L. but |μνmω|= Q +
not regular.
Qp = Q(1+p) and Q(1+p) is not prime. so μν mω ∉
2
Example: Show that the set L = { a i | I ≥ 1 } is
L. this is contradiction. thus L is not regular.
not regular.
Example: Show that L = { 0i1i | i≥1} is not
1 4 9 16
Sol: L = {∧, a , a , a , a , . . . } regular.
= { ∧, a, aaaa, aaaaaaaaa, . . . } Solution: Step 1: Suppose L is regular. Let n be
Step 1: Suppose L is regular. let n be the number the number of states in the finite automaton
of states in finite automaton accepting L. accepting L.
2
Step 2: let x = a n . then |x| = n 2 > n. by Step 2: let x = 0n1n. then |x| = 2n > n. by pumping
pumping lemma, we can write x= μνω with |μν|≤ lemma, we write x = μνω with |μν|≤ n and |ν| > 0.
n and |ν| > 0.
2
Step 3: we want to find m, s the μνmω ∈ L for
Step 3: Consider μν ω. getting a contradiction. the string ν can be in any
| μν2ω | = | μ | + 2|ν| + |ω | > |μ | + |ν| + |ω| as |ν| > of the following:
0. case 1: ν has only 0’s i.e. ν = 0k for some k≥1.
this means case 2: ν has only 1’s i.e. ν = 1l for some l≥1.
n 2 = | μνω | = |μ | + |ν| + |ω| < | μν2ω | case 3: ν has both 0’s and 1’s i.e. ν = 0k1l for
as |μν|≤ n we have |ν|≤ n. therefore some k, l≥1.
| μν2ω | =| μ | + 2|ν| + |ω | ≤ n 2 + n. in case 1, we can take m=0, as μνω = 0n1n, μω=
0n-k1n. as k≥1, n-k≠n so μω ∉ L.
i.e.
In case 2, we can take m =0, as μνω = 0n1n, μω=
n 2 <| μν2ω | ≤ n 2 + n < n 2 + n + n + 1 0n1n-l. as l≥1, n-l≠n so μν∉ L.
n 2 <| μν2ω | < ( n + 1)2
In case 3, we can take m =2, as μνω = 0n-k0k1l1n-l. The term ‘closure property’ relates to a
μν2ω = 0n-k0k1l0k1l1n-l, as μν2ω is not of the form mathematical system (structure) containing a set
0n1n, μν2ω∉ L. thus in all the cases we get a and operations performed on the elements of the
contradiction. Thus L is not regular. set. For example, let I+ be the set of positive
integers and addition (+) and subtraction (-) be the
Example: Show that L = {zz | z∈{a, b}*} is not two operations performed on the elements of this
regular. set. When the addition operation is performed on
Sol: Step 1: suppose L is regular, let n be the the elements of this set the result obtained is some
number of states in the automaton M accepting L. positive integer and belongs I+. When the
subtraction operation is performed, the result
Step 2: let us consider zz = anbanb in L |zz| = obtained may or may not belongs to I+. Thus the
2(n+1) > n. we can apply pumping lemma to execution of the addition operation does not
write zz = μνω with |μν|≤ n and |ν| > 0. violate the boundary of the set I+ whereas
Step 3: We want to find m so that μνmω ∈ L for subtraction may do so. We say that the set I+ is
getting a contradiction. the string ν can be in only closed over the addition operation but not over
one of the following form: subtraction. Similarly, a set of all 3 × 3matrices is
closed over the operation of addition, subtraction
case 1: ν has no b’s i.e. y =ak for some k≥1.
and transpose, but not over the operation of the
case 2: ν has only one b. determinant.
we may note that ν can not have two b’s if so |ν| ≥
Every regular set can be expressed by its
n+2. but |ν| ≤ |μν| ≤ n.
corresponding regular expression. In addition, for
in case 1, we can take m =0. then μν0ω = μω is of every regular expression, there exists a
the for an-kbanb, here n-k ≠ n, we can not write μω corresponding regular set. If an operation
in the form so μω ∉ L. performed on regular set(s) leads to another set,
In case 2, we can take m = 0. then μν0ω = μω has which is also regular, then the regular set(s) are
only one b ( as one b is removed from μνω, b closed over that operation.
being in ν). so μω∉ L as any element in L should
The regular sets are closed over the operations of
have an even number of a’s and an even number
union, concatenation, transpose, complement,
of b’s. thus in both case, we get a contradiction.
intersection, difference and Kleene’s star.
therefore, L is not regular.
1. Regular sets are closed over the union
2n
Example: Is L = {a | n ≥ 1} regular? operation.
Solution: We can write a2n as aa(a2)m, where m ≥ Proof: let S1 and S2 be two regular sets
0 } is simply {a2 }* so L is represented by the associated with regular expressions R1 and R2
regular expression aa(P)*, where P represents respectively. Let there be a set S3 = ( S1 ∪ S2).
{a2}. the corresponding FA is shown in figure: then every element of S3 can be expressed
either by expression R1, R2 or both. Thus, the
a set S3 can be generated by the regular
q2
a a
q0 q1 qf a expression (R1 + R2). The association of S3
with regular sets has generated a regular set,
Pumping lemma fails to solve this problem regular sets are closed over the Union
because this is a regular grammar. operation.
2. Regular sets are closed over the concatenation
Closure properties of Regular sets: operation.
Proof: Let S1 and S2 be the two regular sets 0 1
1
associated with the regular expressions R1 and q0 q1
R2 respectively. Let there be a set S3 created
by the concatenation of the elements of S1 and 0
S2 in order. Now each string belonging to S3 is
such that it can be decomposed into two parts, q2 0,1
with the first belonging to S1 (corresponding
to R1) and the second to S2 (corresponding to If final state is reachable from initial state then LT
R2). Thus, every element of S3 can be is also regular.
generated by the regular expression R1R2. The 4. Regular sets are closed over the complement
association of S3 with a regular expression operation
(R1R2) indicates that S3 is a regular set. Since Proof: let L be a regular set(language) over
concatenation of two regular sets has the character set Σ; then its complement L is
generated a regular set, regular sets are closed a set of all string over Σ* that are not in L,
over concatenation operation.
that is L = Σ* - L.
3. Regular sets are closed over the transpose
Let M be the finite automaton for the language
(string reversal) operation.
L. now, covert all the final states ofM to non-
Proof: Let S1 be a regular set associated with
final states and vice versa to generate a new
the regular expression R1. let M1 be the finite
finite automaton, say M’. Now, if for a string
automaton corresponding to R1. Now, for
ω, M stops in final state the M’ stops in the
every string (w ∈ S1), there is a path in M1
non-final state and vice-
from the initial state to final state. Now, the
following operations are performed on M1 to versa. Hence M’ is the finite automaton for
create a new finite automaton, say M2. Since there is a finite automaton for , is
a. Reverse the direction of every arc/arm. a regular set. Hence, regular sets are closed
b. Change the initial state ( origionally in over the complement operation.
M1) to the final state. 5. Regular sets are closed over intersection
c. Create a new start state S and connect it operation
to all the acceptor states of M1 using ∧- Proof: let S1 and S2 be two regular sets.
transitions. Therefore, their complements s1 s2
and
d. Remove all ∧-transitions.
are also regular sets. Union of s 1 and s 2,
Let S2 be a set of all strings accepted by M2.
that is, ( s 1 ∪ s 2) is also a regular sets.
Now every string (x∈S2) is reverse
(transpose) of some string (w∈S1) thus S2 is a Complement of ( s 1 ∪ s 2), that is, ( s1 s 2 )
set of transposed strings of S1. Since S2 is is also a regular set.
associated with a finite automaton M2, it is
associated with a regular expression, Hence By De Morgan’s Law, S1 ∩ S2 = ( s1 s2 ). 
S2 is a regular set has created another regular Hence, (S1 ∩ S2) is also a regular set.
set, regular sets are loosed over the transpose Therefore, regular sets are closed over the
operation. intersection operation.
0 1 6. Regular sets are closed over the difference
1
q0 q1 operation.

d0,1
Fo
Proof: let S1 and S2 be te two regular sets. C1 belongs to the language set L and those in the
since S2 is a regular set, s 2 is also a regular class C2 do not belongs to L.

set, (S1 ∩ s 2) is also a regular set. The language L can be implemented on the finite
state machine (FSM) such that each state in the
S1 ∩ s 2 = S1 – S2 is also a regular set.
FSM corresponds to a particular class.
Therefore, regular sets are closed over the
intersection operation. FA contains minimum two states.
7. Regular sets are closed over the Kleene’s
1. where the strings belonging to the class
star. C1 reach the final state and
proof: The closure over Kleene’s star(∗) is 2. Other where the strings belonging to the
also known as Kleene’s closure. closure of a class C2 reach the non-final state. Thus,
regular set over Kleene’s star means that if R the language L can be implemented using
is a regular expression, then R* is also a a FA.
regular expression. 0 0
1
Let R be a regular expression and M be its
F
corresponding finite automaton, as shown in S
figure, 1
Since L1 is regular.
q0 qi qk qf
Similarly consider a language L2 over {0, 1} such
that all strings belonging to L2 wnd with 00.
Now wrap around the finite automaton M and
all the string classified into 5-classes.
superimpose the final state qf with the initial state
q0 to make the initial state as the final state and to Class C1: string length less than 2 I.e. ∧, 0, 1.
create a new finite automaton, say M’ as shown Class C2: those ending with 00.
in figure. Class C3: those ending with 01.
Class C4: those ending with 10.
q0 qi qk Class C5: those ending with 11.

1 0
Now if a string ω is accepted by the finite 0
0 qf
automaton M, then M’ accepts all the strings that q0 q1
involve the repetition of ω. such as ∧, ω, ωω,
1
ωωω and so on. Thus, M’ is a finite automaton
for R*. since there exists a finite automaton for since L2 is regular
R*, it is a regular set corresponding to R*. Hence, “If the number of equivalent classes over a
regular sets are closed over Kleene’s closure. language L is finite then the language L is
regular”. This statement is refered to as Myhill-
Myhill-Nerode Theorem [ Equivalent classes
Nerode theorem.
and Regular Languages]: Consider a language
L with Σ = {0, 1} such that a string ω belong to L L3 = {0n1n|n>0} to recognize this machine should
if and only if it ends with 0. we can categorized, be able to remember how many 0’s it has seen
all the strings into two categories ( classes), those and if the no. of 1’s is exactly the same as that of
ending with 0(say class C1) and those ending number of 0’s. However, the FSM is devoid of
with 1(say class C2). All the strings in the class any kind of memory the 0 count and match it
with the 1 count. the no. of equivalent classes belongs to L6, otherwise it does not since the
generated by the language L3 over {0,1}* is number of equivalent classes. for L6 is finite(9),
infinite, with each class corresponding to number the language L6 can be implemented on the FSM
of 0’s on any string. Since the number equivalent and therefore L6 is regular.
classes are not finite, according to Myhill-Nerode Current Input Symbol
theorem, the language L3 is not regular. state 0 1 2 3 4 5 6 7 8 9
⟶ q0 q0 q1 q2 q3 q4 q5 q6 q7 q8 q0
Consider a language L4 = {w|w is palindrome q1 q1 q2 q3 q4 q5 q6 q7 q8 q0 q1
over {a,b}}. q2 q2 q3 q4 q5 q6 q7 q8 q0 q1 q2
q3 q3 q4 q5 q6 q7 q8 q0 q1 q2 q3
Now, the recursive definition of a palindrome q4 q4 q5 q6 q7 q8 q0 q1 q2 q3 q4
over {a, b} is as follows: q5 q5 q6 q7 q8 q0 q1 q2 q3 q4 q5
∧ - is a palindrome q6 q6 q7 q8 q0 q1 q2 q3 q4 q5 q6
q7 q7 q8 q0 q1 q2 q3 q4 q5 q6 q7
a – is a palindrome
q8 q8 q0 q1 q2 q3 q4 q5 q6 q7 q8
b – is a palindrome
if a string x is a palindrome then axa, bxb are Minimization of Finite Automata:
palindromes.
Definition: Two state q1 and q2 are equivalent (
To recognize L4, a machine should be able to denoted by q1≡q2). if both δ(q1, x) and δ(q2, x) are
mark the middle of the string and match the final states or both of them are non final state for
symbols on the both sides of the middle. FSM all x∈Σ*.
has no memory, so counting is n’t possible.
As it is difficult to construct δ(q1, x) and δ(q2, x)
another possible mechanism is to create a class
for all x∈Σ* because there are an infinite number
corresponding to the string before the middle of
of strings in Σ*.
the input string and to match this class with the
class of the reverse string after the middle. if they Definition: Two states q1 and q2 are k-equivalent(
are same then the string is a palindrome. k≥ 0 ) if both δ(q1, x) and δ(q2, x) are final states
Otherwise, it is not. However the number of or both non final states for all strings x of length
possible classes for the string before the middle is k or less.
infinite; hence the language L4 can not be Example:
implemented on a finite automaton and hence, is Current State Input State
not regular. a b
⟶q0 q1(N) q4(N)
L5 = {ww | w is a string over {0.1} is not regular} q1 q5(N) qf(F)
because the language L5 belongs to the same q2 qf(F) q5(N)
group as the language L4. q3 q6(N) q4(N)
q4 qf(F) q5(N)
L6 over Σ = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; a string w
q5 q5(N) q3(N)
over Σ* belongs to L6 if the number formed by w q6 q5(N) qf(F)
is divisible by 9. q0(N) qf(F)
qf
For example: 9, 18, 27, . . . are belongs to L6 1,
2, 3, . . . rest does not belongs to L6. a) 0-level equivalence: The only string with
Here string can be divided into 9 equivalent length zero i.e. ∧, if ∧ is applied on any state
classes, with each class corresponding to a qi remains on the same state qi.
remainder 0 to 8. if remainder 0, then the string if ∧ is applied in state qf we get final state.
if ∧ is applied in state any other state,
we get non final state. Current Input Symbol
The state of state Q can be partitioned state aaa aab aba abb baa bab bba bbb
into two subsets: {qf} and {q0, q1, q2, q3, q0 q5(N) q3(N) q0(N) qf(N) q0(N) qf(N) q5(N) q3(N)
q3 q5(N) q3(N) q0(N) qf(N) q0(N) qf(N) q5(N) q3(N)
q4, q5, q6}
This partition is denoted by
q1 q5(N) q3(N) q0(N) q4(N) q1(N) q4(N) q0(N) qf(N)
π0 = { {q0, q1, q2, q3, q4, q5, q6}, {qf}} q6 q5(N) q3(N) q3(N) q4(N) q1(N) q4(N) q0(N) qf(N)
b) 1- Level equivalence: The strings with
length one are a and b, equivalence at q2 q1(N) q4(N) q0(N) qf(N) q5(N) q3(N) q6(N) q4(N)
level 1 can exists if and only if, there q4 q1(N) q4(N) q0(N) qf(N) q5(N) q3(N) q6(N) q4(N)
exists equivalence at level 0. Hence, qf
cannot be equivalent to any other state at Algorithm (minimization of Finite
level 1. Automaton):
1) The state q0, q3, & q5 have same
behavior. These state lead to a non-final Step 1: (construction of π0): By definition of 0-
state for both the strings a and b. level equivalence, π0 = {Q10, Q20 } where Q10 is
2) The state q2 and q4 have the same the set of all final states and Q20 = Q – Q10.
behavior a- F, b-NF. Step 2: (Construction of πk+1 and πk ): let Qik be
Hence the set partition for 1-level any subset in πk. if q1 and q2 are in Qik, they are
equivalence is as follows: (k+1)-equivalent provided δ(q1, a ) and δ(q2, a )
π1 = { {q0, q3, q5}, {q1,q6}, {q2 q4}}, {qf}} are in the same equivalent class in πk for every
a∈Σ.
Current Input String
state aa ab ba bb if so, q1 and q2 are (k+1)- equivalent. in this way,
q0 q5(N) qf(F) qf(F) q5(N) Qik is further divided into (k+1)-equivalent
q3 q5(N) qf(F) qf(F) q5(N) classes. repeat this for every Qik in πk to get all
q5 q5(N) q3(N) q6(N) q4(N)
the elements of πk+1.
q1 q5(N) q3(N) q0(N) qf(F) Step 3: Construct πn for n = 1, 2, … until πn =
q6 q5(N) q3(N) q0(N) qf(F) πn+1.

q2 q0(N) qf(F) q5(N) q3(N) Example:


q4 q0(N) qf(F) q5(N) q3(N)
Current State Input Symbol
a b
c) 2-Level equivalence: The string length two ⟶q0 q1(N) q0(N)
is aa, ab, ba & bb. Equivalence at level 2 can q1 q0(N) q2(N)
exist. If there is equivalence at level 1. q2 q3(F) q1(N)
{q0, q3, q5}, {q1,q6}, {q2 q4} q3 q3(F) q0(N)
q4 q3(F) q5(N)
π2 = { {q0, q3},{q5}, {q1,q6}, {q2 q4}, {qf}} q5 q6(N) q4(N)
d) 3-level equivalence: the strings with length q6 q5(N) q6(N)
q7 q6(N) q3(F)
three are aaa, aab, aba, abb, baa, bab, bba,
and bbb.
By Step 1:
π3 = { {q0, q3},{q5}, {q1,q6}, {q2 q4}, {qf}}
Q10 = {q3}, Q20 = Q – Q10
π3 is same as π2. Hence, no further division is
possible.
π0 = {{q3}, { q0, q1, q2, q4, q5, q6, q7 }}. As {q3 } Q13 = {q2}, Q33 = {q1, q7 }, Q23 = {q6 }, Q43 = {q3,
can not be partitioned further. q5}, Q53 = {q0, q4 }.
Q11 = {q3 }, Q21 = {q2, q4 }, Q31 = {q7 }, Q41 = π3 ={{q2}, {q1, q7 }, {q6 }, {q3, q5}, {q0, q4 }}.
{q0, q1, q5, q6 } π3 = π2 (πn+1 = πn )
π1 = {{q3 }, {q2, q4 }, {q7 }, {q0, q1, q5, q6 }} Hence at higher level, we will get the same
Q12 = {q3}, Q32 = {q7 }, Q22 = {q0, q6 }, Q42 = {q1, equivalence.
q5}, Q52 = {q2, q4 }. Q’ = {[ q2], [q1, q7 ], [q6 ], [q3, q5], [q0, q4] }
Thus q0’ = [q0, q4], F’ = [ q2].
π2 = {{q3 }, {q0, q6}, {q7 }, {q1, q5}, {q2, q4 }}
Equivalence of Two Finite Automata: Two
Q13 = {q3}, Q33 = {q7 }, Q23 = {q0, q6 }, Q43 = {q1,
finite automata over Σ are equivalent if they
q5}, Q53 = {q2, q4 }.
accept the same set of strings over Σ. when two
π3 = {{q3 }, {q0, q6}, {q7 }, {q1, q5}, {q2, q4 }} finite automata are not equivalent; there is some
π3 = π2 (πn+1 = πn ) string ω over Σ satisfying the following: One
Hence at higher level, we will get the same automaton reaches a final state on application of
equivalence. ω, whereas the other automaton reaches a non-
final state.
Q’ = {[q3 ], [q0, q6], [q7 ], [q1, q5], [q2, q4 ]}
Comparison Method: Let M and M’ be two
q0’ = [q0, q6] F’ = [q3].
finite automata over Σ. we construct a
Example 2: comparison table consisting of n+1 columns,
Current State Input Symbol where n is the number of input symbols. the first
0 1 column consists of pair of vertices of the form (q,
⟶q0 q1(N) q5(N) q’) where q∈M and q’∈M’.
q1 q6(N) q2(F)
q2 q0(N) q2(F) Case 1: If we reach a pair of (q, q’) such that q is
q3 q2(F) q6(N) final state of M and q’ is a non-final of M’ or
q4 q7(N) q5(N) vice-versa, we terminate the construction and
q5 q2(F) q6(N) conclude that M and M’ are not equivalent.
q6 q6(N) q4(N)
q7 q6(N) q2(F) Case 2: Here the construction is terminated when
no new element appears in the second and
By Step 1: subsequent columns which are not in the first
column (i.e. when all the elements in the second
Q10 = F = {q2}, Q20 = Q – Q10 = { q0, q1, q3, q4, q5,
and subsequent column appear in the first
q6, q7 }
column). In this case we conclude that M and M’
π0 = {{q2}, { q0, q1, q3, q4, q5, q6, q7 }}. As {q2 } are equivalent.
can not be partitioned further.
Example:
Q11 = {q2 }, Q21 = {q3, q5 }, Q31 = {q1, q7 }, Q41 =
Consider the following two DFAs M and M’ over
{q0, q4, q6 }
{0, 1} given in figure. determine M and M’ are
π1 ={ {q2 }, {q3, q5 }, {q1, q7 }, {q0, q4, q6 }} c
equivalent.
Q12 = {q2}, Q32 = {q1, q7 }, Q22 = {q6 }, Q42 = {q3, d
q1
q5}, Q52 = {q0, q4 }.
q3
π2 ={{q2}, {q1, q7 }, {q6 }, {q3, q5}, {q0, q4 }}. d d c
c
q2
gp
Figure: Automaton M from q2 and q5 respectively. As q1 is a final state
c in M1 and q6 is a non-final state in M2, we see that
M1 and M2 are not equivalent: we can also not
d that q1 id dd-reachable from q1 and hence dd is
q4 q7 accepted by M1. dd is not acceptable by M2 as
c only q6 is dd-reachable from q4, but q6 is non-
d d c final.
c
q5 q6 Current state Input Symbol
d
c d
(q,q’) (qc,qc’) (qd,qd’)
Figure: Automaton M’ (q1,q4) (q1,q4) (q2,q5)
(q2,q5) (q3,q7) (q1,q6)
Sol: The initial states in M and M’ are q1 and q4
respectively. Hence the first element of the first
column in the comparison table must be (q1, Grammar: Before giving the definition of
q4). the first element in the second column in grammar, we shall study, two types of sentences
(q1, q4) since both q1 and q4 are c-reachable in English, with a view to formalizing the
from the respective initial states. construction of theses sentences. The sentences
we consider are those with a noun and a verb, or
Current State Input Symbol those with a noun-verb and adverb (such as ‘Ram
(q, q’) c (qc, qc’) d (qd, qd’) ate quickly’ or ‘Sham ran’). the sentences ‘Ram
⟶(q1, q4) (q1, q4) (q2, q5)
(q2, q5) (q3, q6) (q1, q4) are quickly’ has the words ‘Ram’, ‘ate’, ‘quickly’
(q3, q6) (q2, q7) (q3, q6) written in that order. If we replace ‘Ram’ by
(q2, q7) (q3, q6) (q1, q4) ‘sham’, ‘tom’, etc. i.e. be any verb in the past
tense, and ‘quickly’ by ‘slowly’ i.e. by an adverb,
we get other grammatically correct sentences so
As we do not get a pair of (q, q’), where q is a
the structure of ‘Ram ate quickly’ can be given as
final state and q’ is a non-final state( or vice-
<noun><verb><adverb>.
versa) at every row, we proceed all the
elements. Therefore M and M’ are equivalent. for <noun>, we can substitute ‘Ram’, ‘Sham’,
‘Tom’ etc.
Example: show that the automat M1 and M2
defined by figure are not equivalent. for <verb>, we can substitute ‘ate’, ‘ran’,
c ‘walked’ etc.
c
for <adverb>, we can substitute ‘quickly’,
d q4 c
q7 ‘slowly’ etc.
q1
c we have to note that <noun> <verb> <adverb>
d d c
q3 d c
c is not a sentence but only the description of a
c particular type of sentence. if we replace
q2 q5 q6
d d <noun> <verb> and <adverb> by suitable
Sol: The initial states in M1 and M2 are q1 and q4 words, we get actual grammatically correct
respectively. Hence the first column in sentences.
comparison table is (q1, q4). q2 and q5 are d- Let S be a variable denoting a sentence. Now we
reachable from q1 and q4. we see fro the can form the following rules to generate two
comparison table that q1 and q6 are d-reachable types of sentences.

You might also like