1 more properties of regular languages. 2 we have proven regular languages are closed under: union...

59
1 More Properties of Regular Languages

Post on 19-Dec-2015

219 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

1

More Properties of

Regular Languages

Page 2: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

2

We have proven

Regular languages are closed under:

Union

Concatenation

Star operation

Reverse

Page 3: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

3

Namely, for regular languages and :1L 2L

21 LL

21LL

1L

Union

Concatenation

Star operation

Reverse RL1

RegularLanguages

Page 4: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

4

We will prove

Regular languages are closed under:

Complement

Intersection

Page 5: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

5

Namely, for regular languages and :1L 2L

1L

21 LL

Complement

Intersection

RegularLanguages

Page 6: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

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: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

7

Example:a

b ba,

ba,

0q 1q 2q

)*( baLL

a

b ba,

ba,

0q 1q 2q

)*))((**( bababaaLL

Page 8: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

8

Intersection

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

1L 2L

Proof: Apply DeMorgan’s Law:

2121 LLLL

Page 9: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

9

21 , LL regular

21 , LL regular

21 LL regular

21 LL regular

21 LL regular

Page 10: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

10

Standard Representations of

Regular Languages

Page 11: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

11

Standard Representations of Regular Languages

Regular Languages

DFAs

NFAsRegularExpressions

RegularGrammars

Page 12: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

12

When we say: We are given a Regular Language

We mean:

L

Language is in a standard representation

L

Page 13: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

13

Elementary Questions

about

Regular Languages

Page 14: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

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: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

15

DFA

Lw

DFA

Lw

w

w

Page 16: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

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: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

17

DFA

L

DFA

L

Page 18: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

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: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

19

DFA

L is infinite

DFA

L is finite

Page 20: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

20

Given regular languages and how can we check if ?

1L 2L

21 LL Question:

)()( 2121 LLLLFind ifAnswer:

Page 21: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

21

)()( 2121 LLLL

21 LL 21 LLand

21 LL

1L 2L 1L2L

21 LL 12 LL 2L 1L

Page 22: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

22

)()( 2121 LLLL

21 LL 21 LLor

1L 2L 1L2L

21 LL 12 LL

21 LL

Page 23: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

23

Non-regular languages

Page 24: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

24

Regular languages

ba* acb *

...etc

*)( bacb

Non-regular languages}0:{ nba nn

}*},{:{ bawwwR

Page 25: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

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: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

26

The Pigeonhole Principle

Page 27: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

27

pigeons

pigeonholes

4

3

Page 28: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

28

A pigeonhole mustcontain at least two pigeons

Page 29: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

29

...........

...........

pigeons

pigeonholes

n

m mn

Page 30: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

30

The Pigeonhole Principle

...........

pigeons

pigeonholes

n

m

mn There is a pigeonhole with at least 2 pigeons

Page 31: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

31

The Pigeonhole Principle

and

DFAs

Page 32: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

32

DFA with states 4

1q 2q 3qa

b

4q

b

b b

b

a a

Page 33: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

33

1q 2q 3qa

b

4q

b

b

b

a a

a

In walks of strings:

aab

aa

a no stateis repeated

Page 34: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

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: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

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: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

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: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

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: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

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: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

39

The Pumping Lemma

Page 40: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

40

Take an infinite regular languageL

DFA that accepts L

mstates

Page 41: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

41

Take string with w Lw

There is a walk with label :w

.........

walk w

Page 42: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

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: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

43

Write zyxw

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

x

y

z

Page 44: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

44

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

x

y

z

Observations: myx ||length numberof states

1|| ylength

Page 45: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

45

The string is accepted zxObservation:

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

x

y

z

Page 46: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

46

The string is accepted

zyyxObservation:

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

x

y

z

Page 47: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

47

The string is accepted

zyyyxObservation:

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

x

y

z

Page 48: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

48

The string is accepted

zyx iIn General:

...,2,1,0i

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

x

y

z

Page 49: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

49

In other words, we described:

The Pumping Lemma !!!

Page 50: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

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: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

51

Applications

of

the Pumping Lemma

Page 52: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

52

Theorem: The language }0:{ nbaL nn

is not regular

Proof: Use the Pumping Lemma

Page 53: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

53

Assume for contradictionthat is a regular languageL

Since is infinitewe can apply the Pumping Lemma

L

}0:{ nbaL nn

Page 54: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

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: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

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: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

56

From the Pumping Lemma: Lzyx i

...,2,1,0i

Thus:

mmbazyx

Lbazyyxzyx mkm 2

Lzyx 2

We have: 1, kay k

Page 57: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

57

Lba mkm Therefore:

}0:{ nbaL nnBUT:

Lba mkm

CONTRADICTION!!!

Page 58: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

58

Our assumption thatis a regular language is not true

L

Conclusion: L is not a regular language

Therefore:

Page 59: 1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse

59

Regular languages

ba* acb *

...etc

*)( bacb

Non-regular languages }0:{ nba nn