Tài liệu Bài giảng Theory Of Automata - Lecture 25: Recap lecture 24
Regular languages, complement of a
language, theorem, proof, example,
intersection of two regular languages
Theorem
Statement: If L1 and L2 are two regular
languages, then L1 L2 is also regular.
Proof: Using De-Morgan's law for sets
(L1
c U L2
c)c = (L1
c)c (L2
c)c = L1 L2
Since L1 and L2 are regular languages, so
are L1
c and L2
c. L1
c and L2
c being regular
provide that L1
c U L2
c is also regular
language and so (L1
c U L2
c)c = L1 L2,
being complement of regular language is
regular language.
Following is a remark
Remark
If L1 and L2 are regular languages, then
these can be expressed by the corresponding
FAs. Finding regular expressions defining the
language L1 L2 is not so easy and building
corresponding FA is rather harder.
Following is an example of finding an FA
accepting the intersection of two regular
languages
Example
Consider two regular languages L1 and
L2, defined over the alphabet Σ = {a, b},...
26 trang |
Chia sẻ: honghanh66 | Lượt xem: 990 | Lượt tải: 0
Bạn đang xem trước 20 trang mẫu tài liệu Bài giảng Theory Of Automata - Lecture 25, để tải tài liệu gốc về máy bạn click vào nút DOWNLOAD ở trên
Recap lecture 24
Regular languages, complement of a
language, theorem, proof, example,
intersection of two regular languages
Theorem
Statement: If L1 and L2 are two regular
languages, then L1 L2 is also regular.
Proof: Using De-Morgan's law for sets
(L1
c U L2
c)c = (L1
c)c (L2
c)c = L1 L2
Since L1 and L2 are regular languages, so
are L1
c and L2
c. L1
c and L2
c being regular
provide that L1
c U L2
c is also regular
language and so (L1
c U L2
c)c = L1 L2,
being complement of regular language is
regular language.
Following is a remark
Remark
If L1 and L2 are regular languages, then
these can be expressed by the corresponding
FAs. Finding regular expressions defining the
language L1 L2 is not so easy and building
corresponding FA is rather harder.
Following is an example of finding an FA
accepting the intersection of two regular
languages
Example
Consider two regular languages L1 and
L2, defined over the alphabet Σ = {a, b},
where
L1 = language of words with double
a’s.
L2 = language of words containing even
number of a’s.
FAs accepting languages L1 and L2 may
be as follows
Example continued
FA1
FA2
Their corresponding REs may be
bb
2
a
1
a
a,b
ab
a
b
p- r+q
Example continued
r1 = (a+b)
*aa(a+b)*
r2 = (b+ab
*a)*
Now FAs accepting L1
c and L2
c , by
definition, may be
FA1
c a,bab
a
b
p rq+
Example continued
FA2
c
Now FA accepting L1
c U L2
c , using the
method described earlier, may be as
follows
bb
2+
a
1-
a
Example continued
Old States
New States after reading
a b
z1(p,1) (q,2)z4 (p,1)z1
a,b
ab
a
b
p rq+
bb
2+
a
1-
a
FA1
c
FA2
c
Example continued
Old States
New States after reading
a b
z2+(p,2) (q,1)z3 (p,2) z2
z3+(q,1) (r,2)z6 (p,1) z1
z4+(q,2) (r,1) z5 (p,2) z2
z5(r,1) (r,2) z6 (r,1) z5
z6+(r,2) (r,1) z5 (r,2) z6
Here all the possible combinations of states of
FA1
c and FA1
c are considered
Example continued
bb
z6+
a
z5
a
a
z4+
b
z3+
b
z2+
z1
a
a
b a
b
Example continued
An FA that accepts the language
(L1
c U L2
c)c=L1 L2may be
Corresponding RE
can be determined
as follows
bb
z6
a
z5+
a
a
z4
b
z3
b
z2
z1-
a
a
b a
b
Example continued
The regular expression defining the
language L1 L2 can be obtained,
converting and reducing the previous
FA into a GTG as
after eliminating states z2 and z6
Example continued
after eliminating state z3
z5+
a
z4
b
z3
b
z1-
a
b
ab*a
ab*a+b
bb*a
Example continued
z4 can obviously be
eliminated as follows
z5+
z4
z1-
b+abb*ab
a
b+ab*a
a+bb*aab*a
Example continued
eliminating the loops at z1 and z5
Thus the required RE may be
(b+abb*ab)*a(a+bb*aab*a)(b+ab*a)*
z1- z5+
b+ab*ab+abb*ab
a(a+bb*aab*a)
z1- z5+
(b+abb*ab)*a(a+bb*aab*a)(b+ab*a)*
FA corresponding to
intersection of two regular
languages (short method)
Let FA3 be an FA accepting L1 L2, then
the initial state of FA3 must correspond to
the initial state of FA1 and the initial state
of FA2.
Since the language corresponding to L1
L2 is the intersection of corresponding
languages L1 and L2, consists of the
strings belonging to both L1and L2,
therefore a final state of FA3 must
correspond to a final state of FA1 and FA2.
Following is an example regarding short
method of finding an FA corresponding to
Example
Let r1= (a+b)
*aa(a+b)* and FA1 be
also r2 = (b+ab
*a)* and FA2 be
a,b
ab
a
b
p- r+q
bb
2
a
1
a
Example continued
To construct an FA corresponding to L1 L2
Old States
New States after reading
a b
z1-(p,1) (q,2)z4 (p,1)z1
a,b
ab
a
b
p- r+q
bb
2
a
1
a
Example continued
The corresponding transition diagram may be as
follows
Old States
New States after reading
a b
z2(p,2) (q,1)z3 (p,2) z2
z3(q,1) (r,2)z6 (p,1) z1
z4(q,2) (r,1) z5 (p,2) z2
z5+(r,1) (r,2) z6 (r,1) z5
z6(r,2) (r,1) z5 (r,2) z6
Example continued
bb
z6
a
z5+
a
a
z4
b
z3
b
z2
z1-
a
a
b a
b
Task
Build an FA corresponding to FA1 FA2
where
FA1
FA2
b
ab
X1–
a
X2+
a,b
a,b
y1- y2+
Nonregular languages
The language that cannot be expressed by
any regular expression is called a
Nonregular language.
The languages PALINDROME and PRIME
are the examples of nonregular languages.
Note: It is to be noted that a nonregular
language, by Kleene’s theorem, can’t be
accepted by any FA or TG.
Example
Consider the language
L = {Λ, ab, aabb, aaabbb, }
i.e. {an bn : n=0,1,2,3,}
Suppose, it is required to prove that this
language is nonregular. Let, contrary, L be
a regular language then by Kleene’s
theorem it must be accepted by an FA,
say, F. Since every FA has finite number
of states then the language L (being
infinite) accepted by F must have words of
length more than the number of states.
Which shows that, F must contain a circuit.
Example continued
For the sake of convenience suppose that
F has 10 states. Consider the word a9 b9
from the language L and let the path
traced by this word be shown as under
a
1-
2
a
3
4
a
5
6
b
7
8
b
9+
10
a
a
a b
b b
Example continued
But, looping the circuit generated by the
states 3,4,6,5,3 with a-edges once more, F
also accepts the word a9+4 b9, while a13b9
is not a word in L. It may also be observed
that, because of the circuit discussed
above, F also accepts the words a9(a4 )m
b9, m = 1,2,3,
Moreover, there is another circuit
generated by the states 9,10,9. Including
the possibility of looping this circuit, F
accepts the words a9(a4 )m b9(b2 )n
where m,n=0,1,2,3,(m and n not being 0
simultaneously).Which shows that F
accepts words that are not belonging to L.
Summing Up
Intersection of two regular languages is
regular, examples, non regular language,
example
Các file đính kèm theo tài liệu này:
- theory_of_automata_cs402_power_point_slides_lecture_25_0883.pdf