more properties of regular languages

59
1 More Properties of Regular Languages

Upload: bonita

Post on 07-Feb-2016

29 views

Category:

Documents


0 download

DESCRIPTION

More Properties of Regular Languages. We have proven. Regular languages are closed under:. Union Concatenation Star operation Reverse. Namely, for regular languages and :. Union Concatenation Star operation Reverse. Regular Languages. We will prove. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: More Properties  of  Regular Languages

1

More Properties of

Regular Languages

Page 2: More Properties  of  Regular Languages

2

We have proven

Regular languages are closed under:

Union

Concatenation

Star operation

Reverse

Page 3: More Properties  of  Regular Languages

3

Namely, for regular languages and :1L 2L

21 LL

21LL

1L

Union

Concatenation

Star operation

Reverse RL1

RegularLanguages

Page 4: More Properties  of  Regular Languages

4

We will prove

Regular languages are closed under:

Complement

Intersection

Page 5: More Properties  of  Regular Languages

5

Namely, for regular languages and :1L 2L

1L

21 LL

Complement

Intersection

RegularLanguages

Page 6: More Properties  of  Regular Languages

6

Complement

Theorem:For regular language the complement is regular L

L

Proof: Take DFA that accepts and make • nonfinal states final• final states nonfinal

Resulting DFA accepts

L

L

Page 7: More Properties  of  Regular Languages

7

Example:a

b ba,

ba,

