On the degree of ambiguity of finite automata - Springer Link

3 downloads 21999 Views 398KB Size Report
(c I ~ 2.0566). We present an algorithm which decides in polynomial time whether the degree of ambiguity of a NFA is finite or not. Additionally, the authors ...
ON

THE

DEGREE

Andreas

Weber

Fachbereich D-6000

OF AMBIGUITY

and H e l m u t

Informati~,

Frankfurt

OF FINITE

AUTOMATA

Seidl, J. W. G o e t h e - U n i v e r s i t ~ t ,

am Main,

West Germany.

Abstract We show that the d e g r e e maton

(NFA)

with

(c I ~ 2.0566). whether

the authors

mial-time finite

We p r e s e n t

the degree

valuedness

of a m b i g u i t y

n states,

is not greater

an a l g o r i t h m

which decides

of a m b i g u i t y

obtain

in

of a NFA is finite

[14] a c o r r e s p o n d i n g

of a n o r m a l i z e d algorithm

of a n o n d e t e r m i n i s t i c

if finite,

which

finite

upper

transducer

decides w h e t h e r

than

finite

+ c1"n

in p o l y n o m i a l

or not.

bound

(NFT),

auto-

2n ' l ° g ~ n

time

Additionally,

for the finite

and also a polyno-

the v a l u e d n e s s

of a NFT is

or not.

Introduction Let x be an input

string

of a n o n d e t e r m i n i s t i c

and also of a n o r m a l i z e d guity

of x in M is d e f i n e d

The v a l u e d n e s s strings M

finite

of x in M~

on the a c c e p t i n g

