Professional Documents
Culture Documents
Example: Consider The Following TG
Example: Consider The Following TG
Example: Consider The Following TG
3+
1-
aa
a
a
2-
4+
bb
Example continued
b
aa
a
bb
Example continued
b
b+aa
a+bb
(a+bb)a*
Example continued
(b+aa)b*
-
(a+bb)a*
(b+aa)b*+(a+bb)a*
Example
Consider the following TG, accepting EVENEVEN language
aa,bb
-+1
ab,ba
ab,ba
aa,bb
aa+bb
3-
ab+ba
ab+ba
aa+bb
4+
3-
(ab+ba)(aa+bb)*(ab+ba)
4+
3-
4+
3-
(aa+bb+(ab+ba)(aa+bb)*(ab+ba))*
4+
Example
Consider the language, defined over
={a,b}, consisting of only b, then this
language may be accepted by the following
FA
a,b
a, b
Example
Consider the language, defined over
={a,b}, consisting of only , then this
language may be accepted by the
a, b
following FA
a, b
Example
Let r1=(a+b)*b defines L1 and the FA1
a
b
b
be
X1
X2
y 1b
y3+
Example continued
a
X1
X2
a,b
a
y2
y 1
y3+
Old states
z1(x1,y1)
(x1,y2) z2
(x2,y1) z3
Example continued
Old States
z2 (x1,y2)
(x1,y3) z4
(x2,y1) z3
z3+ (x2,y1)
(x1,y2) z2
(x2,y1) z3
z4+ (x1,y3)
(x1,y3) z4
(x2,y3) z5
z5+ (x2,y3)
(x1,y3) z4
(x2,y3) z5
Example continued
Z2
a
a
a
Z1-
Z4 +
b
Z3+
b
a
b
Z5 +
Task
Z2
a
a
a
Z1-
Z4 +
b
Z3+
b
a
b
Z5 +
Example
Let r1=(a+b)*a and the
b
a
corresponding
FA1 be
X1
a
X2
also r2 = (a+b)((a+b)(a+b))* or
((a+b)(a+b))*(a+b) and FA2 be
a,b
y 2+
y 1-
a,b
Example continued
b
X1
a
+
X2
a,b
y1-
a,b
Old States
z1-(x1,y1)
(x2,y2) z2
(x1,y2) z3
y 2+
Example continued
Old States
z2+(x2,y2)
(x2,y1) z4
(x1,y1) z1
z3+ (x1,y2)
(x2,y1) z4
(x1,y1) z1
z4+ (x2,y1)
(x2,y2) z2
(x1,y2) z3
Example continued
a
z2+
z1-
z3+
z4+
Example
Let r1=((a+b)(a+b))* and the
corresponding FA1 be
a,b
x1
x2
a,b
also r2 = (a+b)((a+b)(a+b))* or
((a+b)(a+b))*(a+b) and FA2 be
a,b
y 2+
y 1-
a,b
Example continued
a,b
x1
a,b
x2
a,b
y1-
y2+
a,b
Old States
z1(x1,y1)
(x2,y2) z2
(x2,y2) z2
Example continued
Old States
z2+(x2,y2)
(x1,y1) z1
(x1,y1) z1
Example continued
a,b
z1
z2 +
a,b
Task
Build an FA corresponding to the union
a,b
of these two FAs i.e. FA1 U FA2 where
FA1
x1 -
x2
a,b
x4
b
FA2
y1 -
a,b
y 2+
a
x3 +
Example
Let r1=(a+b)*b defines L1 and FA1 be
a
X1
X2
y 1b
y3+
Example continued
a
X1
X2
a,b
a
y2
y 1-
y3+
Old States
z1-x1
(x2,y1) z2
Example continued
Old States
z2(x2,y1)
(x1,y2)z3
(x2,y1) z2
z3(x1,y2)
(x1,y3)z4
(x2,y1) z2
z4+(x1,y3)
(x1,y3) z4
(x2,y1,y3) z5
z5+(x2,y1,y3)
(x1,y2 ,y3) z6
(x2,y1,y3) z5
z6+(x1,y2,y3)
(x1,y3) z4
(x2 ,y1,y3) z5
Example continued
b
z2
z3
z1 -
z4 +
a
b
b
z 5+
z6 +
Assignment
1. As, if r1 and r2 are regular expressions then their
sum, concatenation and closure are also regular
expressions, so an FA can be built for any regular
expression if the methods can be developed for
building the FAs corresponding to the sum,
concatenation and closure of the regular expressions
along with their FAs. We have seen the two
methods sum and concatenation, you have to
proved the closure with example.
2. Write a function (in any language) that takes two
parameters Regular expression and String. And it
check whether string generated by that regular
expression.