0% found this document useful (0 votes)
2 views67 pages

Lec04 RegularLanguageProperties

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)
2 views67 pages

Lec04 RegularLanguageProperties

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/ 67

Properties of

Regular Languages

• Minimization and Equivalence of Automata


• Closure Properties of Regular Languages
• Decision Properties of Regular Languages
• The Pumping Lemma for Regular Languages

BBM401 Automata Theory and Formal Languages 1


Minimization and Equivalence of Automata

BBM401 Automata Theory and Formal Languages 2


DFA Minimization
• Every DFA defines a regular language
• In general, there can be many DFAs for a given regular language.
• These DFAs accept the same regular language.
– Language: The set of strings of 0’s and 1’s containing even number of 1’s

0 0 0 0 0
1 1 1

1 1
A minimal DFA

• In practice, we are interested in the DFA with the minimal number of states.
– Use less memory
– Use less hardware (flip-flops)
• We can find a minimal DFA for any given DFA and their languages are equal.

BBM401 Automata Theory and Formal Languages 3


Indistinguishable States
• Let A = (Q,,,q0,F) be a DFA, and {p,q}  Q, we say that p and q are
indistinguishable (equivalent) states if:

for all w∈* ෡


𝛅(p,w)F ෡
iff 𝛅(q,w)F

• This means that for all w∈*



– 𝛅(p,w)F ෡
iff 𝛅(q,w)F and

– 𝛅(p,w)∉F ෡
iff 𝛅(q,w)∉F
• Two indistinguishable states behave same for all possible strings.

• Hence, a state p is distinguishable from state q if there is at least one string w such

that either 𝛅(p,w)F ෡
or 𝛅(q,w)F and the other is NOT.
– There exists a string w such that

(𝛅(p,w)F a𝐧𝐝 𝛅෡ (q,w)∉ F) OR (𝛅(p,w)∉F
෡ ෡
and 𝛅(q,w)F)

BBM401 Automata Theory and Formal Languages 4


Indistinguishable States
• Indistinguishable states behave the same for all possible strings.
– So, we do not need all of states from a set of indistinguishable states.
– We can eliminate all of them by keeping only one of them to represent that set of
indistinguishable states.

• Indistinguishability is an equivalence relation:


– Reflexive: Each state is indistinguishable from itself
– Symmetric: If p is indistinguishable from q, then q is indistinguishable from p
– Transitive: If p is indistinguishable from q, and q is indistinguishable from r, then
p is indistinguishable from r.

BBM401 Automata Theory and Formal Languages 5


Indistinguishable States
• An equivalence relation on a set of states Q induces a partitioning 1, 2,…,k such
that:
– For all different i and j, i∩j=  and
– ‫𝐐 = 𝐢𝛑 𝟏=𝐢𝐤ڂ‬

BBM401 Automata Theory and Formal Languages 6


Finding Distinguishable States –
Table Filling Algorithm
• We can compute distinguishable states with an inductive table filling algorithm.

Basis:
• Any non-accepting state is distinguishable from any accepting state.

Induction:
• States p and q are distinguishable if there is some input symbol a such that (p,a)
is distinguishable from (q,a).

• All other pairs of states are indistinguishable, and can be merged appropriately.

BBM401 Automata Theory and Formal Languages 7


Finding Distinguishable States –
Table Filling Algorithm

• Consider all pairs of states (p,q)


– if p∈F and q∉F or p∉F and q∈F, mark (p,q) as distinguishable
• 3
• Repeat the following until no previously unmarked pairs are marked:
– p,q∈Q and a∈, find (p,a)=r and (q,a)=s ,
– if (r,s) is marked as distinguishable then mark (p,q) as distinguishable.

BBM401 Automata Theory and Formal Languages 8


Minimization of DFA
Table Filling Algorithm
• We can also use table filling algorithm to minimize a DFA by merging all equivalent
states.
• That is, we replace a state p with its equivalence class found by the table filling
algorithm.

• Equivalence Classes:  = {1, 2,…,k}

– So, each equivalence class i will be a state in the minimized DFA.


