0% found this document useful (0 votes)
19 views33 pages

Regular Language Properties

The document discusses the properties of regular languages, including how to prove whether a language is regular or not, the closure properties of regular languages, and the minimization of Deterministic Finite Automata (DFAs). It explains the Pumping Lemma as a technique to show that certain languages are not regular and outlines the steps to use this lemma effectively. Additionally, it covers decision properties of regular languages, such as membership, emptiness, and finiteness tests, as well as methods for minimizing DFAs and determining equivalence between them.

Uploaded by

shreyaup66
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views33 pages

Regular Language Properties

The document discusses the properties of regular languages, including how to prove whether a language is regular or not, the closure properties of regular languages, and the minimization of Deterministic Finite Automata (DFAs). It explains the Pumping Lemma as a technique to show that certain languages are not regular and outlines the steps to use this lemma effectively. Additionally, it covers decision properties of regular languages, such as membership, emptiness, and finiteness tests, as well as methods for minimizing DFAs and determining equivalence between them.

Uploaded by

shreyaup66
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33

Properties of Regular

Languages
Reading: Chapter 4

1
Topics
1) How to prove whether a given
language is regular or not?

2) Closure properties of regular


languages

3) Minimization of DFAs

2
Some languages are not
regular
When is a language is regular?
if we are able to construct one of the
following: DFA or NFA or  -NFA or regular
expression

When is it not?
If we can show that no FA can be built for a
language

3
How to prove languages are
not regular?
What if we cannot come up with any FA?
A) Can it be language that is not regular?
B) Or is it that we tried wrong approaches?

How do we decisively prove that a language


is not regular?

“The hardest thing of all is to find a black cat in a dark room,


especially if there is no cat!” -Confucius
4
Example of a non-regular
language
Let L = {w | w is of the form 0n1n , for all n≥0}
 Hypothesis: L is not regular

 Intuitive rationale: How do you keep


track of a running count in an FA?
 A more formal rationale:
 By contradition, if L is regular then there should exist a DFA
for L.
 Let k = number of states in that DFA.
 Consider the special word w= 0k1k => w L
 DFA is in some state pi, after consuming the first i symbols in
w
5
Uses Pigeon Hole Principle

Rationale…
 Let {p0,p1,… pk} be the sequence of states that the
DFA should have visited after consuming the first k
symbols in w which is 0k
 But there are only k states in the DFA!
 ==> at least one state should repeat somewhere
along the path (by ++
Principle)
 ==> Let the repeating state be pi=pJ for i < j
 ==> We can fool the DFA by inputing 0(k-(j-i))1k and
still get it to accept (note: k-(j-i) is at most k-1).
 ==> DFA accepts strings w/ unequal number of 0s
and 1s, implying that the DFA is wrong! 6
The Pumping Lemma for
Regular Languages
What it is?
The Pumping Lemma is a property
of all regular languages.
How is it used?
A technique that is used to show that
a given language is not regular
7
Pumping Lemma for Regular
Languages
Let L be a regular language

Then there exists some constant N such that for


every string w  L s.t. |w|≥N, there exists a
way to break w into three parts, w=xyz,
such that:
1. y≠ 
2. |xy|≤N
3. For all k≥0, all strings of the form xykz  L

This property should hold for all regular languages.

Definition: N is called the “Pumping Lemma Constant” 8


The Purpose of the Pumping
Lemma for RL
 To prove that some languages cannot
be regular.

9
How to use the pumping
lemma?
Think of playing a 2 person game
 Role 1: We claim that the language cannot
be regular

 Role 2: An adversary who claims the


language is regular

 We show that the adversary’s statement will lead


to a contradiction that implies pumping lemma
cannot hold for the language.

 We win!!
