Professional Documents
Culture Documents
Lecture 09
Lecture 09
Lecture No 9
Regular Languages
Topics covered
1. Regular Languages
1. Union of regular languages
2. Concatenation of regular languages
3. Kleene star closure of a regular
language
2. Complement of a Language
3. Intersection of Languages
1. Using union and complement
2. Direct (short) methods
1. Regular Languages
Definition
As already been discussed earlier that any
language that can be expressed by a RE is said
to be regular language
Theorem
L1 and L2 are regular languages then L1
+L2 , L1L2 and L1* are also regular
languages.
Note
This fact can be proved by following two
methods
1. Regular Languages
Proof (Method 1)
By Regular
Expressions
We know that if r1, r2 are regular expressions,
corresponding to languages L1 and L2 then
the languages:
–L1 + L2 (generated by r1+ r2)
– L1L2 (generated by r1r2)
–L1* (generated by r*)
are also regular
1. Regular Languages
Proof (Method 2)
By TGs
• If L1 and L2 are regular languages then L1
and L2 can also be expressed by some
REs
• And hence using Kleene’s theorem, L1 and L2
can also be expressed by some TGs.
Note
• Following are methods showing that there
exist TGs corresponding to L1 + L2, L1L2
and
Proof Contd. TG Accepting L1 + L2
If L1 and L2 are expressed by TG1 and
TG2 then following is a TG accepting L1 +
L2
Λ Λ
1- - p-
TG1 TG2
n+ m+
Example of TG Accepting L1 + L2
TG1 and TG2 (for L1 and L2)
aa, bb aa, a,b a, b
bb ab, ba
aaa, bbb
1 TG1 2 p- q+
TG2
ab, ba
-
Λ Λ
1- TG1 n+ p- TG2
m+
1- TG1 n Λ p TG2 m+
Example: TG Accepting L1L2
a a, aa, bb a,b a, b
bb ab, ba
aaa, bbb
TG1 2 p- q+
TG2
1
ab, ba
TG accepting L1 L2
Λ
aa, bb aa, bb a, b a, b
ab, ba
2 p aaa,
1- TG1 TGbbb
2
q+
ab, ba
Proof Contd. TG Accepting L*
If L is expressed by TG1 then TG accepting
L*
1- TG1 n+
Λ
Example: TG Accepting L*
If L is expressed by TG2 then TG
accepting L* is given below
a,b a, b
aaa, bbb
p-
a, b Λ a, b
q+
p- aaa,
TG bbb q+
TG22
Λ
2. Complement of a Language
• Definition: Let L be a language defined
over alphabet Σ, then language of strings
defined over Σ, not belonging to L, is
called Complement of L, denoted by Lc or
L’.
Note
• To describe complement of a language, it is
important to describe alphabet of that
language over which language is defined.
• For a certain language L, the complement Lc is
the given language L, i. e., (Lc)c =L
Theorem: Complement of a Language
Statement: If L is a regular language then, Lc is
also a regular language.
Proof
• Since L is a regular language, so by Kleene’s
theorem, there exists an FA, F, accepting it
• Convert each final state of F to non-final state and
old non-final state to final state
• Resultant FA will reject every string in L and
accept every string not in L.
• Hence FA accepts the language Lc.
• Lc can be expressed by RE, thus Lc is regular.
Example: Complement of a Language
Example Let L be a language over the alphabet Σ =
{a, b} consisting of only two words aba and abb
then find complement of L.
Solution: The FA accepting L is
n- a b a, b
o q+
b pa a, b
a, b
r
Example Contd. Complement of a Language
Convert final states to non-final states and
old non-final states to final states, then FA
accepting Lc is
n+/- a b a, b
o+ q
b p+ a a, b
a, b
r+
3. Intersection of Languages
Theorem
If L1 and L2 are two regular languages,
then L1 L2 is also regular.
Proof: Using De-Morgan's law
(L1c L2c)c = (L1c)c (L2c)c = L1
L2
• Since L1 and L2 are regular languages, so are L1c
and L2c.
• L1c L2c is also regular language and
• (L1c L2c)c = L1 L2, being complement of
regular language is regular.
Example: Intersection of Languages
• Consider two regular languages L1 and
L2, defined over the alphabet Σ = {a,
b}, where
• L1 = language with double a’s =
(a+b)*aa(a+b)*
• L2 = containing even number of a’s =
a a, b
(b+ab*a)* a
q r+
• FAsbaccepting L1 and b L2 is as follows b
a
b
1+/- 2
p-
a
Example Contd. Intersection of Languages
Now FAs accepting L1c and L2c
b a a, b
L1c p+- a
q+ r
b
b a b
L2c 1- 2+
a
Example Contd. Intersection of Languages
(L1c L2c)
New States after reading
Old States
a b
b z 1+
a b
b
z 4+ z 2+ a z 3+
b
a
a
b a b
z z 6+
5 a
Example Contd. Intersection of Languages
b z 1-
FA for (L1c L2c)c
b b
a
z4 z2 z3
b a
a
a
b a b
z 5+ z6
a
3. Short Method Finding Intersection
a a
b a b
z 5+
a
z6