– For each symbol a, min(i ,a)=j where there are states p,q p∈i q∈j such that (p,a)=q

BBM401 Automata Theory and Formal Languages 9


Table Filling Algorithm: Example 1

0
q x • p is distinguishable from q
p q
r x and r by basis, mark them
1 1 p q
1
0
r

• Both q and r go to p with 0, so


q x no string beginning with 0 will
r x distinguish them
• Starting in either q and r , an
p q
input of 1 takes us to either,
• so they are indistinguishable.
• Equivalence relation partitions (equivalence
classes): { {p}, {q,r} }

BBM401 Automata Theory and Formal Languages 10


Table Filling Algorithm: Example 1

p
0 q • Equivalence relation partitions (equivalence
classes): { {p}, {q,r} }
1 1
1 • q and r are indistinguishable.
0
r

p
0,1 {q,r} 1

DFA with minimal states

BBM401 Automata Theory and Formal Languages 11


Minimization of DFA
Table Filling Algorithm: Example 2

BBM401 Automata Theory and Formal Languages 12


Minimization of DFA
Table Filling Algorithm: Example 2

PASS 0: Distinguish accepting states from


non-accepting states

• C is only accepting state, it is distinguishable


from all other non-acceptingt states.

BBM401 Automata Theory and Formal Languages 13


Minimization of DFA
Table Filling Algorithm: Example 2

PASS 1: Consider column A

A ≢ B since (A,1)=F, (B,1)=C and F ≢ C


A ≢ D since (A,0)=B, (D,0)=C and B ≢ C
A ≡ E since
• (A,0)=B, (E,0)=H and B ≡ H
• (A,1)=F, (E,1)=F and F ≡ F
A ≢ F since (A,0)=B, (F,0)=C and B ≢ C
A ≡ G since
• (A,0)=B, (G,0)=G and B ≡ G
• (A,1)=F, (G,1)=E and F ≡ E
A ≢ H since (A,1)=F, (H,1)=C and F ≢ C

BBM401 Automata Theory and Formal Languages 14


Minimization of DFA
Table Filling Algorithm: Example 2

PASS 1: Consider column B

B ≢ D since (B,1)=C, (D,1)=G and C ≢ G


B ≢ E since (B,1)=C, (E,1)=F and C ≢ F
B ≢ F since (B,1)=C, (F,1)=G and C ≢ G
B ≢ G since (B,1)=C, (G,1)=E and C ≢ E
B ≡ H since
• (B,0)=G, (H,0)=G and G ≡ G
• (B,1)=C, (H,1)=C and C ≡ C

BBM401 Automata Theory and Formal Languages 15


Minimization of DFA
Table Filling Algorithm: Example 2

PASS 1: Consider column D

D ≢ E since (D,0)=C, (E,0)=H and C ≢ H


D ≡ F since
• (D,0)=C, (F,0)=C and C ≡ C
• (D,1)=G, (F,1)=G and G ≡ G
D ≢ G since (D,0)=C, (G,0)=G and C ≢ G
D ≢ H since (D,0)=C, (H,0)=G and C ≢ G

BBM401 Automata Theory and Formal Languages 16


Minimization of DFA
Table Filling Algorithm: Example 2

PASS 1: Consider columns E, F, G

E ≢ F since (E,0)=H, (F,0)=C and H ≢ C


E ≢ G since (E,1)=F, (G,1)=E and F ≢ E
E ≢ H since (E,1)=F, (H,1)=C and F ≢ C

F ≢ G since (F,0)=C, (G,0)=G and C ≢ G


F ≢ H since (F,0)=C, (H,0)=G and C ≢ G

G ≢ H since (G,1)=E, (H,1)=C and E ≢ C

BBM401 Automata Theory and Formal Languages 17


Minimization of DFA
Table Filling Algorithm: Example 2

PASS 2: Consider columns A, B, D

A ≡ E since
• (A,0)=B, (E,0)=H and B ≡ H
• (A,1)=F, (E,1)=F and F ≡ F
A ≡ G since (A,1)=F, (G,1)=E and F ≢ E

B ≡ H since
• (B,0)=G, (H,0)=G and G ≡ G
• (B,1)=C, (H,1)=C and C ≡ C

