0% found this document useful (0 votes)
37 views50 pages

Wa0012.

Uploaded by

mohammad97kaif
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)
37 views50 pages

Wa0012.

Uploaded by

mohammad97kaif
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/ 50

Properties of Regular Languages

Standard Representations of Regular Languages


A language L over an alphabet  is regular iff
• It is accepted by FA (DFA, or NFA)
• It is described by a regular expression.
• It is generated by regular grammar (Left-linear or Right-linear).
Closure Properties
• Recall that a closure property is a statement that a certain operation
on languages, when applied to languages in a class, produces a
result that is also in that class.

Given two regular languages, L1 and L2,


is their union regular?

If it is true for all regular languages,


then the family of regular languages is
closed under union.
• For regular languages, we can use any of its representations to
prove a closure property.
Properties of RLs
For regular languages L1 and L2,
We will prove that:

regular
Languages

It means the family of Regular languages are


closed under the above operations.
Example
Regular language L1 Regular language L2

L(M1 ) = L1 L(M 2 ) = L2

NFA M1 NFA M2

Single final state Single final state


Example
𝑀3
a
L3 ={anb :n≥0} b

𝑀4

𝐿4 = 𝑏𝑎 b a
Union
NFA for 𝐿1 ∪ 𝐿2

Example: NFA for


𝐿3 ∪ 𝐿4 = {𝑎𝑛 𝑏} ∪ {𝑏𝑎}
Concatenation
NFA for L1L2

𝑛 𝑛
NFA for 𝐿 𝐿
3 4 = {𝑎 𝑏}{𝑏𝑎} = {𝑎 𝑏𝑏𝑎} n0
Star Operation

NFA for L1 *

𝑛
NFA for 3𝐿 ∗= {𝑎 𝑏} ∗
The string in L3* is w.
w = w1w2  wk
wi  L1
Reversal
R
NFA for L1
L1 M1 M1

1. NFA M1 with a single final state is given


2. Reverse all transitions
3. Mark the initial state as the final state and
vice versa
Example
M1
a
L1 = {a b}
n
b

M1
a
R
L1 = {ba }
n b
Complement

L1 M1 L1 M1

1. Take the DFA that accepts L1


2. Mark final states as non-final, and vice-versa.
Example
M1
a a, b

L1 = {a b}
n b a, b

M1
a a, b
L1 = {a, b} * −{a b}
n

b a, b
Intersection
DeMorgan’s Law: L1  L2 = L1  L2
L1 , L2 regular

L1 , L2 regular

L1  L2 regular

L1  L2 regular
L1  L2 regular
Example

L1 = {a b} regular
n
L1  L2 = {ab}
L2 = {ab, ba} regular regular

a b
a
b a, b

a, b
Intersection (Product)
L1 = L(M1), M1 = (Q, , 1, q0, F1), Q = {q0, q1…... qm,}
L2 = L(M2), M2 = (P, , 2, p0, F2), Q = {p0, p1…... pn,}
M1 and M2 are DFAs.

Define new automation, M’ = (Q’, , ’, (q0, p0), F’)


Q’ = QXP = {(qi, pj): qi ε Q, pj ε P}
Q’ = QXP = {q0, q1…... qm,} X {p0, p1…... pn,} = {(q0,p0), (q0,p1), (q0,
p2),………….(q0, pn), (q1, p0),………………………… (qm, pn)}

Define transition function ’ s.t.


’( (qi, pj), a ) = (qk, pl)
If 1(qi, a ) = qk
AND 2(pj, a ) = pl
Define transition for all states.
The initial state is (q0, p0),
F’ is the set of all states (qi, pj) s.t.
qi, ε F1, pj ε F2
Example-1
Example-2
Find product

What is your answer?


DIFFERENCE
L1 = L(M1), M1 = (Q, , 1, q0, F1), Q = {q0, q1…... qm,}
L2 = L(M2), M2 = (P, , 2, p0, F2), Q = {p0, p1…... pn,}
M1 and M2 are DFAs
𝐿1 − 𝐿2 = 𝐿1 ∩ 𝐿2

L1 , L2 regular

𝐿1 , 𝐿2 regular

𝐿1 ∩ 𝐿2 regular
DIFFERENCE
If L1 and L2 are regular languages, So is L1 - L2
L1 - L2 consists of strings in L1 but not L2 i.e.,
𝐿1 − 𝐿2 = 𝐿1 ∩ 𝐿2

Let M1 and M2 be DFA’s whose languages are L1 and L2,


respectively.
Construct C, the product automaton of M1 and M2.

Make the final states of C be the pairs where M1-state


is final but M2-state is not.
Example
Exercise
For the given languages, construct the FAs for.
• Union
• Star closure
• Concatenation
• Complement
• Reversal
• Intersection
• Difference

Exercise-1
L1 = L ( (a+b)a*)
L2 = L( baa*)
Exercise -2
L3 = {w ε {0, 1 }* : w consists of 0’s in multiple of 3}
L4 = {w ε {0, 1 }* : w consists of odd number of 0’s}
Elementary Questions

about

Regular Languages
Membership Question
Question-1 Given regular language L
and string w
how can we check if w  L?
Answer: Take the DFA that accepts L
and check if w is accepted
w
DFA w L
If there is a path from initial state to final state with labeled w; Accepted
w
DFA w L
If there is no path from initial state to final state with labeled w; Rejected
Given regular language L
Question-2 how can we check
ifL is empty:( L = ) ?
Take the DFA that accepts L
Answer:
Check if there is any path from
the initial state to a final state

