30
Introduction to Computability Theory Discussion1: Conversion of A DFA to a Regular Expression 1 A DFA to a Regular Expression Prof. Amos Israeli

Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Intr

od

uct

ion

to

Co

mp

uta

bil

ity

Th

eo

ry

Dis

cuss

ion

1:

Co

nv

ers

ion

of

A D

FA t

o a

Re

gu

lar

Ex

pre

ssio

n

1

A D

FA t

o a

Re

gu

lar

Ex

pre

ssio

nP

rof.

Am

os

Isra

eli

Page 2: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Giv

en

a G

NFA

G,

an

y s

tate

of

G,

no

t in

clu

din

g

an

d

,

ca

n b

e r

ipp

ed

off

G,

wh

ile

pre

serv

ing

.

Th

is i

s d

em

on

stra

ted

in

th

e n

ext

slid

e b

y

Rip

pin

g a

sta

te f

rom

a G

NFA

(re

m.)

()

GL

sta

rtq

accep

tq

Th

is i

s d

em

on

stra

ted

in

th

e n

ext

slid

e b

y

con

sid

eri

ng

a g

en

era

l st

ate

, d

en

ote

d b

y

,

an

d a

n a

rbit

rary

pa

ir o

f st

ate

s,

a

nd

:

2

rip

q

iq

jq

Page 3: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Re

mo

vin

g a

sta

te f

rom

a G

NFA

iq

jq

4R

()(

)(

)4

3

*

21

RR

RR

iq

jq

Be

fore

Rip

pin

gA

fte

r R

ipp

ing

3

1R

ij

q

rip

q

3R

2R

iq

jq

No

te:

Th

is s

ho

uld

be

do

ne

fo

r e

ve

ry p

air

of

inco

min

g a

nd

ou

tgo

ing

tra

nsi

tio

ns.

Page 4: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Ell

ab

ora

tio

n

Ass

um

e t

he

fo

llo

win

g s

itu

ati

on

:

In o

rde

r to

rip

,

all

pa

irs

of

inco

min

g a

nd

ou

tgo

ing

tra

nsi

tio

ns

sho

uld

be

co

nsi

de

red

1t2t

3tri

pq

qtr

an

siti

on

s sh

ou

ld b

e c

on

sid

ere

d

in t

he

wa

y s

ho

we

d o

n t

he

pre

vio

us

slid

e n

am

ely

co

nsi

de

r

on

e a

fte

r th

e o

the

r. A

fte

r th

at

c

an

be

rip

pe

d w

hil

e p

rese

rvin

g

.

4

5t4t

()(

)(

)(

)(

)

()

53

43

52

42

51

41

,

,,

,,

,,

,,

,,

tt

tt

tt

tt

tt

tt

rip

q

rip

q

()

GL

Page 5: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Th

e C

on

ve

rsio

n A

lgo

rith

m -

Ou

tlin

e

Th

e c

on

ve

rsio

n a

lgo

rith

m h

as

3 s

tag

es:

1.

Co

nve

rtin

g a

DFA

D w

ith

k s

tate

s to

an

eq

uiv

ale

nt

GN

FA G

wit

h

sta

tes

.

2.

Re

pe

ate

dly

rip

pin

g a

n a

rbit

rari

ly c

ho

sen

sta

te

2+

k

2.

Re

pe

ate

dly

rip

pin

g a

n a

rbit

rari

ly c

ho

sen

sta

te

of

G w

hil

e p

rese

rvin

g i

ts f

un

ctio

na

lity

un

til

rem

ain

ing

wit

h a

2 s

tate

s e

qu

iva

len

t G

NFA

wit

h t

wo

sta

tes.

3.

Re

turn

th

e R

E l

ab

eli

ng

re

ma

inin

g t

ran

siti

on

.

5

Page 6: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Exe

rcis

e

Ap

ply

th

e a

lgo

rith

m t

o o

bta

in t

he

re

gu

lar

exp

ress

ion

eq

uiv

ale

nt

to D

:

0

aq

bq

1

cq

Wh

at

is t

he

eq

uiv

ale

nt

Re

gu

lar

exp

ress

ion

?

6

()*

*1

01

01

∪+a

qb

qc

q

10

1,0

Page 7: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

1:

Co

nv

ert

Dto

a G

NFA

1.0

Sta

rt w

ith

D

aq

cq

7

0

aq

bq

1

1

0

1,0

Page 8: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

1:

Co

nv

ert

Dto

a G

NFA

1.1

Ad

d 2

ne

w s

tate

s

aq

cq

8

0

aq

bq

1

1

0

1,0

acc

ept

qst

art

q

Page 9: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

1:

Co

nv

ert

Dto

a G

NFA

1.2

Ma

ke

the

in

itia

l st

ate

an

d

th

e f

ina

l

sta

te.

aq

cq

sta

rtq

acc

ept

q

9

0

aq

bq

1

1

0

1,0

acc

ept

qst

art

qεε

Page 10: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

1:

Co

nv

ert

Dto

a G

NFA

1.3

Re

pla

ce m

ult

i la

be

l tr

an

siti

on

s b

y t

he

ir

un

ion

.

aq

cq

10

0

aq

bq

1

1

0

10∪

acc

ept

qst

art

qεε

Page 11: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

1:

Co

nv

ert

Dto

a G

NFA

1.4

Ad

d a

ll m

issi

ng

tra

nsi

tio

ns

an

d l

ab

el

the

m

.

φ

11

0

aq

bq

1

cq

1

0

sta

rtq

εε

acc

ept

q

10∪

Page 12: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.0

Sta

rt w

ith

G.

12

0

aq

bq

1

cq

1

0

sta

rtq

εε

acc

ept

q

10∪

Page 13: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.1

Ch

oo

se a

n a

rbit

rary

sta

te t

o b

e r

ipp

ed

.

13

0

aq

bq

1

cq

1

0

sta

rtq

εε

acc

ept

q

10∪

Page 14: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.1

Re

mo

ve

all

-la

be

led

in

com

ing

an

d

ou

tgo

ing

tra

nsi

tio

ns.

(No

te:

Th

is s

tag

e d

oe

s n

ot

ap

pe

ar

in t

he

bo

ok

).

φ

bo

ok

).

2.3

Re

pla

ce e

ach

pa

ir o

f in

com

ing

an

d o

utg

oin

g

tra

nsi

tio

ns

usi

ng

th

e p

roce

du

re w

e s

ho

we

d

be

fore

.

14

Page 15: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

Re

min

de

r: i

fth

e i

nco

min

g t

ran

siti

on

fro

m

t

o

is l

ab

ele

d

, th

e s

elf

-lo

op

of

,

,

th

e

tra

nsi

tio

n f

rom

to

w

ith

, a

nd

th

e

tra

nsi

tio

n f

rom

to

i

s la

be

led

wit

h

1R

2R

rip

qri

pq

iq

rip

qj

q3

R

4R

iq

jq

tra

nsi

tio

n f

rom

to

i

s la

be

led

wit

h

the

n t

he

ne

w l

ab

el

fro

m

t

o

is

lab

ele

d

.

Als

o n

ote

: fo

r a

ny

re

gu

lar

exp

ress

ion

R,

15

()(

)(

)4

3

*

21

RR

RR

∪i

qj

q

4R

φφ

φ=

=R

Ro

o

iq

jq

Page 16: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.1

Re

mo

ve

all

-la

be

led

in

com

ing

tra

nsi

tio

ns.

φ

16

0

aq

bq

1

cq

1

0

10∪

sta

rtq

εε

acc

ept

φ

Page 17: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.1

Re

mo

ve

all

-la

be

led

ou

tgo

ing

tra

nsi

tio

ns.

φ

17

0

aq

bq

1

cq

1

0

10∪

sta

rtq

εε

acc

ept

φ

Page 18: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.1

Re

mo

ve

all

-la

be

led

ou

tgo

ing

tra

nsi

tio

ns.

φ

18

0

aq

bq

1

cq

1

0

10∪

sta

rtq

εε

acc

ept

φ

Page 19: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.1

Re

mo

ve

tra

nsi

tio

ns

ne

w l

ab

el

is

.

φ1

01

00

*+

=∪

φ

10+

19

0

aq

bq

1

cq

1

0

sta

rtq

εε

acc

ept

q

φ

10∪

Page 20: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.1

No

w a

ll i

nco

min

g t

ran

siti

on

s a

re r

em

ove

d.

φ1

0+

20

aq

bq

1

cq

1

0

sta

rtq

εε

acc

ept

q

φ

10∪

Page 21: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.2

Re

mo

ve

ou

tgo

ing

tra

nsi

tio

ns.

φ1

0+

21

aq

bq

cq

1

sta

rtq

ε

acc

ept

q

φ

ε1

0∪

Page 22: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.3

ch

oo

se a

ne

w

.

φ1

0+

rip

q

22

aq

cq

1

sta

rtq

ε

acc

ept

q

φ

ε1

0∪

Page 23: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.1

Re

mo

ve

all

-la

be

led

in

com

ing

tra

nsi

tio

ns.

φ1

0+

φ

23

aq

cq

1

sta

rtq

ε

acc

ept

q

φ

ε1

0∪

Page 24: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.1

Re

mo

ve

all

-la

be

led

ou

tgo

ing

tra

nsi

tio

ns.

10+

φ

24

aq

cq

1

sta

rtq

ε

acc

ept

q

φ

ε1

0∪

Page 25: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.1

Re

mo

ve

all

-la

be

led

ou

tgo

ing

tra

nsi

tio

ns.

10+

φ

25

aq

cq

1

sta

rtq

ε

acc

ept

q

φ

ε1

0∪

Page 26: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.2

Re

mo

ve

tra

nsi

tio

ns

ne

w l

ab

el

is

.

.

10+

()*

10

10

∪+

26

aq

cq

1

sta

rtq

ε

acc

ept

q

φ

()

()*

*1

01

01

01

0∪

=∪

∪+

φ

ε1

0∪

Page 27: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.3

Re

mo

ve

a

nd

all

its

tra

nsi

tio

ns.

rip

q

27

aq

1

sta

rtq

ε

acc

ept

q

φ

()

()*

*1

01

01

01

0∪

=∪

∪+

φ

Page 28: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

la

st s

tate

2.3

Ch

oo

se t

he

la

st r

em

ain

ing

sta

te t

o b

e r

ipp

ed

.

28

aq

1

sta

rtq

ε

acc

ept

q

φ

()

()*

*1

01

01

01

0∪

=∪

∪+

φ

Page 29: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

2:

Rip

a s

tate

2.3

ch

oo

se a

ne

w

a

nd

re

pe

at

pro

ced

ure

.ri

pq

29

sta

rtq

acc

ept

q

()

()*

**

*1

01

01

10

10

1∪

=∪

∪+

φ

Page 30: Introduction to Computability Theory · Microsoft PowerPoint - Discussion2.pptx Author: amos Created Date: 10/9/2008 1:26:24 PM

Sta

ge

3:

Re

turn

th

e r

em

ain

ing

RE

. 30

sta

rtq

acc

ept

q

()*

*1

00

11

∪+