pumping lemma for regular languages

68
1 Non-regular languages

Upload: rahulnalawade

Post on 11-Dec-2015

233 views

Category:

Documents


0 download

DESCRIPTION

Theoritical understanding of Pumping Lemma for Regular Languages in Automata Theory.

TRANSCRIPT

Page 1: Pumping Lemma for Regular Languages

1

Non-regular languages

Page 2: Pumping Lemma for Regular Languages

2

Regular languages

ba* acb *

...etc

*)( bacb

Non-regular languages }0:{ nba nn

}*},{:{ bavvvR

Page 3: Pumping Lemma for Regular Languages

3

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 !!!

Page 4: Pumping Lemma for Regular Languages

4

The Pigeonhole Principle

Page 5: Pumping Lemma for Regular Languages

5

pigeons

pigeonholes

4

3

Page 6: Pumping Lemma for Regular Languages

6

A pigeonhole must

contain at least two pigeons

Page 7: Pumping Lemma for Regular Languages

7

...........

...........

pigeons

pigeonholes

n

m mn

Page 8: Pumping Lemma for Regular Languages

8

The Pigeonhole Principle

...........

pigeons

pigeonholes

n

m

mn There is a pigeonhole

with at least 2 pigeons

Page 9: Pumping Lemma for Regular Languages

9

The Pigeonhole Principle

and

DFAs

Page 10: Pumping Lemma for Regular Languages

10

DFA with states 4

1q 2q 3qa

b

4q

b

b b

b

a a

Page 11: Pumping Lemma for Regular Languages

11

1q 2q 3qa

b

4q

b

b

b

a a

a

In walks of strings:

aab

aa

a no state

is repeated

Page 12: Pumping Lemma for Regular Languages

12

In walks of strings:

1q 2q 3qa

b

4q

b

b

b

a a

a

...abbbabbabb

abbabb

bbaa

aabb a state

is repeated

Page 13: Pumping Lemma for Regular Languages

13

If string has length :

1q 2q 3qa

b

4q

b

b

b

a a

a

w 4|| w

Thus, a state must be repeated

Then the transitions of string

are more than the states of the DFA

w

Page 14: Pumping Lemma for Regular Languages

14

In general, for any DFA:

String has length number of states w

A state must be repeated in the walk of wq

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

walk of w

Repeated state

Page 15: Pumping Lemma for Regular Languages

15

In other words for a string :

transitions are pigeons

states are pigeonholes q

a

w

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

walk of w

Repeated state

Page 16: Pumping Lemma for Regular Languages

16

The Pumping Lemma

Page 17: Pumping Lemma for Regular Languages

17

Take an infinite regular language L

There exists a DFA that accepts L

mstates

Page 18: Pumping Lemma for Regular Languages

18

Take string with w Lw

There is a walk with label : w

.........

walk w

Page 19: Pumping Lemma for Regular Languages

19

If string has length w mw || (number

of states

of DFA)

then, from the pigeonhole principle:

a state is repeated in the walk w

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

walk w

Page 20: Pumping Lemma for Regular Languages

20

q

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

walk w

Let be the first state repeated in the

walk of w

Page 21: Pumping Lemma for Regular Languages

21

Write zyxw

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

x

y

z

Page 22: Pumping Lemma for Regular Languages

22

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

x

y

z

Observations: myx ||length number

of states

of DFA 1|| ylength

Page 23: Pumping Lemma for Regular Languages

23

The string

is accepted

zxObservation:

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

x

y

z

Page 24: Pumping Lemma for Regular Languages

24

The string

is accepted

zyyxObservation:

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

x

y

z

Page 25: Pumping Lemma for Regular Languages

25

The string

is accepted

zyyyxObservation:

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

x

y

z

Page 26: Pumping Lemma for Regular Languages

26

The string

is accepted

zyx iIn General:

...,2,1,0i

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

x

y

z

Page 27: Pumping Lemma for Regular Languages

27

Lzyx i ∈In General: ...,2,1,0i

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

x

y

z

Language accepted by the DFA

Page 28: Pumping Lemma for Regular Languages

28

In other words, we described:

The Pumping Lemma !!!

Page 29: Pumping Lemma for Regular Languages

29

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 and myx || 1|| y

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

Page 30: Pumping Lemma for Regular Languages

30

Applications

of

the Pumping Lemma

Page 31: Pumping Lemma for Regular Languages

31

Theorem: The language }0:{ nbaL nn

is not regular

Proof: Use the Pumping Lemma

Page 32: Pumping Lemma for Regular Languages

32

Assume for contradiction

that is a regular language L

Since is infinite

we can apply the Pumping Lemma

L

}0:{ nbaL nn

Page 33: Pumping Lemma for Regular Languages

33

Let be the integer in the Pumping Lemma

Pick a string such that: w Lw

mw ||length

mmbaw We pick

m

}0:{ nbaL nn

Page 34: Pumping Lemma for Regular Languages

34

it must be that length

From the Pumping Lemma

1||,|| ymyx

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

1, kay k

x y z

m m

Write: zyxba mm

Thus:

Page 35: Pumping Lemma for Regular Languages

35

From the Pumping Lemma: Lzyx i

...,2,1,0i

Thus:

mmbazyx

Lzyx 2

1, kay k

Page 36: Pumping Lemma for Regular Languages

36

From the Pumping Lemma:

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

x y z

km m

Thus:

Lzyx 2

mmbazyx 1, kay k

y

Lba mkm

Page 37: Pumping Lemma for Regular Languages

37

Lba mkm

}0:{ nbaL nnBUT:

Lba mkm

CONTRADICTION!!!

1≥k

Page 38: Pumping Lemma for Regular Languages

38

Our assumption that

is a regular language is not true

L

Conclusion: L is not a regular language

Therefore:

Page 39: Pumping Lemma for Regular Languages

39

Regular languages

Non-regular languages }0:{ nba nn

Page 40: Pumping Lemma for Regular Languages

40

Regular languages

Non-regular languages *}:{ vvvL R

Page 41: Pumping Lemma for Regular Languages

41

Theorem: The language

is not regular

Proof: Use the Pumping Lemma

*}:{ vvvL R },{ ba

Page 42: Pumping Lemma for Regular Languages

42

Assume for contradiction

that is a regular language L

Since is infinite

we can apply the Pumping Lemma

L

*}:{ vvvL R

Page 43: Pumping Lemma for Regular Languages

43

mmmm abbaw We pick

Let be the integer in the Pumping Lemma

Pick a string such that: w Lw

mw ||length

m

and

*}:{ vvvL R

Page 44: Pumping Lemma for Regular Languages

44

Write zyxabba mmmm

it must be that length

From the Pumping Lemma

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

x y z

m m m m

1||,|| ymyx

1, kay kThus:

Page 45: Pumping Lemma for Regular Languages

45

From the Pumping Lemma: Lzyx i

...,2,1,0i

Thus: Lzyx 2

1, kay kmmmm abbazyx

Page 46: Pumping Lemma for Regular Languages

46

From the Pumping Lemma:

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

x y z

km + m m m

1, kay k

y

Lzyx 2

Thus:

mmmm abbazyx

Labba mmmkm

Page 47: Pumping Lemma for Regular Languages

47

Labba mmmkm

Labba mmmkm

BUT:

CONTRADICTION!!!

1k

*}:{ vvvL R

Page 48: Pumping Lemma for Regular Languages

48

Our assumption that

is a regular language is not true

L

Conclusion: L is not a regular language

Therefore:

Page 49: Pumping Lemma for Regular Languages

49

Regular languages

Non-regular languages

}0,:{ lncbaL lnln

Page 50: Pumping Lemma for Regular Languages

50

Theorem: The language

is not regular

Proof: Use the Pumping Lemma

}0,:{ lncbaL lnln

Page 51: Pumping Lemma for Regular Languages

51

Assume for contradiction

that is a regular language L

Since is infinite

we can apply the Pumping Lemma

L

}0,:{ lncbaL lnln

Page 52: Pumping Lemma for Regular Languages

52

mmm cbaw 2We pick

Let be the integer in the Pumping Lemma

Pick a string such that: w Lw

mw ||length

m

}0,:{ lncbaL lnln

and

Page 53: Pumping Lemma for Regular Languages

53

Write zyxcba mmm 2

it must be that length

From the Pumping Lemma

cccbcabaaaaaxyz ..................

x y z

m m m2

1||,|| ymyx

1, kay kThus:

Page 54: Pumping Lemma for Regular Languages

54

From the Pumping Lemma: Lzyx i

...,2,1,0i

Thus:

mmm cbazyx 2

Lxzzyx ∈=0

1, kay k

Page 55: Pumping Lemma for Regular Languages

55

From the Pumping Lemma:

Lcccbcabaaaxz ...............

x z

km m m2

mmm cbazyx 2 1, kay k

Lxz

Thus: Lcba mmkm 2

Page 56: Pumping Lemma for Regular Languages

56

Lcba mmkm 2

Lcba mmkm 2

BUT:

CONTRADICTION!!!

}0,:{ lncbaL lnln

1k

Page 57: Pumping Lemma for Regular Languages

57

Our assumption that

is a regular language is not true

L

Conclusion: L is not a regular language

Therefore:

Page 58: Pumping Lemma for Regular Languages

58

Regular languages

Non-regular languages }0:{ ! naL n

Page 59: Pumping Lemma for Regular Languages

59

Theorem: The language

is not regular

Proof: Use the Pumping Lemma

}0:{ ! naL n

nnn )1(21!

Page 60: Pumping Lemma for Regular Languages

60

Assume for contradiction

that is a regular language L

Since is infinite

we can apply the Pumping Lemma

L

}0:{ ! naL n

Page 61: Pumping Lemma for Regular Languages

61

!maw We pick

Let be the integer in the Pumping Lemma

Pick a string such that: w Lw

mw ||length

m

}0:{ ! naL n

Page 62: Pumping Lemma for Regular Languages

62

Write zyxam !

it must be that length

From the Pumping Lemma

aaaaaaaaaaaxyz m ...............!

x y z

m mm !

1||,|| ymyx

mkay k 1,Thus:

Page 63: Pumping Lemma for Regular Languages

63

From the Pumping Lemma: Lzyx i

...,2,1,0i

Thus:

!mazyx

Lzyx 2

mkay k 1,

Page 64: Pumping Lemma for Regular Languages

64

From the Pumping Lemma:

Laaaaaaaaaaaazxy ..................2

x y z

km mm !

Thus:

!mazyx mkay k 1,

Lzyx 2

y

La km !

Page 65: Pumping Lemma for Regular Languages

65

La km !

!! pkm

}0:{ ! naL nSince:

mk 1

There must exist such that: p

Page 66: Pumping Lemma for Regular Languages

66

However:

)!1(

)1(!

!!

!!

!

m

mm

mmm

mm

mmkm ! for 1m

)!1(! mkm

!! pkm for any p

Page 67: Pumping Lemma for Regular Languages

67

La km !

La km !

BUT:

CONTRADICTION!!!

}0:{ ! naL n

mk 1

Page 68: Pumping Lemma for Regular Languages

68

Our assumption that

is a regular language is not true

L

Conclusion: L is not a regular language

Therefore: