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

Post on 19-Dec-2015

219 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

4

We will prove

Regular languages are closed under:

Complement

Intersection

5

Namely, for regular languages and :1L 2L

1L

21 LL

Complement

Intersection

RegularLanguages

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

7

Example:a

b ba,

ba,

0q 1q 2q

)*( baLL

a

b ba,

ba,

0q 1q 2q

)*))((**( bababaaLL

8

Intersection

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

1L 2L

Proof: Apply DeMorgan’s Law:

2121 LLLL

9

21 , LL regular

21 , LL regular

21 LL regular

21 LL regular

21 LL regular

10

Standard Representations of

Regular Languages

11

Standard Representations of Regular Languages

Regular Languages

DFAs

NFAsRegularExpressions

RegularGrammars

12

When we say: We are given a Regular Language

We mean:

L

Language is in a standard representation

L

13

Elementary Questions

about

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

15

DFA

Lw

DFA

Lw

w

w

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:

17

DFA

L

DFA

L

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:

19

DFA

L is infinite

DFA

L is finite

20

Given regular languages and how can we check if ?

1L 2L

21 LL Question:

)()( 2121 LLLLFind ifAnswer:

21

)()( 2121 LLLL

21 LL 21 LLand

21 LL

1L 2L 1L2L

21 LL 12 LL 2L 1L

22

)()( 2121 LLLL

21 LL 21 LLor

1L 2L 1L2L

21 LL 12 LL

21 LL

23

Non-regular languages

24

Regular languages

ba* acb *

...etc

*)( bacb

Non-regular languages}0:{ nba nn

}*},{:{ bawwwR

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

26

The Pigeonhole Principle

27

pigeons

pigeonholes

4

3

28

A pigeonhole mustcontain at least two pigeons

29

...........

...........

pigeons

pigeonholes

n

m mn

30

The Pigeonhole Principle

...........

pigeons

pigeonholes

n

m

mn There is a pigeonhole with at least 2 pigeons

31

The Pigeonhole Principle

and

DFAs

32

DFA with states 4

1q 2q 3qa

b

4q

b

b b

b

a a

33

1q 2q 3qa

b

4q

b

b

b

a a

a

In walks of strings:

aab

aa

a no stateis repeated

34

In walks of strings:

1q 2q 3qa

b

4q

b

b

b

a a

a

...abbbabbabb

abbabb

bbaa

aabb a stateis repeated

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

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

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

38

In general:

A string has length number of states w

A state must be repeated in the walk wq

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

walk of w

39

The Pumping Lemma

40

Take an infinite regular languageL

DFA that accepts L

mstates

41

Take string with w Lw

There is a walk with label :w

.........

walk w

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

43

Write zyxw

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

x

y

z

44

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

x

y

z

Observations: myx ||length numberof states

1|| ylength

45

The string is accepted zxObservation:

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

x

y

z

46

The string is accepted

zyyxObservation:

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

x

y

z

47

The string is accepted

zyyyxObservation:

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

x

y

z

48

The string is accepted

zyx iIn General:

...,2,1,0i

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

x

y

z

49

In other words, we described:

The Pumping Lemma !!!

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

51

Applications

of

the Pumping Lemma

52

Theorem: The language }0:{ nbaL nn

is not regular

Proof: Use the Pumping Lemma

53

Assume for contradictionthat is a regular languageL

Since is infinitewe can apply the Pumping Lemma

L

}0:{ nbaL nn

54

Let be the integer in the Pumping Lemma

Pick a string such that: w Lw

mw ||length

Example: mmbawpick

m

}0:{ nbaL nn

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

56

From the Pumping Lemma: Lzyx i

...,2,1,0i

Thus:

mmbazyx

Lbazyyxzyx mkm 2

Lzyx 2

We have: 1, kay k

57

Lba mkm Therefore:

}0:{ nbaL nnBUT:

Lba mkm

CONTRADICTION!!!

58

Our assumption thatis a regular language is not true

L

Conclusion: L is not a regular language

Therefore:

59

Regular languages

ba* acb *

...etc

*)( bacb

Non-regular languages }0:{ nba nn

top related