D ≡ F since
• (D,0)=C, (F,0)=C and C ≡ C
• (D,1)=G, (F,1)=G and G ≡ G

BBM401 Automata Theory and Formal Languages 18


Minimization of DFA
Table Filling Algorithm: Example 2

PASS 3: Consider columns A, B, D

A ≡ E since
• (A,0)=B, (E,0)=H and B ≡ H
• (A,1)=F, (E,1)=F and F ≡ F

B ≡ H since
• (B,0)=G, (H,0)=G and G ≡ G
• (B,1)=C, (H,1)=C and C ≡ C

D ≡ F since
• (D,0)=C, (F,0)=C and C ≡ C
• (D,1)=G, (F,1)=G and G ≡ G

No new marked states in PASS 3. We are done, and


we found all distinguishable states (marked ones).

BBM401 Automata Theory and Formal Languages 19


Minimization of DFA
Table Filling Algorithm: Example 2

Equivalence Classes:

{ {A,E}, {B,H}, {C}, {D,F}, {G} }

BBM401 Automata Theory and Formal Languages 20


Minimization of DFA
Table Filling Algorithm: Example 2

Equivalence Classes:
{ {A,E}, {B,H}, {C}, {D,F}, {G} }

BBM401 Automata Theory and Formal Languages 21


Is the Minimized DFA Really Minimal?
• Let M be the minimized DFA found by the table filling algorithm and assume that its
states P = {p0,…,pm} and its transition function is .

• Since all states of M are distinguishable (since M is minimal), there must be distinct
෠ 0,wi) = pi for all i.
strings w1,…,wm such that δ(p

• Suppose there is an equivalent DFA M1 with transition function 1 but with fewer
states Q = {q0,…,qn} where n<m.

BBM401 Automata Theory and Formal Languages 22


Is the Minimized DFA Really Minimal?
• Since M1 has fewer states than M, then there must be strings wk and wj among distinct
strings w1,…,wm such that δ෠ 1(q0,wk) = δ෠ 1(q0,wj) (pigeonhole principle)

• Since pk and pj are distinguishable, there must be some string x such that
෠ 0,wk.x) = δ(p
– δ(p ෠ k,x)= is a final state and
෠ 0,wj.x) = δ(p
– δ(p ෠ j,x)= is NOT a final state, or vice versa.
– So wk.x is accepted and wj.x is not (or vice versa)

• But
෡1(q0,wk.x) =𝛅
𝛅 ෡ 1 (𝛅
෡1(q0,wk),x) =𝛅
෡ 1(𝛅
෡1(q0,wj),x) = 𝛅
෡1(q0,wj.x)

• So M1 either accepts both wk.x and wj.x or rejects both.

• So M1 and M can not be equivalent. So M1 can not exist.

BBM401 Automata Theory and Formal Languages 23


Testing Equivalence of Regular Languages
with Table Filling Algorithm
1st Approach to Test Equivalence:
– Minimize their DFAs,
– Check whether they are isomorphic (ie. they are same with renaming states)

2nd Approach to Test Equivalence:


– Let L and M be regular languages, to test whether L = M
– Create DFAs for both L and M
– Imagine the DFA that is the union of the two DFA's (never mind there are two
start states)
– If the table filling algorithm says that the two start states are distinguishable, then
L  M, otherwise L = M.

BBM401 Automata Theory and Formal Languages 24


Testing Equivalence of Regular Languages
with Table Filling Algorithm - Example

• Since A and C are equivalent,


these two DFAs are equivalent.

• Their languages are also equivalent.

BBM401 Automata Theory and Formal Languages 25


Closure Properties of Regular Languages

BBM401 Automata Theory and Formal Languages 26


Closure Properties of Regular Languages
• Closure Properties of Regular Languages are the theorems indicate that the regular
languages are closed under certain operations.

• A closure property of regular languages say that


– If a language is created from regular languages using the operation
mentioned in the theorem, it is also a regular language.

• Closure properties of regular languages also indicate that how their DFAs can be
created from DFAs of other regular languages using certain operations.

