More Properties of Regular Languages

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 59

1

More Properties
of
Regular Languages
2
We have proven
Regular languages are closed under:
Union

Concatenation

Star operation

Reverse
3
Namely, for regular languages and :
1
L
2
L
2 1
L L
2 1
L L
-
1
L
Union

Concatenation

Star operation

Reverse
R
L
1
Regular
Languages
4
We will prove
Regular languages are closed under:
Complement


Intersection
5
Namely, for regular languages and :
1
L
2
L
1
L
2 1
L L
Complement


Intersection
Regular
Languages
6
Complement
Theorem:
For regular language
the complement is regular
L
L
Proof:
Take DFA that accepts and make
nonfinal states final
final states nonfinal
Resulting DFA accepts
L
L
7
Example:
a
b
b a,
b a,
0
q
1
q
2
q
) * ( b a L L =
a
b
b a,
b a,
0
q
1
q
2
q
)*) )( ( * * ( b a b a b a a L L + + + =
8
Intersection
Theorem:
For regular languages and
the intersection is regular
2 1
L L
1
L
2
L
Proof: Apply DeMorgans Law:
2 1 2 1
L L L L =
9
2 1
, L L regular
2 1
, L L regular
2 1
L L regular
2 1
L L regular
2 1
L L regular
10
Standard Representations
of
Regular Languages
11
Standard Representations
of Regular Languages
Regular Languages
DFAs
NFAs
Regular
Expressions
Regular
Grammars
12
When we say:
We are given
a Regular Language
We mean:
L
Language is in a standard
representation
L
13
Elementary Questions

about

Regular Languages

14
Membership Question
Question: Given regular language
and string
how can we check if ?
L
L w e
w
Answer: Take the DFA that accepts
and check if is accepted
L
w
15
DFA
L we
DFA
L we
w
w
16
Given regular language
how can we check
if is empty: ?
L
L
Take the DFA that accepts

Check if there is a path from
the initial state to a final state
L
) ( C = L
Question:
Answer:
17
DFA
C = L
DFA
C = L
18
Given regular language
how can we check
if is finite?
L
L
Take the DFA that accepts

Check if there is a walk with cycle
from the initial state to a final state
L
Question:
Answer:
19
DFA
L is infinite
DFA
L is finite
20
Given regular languages and
how can we check if ?
1
L
2
L
2 1
L L =
Question:
C = ) ( ) (
2 1 2 1
L L L L Find if
Answer:
21
C = ) ( ) (
2 1 2 1
L L L L
C =
2 1
L L C =
2 1
L L
and
2 1
L L =
1
L
2
L
1
L
2
L
2 1
L L _
1 2
L L _
2
L
1
L
22
C = ) ( ) (
2 1 2 1
L L L L
C =
2 1
L L C =
2 1
L L
or
1
L
2
L
1
L
2
L
2 1
L L .
1 2
L L .
2 1
L L =
23
Non-regular languages

24
Regular languages
b a*
a c b + *
... etc
* ) ( b a c b + +
Non-regular languages
} 0 : { > n b a
n n
}*} , { : { b a w ww
R
e
25
How can we prove that a language
is not regular?
L
Prove that there is no DFA that accepts L
Problem: this is not easy to prove
Solution: the Pumping Lemma !!!
26

The Pigeonhole Principle
27

pigeons
pigeonholes
4
3
28

A pigeonhole must
contain at least two pigeons
29

...........
...........
pigeons
pigeonholes
n
m
m n >
30
The Pigeonhole Principle

...........
pigeons
pigeonholes
n
m
m n >
There is a pigeonhole
with at least 2 pigeons
31
The Pigeonhole Principle

and

DFAs

32

DFA with states
4
1
q
2
q
3
q
a
b
4
q
b
b b
b
a
a
33

1
q
2
q
3
q
a
b
4
q
b
b
b
a
a
a
In walks of strings:
aab
aa
a no state
is repeated
34

In walks of strings:
1
q
2
q
3
q
a
b
4
q
b
b
b
a
a
a
... abbbabbabb
abbabb
bbaa
aabb
a state
is repeated
35

If the walk of string has length
1
q
2
q
3
q
a
b
4
q
b
b
b
a
a
a
w
4 | | > w
then a state is repeated
36
If in a walk of a string
transitions states of DFA
then a state is repeated
1
q
2
q
3
q
a
b
4
q
b
b
b
a
a
a
>
Pigeonhole principle for any DFA:
w
37
In other words for a string :

transitions are pigeons

states are pigeonholes
1
q
2
q
3
q
a
b
4
q
b
b
b
a
a
a
q
a
w
38
In general:

A string has length number of states
w >
A state must be repeated in the walk w
q
q
...... ......
walk of
w
39
The Pumping Lemma

40
Take an infinite regular language
L
DFA that accepts
L
m
states
41
Take string with
w
L we
There is a walk with label : w
.........
walk w
42
If string has length w
m w > | |
number
of states
then, from the pigeonhole principle:

a state is repeated in the walk
q
w
q
...... ......
walk w
43
Write
z y x w=
q
...... ......
x
y
z
44
q
...... ......
x
y
z
Observations:
m y x s | |
length
number
of states
1 | | > y
length
45
The string is accepted
z x
Observation:
q
...... ......
x
y
z
46
The string
is accepted
z y y x
Observation:
q
...... ......
x
y
z
47
The string
is accepted
z y y y x Observation:
q
...... ......
x
y
z
48
The string
is accepted
z y x
i
In General:
... , 2 , 1 , 0 = i
q
...... ......
x
y
z
49
In other words, we described:
The Pumping Lemma !!!
50
The Pumping Lemma:
Given a infinite regular language L
there exists an integer m
for any string with length L we
m w > | |
we can write z y x w=
with and
m y x s | | 1 | | > y
such that:
L z y x
i
e
... , 2 , 1 , 0 = i
51
Applications

of

the Pumping Lemma

52
Theorem:
The language } 0 : { > = n b a L
n n
is not regular
Proof: Use the Pumping Lemma
53
Assume for contradiction
that is a regular language L
Since is infinite
we can apply the Pumping Lemma
L
} 0 : { > = n b a L
n n
54
Let be the integer in the Pumping Lemma
Pick a string such that: w
L w e
m w > | |
length
Example:
m m
b a w=
pick
m
} 0 : { > = n b a L
n n
55
Write:
z y x b a
m m
=
it must be that: length
From the Pumping Lemma
1 | | , | | > s y m y x
Therefore:
b ab a aa a b a
m m
... ... ... ... =
1 , > = k a y
k
x y z
m m
56
From the Pumping Lemma:
L z y x
i
e
... , 2 , 1 , 0 = i
Thus:
m m
b a z y x =
L b a z y y x z y x
m k m
e = =
+ 2
L z y x e
2
We have:
1 , > = k a y
k
57
L b a
m k m
e
+
Therefore:
} 0 : { > = n b a L
n n
BUT:
L b a
m k m
e
+
CONTRADICTION!!!
58
Our assumption that
is a regular language is not true
L
Conclusion: L is not a regular language
Therefore:
59
Regular languages
b a*
a c b + *
... etc
* ) ( b a c b + +
Non-regular languages
} 0 : { > n b a
n n

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