formal languages non-regular languages

39
Fall 2003 Costas Busch - RPI Formal Languages Non-Regular Languages

Upload: mikayla-ward

Post on 03-Jan-2016

87 views

Category:

Documents


2 download

DESCRIPTION

Formal Languages Non-Regular Languages. Non-regular languages. Regular languages. Prove that there is no DFA that accepts. How can we prove that a language is not regular?. Problem: this is not easy to prove. Solution: the Pumping Lemma !!!. The Pigeonhole Principle. pigeons. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Formal Languages Non-Regular Languages

Fall 2003 Costas Busch - RPI

Formal Languages

Non-Regular Languages

Page 2: Formal Languages Non-Regular Languages

2

Regular languages

ba* acb *

...etc

*)( bacb

Non-regular languages}0:{ nba nn

}*},{:{ bavvvR

Page 3: Formal Languages Non-Regular Languages

3

How can we prove that a languageis 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: Formal Languages Non-Regular Languages

4

The Pigeonhole Principle

Page 5: Formal Languages Non-Regular Languages

5

pigeons

pigeonholes

4

3

Page 6: Formal Languages Non-Regular Languages

6

A pigeonhole mustcontain at least two pigeons

Page 7: Formal Languages Non-Regular Languages

7

...........

...........

pigeons

pigeonholes

n

m mn

Page 8: Formal Languages Non-Regular Languages

8

The Pigeonhole Principle

...........

pigeons

pigeonholes

n

m

mn There is a pigeonhole with at least 2 pigeons

Page 9: Formal Languages Non-Regular Languages

9

The Pigeonhole Principle

and

DFAs

Page 10: Formal Languages Non-Regular Languages

10

DFA with states 4

1q 2q 3qa

b

4q

b

b b

b

a a

Page 11: Formal Languages Non-Regular Languages

11

1q 2q 3qa

b

4q

b

b

b

a a

a

In walks of strings:

aab

aa

a no stateis repeated

Page 12: Formal Languages Non-Regular Languages

12

In walks of strings:

1q 2q 3qa

b

4q

b

b

b

a a

a

...abbbabbabb

abbabb

bbaa

aabb a stateis repeated

Page 13: Formal Languages Non-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: Formal Languages Non-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: Formal Languages Non-Regular Languages

15

In other words for a string : transitions are pigeons

states are pigeonholesq

a

w

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

walk of w

Repeated state

Page 16: Formal Languages Non-Regular Languages

16

The Pumping Lemma

Page 17: Formal Languages Non-Regular Languages

17

Take an infinite regular languageL

There exists a DFA that accepts L

mstates

Page 18: Formal Languages Non-Regular Languages

18

Take string with w Lw

There is a walk with label :w

.........

walk w

Page 19: Formal Languages Non-Regular Languages

19

If string has length w mw || (number of statesof DFA)

then, from the pigeonhole principle: a state is repeated in the walkw

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

walk w

Page 20: Formal Languages Non-Regular Languages

20

q

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

walk w

Let be the first state repeated in thewalk of w

Page 21: Formal Languages Non-Regular Languages

21

Write zyxw

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

x

y

z

Page 22: Formal Languages Non-Regular Languages

22

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

x

y

z

Observations: myx ||length numberof statesof DFA1|| ylength

Page 23: Formal Languages Non-Regular Languages

23

The string is accepted

zxObservation:

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

x

y

z

Page 24: Formal Languages Non-Regular Languages

24

The string is accepted

zyyxObservation:

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

x

y

z

Page 25: Formal Languages Non-Regular Languages

25

The string is accepted

zyyyxObservation:

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

x

y

z

Page 26: Formal Languages Non-Regular Languages

26

The string is accepted

zyx iIn General:

...,2,1,0i

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

x

y

z

Page 27: Formal Languages Non-Regular Languages

27

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

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

x

y

z

Language accepted by the DFA

Page 28: Formal Languages Non-Regular Languages

28

In other words, we described:

The Pumping Lemma !!!

Page 29: Formal Languages Non-Regular Languages

29

The Pumping Lemma:

• Given an 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

Page 30: Formal Languages Non-Regular Languages

30

Applications

of

the Pumping Lemma

Page 31: Formal Languages Non-Regular Languages

31

Theorem:The language }0:{ nbaL nn

is not regular

Proof: Use the Pumping Lemma

Page 32: Formal Languages Non-Regular Languages

32

Assume for contradictionthat is a regular languageL

Since is infinitewe can apply the Pumping Lemma

L

}0:{ nbaL nn

Page 33: Formal Languages Non-Regular Languages

33

Let be the integer in the Pumping Lemma

Pick a string such that: w Lw

mw ||length

mmbawWe pick

m

}0:{ nbaL nn

Page 34: Formal Languages Non-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: Formal Languages Non-Regular Languages

35

From the Pumping Lemma: Lzyx i

...,2,1,0i

Thus:

mmbazyx

Lzyx 2

1, kay k

Page 36: Formal Languages Non-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: Formal Languages Non-Regular Languages

37

Lba mkm

}0:{ nbaL nnBUT:

Lba mkm

CONTRADICTION!!!

1≥k

Page 38: Formal Languages Non-Regular Languages

38

Our assumption thatis a regular language is not true

L

Conclusion: L is not a regular language

Therefore:

Page 39: Formal Languages Non-Regular Languages

39

Regular languages

Non-regular languages }0:{ nba nn