BBM401 Automata Theory and Formal Languages 27


Principal Closure Properties
of Regular Languages
1. The union of two regular languages is regular.

2. The concatenation of regular languages is regular.

3. The closure (star) of a regular language is regular.

4. The complement of a regular language is regular.

5. The intersection of two regular languages is regular.

6. The difference of two regular languages is regular.

7. The reversal of a regular language is regular.

8. A homomorphism (substitution of strings for symbols) of a regular language is


regular.

9. The inverse homomorphism of a regular language is regular.

BBM401 Automata Theory and Formal Languages 28


Union of Two Regular Languages is Regular
Theorem: (closure under union)
If L and M are regular languages, then L∪M is regular.

Proof:
• Since L and M are regular, they have regular expressions; say L = L(R) and M = L(S).
• Then L∪M = L(R+S) by the definition of the + operator for regular expressions.
• Thus, L∪M is regular.

BBM401 Automata Theory and Formal Languages 29


Concatenation of Regular Languages is Regular
Theorem: (closure under concetanation)
If L and M are regular languages, then LM is regular.

Proof:
• Since L and M are regular, they have regular expressions; say L=L(R) and M=L(S).
• Then LM=L(RS) by the definition of the concatenation operator for regular
expressions.
• Thus, LM is regular

BBM401 Automata Theory and Formal Languages 30


Closure of a Regular Language is Regular
Theorem: (closure under star)
If L is a regular language, then L* is regular.

Proof:
• Since L is regular, it has a regular expression; say L=L(R).
• Then L*=L(R*) by the definition of the closure operator for regular expressions.
• Thus, L* is regular.

BBM401 Automata Theory and Formal Languages 31


Complement of a Regular Language is Regular
Theorem: (closure under complement)
If L is a regular language over alphabet , then its complement 𝐋=
ҧ *-L is also a
regular language.

