kleene theorem ii

55
Kleene Theorem II Equivalence of FA, NDFA,NDFA-

Upload: jael

Post on 21-Jan-2016

71 views

Category:

Documents


0 download

DESCRIPTION

Kleene Theorem II. Equivalence of FA, NDFA,NDFA- . Announcement. Microsoft is coming to RIT Integrating Technology for Performance Xcellence” Mike Adams, Director of Global Performance Xcellence Monday, April 1 – 3pm Webb Auditorium (Rm 1350) Booth Bld Reception will follow - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Kleene Theorem II

Kleene Theorem II

Equivalence of FA, NDFA,NDFA-

Page 2: Kleene Theorem II

Announcement

Microsoft is coming to RIT– Integrating Technology for Performance

Xcellence”– Mike Adams, Director of Global

Performance Xcellence– Monday, April 1 – 3pm– Webb Auditorium (Rm 1350) Booth Bld– Reception will follow

• RSVP 475-2199 or [email protected]

Page 3: Kleene Theorem II

Announcement

CS Colloquium– Many to Many Invocation: A New Paradigm for Ad

Hoc Collaborative Systems

– Hans-Peter Bischof

– Tuesday, April 2– 1-2 pm– 10-1124

Page 4: Kleene Theorem II

Homework

Homework #1 returned today Homework #2 due today

Page 5: Kleene Theorem II

Homework

Speaking of Homework– Here’s Homework #3 (Due April 4)

• From the textbook– 4.8b,c– 4.13b,c– 4.16b,c– 4.31c,d– 4,32a

Page 6: Kleene Theorem II

Before We Start

Any questions?

Page 7: Kleene Theorem II

Plan for today

Last time – We introduced two variants of the FA

– Today we will show that each of three FAs are equivalent w.r.t. the class of languages that they accept

Page 8: Kleene Theorem II

Languages

Recall.– What is a language?– What is a class of languages?

Page 9: Kleene Theorem II

Regular Languages

Regular languages– Means of defining: Regular Expressions– Machine for accepting: Finite Automata

Page 10: Kleene Theorem II

Finite Automata

A finite automaton (finite-state machine) is a 5-tuple (Q, , qo, , A) where

– Q is a finite set (of states) is a finite alphabet of symbols

– qo Q is the start state

– A Q is the set of accepting states is a function from Q x to Q (transition

function)

Page 11: Kleene Theorem II

Kleene Theorem

A language L over is regular iff there exists an FA that accepts L.

1. If L is regular there exists an FA M such that L = L(M)

2. For any FA, M, L(M) is regular L(M), the language accepted by the FA can be

expressed as a regular expression.

Page 12: Kleene Theorem II

Proving Kleene Theorem

Approach– Define 2 variants of the Finite Automata

• Nondeterministic Finite Automata (NDFA)• Nondeterministic Finite Automata with transitions

(NDFA- )

– Prove that FA, NDFA, and NDFA- are equivalent w.r.t. the languages they accept

– For a regular expression, build a NDFA- that accepts the same language

– For an FA build a regular expression that describes the language accepted by the FA.

Page 13: Kleene Theorem II

Tonight

Last time we defined these two FA variants:– Nondeterministic Finite Automata (NDFA)– Nondeterministic Finite Automata with

transitions (NDFA- )

Today we show they are equivalent

Questions?

Page 14: Kleene Theorem II

Equivalence

If L is a language over *, then the following 3 statements are equivalent:

1. L is accepted by a FA

2. L is accepted by a NDFA

3. L is accepted by a NDFA-

Page 15: Kleene Theorem II

Equivalence

How we will show this1. Given an NDFA that accepts L, create an

FA that also accepts L2. Given an NDFA- that accepts L, create

an NDFA that also accepts L3. Given an FA that accepts L, create a

NDFA- that also accepts L.

Are we ready?

Page 16: Kleene Theorem II

Step 1: NDFA->FA

Given NDFA find FA– Let M = (Q, , q0, A, ) be a NDFA then

• There exists a FA, M1 = (Q1, , q1, A1, 1)

• Such that L(M) = L(M1)

Page 17: Kleene Theorem II

Step 1: NDFA -> FA

Basic idea– Recall that for a NDFA, : Q x 2Q

– Use the states of M1 to represent subsets of Q.

– If there is one state of M1 for every subset of Q, then the non-determinism of M can be eliminated.

– This technique, called subset construction, is a primary means for removing non-determinism from an NDFA.

Page 18: Kleene Theorem II

Step 1: NDFA -> FA

Formal definition– M = (Q, , q0, A, ) be a NDFA– We define FA, M1 = (Q1, , q1, A1, 1)

• Q1 = 2Q • q1 = {q0}• For q Q1 and a ,•

• A1 = {q Q1 | q A }