DFA L

DFA L=
Given regular language L
Question-4 how can we check
if L is finite?

Take the DFA that accepts L


Answer: Check if there is a walk with cycle
from the initial state to a final state

DFA L is infinite

DFA L is finite
Example
Non-regular languages
Regular Languages
Every finite language is regular.
Some infinite languages are regular
L1 ={anb : n >=0} → aaab

Regularity:
The language is regular if, in processing any string, the information
that has to be remembered at any stage is strictly limited.

Some infinite languages are not regular


L2 = {anbn : n >=0} → aaabbb

How can we prove that a language L is regular?


Prove/Show that there is DFA M that accepts L
Prove/Show that there is RE r that generates L
Prove/Show that there is RG G that generates L
{a b : n  0}
n n
Non-regular languages
{vv : v {a, b}*}
R

Regular languages
a *b b*c + a
b + c ( a + b) *
etc...
How can we prove that a language L is not
regular?

Prove that there is no DFA/RE/RG that


accepts L

Problem: This is not easy to prove


Solution: The Pumping Lemma !!!
The pumping Lemma is Proof-by-Contradiction
method and uses pigeonhole principle.
Proof by Contradiction-Example
Statement: 2 is not rational
Proof: Assume 2 is rational
2 = n/m n and m have no common factors
We will show that this is impossible
The Pigeonhole Principle
4 pigeons
3 pigeonholes

A pigeonhole must contain at least two pigeons


The Pigeonhole Principle

If we put n objects into m boxes and if n > m


• then at least one box must have more than
one object in it.
In other words for a string w:

a transitions are pigeons

q states are pigeonholes

walk of w
...... q ......
Repeated state
In general, for any DFA:

String w has length  number of states

A state q must be repeated in the walk of w

walk of w
...... q ......
Repeated state
The Pigeonhole Principle and DFAs

In walks of strings: aab


At-least one state
abab
is repeated
aabb
b
b b aabbb

q1 a q2 a q3 b q4
DFA with 4 states a a
In string length < 4 no state is repeated
If string w | w |  4:
has length
Then the transitions of string w are more
than the states of the DFA
Thus, a state must be repeated
b
b b

q1 a q2 a q3 b q4
a a
Thus, the repeated state represents a pattern in RL.
The Pumping Lemma:
• Assume that given infinite L language is regular
• There exists an integer m for any string

w L with length | w| m


Then, we can decompose w= x y z

with | x y |  m and | y | 1
such that: xy z  L
i i = 0, 1, 2, ...
Applications

of

the Pumping Lemma


Prove that the language L = {a b : n  0}
n n
is not regular.

Proof: Since L is infinite.


we can apply Pumping Lemma

Assume for contradiction that L is a regular language

Let m be the integer in the Pumping Lemma

Pick a string w such that: w  L


length | w| m
We pick w=a b m m
Write: a b =xyz
m m

From the Pumping Lemma

It must be given that length | x y |  m, | y | 1


m m
x = al
xyz = a bm m
= a...aa...aa...ab...b y= ak

x y z
z = am –(l+k) bm
Thus: y = a , k 1
k
x y z=a b m m
y = a , k 1
k

From the Pumping Lemma: xy z  L


i
x = al

i = 0, 1, 2, ... y= ak
z = am –(l+k) bm
i=0 → am-kbm
i= 1 → ambm
Thus: xy z  L 2 i=2 → am+kbm
i=3 → am+2kbm
i=4 → am+3kbm

xy z = a...aa...aa...aa...ab...b  L
2

x y y z
m+ k m
Therefore: a b L
m+ k m k≥ 1
a b L

BUT: L = {a b : n  0}
n n

m+ k m
a b  L CONTRADICTION!
Therefore: Our assumption that L is a
regular language is not true

Conclusion: L is not a regular language


Prove that the language L = {vv : v  *}
R
is not regular  = {a, b}
Proof: Since L is infinite
we can apply the Pumping Lemma

Assume for contradiction


that L is a regular language

Let m be the integer in the Pumping Lemma


Pick a string w such that: w  L and | w |  m

We pick w=a b b a
m m m m
Write a b b a =xyz
m m m m

From the Pumping Lemma


It must be that length | x y |  m, | y | 1
m m m m
xyz = a...aa...a...ab...bb...ba...a
x y z

Thus: y = a , k 1
k
x y z=a b b a
m m m m
y = a , k 1
k

From the Pumping Lemma: xy z  L


i

i = 0, 1, 2, ...
xy z  L
Thus:
2

m+k m m m
2
xy z = a...aa...aa...a...ab...bb...ba...a ∈L
x y y z
m+ k m m m
Thus: a b b a L
m+ k m m m
a b b a L k 1

BUT: L = {vv : v  *}


R

m+ k m m m
a b b a L CONTRADICTION!

Therefore: Our assumption that L


is a regular language is not true

Conclusion: L is not a regular language


Exercise
Prove that the following languages are not
regular.
• L ={anblak : k ≥ n+l }
• L ={anbn : n ≥ 0 }
• L = {anbn+1 : n ≥ 0 }
• L = {anbn+1 : n ≥ 0 }
• L ={an! : n ≥ 1 }

Are the following languages are regular ?


• L ={w ε {a, b, c}* : |w| = 3na(w)}
• L ={w1cw2 : w1, w2 ε {a, b}*, w1 ≠w2}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy