Closure under the Regular Operations Closure under the Regular - - PowerPoint PPT Presentation

closure under the regular operations
SMART_READER_LITE
LIVE PREVIEW

Closure under the Regular Operations Closure under the Regular - - PowerPoint PPT Presentation

Closure under the Regular Operations Closure under the Regular Operations p.1/26 Application of NFA Now we use the NFA to show that the collection of regular languages is closed under regular operations union, concatenation, and star


slide-1
SLIDE 1

Closure under the Regular Operations

Closure under the Regular Operations – p.1/26

slide-2
SLIDE 2

Application of NFA

  • Now we use the NFA to show that the collection of

regular languages is closed under regular operations union, concatenation, and star

Closure under the Regular Operations – p.2/26

slide-3
SLIDE 3

Application of NFA

  • Now we use the NFA to show that the collection of

regular languages is closed under regular operations union, concatenation, and star

  • Earlier we have shown this closure for union using a

Cartesian product of DFA

Closure under the Regular Operations – p.2/26

slide-4
SLIDE 4

Application of NFA

  • Now we use the NFA to show that the collection of

regular languages is closed under regular operations union, concatenation, and star

  • Earlier we have shown this closure for union using a

Cartesian product of DFA

  • For uniformity reason we reconstruct that proof using

NFA

Closure under the Regular Operations – p.2/26

slide-5
SLIDE 5

Theorem 1.45

The class of regular languages is closed under the union

  • peration

Closure under the Regular Operations – p.3/26

slide-6
SLIDE 6

Theorem 1.45

The class of regular languages is closed under the union

  • peration

Proof idea:

Closure under the Regular Operations – p.3/26

slide-7
SLIDE 7

Theorem 1.45

The class of regular languages is closed under the union

  • peration

Proof idea:

  • Let regular languages
✂✁

and

✂✄

be recognized by NFA

☎ ✁

and

☎ ✄

, respectively

Closure under the Regular Operations – p.3/26

slide-8
SLIDE 8

Theorem 1.45

The class of regular languages is closed under the union

  • peration

Proof idea:

  • Let regular languages
✂✁

and

✂✄

be recognized by NFA

☎ ✁

and

☎ ✄

, respectively

  • To show that

is regular we will construct an NFA

that recognizes

Closure under the Regular Operations – p.3/26

slide-9
SLIDE 9

Theorem 1.45

The class of regular languages is closed under the union

  • peration

Proof idea:

  • Let regular languages
✂✁

and

✂✄

be recognized by NFA

☎ ✁

and

☎ ✄

, respectively

  • To show that

is regular we will construct an NFA

that recognizes

must accept its input if either

☎ ✁
  • r
☎ ✄

accepts its input. Hence,

must have a new state that will allow it to guess nondeterministically which of

☎ ✁
  • r
☎ ✄

accepts it

Closure under the Regular Operations – p.3/26

slide-10
SLIDE 10

Theorem 1.45

The class of regular languages is closed under the union

  • peration

Proof idea:

  • Let regular languages
✂✁

and

✂✄

be recognized by NFA

☎ ✁

and

☎ ✄

, respectively

  • To show that

is regular we will construct an NFA

that recognizes

must accept its input if either

☎ ✁
  • r
☎ ✄

accepts its input. Hence,

must have a new state that will allow it to guess nondeterministically which of

☎ ✁
  • r
☎ ✄

accepts it

  • Guessing is implemented by
  • transitions from the new state to

the start states of

☎ ✁

and

☎ ✄

, as seen in Figure 1

Closure under the Regular Operations – p.3/26

slide-11
SLIDE 11

An NFA recognizing

✂☎✄ ✆ ✝ ✝ ✝ ✂☎✞ ✆ ✝ ✝ ✝ ✂ ✆ ✆ ✆ ✟ ✟ ✝ ✝ ✝ ✝ ✝ ✝

Figure 1: Construction of

to recognize

Closure under the Regular Operations – p.4/26

slide-12
SLIDE 12

Proof

Let

✂✁ ✄ ☎ ✆ ✁✞✝ ✟ ✝ ✠ ✁ ✝ ✡ ✁ ☛ ✝ ☞ ✁ ✌

, and

✂✍ ✄ ☎ ✆ ✍✞✝ ✟ ✝ ✠ ✍ ✝ ✡ ✍ ☛ ✝ ☞ ✍ ✌

Construct

☎ ✆ ✝ ✟ ✝ ✠ ✝ ✡ ☛ ✝ ☞ ✌

to recognize

✎ ✁ ✏ ✎ ✍

using the following procedure:

Closure under the Regular Operations – p.5/26

slide-13
SLIDE 13

Construction procedure

1.

✂☎✄ ✆ ✝ ✁

: That is, the states of

are all states on

☎ ✁

and

☎ ✄

with the addition of a new state

✄ ✆

Closure under the Regular Operations – p.6/26

slide-14
SLIDE 14

Construction procedure

1.

✂☎✄ ✆ ✝ ✁

: That is, the states of

are all states on

☎ ✁

and

☎ ✄

with the addition of a new state

✄ ✆
  • 2. The start state of

is

✄ ✆

Closure under the Regular Operations – p.6/26

slide-15
SLIDE 15

Construction procedure

1.

✂☎✄ ✆ ✝ ✁

: That is, the states of

are all states on

☎ ✁

and

☎ ✄

with the addition of a new state

✄ ✆
  • 2. The start state of

is

✄ ✆
  • 3. The accept states of

are

: That is, the accept states

  • f

are all the accept states of

☎ ✁

and

☎ ✄

Closure under the Regular Operations – p.6/26

slide-16
SLIDE 16

Construction procedure

1.

✂☎✄ ✆ ✝ ✁

: That is, the states of

are all states on

☎ ✁

and

☎ ✄

with the addition of a new state

✄ ✆
  • 2. The start state of

is

✄ ✆
  • 3. The accept states of

are

: That is, the accept states

  • f

are all the accept states of

☎ ✁

and

☎ ✄
  • 4. Define
  • so that for any
✄ ✁
  • and any
✂ ✁ ✄✆☎

:

✄ ✞ ✂ ✟ ✁ ✠ ✡☛✡☞✡✌✡☛✡☞✍ ✡☛✡✌✡☞✡☛✡✌✎
✝ ✄ ✞ ✂ ✟ ✞

if

✄ ✁
✝ ✄ ✞ ✂ ✟ ✞

if

✄ ✁
✂☎✄ ✁ ✆ ✞ ✄ ✄ ✆ ✝ ✞

if

✄ ✁ ✄ ✆

and

✂ ✁

if

✄ ✁ ✄ ✆

and

✂ ✑ ✁
  • .

Closure under the Regular Operations – p.6/26

slide-17
SLIDE 17

Application

Consider the alphabet

✟ ✄
✝ ✂ ✄

and the languages:

✂ ☎ ✆ ☎ ✝✟✞ ✠ ✡☞☛ ✌ ☎ ✡ ✍ ✎ ✏ ✂ ☛ ✑ ✞ ☛ ✑ ✌ ☎ ✡ ✍ ✎ ✒ ✝ ✓ ✁ ✂ ☎ ✆ ☎✔ ✕ ☛ ✍ ✂ ✡ ☛ ✌ ✂ ✍ ✖ ✞ ✂ ✌ ✍ ✍ ✎✟✗ ✞ ✞ ✏ ✝ ✘ ✁ ✂ ☎ ✆ ☎ ✁ ✙ ✒ ✏ ✒ ✏ ✚ ✞ ✙ ✞ ✚ ✁ ✄ ✛ ✝ ✜ ✁ ✂ ☎ ✆ ☎ ✑ ✕ ✞ ✌ ☛ ✕ ✍ ✔ ✕ ☛ ✍ ✂ ✡ ☛ ✍ ✎ ✞ ✌✢ ✝ ✌ ✍ ✗ ✡☞☛ ✠ ✏ ✏ ✒ ✝

Use the construction given in the proof of theorem 1.45 to give the state diagrams recognizing the languages

✎ ✏ ✣

and

✤ ✏ ✥

.

Closure under the Regular Operations – p.7/26

slide-18
SLIDE 18

Theorem 1.47

The class of regular languages is closed under concatenation operation Proof idea: Assume two regular languages,

✎ ✁

and

✎ ✍

rec-

  • gnized by NFAs

and

✂✍

, respectively. Construct

  • as

suggested in Figure 2

Closure under the Regular Operations – p.8/26

slide-19
SLIDE 19

Construction of NFA

✂ ✄ ✆ ✝ ✝ ✝ ✂ ✞ ✆ ✝ ✝ ✝ ✝ ✆ ✝ ✝ ✝ ✝ ✝ ✝ ✝
✟ ✆ ✟ ✂ ✂ ✂ ✂ ✄ ✟ ✂

Figure 2: Construction of

to recognize

Closure under the Regular Operations – p.9/26

slide-20
SLIDE 20

Construction procedure

  • Combine
✂✁

and

✂✍

into a new automaton

  • that

starts in the start state of

Closure under the Regular Operations – p.10/26

slide-21
SLIDE 21

Construction procedure

  • Combine
✂✁

and

✂✍

into a new automaton

  • that

starts in the start state of

  • Add
  • transitions from the accept states of

to the start state of

Closure under the Regular Operations – p.10/26

slide-22
SLIDE 22

Construction procedure

  • Combine
✂✁

and

✂✍

into a new automaton

  • that

starts in the start state of

  • Add
  • transitions from the accept states of

to the start state of

  • Set accept states of
  • to be the accept states on

Closure under the Regular Operations – p.10/26

slide-23
SLIDE 23

Proof

Let

✂✁ ✄ ☎ ✆ ✁✞✝ ✟ ✝ ✠ ✁ ✝ ✡ ✁ ☛ ✝ ☞ ✁ ✌

recognize

✎ ✁

and

✄ ☎ ✆ ✍ ✝ ✟ ✝ ✠ ✍ ✝ ✡ ✍ ☛ ✝ ☞ ✍ ✌

recognize

✎ ✍

. Construct

☎ ✆ ✝ ✟ ✝ ✠ ✝ ✡ ✁ ☛ ✝ ☞ ✍ ✌

by the following procedure:

Closure under the Regular Operations – p.11/26

slide-24
SLIDE 24

Construction procedure

1.

. The states of

are all states of

☎ ✁

and

☎ ✄

Closure under the Regular Operations – p.12/26

slide-25
SLIDE 25

Construction procedure

1.

. The states of

are all states of

☎ ✁

and

☎ ✄
  • 2. The start state is the state
✄ ✁ ✆
  • f
☎ ✁

Closure under the Regular Operations – p.12/26

slide-26
SLIDE 26

Construction procedure

1.

. The states of

are all states of

☎ ✁

and

☎ ✄
  • 2. The start state is the state
✄ ✁ ✆
  • f
☎ ✁
  • 3. The accept states is the set
  • f the accept states of
☎ ✄

Closure under the Regular Operations – p.12/26

slide-27
SLIDE 27

Construction procedure

1.

. The states of

are all states of

☎ ✁

and

☎ ✄
  • 2. The start state is the state
✄ ✁ ✆
  • f
☎ ✁
  • 3. The accept states is the set
  • f the accept states of
☎ ✄
  • 4. Define
  • so that for any
✄ ✁
  • and any
✂ ✁ ✄✆☎

:

✄ ✞ ✂ ✟ ✁ ✠ ✡✌✡☞✡☛✡✌✡☞✍ ✡☛✡✌✡☞✡☛✡✌✎
✝ ✄ ✞ ✂ ✟ ✞

if

✄ ✁

and

✄ ✑ ✁
✝ ✄ ✞ ✂ ✟ ✞

if

✄ ✁

and

✂ ✑ ✁
✝ ✄ ✞ ✂ ✟ ✁ ✂ ✄ ✄ ✆ ✝ ✞

if

✄ ✁

and

✂ ✁
✝ ✄ ✞ ✂ ✟ ✞

if

✄ ✁

.

Closure under the Regular Operations – p.12/26

slide-28
SLIDE 28

Application

Consider the alphabet

✟ ✄
✝ ✂ ✄

and the languages:

✂ ☎ ✆ ✆ ☎ ✆
✝ ✓ ✁ ✂ ☎ ✆ ✞ ✂ ✞ ✗ ✚ ✕ ✑ ✑ ✄ ✕ ✌ ✡ ✍ ✡ ✕ ☛ ✕ ☎ ☎ ✡ ✌ ✏ ✝ ✘ ✁ ✂ ☎ ✆ ☎ ✔ ✕ ☛ ✍ ✂ ✡ ☛ ✌ ✂ ✍ ✖ ✞ ✂ ✌ ✍ ✍ ✎ ✗ ✞ ✞ ✏ ✝ ✜ ✁ ✂

Use the construction given in the proof of theorem 1.47 to give the state diagrams recognizing the languages

✎ ✆ ✣

and

✤ ✆ ✥

where

is concatenation operator.

Closure under the Regular Operations – p.13/26

slide-29
SLIDE 29

Theorem 1.49

The class of regular languages is closed under star

  • peration

Proof idea: we have a regular language

✎ ✁

, recognized by the NFA

✂✁

and want to prove that

is also a regular language. The procedure to prove this theorem is by construction of the NFA

  • that recognizes

as shown in Figure 3

Closure under the Regular Operations – p.14/26

slide-30
SLIDE 30

Procedure for the construction of

✂ ✄ ✆ ✝ ✝ ✂ ✆ ✝ ✝ ✆ ✟
✁ ✟

Figure 3: Construction of

to recognize

Closure under the Regular Operations – p.15/26

slide-31
SLIDE 31

More on the proof idea

  • is like

with a new start state and an

  • transition

from the new start state to

✡ ✁

Closure under the Regular Operations – p.16/26

slide-32
SLIDE 32

More on the proof idea

  • is like

with a new start state and an

  • transition

from the new start state to

✡ ✁
  • Since

the new start state is an accepts state

Closure under the Regular Operations – p.16/26

slide-33
SLIDE 33

More on the proof idea

  • is like

with a new start state and an

  • transition

from the new start state to

✡ ✁
  • Since

the new start state is an accepts state

  • We add
  • transitions from the previous accept states of

to the start state of

allowing the machine to read and recognize strings of the form

✆✂✁ ✁ ✁ ✆ ☎✄

where

✝ ✁ ✁ ✁ ✝ ☎✄

Closure under the Regular Operations – p.16/26

slide-34
SLIDE 34

Proof

Let

✂✁ ✄ ☎ ✆ ✁✞✝ ✟ ✝ ✠ ✁ ✝ ✡ ✁ ☛ ✝ ☞ ✁ ✌

recognize

✎ ✁

. Construct

☎ ✆ ✝ ✟ ✝ ✠ ✝ ✡ ☛ ✝ ☞ ✌

by the procedure:

Closure under the Regular Operations – p.17/26

slide-35
SLIDE 35

Construction procedure

1.

✂☎✄ ✆ ✝ ✁

; i.e. states of

☎ ✁

plus a new state

✄ ✆

Closure under the Regular Operations – p.18/26

slide-36
SLIDE 36

Construction procedure

1.

✂☎✄ ✆ ✝ ✁

; i.e. states of

☎ ✁

plus a new state

✄ ✆
  • 2. Start state if

is

✄ ✆

Closure under the Regular Operations – p.18/26

slide-37
SLIDE 37

Construction procedure

1.

✂☎✄ ✆ ✝ ✁

; i.e. states of

☎ ✁

plus a new state

✄ ✆
  • 2. Start state if

is

✄ ✆

3.

✂☎✄ ✆ ✝ ✁

; that is, the accept states of

are the accept states of

☎ ✁

plus the new start state

Closure under the Regular Operations – p.18/26

slide-38
SLIDE 38

Construction procedure

1.

✂☎✄ ✆ ✝ ✁

; i.e. states of

☎ ✁

plus a new state

✄ ✆
  • 2. Start state if

is

✄ ✆

3.

✂☎✄ ✆ ✝ ✁

; that is, the accept states of

are the accept states of

☎ ✁

plus the new start state

  • 4. Define
  • so that for any
✄ ✁
  • and
✂ ✁ ✄ ☎

:

✄ ✞ ✂ ✟ ✁ ✠ ✡✌✡☛✡☞✡✌✡☛✡☞✡✌✡☛✍ ✡☞✡✌✡☛✡☞✡✌✡☛✡☞✡✌✎
✝ ✄ ✞ ✂ ✟ ✞

if

✄ ✁

and

✄ ✑ ✁
✝ ✄ ✞ ✂ ✟ ✞

if

✄ ✁

and

✂ ✑ ✁
✝ ✄ ✞ ✂ ✟ ✁ ✂ ✄ ✁ ✆ ✝ ✞

if

✄ ✁

and

✂ ✁
  • ✂☎✄
✁ ✆ ✝ ✞

if

✄ ✁ ✄ ✆

and

✂ ✁

if

✄ ✁ ✄ ✆

and

✂ ✑ ✁
  • .

Closure under the Regular Operations – p.18/26

slide-39
SLIDE 39

Application

Consider the alphabet

✟ ✄
✝ ✂ ✄

and the languages:

✂ ☎ ✆ ☎✔ ✕ ☛ ✍ ✂ ✡ ☛ ✌ ✂ ✍ ✖ ✞ ✂ ✌ ✍ ✍ ✎✟✗ ✞ ✞ ✏ ✌ ✝ ✓ ✁ ✂ ☎ ✆ ☎✔ ✕ ☛ ✍ ✂ ✡ ☛ ✌ ✂ ✍ ✖ ✞ ✂ ✌ ✍ ✍ ☎ ✕ ✒ ✌ ✂ ☛ ✑ ✂ ✍
✌ ✍ ✕ ☛ ✞ ✏ ✝ ✘ ✁ ✂

Use the construction given in the proof of theorem 1.49 to give the state diagrams recognizing the languages

  • ,
  • and
  • .

Closure under the Regular Operations – p.19/26

slide-40
SLIDE 40

Closure under complementation

  • The class of regular languages is closed under

complementation.

Closure under the Regular Operations – p.20/26

slide-41
SLIDE 41

Closure under complementation

  • The class of regular languages is closed under

complementation.

  • For that we will fi rst show thatif

is a DFA that recognizes a language

, swapping the accept and non-accept states in yields a new DFA that recognizes the complement of

.

Closure under the Regular Operations – p.20/26

slide-42
SLIDE 42

Proof

Let

be the DFA

  • with accept and non-accept states swapped. We

will show that

recognizes the complement of

Closure under the Regular Operations – p.21/26

slide-43
SLIDE 43

Proof

Let

be the DFA

  • with accept and non-accept states swapped. We

will show that

recognizes the complement of

  • 1. uppose

accept

, i.e., if we run

  • n

we end in an accept state of

Closure under the Regular Operations – p.21/26

slide-44
SLIDE 44

Proof

Let

be the DFA

  • with accept and non-accept states swapped. We

will show that

recognizes the complement of

  • 1. uppose

accept

, i.e., if we run

  • n

we end in an accept state of

  • 2. Because
  • and

have swapped accept/non-accept states, if we run

  • n

we would end in a non-accept state. Hence,

✙ ✑ ✁ ✓

Closure under the Regular Operations – p.21/26

slide-45
SLIDE 45

Proof

Let

be the DFA

  • with accept and non-accept states swapped. We

will show that

recognizes the complement of

  • 1. uppose

accept

, i.e., if we run

  • n

we end in an accept state of

  • 2. Because
  • and

have swapped accept/non-accept states, if we run

  • n

we would end in a non-accept state. Hence,

✙ ✑ ✁ ✓
  • 3. Similarly, if

is not accepted by

, it would be accepted by

  • Closure under the Regular Operations – p.21/26
slide-46
SLIDE 46

Proof

Let

be the DFA

  • with accept and non-accept states swapped. We

will show that

recognizes the complement of

  • 1. uppose

accept

, i.e., if we run

  • n

we end in an accept state of

  • 2. Because
  • and

have swapped accept/non-accept states, if we run

  • n

we would end in a non-accept state. Hence,

✙ ✑ ✁ ✓
  • 3. Similarly, if

is not accepted by

, it would be accepted by

  • Consequently,

accepts those strings that are not accepted by

  • and therefore

recognizes the complement of

.

Closure under the Regular Operations – p.21/26

slide-47
SLIDE 47

Conclusion

has been an arbitrary regular language. Therefore,

  • ur construction shows how to build an automaton to

recognize its complement

Closure under the Regular Operations – p.22/26

slide-48
SLIDE 48

Conclusion

has been an arbitrary regular language. Therefore,

  • ur construction shows how to build an automaton to

recognize its complement

  • Hence, the complement of any regular language is

also regular

Closure under the Regular Operations – p.22/26

slide-49
SLIDE 49

Conclusion

has been an arbitrary regular language. Therefore,

  • ur construction shows how to build an automaton to

recognize its complement

  • Hence, the complement of any regular language is

also regular

  • Consequently the class of regular languages is closed

under complementation

Closure under the Regular Operations – p.22/26

slide-50
SLIDE 50

Interesting property

If is an NFA that recognizes language

, swapping its accept and non-accept states doesn’t necessarily yield a new NFA that recognizes the complement of

.

Closure under the Regular Operations – p.23/26

slide-51
SLIDE 51

Proof

We prove the interesting property by constructing a counter-example.

  • Consider the construction in Figure 4, where both

NFA-s, and

  • , accept aa.

1

a 2

a,b

b

1

a 2

a,b

b

Figure 4: NFAs

  • and

Closure under the Regular Operations – p.24/26

slide-52
SLIDE 52

Question

Is the class of languages recognized by NFAs closed under complementation?

Closure under the Regular Operations – p.25/26

slide-53
SLIDE 53

Closure under complementation

  • The class of languages recognized by NFA is still

closed under complementation

Closure under the Regular Operations – p.26/26

slide-54
SLIDE 54

Closure under complementation

  • The class of languages recognized by NFA is still

closed under complementation

  • This follows from the fact that the class of languages

recognized by NFAs is precisely the class of languages recognized by DFA

Closure under the Regular Operations – p.26/26

slide-55
SLIDE 55

Closure under complementation

  • The class of languages recognized by NFA is still

closed under complementation

  • This follows from the fact that the class of languages

recognized by NFAs is precisely the class of languages recognized by DFA

  • The counter-example in Figure 4 shows the difference

between the process of computations performed by DFAs and NFAs

Closure under the Regular Operations – p.26/26