Proof:
• Let L=L(A) for some DFA A = (Q, , , q0, F).
• Then Lത =L(B), where B is the DFA = (Q, , , q0, Q-F).
• That is, B is exactly like A, but the accepting states of A have become non-accepting
states of B, and vice versa.
෠ 0,w) in Q-F, which occurs if and only if w is not
• Then, w is in L(B) if and only if δ(q
in L(A).
• Thus, Lത is regular.

BBM401 Automata Theory and Formal Languages 32


Closure Under Complement - Example

L=L(A) : strings of 0's and l’s


that end in 01;
In regular-expression terms,
L(A) = L((0+l)*01).

L=L(A) : strings of 0's and l’s


that do not end in 01;

BBM401 Automata Theory and Formal Languages 33


Intersection of Two Regular Languages is Regular
Theorem: (closure under intersection)
If L and M are regular languages, then L∩M is regular.

Proof: (Simple Proof)


• By DeMorgan’s law L∩M = Lത ∪ M.

• We already know that regular languages are closed under complement and union.
• So, L∩M is regular when L and M are regular.

BBM401 Automata Theory and Formal Languages 34


Closure Under Intersection
DFA Construction Proof
Theorem: (closure under intersection)
If L and M are regular languages, then L∩M is regular.

Proof: (DFA Construction Proof)


• Let L be the language of DFA AL = (QL, , L, qL, FL) and M be the language of
DFA AM = (QM, , M, qM, FM).
• We will construct an automaton that simulates AL and AM in parallel, and accepts if
and only if both AL and AM accept.
• If AL goes from state p to state s on reading a, and AM goes from state q to state t on
reading a, then ALM will go from state (p,q) to state (s,t) on reading a.
• Formally, ALM = (QLxQM, , LM, (qL,qM), FLxFM) where
LM((p,q),a) = (L(p,a),M(q,a))

BBM401 Automata Theory and Formal Languages 35


Closure Under Intersection
DFA Construction Proof (cont.)
• By induction |w|, it can be shown that
δ෠ LM((qL,qM),w) = (δ෠ L(qL,w), δ෠ M(qM,w))

• To see why L(ALM) = L(AL)∩L(AM), first we can observe that an induction on |w|
proves that δ෠ LM((qL,qM),w) = (δ෠ L(qL,w), δ෠ M(qM,w)).

• But ALM accepts w if and only if δ෠ LM((qL,qM),w) is a pair of accepting states.

• That is, δ෠ L(qL,w) must be in FL and δ෠ M(qM,w) must be in FM.

• w is accepted by ALM if and only if both AL and AM accept w.

• Thus, ALM accepts the intersection of L(AL) and L(AM).

BBM401 Automata Theory and Formal Languages 36


Closure Under Intersection
Product Construction -- Example

DFA AL

DFA AM

• DFA ALM is the cross product of AL and AM. DFA ALM

• L(ALM) = L(AL)∩L(AM).
• L(AL) is the set of strings containing at least one 0.
• L(AM) is the set of strings containing at least one 1.
• L(ALM) is the set of strings containing at least one 0 and one 1.

BBM401 Automata Theory and Formal Languages 37


Difference of Two Regular Languages is Regular
Theorem: (closure under difference)
If L and M are regular languages, then L-M is regular.

Proof:

• We can observe that L - M = L ∩ M.
ഥ is regular.
• By closure under complement, M
ഥ is regular.
• By closure under intersection, L ∩ M
• Thus, L-M is regular.

BBM401 Automata Theory and Formal Languages 38


Reversal of a Regular Language is Regular
• The reversal of a string a1a2 ... an is the string written backwards, that is, anan-1 ... a1.

• We use wR for the reversal of string w.


– Thus, 0010R is 0100, and
– R = .

• The reversal of a language L, written LR is the language consisting of the reversals of


all its strings.
– For instance, if L={001,10,111}, then LR ={100,01,111}.

• Reversal is another operation that preserves regular languages; that is, if L is a regular
language, so is LR.

BBM401 Automata Theory and Formal Languages 39


Reversal of a Regular Language is Regular
Theorem: (closure under reversal)
If L is a regular language, then its reversal LR is regular.

Proof: (proof by automaton creation)


• Let L be recognized by a Finite Automaton A.
• Turn A into a FA for LR, by
1. Reverse all the arcs in the transition diagram for A,
2. Make the start state of A be the only accepting state for the new automaton.
3. Create a new start state p0 with transitions on  to all the accepting states of A.
• The result is an automaton that, simulates A "in reverse" and therefore accepts a string
w if and only if A accepts wR.

BBM401 Automata Theory and Formal Languages 40


Closure Under Reversal
Induction Proof on Regular Expressions
Theorem: (closure under reversal)
If L is a regular language, then its reversal LR is regular.

Proof: (induction proof on regular expressions)


• Assume L is defined by regular expression E.
• The proof is a structural induction on the size of E.
• We can show that there is another regular expression ER such that L(ER) = (L(E))R;
that is, the language of ER is the reversal of the language of E.

BBM401 Automata Theory and Formal Languages 41


Closure Under Reversal
Induction Proof on Regular Expressions (cont.)
BASIS:
• If E is , , or a, for some symbol a, then ER is the same as E.
• We know {}R = {}, R = , and {a}R = {a}.

INDUCTION:
• There are three cases, depending on the form of E.

Case 1. E = F + G  ER = FR + GR
• The reversal of the union of two languages is obtained by computing the reversals of
the two languages and taking the union of those languages.
• So, L(FR+GR ) = (L(F+G))R

BBM401 Automata Theory and Formal Languages 42


Closure Under Reversal
Induction Proof on Regular Expressions (cont.)
Case 2. E = F G  ER = GR FR
• We reverse the order of the two languages, as well as reversing the languages
themselves.
– For instance, if L(F)={01,111} and L(G)={00,10}, then L(FG) =
{0100,0110,11100,111100}.
– Its reversal is {0010,0110,00111,01111}
– If we concatenate the reversals of L(G) and L(F) in that order, we get
{00,01}{10,111} = {0010,00111,0110,01111} which is the same language as
(L(FG))R .
• In general, if a word w in L(E) is the concatenation of x from L(F) and y from L(G),
then wR = yR xR
• So, L(GRFR ) = (L(FG))R

BBM401 Automata Theory and Formal Languages 43


Closure Under Reversal
Induction Proof on Regular Expressions (cont.)
Case 3. E = F*  ER = (FR )*
• Let w be a string in L(F*) that can be written as w1w2 … wn, where each wi is in L(F).
• Then, wR = wnR wn-1R … w1R
• Since each wiR is in L(FR), wR is in L((FR )*)
• This means that “if w is in L(F*), then wR is L((FR)*)”
• Conversly, let w be a string in L((FR)*) that can be written as w1w2 ... wn, where each
wi is the reversal of a string L(F).
• Since each wiR is in L(F), wR is in L(F*)
• This means that “if w is in L((FR)*), then wR is L(F*)”
• Thus, w is in L(F*) if and only if wR is L((FR)*)
• L((FR)*) = (L(F*))R

BBM401 Automata Theory and Formal Languages 44


Closure Under Reversal -- Example
• Let M be L((0+1)0*)

• Then MR (ie (L((0+1)0*)) R ) can be found as follows:

MR = ( L((0+1)0*) ) R
= L( ((0+1)0*)) R )
= L( (0*)R(0+1)R )
= L( (0R)* (0R+1R) )
= L( 0*(0+1) )