10
How to use the pumping
lemma? (The Steps)
1. (we) L is not regular.
2. (adv.) Claims that L is regular and gives you
a value for N as its P/L constant
3. (we) Using N, choose a string w  L s.t.,
1. |w| ≥ N,
2. Using w as the template, construct other words
wk of the form xykz and show that at least one
such wk  L
=> this implies we have successfully broken the
pumping lemma for the language, and hence that the
adversary is wrong.
(Note: In this process, we may have to try many values of k,
starting with k=0, and then 2, 3, .. so on, until wk L ) 11
Note: We don’t have any control over N, except that it is positive.
We also don’t have any control over how to split w=xyz,
but xyz should respect the P/L conditions (1) and (2).

Using the Pumping Lemma


 What WE do?  What the Adversary does?
1. Claims L is regular
2. Provides N

3. Using N, we construct
our template string w
4. Demonstrate to the
adversary, either
through pumping up or
down on w, that some
string wk  L
(this should happen
regardless of w=xyz) 12
Note: This N can be anything (need not necessarily be the #states in the DFA.
It’s the adversary’s choice.)
Example of using the Pumping Lemma to
prove that a language is not regular
Let Leq = {w | w is a binary string with equal number
of 1s and 0s}
 Your Claim: Leq is not regular
 Proof:
 adv.

By contradiction, let Leq be regular
 P/L constant should exist  adv.

Let N = that P/L constant
 you
 Consider input w = 0N1N
(your choice for the template string)
you
 By pumping lemma, we should be able to break
w=xyz, such that:
1) y≠ 
2) |xy|≤N
3) For all k≥0, the string xykz is also in L 13
Template string w = 0N1N = 00 …. 011 … 1
N N

Proof…

Because |xy|≤N, xy should contain only 0s  you

(This and because y≠ , implies y=0+)
 Therefore x can contain at most N-1 0s
 Also, all the N 1s must be inside z
 By (3), any string of the form xykz  Leq for all k≥0
Setting k=0 is  Case k=0: xz has at most N-1 0s but has N 1s
referred to as
“pumping down”  Therefore, xy0z  Leq
 This violates the P/L (a contradiction)

Another way of proving this will be to show that if


Setting k>1 is the #0s is arbitrarily pumped up (e.g., k=2),
referred to as
“pumping up” then the #0s will become exceed the #1s
14
Exercise 2
Prove L = {0n10n | n≥ 1} is not regular

Note: This n is not to be confused with the pumping


lemma constant N. That can be different.

In other words, the above question is same as


proving:
 L = {0m10m | m≥ 1} is not regular

15
Example 3: Pumping Lemma
Claim: L = { 0i | i is a perfect square} is not regular
 Proof:
 By contradiction, let L be regular.
 P/L should apply
 Let N = P/L constant

Choose w=0N2
 By pumping lemma, w=xyz satisfying all three rules
 By rules (1) & (2), y has between 1 and N 0s
 By rule (3), any string of the form xykz is also in L for all k≥0
 Case k=0:

#zeros (xy0z) = #zeros (xyz) - #zeros (y)

N – N ≤ #zeros (xy0z) ≤ N2 - 1
2


(N-1)2 < N2 - N ≤ #zeros (xy0z) ≤ N2 - 1 < N2

xy0z  L

But the above will complete the proof ONLY IF N>1.

… (proof contd.. Next slide)
16
Example 3: Pumping Lemma
 (proof contd…)

If the adversary pick N=1, then (N-1)2 ≤ N2 – N, and therefore the #zeros(xy0z)
could end up being a perfect square!

This means that pumping down (i.e., setting k=0) is not giving us the proof!

So lets try pumping up next…
 Case k=2:

#zeros (xy2z) = #zeros (xyz) + #zeros (y)

N + 1 ≤ #zeros (xy2z) ≤ N2 + N
2


N2 < N2 + 1 ≤ #zeros (xy2z) ≤ N2 + N < (N+1)2

xy2z  L


(Notice that the above should hold for all possible N values of N>0. Therefore,
this completes the proof.)