– Note that we need only include states on M1 (subsets of Q) if the state is reachable.

qp

apaq

),(),(1

Page 19: Kleene Theorem II

Step 1: NDFA -> FA

Algorithm for building M1

– Add {q0} to Q1

– While there are states of Q1 whose transitions are yet to be defined

• Let q Q1

• For each a , determine the set of states, P, in M that are reachable from q on input a

• If there is no state in Q1 corresponding to P, add one.• Define 1 (q, a) = state in Q1 corresponding to P

– Define A1 as any state in Q1 that corresponds to a subset containing any of the final states of M

Page 20: Kleene Theorem II

Step 1: NDFA -> FA

Example

Page 21: Kleene Theorem II

Step 1: NDFA -> FA

q0 q0q1

q0q2

q0q1q2

q0q3

q0q1q3

q0q2q3

q0q1q2q3

0

0

0

0

0

0

0

01

1

1

1

1

1

1

1

Page 22: Kleene Theorem II

Step 1: NDFA -> FA

Now we must show that M1 accepts the same language as M– Will show that for all x *

*1 (q1, x) = *

(q0, x)

– Show by structural induction• Base case when x =

*1 (q1, ) = q1 definition of *

1

– = {q0} definition of q1

– = * (q0, ) definition of *

– = *

(q0, x) since x =

Page 23: Kleene Theorem II

Step 1: NDFA -> FA

– Show by structural induction• Induction:

– Assume *1 (q1, x) = *

(q0, x)

– Show *1 (q1, xa) = *

(q0, xa)

*1 (q1, xa) = 1 (*

1 (q1, x) , a) def of *1

– = 1 (* (q0, x), a) induction hypothesis

– = def of 1

– = * (q0, xa) def of *

),( 0

*

),(xqp

ap

Page 24: Kleene Theorem II

Step 1: NDFA -> FA

Show that M and M1 recognize the same language– x is accepted by M1 iff *

1 (q1, x) A1

– x is accepted by M1 iff * (q0, x) A1

– By def of A1,

• x is accepted by M1 iff * (q0, x) A

– Thus• x is accepted by M1 iff x is accepted by M

Page 25: Kleene Theorem II

What have we shown

In Step 1 we’ve shown:– Given a NDFA

• There exists an FA that accepts the same language

• Non-determinism can be removed from an NDFA by using a subset construction algorithm.

– Questions?

Page 26: Kleene Theorem II

What have we shown

NDFA

FA

If L NDFA then L FA

Page 27: Kleene Theorem II

Step 2: NDFA- -> NDFA

Given NDFA- find NDFA – Let M = (Q, , q0, A, ) be a NDFA- then

• There exists a NDFA, M1 = (Q1, , q1, A1, 1)

• Such that L(M) = L(M1)

Page 28: Kleene Theorem II

Step 2: NDFA- -> NDFA

Basic idea– Recall that a NDFA- is still non-deterministic– Replace transitions with non- transitions

– Let 1(q,a) be the set of states reachable from q, reading symbol a, including those reachable via transitions

• Which is just * (q,a)

0 0 0

Page 29: Kleene Theorem II

Step 2: NDFA- -> NDFA

Basic idea– Accepting states

• If q0 is not an accepting state of M but it is possible to get to an accepting state by just using transitions, then q0 must be added to the set of accepting states of M1

Page 30: Kleene Theorem II

Step 2: NDFA- -> NDFA

Formal definition– M = (Q, , q0, A, ) be a NDFA-

– We define NDFA, M1 = (Q1, , q1, A1, 1)

• Q1 = Q

• q1 = q0

1 (q,a) = * (q,a)

• A1 = A {qo} if ({qo} ) A in M

• = A otherwise

Page 31: Kleene Theorem II

Step 2: NDFA- -> NDFA

Algorithm for constructing M1

– Set of states is the same as M– Start state is the same as M– Accepting states is the same as M– For each state, q, in M

• compute the closure• For each state in the closure,p, and for each symbol a,

add all elements of (p,a) to the set 1(q, a)

– If you can get to to an accepting state in M from qo by only using transitions, add q0 to A1

Page 32: Kleene Theorem II

Step 2: NDFA- -> NDFA

Example

Page 33: Kleene Theorem II

Step 2: NDFA- -> NDFA

State closure

q0 {q0, p, t }

p {p}

r {r}

s {s, w, q0, p, t }

t {t}

u {u}

v {v, w, q0, p, t }

w {w, q0, p, t}

Page 34: Kleene Theorem II

Step 2: NDFA- -> NDFA

q0

p r s

t u v

w

Page 35: Kleene Theorem II

Step 2: NDFA- -> NDFA

Now we must show that M1 accepts the same language as M– Will show that for all x *

*1 (q, x) = *

(q, x)

– Show by structural induction• Base step: show true for x = a

* (q, a) = 1(q,a) def of 1

– *1 (q, a) = def of *

1

– = 1(q,a) since *1 (q, ) = {q}

),(1

*

),( qp

ap

Page 36: Kleene Theorem II

Step 2: NDFA- -> NDFA

– Show by structural induction• Assume: *

1 (q, x) = * (q, x)

• Show: *1 (q, xa) = *

(q, xa)

def of *1

induction hypothesis

def of 1

),(

1*

1*

1

),(),(xqp

apxaq

),(1

*

),(xqp

ap

),(

*

*

),(xqp

ap

Page 37: Kleene Theorem II

Where we are

In Step 2 we’ve shown:– Given an NDFA-

• There exists an NDFA that accepts the same language

transitions can be removed from an NDFA- by replacing transitions with non- transitions in an already non-deterministic NDFA.

Page 38: Kleene Theorem II

Where we are

NDFA- NDFA

If L NDFA- then L NDFA

Page 39: Kleene Theorem II

Where we are

– We’ve shown that:• If L is accepted by an NDFA- it is also accepted by an

NDFA• If L is accepted by an NDFA it is also accepted by an FA• So if L is accepted by an NDFA- , it is accepted by an

FA.

– We still need to show:• If L is accepted by an FA, it is also accepted by an

NDFA-

– Questions?

Page 40: Kleene Theorem II

Where we are

NDFA- NDFA FA

Page 41: Kleene Theorem II

Step 3: FA-> NDFA-

Given FA find NDFA- – Let M = (Q, , q0, A, ) be a FA then

• There exists a NDFA -, M1 = (Q1, , q1, A1, 1)

• Such that L(M) = L(M1)

Page 42: Kleene Theorem II

Step 3: FA-> NDFA-

Basic idea– Since FAs are more restrictive than NDFA-

s, any FA is essentially an NDFA- that doesn’t take advantage of:

• Non-determinism-transitions

– Must consider details of transition functions

Page 43: Kleene Theorem II

Step 3: FA-> NDFA-

Formal definition– M = (Q, , q0, A, ) be a FA

– We define NDFA-, M1 = (Q1, , q1, A1, 1)

• Q1 = Q

• q1 = q0

• A1 = A

1 (q, ) = for all q Q

1 (q, a) = { (q, a)} for all q Q, a

Page 44: Kleene Theorem II

Step 3: FA-> NDFA-

Now we must show that M1 accepts the same language as M– Will show that for all x *

*1 (q, x) = {*

(q, x) }

– Show by structural induction• Base step: show true for x =

*1 (q, ) = (q) def of *

1

– = {q} since 1 (q, ) =

– = * (q, ) def of *

Page 45: Kleene Theorem II

Step 3: FA-> NDFA-– Show by structural induction

• Assume: *1 (q, x) = {*

(q, x) }• Show: *

1 (q, xa) = {* (q, xa) }

• def of *1

• since 1 (q, ) =

• induction hyp.•

• = { (*

(q, x), a) }• = {*

(q, xa) } def of *

),(

*1

*1

),(),(xqp

apxaq

),(*

1

),(xqp

ap

),(*

),(xqp

ap

Page 46: Kleene Theorem II

Step 3: FA-> NDFA-

Show that M and M1 recognize the same language– x is accepted by M1 iff *

1 (q0, x) A – x is accepted by M1 iff {*

(q0, x)} A – That’s the same as saying

* (q0, x) A or

• x is accepted by M

– Thus• x is accepted by M1 iff x is accepted by M

Page 47: Kleene Theorem II

Equivalence!

What we have shown1. Given an NDFA that accepts L, create an

FA that also accepts L

2. Given an NDFA- that accepts L, create an NDFA that also accepts L

3. Given an FA that accepts L, create a NDFA- that also accepts L.

All 3 are equivalent

Page 48: Kleene Theorem II

Equivalence!

NDFA- NDFA FA

Page 49: Kleene Theorem II

Equivalence!

NDFA- NDFA FA

Page 50: Kleene Theorem II

Questions

break

Page 51: Kleene Theorem II

Example 1

Figure 4-7

Page 52: Kleene Theorem II

Example 2

Fig 2.18 in Hopcraft

Page 53: Kleene Theorem II

Summary

If L is a language over *, then the following 3 statements are equivalent:1.L is accepted by a FA

2.L is accepted by a NDFA

3.L is accepted by a NDFA-

Page 54: Kleene Theorem II

Summary

How we showed this1.Given an NDFA that accepts L, create an

FA that also accepts L (subset construction)

2.Given an NDFA- that accepts L, create an NDFA that also accepts L (-transition elimination)

3.Given an FA that accepts L, create a NDFA- that also accepts L.

Page 55: Kleene Theorem II

Next time

Now we have all the tools needed to prove Kleene’s Theorem directly

Will do this next time