BBM401 Automata Theory and Formal Languages 45


Homomorphism of a Regular Language is Regular
• A homomorphism on an alphabet is a function h that gives a string for each symbol
in that alphabet.
– Suppose  and  are alphabets, the function h: →* is called a
homomorphism.

• Extend to strings by h(a1…an) = h(a1)…h(an).


• Extend to languages h(L) = { h(w) | w∈L }

Example:
• h(0) = ab; h(1) = ε.
• h(01010) = ababab.
• h({010110, 11, 1001}) = {ababab, ε, abab}

BBM401 Automata Theory and Formal Languages 46


Homomorphism of a Regular Language is Regular
Theorem: (closure under homomorphism )
If L is a regular language and h is a homomorphism on its alphabet,
then h(L)={ h(w) | win L } is regular.

Proof:
• Let E be a regular expression for L.
• Apply h to each symbol in E.
• Language of the resulting regular expression is h(L).
• Thus, h(L) is regular.

BBM401 Automata Theory and Formal Languages 47


Closure Under Homomorphism -- Example
• Let h(0) = ab; h(1) = ε.
• Let L be the language of regular expression 01* + 10*.
• Then h(L) is the language of regular expression ab(ε)* + ε(ab)*.
ab(ε)* + ε(ab)* = ab + (ab)* = (ab)*

BBM401 Automata Theory and Formal Languages 48


Decision Properties of Regular Languages

BBM401 Automata Theory and Formal Languages 49


Decision Properties of Regular Languages
• A decision property for a class of languages is an algorithm that takes a formal
description of a language (e.g., a DFA) and tells whether or not some property holds.

• Some Decision Properties:


– Is language L empty?
– Is language L finite?

BBM401 Automata Theory and Formal Languages 50


Decision Properties of Regular Languages
language is empty or not

Theorem: There exist algorithms for determining whether a regular language is


empty or not.

Proof:
• Represent the language with a DFA.
• If there is a path from the start state to some final state, the language is not empty.

BBM401 Automata Theory and Formal Languages 51


Decision Properties of Regular Languages
language is finite or infinite
Theorem: There exist algorithms for determining whether a regular language is
finite or infinite.
Proof:
• Represent the language with a DFA.
• Find all states that form a cycle.
• If any of these cycle states are on path from the start state to a final state, then the
language is infinite.

Key idea:
• If the DFA has n states, and the language contains any string of length n or more,
then the language is infinite.
• Otherwise, the language is surely finite. Limited to strings of length n or less.

BBM401 Automata Theory and Formal Languages 52


More Decision Problems
• To decide if L1  L2, check if L1 - L2 = ϕ

• To decide if  ∊ L, check if q0 ∊ F

• To decide if L contains a string w such that w = wR


– Let M be the DFA for L.
– Construct MR.
– Construct M ∩ MR using the cross-product construction
– Check if L(M ∩ MR ) ≠ ϕ.