(the v a l u e d n e s s

of an input

of M')

string

of M

transducer

by the n u m b e r is d e f i n e d

paths

finite

(NFT)

M'.

of a c c e p t i n g

by the n u m b e r

for x in M'.

is the m a x i m a l

automaton

paths

degree

for x in M. output

of a m b i g u i t y

of a m b i g u i t y

depending

M,

of ambi-

of d i f f e r e n t

The d e g r e e

(M') or is infinite,

(NFA)

The degree

of

(valuedness)

on w h e t h e r

or

not a m a x i m u m exists. The degree which

of a m b i g u i t y

only r e c e n t l y

lence p r o b l e m problem

generalized

attention

and NFT's:

sequential

machines

of a m b i g u i t y

time

[12].

that

the e q u i v a l e n c e

not g r e a t e r

or not the d e g r e e

[13],

with

moves)

of NFA's

in p o l y n o m i a l

conjecture

follows

is d e c i d a b l e

in p o l y n o m i a l

of

is un-

the e q u i v a l e n c e

finite v a l u e d n e s s

[12]

the equiva-

the e q u i v a l e n c e

than d can be tested

of a NFA

parameters,

that the e q u i v a l e n c e

~-(input)

d, however,

d, it can be tested

of a m b i g u i t y

and that

of the E h r e n f e u c h t

of NFT's with

integer

structural

in c o n n e c t i o n

(NFT's w i t h o u t

integer

From a g e n e r a l i z a t i o n

any fixed

are

It is w e l l - k n o w n

is P S P A C E - c o m p l e t e

[5]. For any fixed

w i t h degree

Given

received

for NFA's

for NFA's

decidable

and the v a l u e d n e s s

[4].

time w h e t h e r

(the v a l u e d n e s s

of a NFT

621

[6]i

is greater

space

than d. Chan and Ibarra

algorithms

is finite, teger.

which

and also w h e t h e r

Moreover,

complete.

Using

algorithms placed

which

In section

Such an e x p l i c i t

in

of a m b i g u i t y

[2].

dependently criterion, in

biguity

In section

of us, which

[14]

(cf.

Ibarra

can be tested

~-moves,

a criterion

of a N F A (c I

with

the m e t h o d s

for the i n f i n i t e

in p o l y n o m i a l

and R a v i k u m a r

exhibit

time).

over both r e s u l t s

and to the

+ c1"n

be a c h i e v e d

in e x p o n e n t i a l

carry

are d i f f e r e n t

from those

it is s u f f i c i e n t

for e v e r y

time

de-

(In-

an e q u i v a l e n t

By simple

reduc-

to the d e g r e e

size of p r o d u c t s

of am-

of m a t r i c e s

input

paths

in

to c o n s i d e r

[2] and NFA's

string x, we i n v e s t i g a t e

of x in the NFA,

[10].

First

of a r e s t r i c t e d a graph which

and we use

"pumping

of all, type.

describes

arguments"

in

graphs.

In [14] chieve

[10]

of a m b i g u i t y

2n ' l ° g 2 n

is t e st a b l e

is resequen-

[2]).

all a c c e p t i n g these

in

the authors

ideas used

we show that

3 we introduce

of a m b i g u i t y

relation).

the degree than

is P S P A C E -

(a g e n e r a l i z e d

input-output

in-

two e x p o n e n t i a l - s p a c e

machine

cannot

of a NFA

given

the latter p r o b l e m

if the d e g r e e

upper b o u n d

which

than an a r b i t r a r y

that

is not g r e a t e r

of NFA's,

of NFA's with

IN0

Then,

length-preserving

two p o l y n o m i a l -

of a m b i g u i t y

they o b t a i n e d

of a s e q u e n t i a l

if finite,

gree

The

reduction,

2 of this paper we show that

used

tions,

it is g r e a t e r

solve both problems,

with

with n states, 2.0566).

[2] e x h i b i t e d

the d e g r e e

they were able to prove a simple

by the v a l u e d n e s s

tial m a c h i n e

over

decide w h e t h e r

the authors

extend

an upper b o u n d

a criterion

the a b o v e - m e n t i o n e d

for the finite

for the infinite

in p o l y n o m i a l In the first

time.

valuedness

The results

in order

of a NFT,

of NFT's,

are p r e s e n t e d

section we summarize

methods

valuedness

which

can be tested

in section

some d e f i n i t i o n s

to a-

and to d e f i n e

4.

and notations.

I. D e f i n i t i o n s

A nondeterministic w here

Q and

finite

Z denote

Q0,F~ Q d e n o t e

automaton

nonempty,

sets of initial

(NFA)

finite

is a 5-tuple

sets of states

and final

states,

and

M=(Q,Z,6,Q0,F),

and input

symbols,

6 is a subset of

Qx~xQ. A path of length m for x from p to q in M is a string Xmq m 6 Q ( Z Q ) *

n = q0xlql ....

so that x = X l . . . x m 6 Z*, p = q0 6 Q, q = q m 6 Q, and for

622

all

i = I .... ,m

path

(qi_1,xi,qi) 6 6. We d e f i n e

for x f r o m p to q in M e x i s t s } .

Note

~

:: { ( p , x , q ) 6 Q w Ze×Q

I a

t h a t 6 is a s u b s e t of ~. We re-

n a m e ~ by 6. A p a t h ~ f r o m p to q is c a l l e d a n d q is a final all x 6

state.

Z* , for w h i c h

form:

da(M))

in M,

i. e. da(M)

The

paths

= sup

states are

of the d e g r e e s

{daM(x)

""

to the d e g r e e

t h e n M is c a l l e d

is the n u m b e r

of a m b i g u i t y

of a m b i g u i t y

of M

(short

of all x 6 ~*

of a m b i g u i t y

path

in M.

relation

in M. If no

reduced.

w i t h a state q 6 Q

(short form:

f r o m p to q and f r o m q to p in M exist.

is an e q u i v a l e n c e

L e t Q be d i v i d e d

daM(x))

if it is on no a c c e p t i n g

A s t a t e p 6 Q is said to be c o n n e c t e d if p a t h s

state

by M, is the set of

I x 6 ~*}.

useless,

irrelevant

s t a t e of M is u s e l e s s ,

p q),

(short form:

for x in M. The d e g r e e

is the s u p r e m u m

if p is an i n i t i a l

accepted

p a t h in M exists.

of x 6 ~* in M

state q 6 Q is c a l l e d

Useless

path,

the l a n g u a g e

an a c c e p t i n g

~he d e g r e e of a m b i g u i t y of all a c c e p t i n g

accepting

L(M),

N o t e that

on Q.

into the e q u i v a l e n c e

classes

QI' .... Qk w.r.t.

M is s a i d to be of type Q0 c Q 1

& FCQk

I, if the f o l l o w i n g holds: k k-1 U QixZxQi U U ~ D (QxT~xQ) c i=I i =I

"".

&

M is said to be of type t h a t the f o l l o w i n g Q0c

g r a p h GM(X)

(i=I, .... k) e x i s t

such

holds:

{pl } & F c {qk}

L e t M be of type

2, if s t a t e s p i , q i 6 Qi

Qix~xQi+1.

&

~ n (Q×~XQ) c

2 such t h a t L(M)

= (V,E)

Qix~.xQi u

k-1 u i=I

{ q i } x Z x { P i + 1 }.

~ ~, and let x = X l . . . x m 6 L(M).

of the a c c e p t i n g

V := {(q,i) 6 Qx{0, .... m}

k u i=I

paths

The

for x in M is d e f i n e d by

I (Pl,Xl---xi,q)

6 6 & ( q , x i + 1 . . . X m , q k)

6 6} a n d E := {((p,i-1), (q,i)) 6 V 2 [ i 6 {I ..... m} Note

t h a t the n u m b e r

the d e g r e e

Let M=(Q,E,6,Q0,F) cluded F'cF.

in M

of p a t h s

of a m b i g u i t y

from

(Pl,0)

to

(qk,m)

in GM(X)

equals

of x in M. !

a n d M ' : ( Q ' , Z ' , 6 ' , Q 0 ,F')

(short form:

& (P,xi,q) 6 6}.

M' c M ) ,

if Q' c Q ,

be two NFA's. E' c E, 6' c 6 ,

M'

is in-

Q0 'c Q0 and

623

2. An U p p e r

In this

Bound

section

MI,...,~cM

we

leads

Theorem

the

degree

where

c I := I +

finite lower

bound

In the

(2/3).iog23

lemma

of is

any NFA M with N

da(M)

~,

$ ~ i=I

t h e n we

n states

and

bound

of N F A ' s

2 n" (I+I/64)

we c o n s i d e r

the c a s e

Let

with

q0 6 Q0'

implies

q 6 Q.

qF 6 F,

for any

following

lemmas

Lemma

of a m b i g u i t y .

2n ' l ° g 2 n

+ c~-n,

I for

n states

the m a x i m a l

is o p t i m a l . see

with

The best

[14]).

one e q u i v a l e n c e

Then,

NFA

such

that

for any x 6 E*,

da(M) < ~.

there

Let

is at m o s t

for x f r o m p to q in M.

(q,v,p) 6 6. We a s s u m e

two

degree

"".

p 6 Q be c o n n e c t e d

In the

< 2n ' l ° g 2 n .

than

of N F A ' s

I: L e t M = ( Q , Z , 6 , Q 0 , F ) be a r e d u c e d

This

finite

greater

(for d e t a i l s

Lemma

Proof:

da(M)

of t h e o r e m

with

w.r.t.

path

NFA's

~ 2.0566.

class

one

n states

d a ( M i) a n d N < 2 n - 3 2 n / 3 .

show:

of M is n o t

the u p p e r

of a m b i g u i t y

of A m b i g u i t y

result:

of a m b i g u i t y

we k n o w

first

for

da(M)
0, we know:

We show by i n d u c t i o n

L(M) ~ 0,

on k:

~ 2n'[l°gzk]-k+1 follows

of

from

(*)

(for f u r t h e r

details

see

[14]).

(*) :

of induction:

follows:

pi,qi6

the d e f i n i t i o n

Q0={Pl }, F={qk},

classes

da(M)

k=1.

Pl is c o n n e c t e d

w i t h q1" A c c o r d i n g

to lemma

I

= 1.

I n d u c t i o n step: Let k ~ 2. D e f i n e 1 := [k/2]. Divide M into NFA's 1 k M I = ( U Qi ' Z , 61, {pl } , {ql }) and M 2 = ( U Qi ' Z ' 62 ' {PI+I } ' i=I i=I+I 1 1-I {qk}), w h e r e 61 := 6 D ( U Q i x ~ × Q i U U {qi} x Z x {Pi+1}) and i=I i=I k k-1 62 := 6 N ( U Qi×ZxQi U U {qi } × Z × {Pi+1 })" i=i+I i=i+I 1 k M I , M 2 are N F A ' s of type 2 w i t h n I := Z #Qi and n 2 := ~ #Qi states i=I i=i+I such that

0 < d a ( M I) < ~ and 0 < d a ( M 2) < ~.

Let X = X l . . . x m 6 L(M). edges

Consider

"from Q1 to QI+I"'

Define

i.e.

J := {j 6 {I ..... m}

daM(x)

I

in the g r a p h GM(X)=(V,E)

((ql,J-1), (Pl+1,j)) 6 E}.

daM(x)

~

hypothesis

follows:

Z 2nl'FiOgz[k/2]]-[k/2]+1-2 j6 J #j . 2 n'[IOgz (k/2) I-k*2

Note that [log2[k/2]] show: #D = #J ~ 2 n-1.

Since that

that

# J > 2 n-1

Define

~ 6 {0,...,t}

= [logz(k/2)].

#J > 2 n-1. and,

• Jl < J2 and A31

Let t 6 ~.

We observe:

= j 6Z J daM1(Xl.. "xj-1 ).daM2 (xj+1"''Xm)"

F r o m the i n d B c t i o n

We a s s u m e

the set D of all

D = {((ql,J-1), (Pl+1,j)) 6 E ] j 6 {I ..... m}}.

Yt

Consider

for all =

A.

32

= #j . 2 n ' [ I O g 2 k ] - n - k * 2 Therefore,

for all

j 6 J , PI+I =:

n2"[l°g2[k/2]]-[k/2]+1

j6 J

it is s u f f i c i e n t

A.

:= [ q 6 Q

to

I (q,J) 6 V}.

6 Aj c Q , 3 jl,J2 6 J exist

such

A.

:= x 1 " ' ' x j

(xj .xj2)t xj ...x m. For all I I +I"" 2 +I and all q 6 A we observe:

625 ( Pl ' x1"''xj

1

(xj1+1"''xj2)T

( q ' (xj1+1"''xj2)T Moreover,

.... x32+I

' q ) 6 d & Xm ' qk ) £ 6.

• there is a path for x31+i

.

1 . from some state in A n i=I U Qi ..x32

to PI+I in M (via (ql,xj ,Pl+1 ) £ 5). From this follows: Thus, da(M) = ~. ~ 2 GM(X):

x.31+I"" .x.32

x1"''Xjl 0 ..........

daM(Y t) ~ t.

xj2+1...x m

Jl ..........

J2 ..........

Aj I

Aj 2

m

Q1

QI+IF Pl+I

Qk~

qk |

This completes the proof of theorem I.

3. A Criterion for the Infinite Degree of Ambiguity,

Which is Decidable

in Polynomial Time Let M=(Q,Z,6,Q0,F)

(DA)

be a NFA. Consider the following criterion for M:

I H q0 6 Q0 3 p,q, 6 Q B q F 6 F & (p,v,p),(p,v,q),(q,v,q) 6 6

v

v

H u , v , w 6 E* : & (q,w,q F) 6 6

(q0,u,p) 6 6 & p ; q.

626

If M c o m p l i e s i.e.

da(M)

there

with

= ~.

(DA),

is a N F A M' c M

section (DA),

show

that

M'

too.

This

leads

only

We can

decide

to the

if M c o m p l i e s

The

graph

G3 =

(Pi,a,qi) 6 6 }. H p,q6 Q

degree

Thus,

with well-known

(on a R A M u s i n g with

(DA)

Theorem

(see

3: L e t

decidable

With

O(n6.#Z

is i n f i n i t e .

and hence

i,

2 and

3,

In this

M complies

with

of M is i n f i n i t e ,

or n o t a N F A c o m p l i e s

NFA with

I H a

cost

6

V

(DA)

we

i 6

with

Consider

the

{1,2,3}

:

as follows:

(p,p,q) can

criterion)

theorem

n states.

~

from

algorithms

M be a N F A w i t h

in time

daM(uvlw)

to l e m m a

E 3 :=

in G 3 a p a t h

the u n i f o r m

i 6~

result:

us to r e w r i t e

graph

[I]).

da(M')

of a m b i g u i t y

be a r e d u c e d

&

all

(DA).

(Q3,E 3) , w h e r e

p ~ q

for

according

(DA),

time w h e t h e r

G 3 allows

:

that

with

((PI'P2'P3)' (ql , q 2 ' q 3 )) 6 Q3 x Q3

= {

that

then,

following

with

in p o l y n o m i a l

(DA) : L e t M = ( Q , ~ , ~ , Q 0 , F ) directed

2 such

complies

2: L e t M be a NFA.

if a n d

we o b s e r v e

is i n f i n i t e ,

of type

we

Theorem

then

If da(M)

to

test

(p,q,q)

in time

whether

or n o t

exists.

O(n6-#Z

+ n 8)

M complies

2 follows:

n states

and

+ n 8) w h e t h e r

an i n p u t

or n o t

alphabet

the d e g r e e

Z.

It is

of a m b i g u i t y

of M is i n f i n i t e .

We r e m a r k (see

~14]).

degree

The

that

Proof:

Case and This

2 of

Q0={PI },

implies:

and with

the p r o o f

of type

2 such

Let and

improved

theorem

of t h e o r e m that

da(M)

to O(n6-#Z)

I the e x a c t

in p o l y n o m i a l

the e q u i v a l e n c e

the

states

pi,qi6

with

the d e f i n i t i o n

F={qk} ,

M is r e d u c e d .

are p',q' 6 Q and y C

two d i f f e r e n t

3 c a n be

(finite)

space.

2. is infinite.

Then,

(DA).

on Q be n u m b e r e d

I: T h e r e

[2]

completes

in c o r r e s p o n d e n c e

know:

in t h e o r e m

of a N F A can be c o m p u t e d

Let M=(Q,Z,6,Q0,F).

"" given

lemma

with

bound

theorem

5: L e t M be a N F A

M complies

we

With

time

of a m b i g u i t y

following

Lemma

the

paths

B p,q 6 Q

E* such

for y f r o m p'

of

:

( p ' , y l , p ) , (p',yl,q), (p,y2,q'), (q,y2,q') 6 6

QI,...,Qk

w.r.t-

(for i=I ..... k)

type

t h a t p'

to q'

3 y l , Y 2 , y 3 6 ~*

classes Qi

2. S i n c e

be

da(M)

is c o n n e c t e d

= ~,

with

in M exist. p ~ q &

&

y = ylY2

&

(q',y3,p') 6 6. D e f i n e

q',

627 v := y2Y3Yl , then: with

{p,q}×{v} × {p,q} c 6. Since M is reduced,

M complies

(DA)..

Case 2: For all i 6 {1,...,k},

all p',q' 6 Q i, and all y 6 Z* there

is at

most one path for~ y from p' to q' in M. Let X = X l . . . X m 6 L ( M ) graph GM(X)=(V,E)

and 1 6 {I,...,k-I} the set Dl(X)

(note:

of all edges

k > 2). Consider

in the

"from Q1 to QI+I"'

i.e.

Dl(X ) = { ((qi,3-I), (Pi+i,3))6 E i 3 6 {I ..... m}}. Define n := #Q. We are able to choose x 6 L ( M ) and 1 6 {I,...,k-I} so that #Dl(X) > 2 n-1. Otherwise

we would have,

V x6L(M) i.e.

da(M)

because of case 2: k-1 ~ #Dl(X) < 2 (n-l)" (k-l) , 1=I

: daM(x)