the pumping lemma

40
The Pumping Lemma Computation Theory M Ayzed Mirza 13-NTU-4005

Upload: m-ayzed-mirza

Post on 28-Dec-2015

30 views

Category:

Documents


0 download

DESCRIPTION

The Pumping Lemma

TRANSCRIPT

Page 1: The Pumping Lemma

The Pumping LemmaComputation Theory

M Ayzed Mirza13-NTU-4005

Page 2: The Pumping Lemma

2

The Pumping Lemma

Page 3: The Pumping Lemma

3

Take an infinite regular languageL

There exists a DFA that accepts L

mstates

(contains an infinite number of strings)

Page 4: The Pumping Lemma

4

mw ||(number of states of DFA)

then, at least one state is repeated in the walk of w

q...... ......1 2 k

Take string with Lw

kw 21Walk in DFA of

Repeated state in DFA

Page 5: The Pumping Lemma

5

Take to be the first state repeatedq

q....

w

There could be many states repeated

q.... ....

Second

occurrence First

occurrence

Unique states

One dimensional projection of walk :

1 2 ki j1i 1j

Page 6: The Pumping Lemma

6

q.... q.... ....

Second

occurrence First

occurrence

1 2 ki j1i 1j

wOne dimensional projection of walk :

ix 1 jiy 1 kjz 1

xyzwWe can write

Page 7: The Pumping Lemma

7

zyxw

q... ...

x

y

z

In DFA:

...

...

1 ki1ij

1j

contains only first occurrence of q

Page 8: The Pumping Lemma

8

Observation: myx ||length numberof statesof DFA

Since, in no state is repeated (except q)

xy

Unique States

q...

x

y

...

1 i1ij

Page 9: The Pumping Lemma

9

Observation: 1|| ylength

Since there is at least one transition in loop

q

y

...

1ij

Page 10: The Pumping Lemma

10

We do not care about the form of string z

q...

x

y

z

...

zmay actually overlap with the paths of and x y

Page 11: The Pumping Lemma

11

The string is accepted

zxAdditional string:

q... ...

x z

...

Do not follow loopy

...

1 ki1ij

1j

Page 12: The Pumping Lemma

12

The string is accepted

zyyx

q... ... ...

x z

Follow loop2 times

Additional string:

y

...

1 ki1ij

1j

Page 13: The Pumping Lemma

13

The string is accepted

zyyyx

q... ... ...

x z

Follow loop3 times

Additional string:

y

...

1 ki1ij

1j

Page 14: The Pumping Lemma

14

The string is accepted

zyx iIn General:

...,2,1,0i

q... ... ...

x z

Follow loop timesi

y

...

1 ki1ij

1j

Page 15: The Pumping Lemma

15

Lzyx i Therefore: ...,2,1,0i

Language accepted by the DFA

q... ... ...

x z

y

...

1 ki1ij

1j

Page 16: The Pumping Lemma

16

The Pumping Lemma:• Given a infinite regular language L

• there exists an integer m

• for any string with length Lw mw ||

• we can write zyxw

• with andmyx || 1|| y

• such that: Lzyx i ...,2,1,0i

(critical length)

Page 17: The Pumping Lemma

17

Applications

of

the Pumping Lemma

Page 18: The Pumping Lemma

18

Observation:Every language of finite size has to be regular

Therefore, every non-regular languagehas to be of infinite size (contains an infinite number of strings)

(we can easily construct an NFA that accepts every string in the language)

Page 19: The Pumping Lemma

19

Suppose you want to prove thatAn infinite language is not regular

1. Assume the opposite: is regular

2. The pumping lemma should hold for

3. Use the pumping lemma to obtain a contradiction

L

L

L

4. Therefore, is not regular L

Page 20: The Pumping Lemma

20

Explanation of Step 3: How to get a contradiction

2. Choose a particular string which satisfies the length condition

Lw

3. Write xyzw

4. Show that Lzxyw i for some 1i

5. This gives a contradiction, since from pumping lemma Lzxyw i

mw ||

1. Let be the critical length for m L

Page 21: The Pumping Lemma

21

Note: It suffices to show that only one stringgives a contradiction

Lw

You don’t need to obtaincontradiction for every Lw

Page 22: The Pumping Lemma

22

Theorem: The language }0:{ nbaL nn

is not regular

Proof: Use the Pumping Lemma

Example of Pumping Lemma application

Page 23: The Pumping Lemma

23

Assume for contradictionthat is a regular languageL

Since is infinitewe can apply the Pumping Lemma

L

}0:{ nbaL nn

Page 24: The Pumping Lemma

24

Let be the critical length for

Pick a string such that: w Lw

mw ||and length

mmbawWe pick

m

}0:{ nbaL nn

L

Page 25: The Pumping Lemma

25

with lengths

From the Pumping Lemma:

1||,|| ymyx

babaaaaabaxyz mm ............

mkay k 1,

x y z

m m

we can write zyxbaw mm

Thus:

w

Page 26: The Pumping Lemma

26

From the Pumping Lemma: Lzyx i

...,2,1,0i

Thus:

mmbazyx

Lzyx 2

mkay k 1,

Page 27: The Pumping Lemma

27

From the Pumping Lemma:

Lbabaaaaaaazxy ...............2

x y z

km m

Thus:

Lzyx 2

mmbazyx

y

Lba mkm

mkay k 1,

Page 28: The Pumping Lemma

28

Lba mkm

}0:{ nbaL nnBUT:

Lba mkm

CONTRADICTION!!!

1≥k

Page 29: The Pumping Lemma

29

Our assumption thatis a regular language is not true

L

Conclusion: L is not a regular language

Therefore:

END OF PROOF

Page 30: The Pumping Lemma

30

More Applications

of

the Pumping Lemma

Page 31: The Pumping Lemma

31

The Pumping Lemma:• Given a infinite regular language L

• there exists an integer (critical length)m

• for any string with length Lw mw ||

• we can write zyxw

• with andmyx || 1|| y

• such that: Lzyx i ...,2,1,0i

Page 32: The Pumping Lemma

32

Regular languages

Non-regular languages *}:{ vvvL R

Page 33: The Pumping Lemma

33

Theorem:The language

is not regular

Proof: Use the Pumping Lemma

*}:{ vvvL R },{ ba

Page 34: The Pumping Lemma

34

Assume for contradictionthat is a regular languageL

Since is infinitewe can apply the Pumping Lemma

L

*}:{ vvvL R

Page 35: The Pumping Lemma

35

mmmm abbaw We pick

Let be the critical length for

Pick a string such that: w Lw

mw ||length

m

and

*}:{ vvvL R

L

Page 36: The Pumping Lemma

36

we can write: zyxabbaw mmmm

with lengths:

From the Pumping Lemma:

ababbabaaaaxyz ..................

x y z

m m m m

1||,|| ymyx

mkay k 1,Thus:

w

Page 37: The Pumping Lemma

37

From the Pumping Lemma: Lzyx i

...,2,1,0i

Thus: Lzyx 2

mmmm abbazyx mkay k 1,

Page 38: The Pumping Lemma

38

From the Pumping Lemma:

Lababbabaaaaaazxy ∈.....................=2

x y z

km + m m m

y

Lzyx 2

Thus:

mmmm abbazyx

Labba mmmkm

mkay k 1,

Page 39: The Pumping Lemma

39

Labba mmmkm

Labba mmmkm

BUT:

CONTRADICTION!!!

1k

*}:{ vvvL R

Page 40: The Pumping Lemma

40

Our assumption thatis a regular language is not true

L

Conclusion: L is not a regular language

Therefore:

END OF PROOF