0q 1q 2q

)*( baLL

a

b ba,

ba,

0q 1q 2q

)*))((**( bababaaLL

Page 8: More Properties  of  Regular Languages

8

Intersection

Theorem:For regular languages and the intersection is regular 21 LL

1L 2L

Proof: Apply DeMorgan’s Law:

2121 LLLL

Page 9: More Properties  of  Regular Languages

9

21 , LL regular

21 , LL regular

21 LL regular

21 LL regular

21 LL regular

Page 10: More Properties  of  Regular Languages

10

Standard Representations of

Regular Languages

Page 11: More Properties  of  Regular Languages

11

Standard Representations of Regular Languages

Regular Languages

DFAs

NFAsRegularExpressions

RegularGrammars

Page 12: More Properties  of  Regular Languages

12

When we say: We are given a Regular Language

We mean:

L

Language is in a standard representation

L

Page 13: More Properties  of  Regular Languages

13

Elementary Questions

about

Regular Languages

Page 14: More Properties  of  Regular Languages

14

Membership Question

Question: Given regular languageand string how can we check if ?

L

Lw w

Answer: Take the DFA that acceptsand check if is accepted

Lw

Page 15: More Properties  of  Regular Languages

15

DFA

Lw

DFA

Lw

w

w

Page 16: More Properties  of  Regular Languages

16

Given regular languagehow can we checkif is empty: ?

L

L

Take the DFA that accepts

Check if there is a path from the initial state to a final state

L

)( L

Question:

Answer:

Page 17: More Properties  of  Regular Languages

17

DFA

L

DFA

L

Page 18: More Properties  of  Regular Languages

18

Given regular languagehow can we checkif is finite?

L

L

Take the DFA that accepts

Check if there is a walk with cyclefrom the initial state to a final state

L

Question:

Answer:

Page 19: More Properties  of  Regular Languages

19

DFA

L is infinite

DFA

L is finite

Page 20: More Properties  of  Regular Languages

20

Given regular languages and how can we check if ?

1L 2L

21 LL Question:

)()( 2121 LLLLFind ifAnswer:

Page 21: More Properties  of  Regular Languages

21

)()( 2121 LLLL

21 LL 21 LLand

21 LL

1L 2L 1L2L

21 LL 12 LL 2L 1L

Page 22: More Properties  of  Regular Languages

22

)()( 2121 LLLL

21 LL 21 LLor

1L 2L 1L2L

21 LL 12 LL

21 LL

Page 23: More Properties  of  Regular Languages

23

Non-regular languages

Page 24: More Properties  of  Regular Languages

24

Regular languages

ba* acb *

...etc

*)( bacb

Non-regular languages}0:{ nba nn

}*},{:{ bawwwR

Page 25: More Properties  of  Regular Languages

25

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 26: More Properties  of  Regular Languages

26

The Pigeonhole Principle

Page 27: More Properties  of  Regular Languages

27

pigeons

pigeonholes

4

3

Page 28: More Properties  of  Regular Languages

28

A pigeonhole mustcontain at least two pigeons

Page 29: More Properties  of  Regular Languages

29

...........

...........

pigeons

pigeonholes

n

m mn

Page 30: More Properties  of  Regular Languages

30

The Pigeonhole Principle

...........

pigeons

pigeonholes

n

m

mn There is a pigeonhole with at least 2 pigeons

Page 31: More Properties  of  Regular Languages

31

The Pigeonhole Principle

and

DFAs

Page 32: More Properties  of  Regular Languages

32

DFA with states 4

1q 2q 3qa

b

4q

b

b b

b

a a

Page 33: More Properties  of  Regular Languages

33

1q 2q 3qa

b

4q

b

b

b

a a

a

In walks of strings:

aab

aa

a no stateis repeated

Page 34: More Properties  of  Regular Languages

34

In walks of strings:

1q 2q 3qa

b

4q

b

b

b

a a

a

...abbbabbabb

abbabb

bbaa

aabb a stateis repeated

Page 35: More Properties  of  Regular Languages

35

If the walk of string has length

1q 2q 3qa

b

4q

b

b

b

a a

a

w 4|| w

then a state is repeated

Page 36: More Properties  of  Regular Languages

36

If in a walk of a string transitions states of DFAthen a state is repeated

1q 2q 3qa

b

4q

b

b

b

a a

a

Pigeonhole principle for any DFA:

w

Page 37: More Properties  of  Regular Languages

37

In other words for a string : transitions are pigeons

states are pigeonholes

1q 2q 3qa

b

4q

b

b

b

a a

a

q

a

w

Page 38: More Properties  of  Regular Languages

38

In general:

A string has length number of states w

A state must be repeated in the walk wq

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

walk of w

Page 39: More Properties  of  Regular Languages

39

The Pumping Lemma

Page 40: More Properties  of  Regular Languages

40

Take an infinite regular languageL

DFA that accepts L

mstates

Page 41: More Properties  of  Regular Languages

41

Take string with w Lw

There is a walk with label :w

.........

walk w

Page 42: More Properties  of  Regular Languages

42

If string has length w mw || number of states

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

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

walk w

Page 43: More Properties  of  Regular Languages

43

Write zyxw

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

x

y

z

Page 44: More Properties  of  Regular Languages

44

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

x

y

z

Observations: myx ||length numberof states

1|| ylength

Page 45: More Properties  of  Regular Languages

45

The string is accepted zxObservation:

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

x

y

z

Page 46: More Properties  of  Regular Languages

46

The string is accepted

zyyxObservation:

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

x

y

z

Page 47: More Properties  of  Regular Languages

47

The string is accepted

zyyyxObservation:

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

x

y

z

Page 48: More Properties  of  Regular Languages

48

The string is accepted

zyx iIn General:

...,2,1,0i

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

x

y

z

Page 49: More Properties  of  Regular Languages

49

In other words, we described:

The Pumping Lemma !!!

Page 50: More Properties  of  Regular Languages

50

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

Page 51: More Properties  of  Regular Languages

51

Applications

of

the Pumping Lemma

Page 52: More Properties  of  Regular Languages

52

Theorem: The language }0:{ nbaL nn

is not regular

Proof: Use the Pumping Lemma

Page 53: More Properties  of  Regular Languages

53

Assume for contradictionthat is a regular languageL

Since is infinitewe can apply the Pumping Lemma

L

}0:{ nbaL nn

Page 54: More Properties  of  Regular Languages

54

Let be the integer in the Pumping Lemma

Pick a string such that: w Lw

mw ||length

Example: mmbawpick

m

}0:{ nbaL nn

Page 55: More Properties  of  Regular Languages

55

Write: zyxba mm

it must be that: length

From the Pumping Lemma 1||,|| ymyx

Therefore: babaaaaba mm ............

1, kay kx y z

m m

Page 56: More Properties  of  Regular Languages

56

From the Pumping Lemma: Lzyx i

...,2,1,0i

Thus:

mmbazyx

Lbazyyxzyx mkm 2

Lzyx 2

We have: 1, kay k

Page 57: More Properties  of  Regular Languages

57

Lba mkm Therefore:

}0:{ nbaL nnBUT:

Lba mkm

CONTRADICTION!!!

Page 58: More Properties  of  Regular Languages

58

Our assumption thatis a regular language is not true

L

Conclusion: L is not a regular language

Therefore:

Page 59: More Properties  of  Regular Languages

59

Regular languages

ba* acb *

...etc

*)( bacb

Non-regular languages }0:{ nba nn