BBM401 Automata Theory and Formal Languages 53


The Pumping Lemma for Regular Languages

BBM401 Automata Theory and Formal Languages 54


The Pumping Lemma
for Regular Languages
• There are languages which are NOT regular.

• Every regular language satisfies the pumping lemma.

• A non-regular language can be shown that it is NOT regular using the pumping
lemma.

• L01 = {0n1n | n ≥ 1 } is not regular.


– We can use the pumping lemma to show that this language is not regular.

BBM401 Automata Theory and Formal Languages 55


The Pumping Lemma
for Regular Languages
• Let L be a regular language.
• Then there exists a constant n such that for every string w in L such
that |w| > n, we can break w into three strings, w = xyz, such that:
1. y  , ie. |y|>0 Number of states of
DFA for L
2. |xy| ≤ n
3. For all k ≥ 0, the string xykz is also in L.
• That is, we can always find a nonempty string y not too far from the
beginning of w that can be "pumped"; that is, repeating y any
number of times, or deleting it (the case k= 0), keeps the resulting
string in the language L.

BBM401 Automata Theory and Formal Languages 56


The Pumping Lemma - Proof
Proof:
• Suppose L is regular
• Then L is recognized by some DFA A with n states, and L= L(A).
• Let a string w=a1a2...am  L, where m>n
෠ 0, a1a2...ai)
• Let pi = δ(q
• Then, there exists j such that i<j and pi = pj
• Now we have w=xyz where
1. x = a1a2...ai
2. y = ai+1ai+2...aj
3. z = aj+1aj+2...am

BBM401 Automata Theory and Formal Languages 57


The Pumping Lemma – Proof (cont.)
• That is, x takes us to pi, once; y takes us from pi back to pi. (since pi is also pj),
and z is the balance of w.
• So we have the following figure, and every string longer than the number of states
must cause a state to repeat.

• Since y can repeat 0 or more times


 xykz  L for any k0. Q.E.D.

BBM401 Automata Theory and Formal Languages 58


Applications of The Pumping Lemma
• Every regular language satisfies the pumping lemma.

• A non-regular language can be shown that it is NOT regular using the pumping
lemma.

• L01 = {0n1n | n ≥ 1 } is not regular.


– We can use the pumping lemma to show that this language is not regular.

BBM401 Automata Theory and Formal Languages 59


Using the Pumping Lemma
• In order to show that a language L is NOT a regular language using the Pumping
Lemma (Proof by Contradiction):
1. Suppose L were a regular language.
2. Then there is an integer n given us by the pumping lemma, which we do not
know, we must plan for any possible n.
3. Pick a string w which must be in L, it must be defined using n and |w|>n.
• Tricky Part 1: You should find a string w so that you can create a contradiction
in step 5. YOU CANNOT SELECT A SPECIFIC STRING.
4. Break w into xyz, subject only to the constraints that |xy|n and y.
5. Pick i and show that xyiz is NOT in L in order to create a contradiction.
• Tricky Part 2: You have to show that xyiz is NOT in L using only the constraints
that |xy|n and y. You may need to look at more than one cases. YOU
CANNOT GIVE A SPECIFIC EXAMPLE.
6. Conclude that L is NOT a regular language (proof by contradiction).

BBM401 Automata Theory and Formal Languages 60


Applications of The Pumping Lemma – Example 1
Example 1: Let us show that the language L01 = {0n1n | n ≥ 1 } is NOT regular.
Proof: (proof by contradiction)
• Suppose L01 were a regular language (our assumption)
• Then, w = 0n1n  L01 for any n
• By the pumping lemma, w=xyz, |xy|≤n, y and xykz  L01.

• Since y and |xy| ≤n, y must contain only one or more 0s.
• If y repeats 0 times, xy0z=xz must be in L01 by the pumping lemma.
• xz has fewer 0’s than 1’s because y can only contain one or more 0s
• So, there is a contradiction with our assumption (L01 is regular)
• Proof by contradiction, we prove that L01 is NOT regular

BBM401 Automata Theory and Formal Languages 61


Applications of The Pumping Lemma – Example 2
Example 2: Let us show that the language Leq is the set of all strings with an equal
number of 0's and l's is NOT a regular language.

Proof: (proof by contradiction)


• The proof is exactly same as the proof of L01.

BBM401 Automata Theory and Formal Languages 62


Applications of The Pumping Lemma – Example 3
Example 3: Let us show that the language Lpr is the set of all strings of l's whose length
is a prime is NOT a regular language.
Proof: (proof by contradiction)
• Suppose Lpr were a regular language (our assumption)
• Choose a prime p≥n+2 (this is possible since there are infinite number of primes.)

• Now, xyp-mz  Lpr by the pumping lemma.


• |xyp-mz| = |xz| + (p-m)|y| = (p-m)+(p-m)m = (1+m)(p-m)
• But, (1+m)(p-m) is not prime unless one of the factors is 1.
– y  (1+m) > 1
– m=|y| ≤ |xy| ≤ n and p≥n+2  (p-m) ≥ (n+2)-n ≥ 2
• So, there is a contradiction with our assumption
 Proof by contradiction, Lpr is NOT regular.
BBM401 Automata Theory and Formal Languages 63
Applications of The Pumping Lemma – Example 4
Example 4: Let us show that the language L is the set of all strings with the number of 0's
is more the number of l's is NOT a regular language.
Proof: (proof by contradiction)
• Suppose L were a regular language (our assumption)
• Then, w=0n+11n  L for any n since n+1>n
• By the pumping lemma, w=xyz, |xy|≤n, y and xykz  L.
w = 000 … 00111…11
x y z
• Since 0≤|xy|≤n, y must contain only 0’s.
• By the pumping lemma, xy0z  L. But the number of 0’s cannot be more than the
number 1’s because 0<|y|≤n and y must contain only 0’s.
• So, there is a contradiction with our assumption (L is regular)
• Proof by contradiction, we prove that L is NOT regular

BBM401 Automata Theory and Formal Languages 64


Applications of The Pumping Lemma – Example 5
Example 5: Show that the language L is the set of all strings of 0’s and 1’s that have an
unequal number of 0’s and 1’s is NOT regular.

Proof: (proof by contradiction)


• It would be hard to use the pumping lemma directly to show that L is not regular. We
can use closure properties of regular languages in addition to the pumping lemma in
order to prove.
• Suppose that L were regular (our assumption)
• The complement of this language Lത is the set of all strings of 0’s and 1’s that have
equal number of 0’s and 1’s.
• By the closure under complement theorem, Lത must be regular.
• But, we showed that Lത is NOT regular previously using the pumping lemma.
• So, there is a contradiction with our assumption (L is regular)
• Proof by contradiction, we prove that L is NOT regular

BBM401 Automata Theory and Formal Languages 65


Properties of Regular Languages – Summary
Minimizing Deterministic Finite Automata:
• We can partition states of any DFA into groups of mutually indistinguishable states.
• Members of two different groups are always distinguishable.
• If we replace each group by a single state we get an equivalent DFA that has as few
states as any DFA for the same language.

Testing Distinguishability of States:


• Two states of a DFA are distinguishable if there is an input string that takes exactly
one of the two states to an accepting state.
• By starting with only the fact that pairs consisting of one accepting and one non-
accepting state are distinguishable and trying to discover additional pairs of
distinguishable states by finding pairs whose successors on one input symbol are
distinguishable we can discover all pairs of distinguishable states.

BBM401 Automata Theory and Formal Languages 66


Properties of Regular Languages – Summary
Closure Properties of Regular Languages:
• There are many operations that preserve the property of being a regular language.
• Among these are union, concatenation, closure, intersection, complement, difference,
reversal, homomorphism.

Decision Properties of Regular Languages:


• Testing emptiness of regular languages
• Testing whether a regular language is finite or not.

The Pumping Lemma for Regular Languages:


• If a language is regular then every sufficiently long string in the language has a
nonempty substring that can be pumped that is repeated any number of times while
the resulting strings are also in the language.
• This fact can be used to prove that many different languages are not regular.

BBM401 Automata Theory and Formal Languages 67

You might also like