17
Closure properties of Regular
Languages

18
Closure properties for Regular
Languages (RL) This
Thisisis
different
differentfrom
from
Kleene
 Closure property: Kleene
closure
closure
 If a set of regular languages are combined using
an operator, then the resulting language is also
regular
 Regular languages are closed under:
 Union, intersection, complement, difference
 Reversal
 Kleene closure
 Concatenation
 Homomorphism

19
RLs are closed under union
 IF L and M are two RLs THEN:

 they both have two corresponding regular


expressions, R and S respectively

 (L U M) can be represented using the regular


expression R+S

 Therefore, (L U M) is also regular

20
RLs are closed under set
difference
Closed under intersection
 We observe: Closed under
 L-M=L∩M complementation

 Therefore, L - M is also regular

21
RLs are closed under reversal
Reversal of a string w is denoted by wR
 E.g., w=00111, wR=11100
Reversal of a language:
 LR = The language generated by

reversing all strings in L

Theorem: If L is regular then LR is also


regular

22
Homomorphisms
 Substitute each symbol in ∑ (main alphabet)
by a corresponding string in T (another
alphabet)
 h: ∑--->T*
 Example:
 Let ∑={0,1} and T={a,b}
 Let a homomorphic function h on ∑ be:

h(0)=ab, h(1)=
 If w=10110, then h(w) = abab = abab
 In general,

h(w) = h(a1) h(a2)… h(an)
23
Decision properties of regular
languages
Any “decision problem” looks like this:

Yes
Decision
Input problem
(generally solver
a question)
No

24
Membership question
 Decision Problem: Given L, is w in L?
 Possible answers: Yes or No
 Approach:
1. Build a DFA for L
2. Input w to the DFA
3. If the DFA ends in an accepting state,
then yes; otherwise no.

25
Emptiness test
 Decision Problem: Is L=Ø ?
 Approach:
On a DFA for L:
1. From the start state, run a reachability test, which
returns:
1. success: if there is at least one final state that is
reachable from the start state
2. failure: otherwise
2. L=Ø if and only if the reachability test fails

How to implement the reachability test?


26
Finiteness
 Decision Problem: Is L finite or infinite?
 Approach:
On a DFA for L:
1. Remove all states unreachable from the start state
2. Remove all states that cannot lead to any accepting state.
3. After removal, check for cycles in the resulting FA
4. L is finite if there are no cycles; otherwise it is infinite
 Another approach
 Build a regular expression and look for Kleene closure

How to implement steps 2 and 3?


27
Finiteness test - examples
Ex 1) Is the language of this DFA finite or infinite?

X FINITE
0
X q6 1

Ex 2) Is the language of this DFA finite or infinite?

INFINITE
X
0
to this
d ue
1
28
Equivalence & Minimization of
DFAs

29
Applications of interest
 Comparing two DFAs:

L(DFA1) == L(DFA2)?

 How to minimize a DFA?


1. Remove unreachable states
2. Identify & condense equivalent states into one

30
When to call two states in a DFA
“equivalent”?
Past doesn’t matter - only future does!

Two states p and q are said to be


equivalent iff:
i) Any string w accepted by starting at p is also accepted by
starting at q;
p
w
AND
q

ii) Any string w rejected by starting at p is also rejected by


starting at q.
p
w
q
 p≡q
31
Putting it all together …

How to minimize a DFA?


 Goal: Minimize the number of states in
a DFA
Depth-first traversal from the start state
 Algorithm:
1. Eliminate states unreachable from the
start state Table filling algorithm
2. Identify and remove equivalent states
3. Output the resultant DFA

32
Summary
 How to prove languages are not regular?
 Pumping lemma & its applications

 Closure properties of regular languages

 Simplification of DFAs
 How to remove unreachable states?

 How to identify and collapse equivalent states?

 How to minimize a DFA?

 How to tell whether two DFAs are equivalent?

33

You might also like