Upload
lamnhu
View
217
Download
0
Embed Size (px)
Citation preview
Deterministic simulation of a NFA with k‐symbol lookahead
SOFSEM 2007
Bala Ravikumar, California State University
(joint work with Nic Santean, University of Waterloo)
Overview
• Definitions: DFA, NFA and lookahead DFA
• Motivation: automated e‐service composition and delegation
• The NFA delegation model, examples, properties
• Characterization of existence of delegator
• Complexity of finding a delegator for unambiguous and general NFA
• An algorithm for general NFA delegation
• Conclusion, further work
DFA – Deterministic Finite Automaton
( )0
~
, , , ,
:
A Q s F
Q Q
δ
δ
= ∑
× ∑ ⎯⎯→
0s 1s
0 1
0
1
( ) ( ){ } ( )2is odd 0 1 1L A w w ∗∗= ∈Σ = +
0 1 1 0 1
NFA – Nondeterministic Finite Automaton
0s 1s
1 0 1 0 1( )( )
0, , , ,
:
M Q s F
Q P Q
δ
δ
= ∑
× ∑ →
( ) ( ) ( ) ( )0 1 1 0 00 1 0 1L A ∗ ∗ ∗= + +
12s 3s1
0
0
0,1 0,1
0
k‐symbols Lookahead DFA
0 1 0 0 1 0 1 0( )0
~
, , , ,
: k
D Q s F
Q Q
δ
δ ≤
= ∑
× ∑ ⎯⎯→
1 010 2 3
4
100
001
101
5
0010
0
3‐symbol lookahead
k‐symbols Lookahead DFA
0 1 0 0 1 0 1 0
1 010 2 3
4
100
001
101
5
0010
0
( )0
~
, , , ,
: k
D Q s F
Q Q
δ
δ ≤
= ∑
× ∑ ⎯⎯→
k‐symbols Lookahead DFA
0 1 0 0 1 0 1 0
1 010 2 3
4
100
001
101
5
0010
0
( )0
~
, , , ,
: k
D Q s F
Q Q
δ
δ ≤
= ∑
× ∑ ⎯⎯→
k‐symbols Lookahead DFA
0 1 0 0 1 0 1 0
1 010 2 3
4
100
001
101
5
0010
0
( )0
~
, , , ,
: k
D Q s F
Q Q
δ
δ ≤
= ∑
× ∑ ⎯⎯→
k‐symbols Lookahead DFA
0 1 0 0 1 0 1 0
1 010 2 3
4
100
001
101
5
0010
0
( )0
~
, , , ,
: k
D Q s F
Q Q
δ
δ ≤
= ∑
× ∑ ⎯⎯→
k‐symbols Lookahead DFA
0 1 0 0 1 0 1 0
1 010 2 3
4
100
001
101
5
0010
0
( )0
~
, , , ,
: k
D Q s F
Q Q
δ
δ ≤
= ∑
× ∑ ⎯⎯→
k‐symbols Lookahead DFA
0 1 0 0 1 0 1 0
1 010 2 3
4
100
001
101
5
0010
0
( )0
~
, , , ,
: k
D Q s F
Q Q
δ
δ ≤
= ∑
× ∑ ⎯⎯→
k‐symbols Lookahead DFA
0 1 0 0 1 0 1 0
1 010 2 3
4
100
001
101
5
0010
0
( )0
~
, , , ,
: k
D Q s F
Q Q
δ
δ ≤
= ∑
× ∑ ⎯⎯→
E‐Services Composition and Delegation
e-Service 1
e-Service j
e-Service r
...
1 2 3 task t ask tastask k ...i i ii + + +
server...Based on the "status" of every e-service, the server
dispatches the next task to e-service .
Each e-service may be modeled by an activity automaton ,and every task by a symbol from a finite alph
i
i j
i Aabet.
E‐Services Composition and Delegation
e-Service 1
e-Service j
e-Service r
...
1 2 3 task task task task ...i i i i+ + +
server...Based on the "status" of every e-service, the server
dispatches the next task to e-service .
Each e-service may be modeled by an activity automaton ,and every task by a symbol from a finite alph
i
i j
i Aabet.
Composition and Delegation Models
( ) ( ) ( ) ( )1
1 2
: represents valid sequences of atomic tasks (e.g. a web session): activity automaton for a specific e-service
; , ..., is if
com
posabl
#
e
#...#
i
r
r
AA i
A A A
L A L A L A L A⊆
(e.g. # )
This is a necessary condition to ensure that the web applicationis feasible. Question: is it sufficient?
xaayby aab xyy∈
Composition and Delegation Models
( ) ( ) ( ) ( )1
1 2
: represents valid sequences of atomic tasks (e.g. a web session): activity automaton for a specific e-service
; , ..., is if
com
# #...#
posab
le
i
r
r
AA i
A A A
L A L A L A L A⊆
(e.g. # )
This is a necessary condition to ensure that the web applicationis feasible. Question: is it sufficient?
xaayby aab xyy∈
Composition and Delegation
1 2 3 4 5
1
22
1 1
2
1
:
:
: ..
.
: rr r
q
p
p
q q q q
p p
p
p
A
p
A
A
A
′ ′′
′
′
2 1 2 3 1 21
4 1 2 5, 1 2
1 2 ( , , ,..., ) ( , , ,..., ) ( , , ,..., ) ( , ,..( , , ,..
,)
).,
.r r r
r r
q p p p q p p pq p p p q p p
q p pp
p ′ ′′
′′ ′ ′′ ′ ′
( )1 #...# rA A A∩
1 2 3 4 a a a a
Composability and Delegation
31 2 4
2 2
5
11 1 1
2
:
:
: ...
:
r rr
A q q
A p p
p
p
q q q
p
p
p
A
A
′′
′
′
′
1 1 2 2 1 2 3 1 2
4 1 2 5, 1 2
( , , ,..., ) ( , , ,.
(.., )
, , ,..., ) ( , ,. ( , , ,..., )
.., ) r
r r
r r q p p pq p p
q p p p q p p pp q p p p
′′
′′ ′ ′′ ′ ′
′
1a
1a
1a
21 3 4 a a a a
( )1 #...# rA A A∩
Composability and Delegation
2 3
1 1 1
41
2 2
1
5
2
:
:
: .
..
: r rr
A q q
A p p
p
p
q
p
pA
q
pA
q
′ ′′
′
′
2 1 2 3 1 21
4 1 2 5, 1
1
2
2( , , ,..., )
( , , ,..., )
( , , ,..., )( , , ,..., ) ( , ,..., )
r r r
r r
qq p p p q p
q p p p p qp
p pp p pp′′ ′ ′′ ′ ′
′ ′′
2a1a
1a 2a
1a2a
1 32 4 a a aa
( )1 #...# rA A A∩
Composability and Delegation
1 2
1 1 1
3 4
1
22
5
2
:
:
: ...
:
r r r
A qq q
A p p
A
A
q
p
p
p
p
q
p
′′
′
′
′
3 1 2
4 1
1 1 2 2 1 2
5, 1 22
( , , ,..., ) (( , , ,.
( , ,...,.., )
,( , , ,..., )
,
)
,..., )r r
r
r
r
q p p pq
q p p p qq p
ppp p p
p pp
′′
′′ ′′ ′ ′′
′
2a
3a
1a
1a 2a
3a
1a2a 3a
3a
31 2 4 aa a a
( )1 #...# rA A A∩
Nondeterministic Delegator
1 2 4 5
1
2 2
3
1 1 1
2
:
:
: ...
:
r r r
A q q
p
A p p
q q q
A p
p
p
A p
′ ′′
′
′
1 1 2 2 1
4 1 2 5, 1 2
2 3 1 2( , , ,..., ) ( , , ,..., ) ( , , ,..., ) ( , , ,..., ) ( , ,..., )
r r
r
r
rqq p p p q p p p
p p p q pq
pp p p
p′′ ′ ′′ ′ ′
′ ′′
2a
3a
4a
1a
1a 2a
3a 4a
1a2a 3a 4a
3a
1 2 3 4 a a aa
( )1 #...# rA A A∩
k‐Lookahead Delegation Model
( ) ( )
( )
0
~0
1
a
, , , , : the composite NFA #...#
How can we use M determi
delegator for is an equivalent -symbol lookaheadDFA , , , , , with : verify
nistically ?
k
r
k M
Q s F
kQ s
A
F Q
M A
Q
A
δ δ
δ
≤
= ∩
−
′ ′∑ ×Σ ⎯⎯
∑
→
( ) ( ) ( )1 1 1
ing:
, ... : , ... , , ki iq a a Q q a a q a i kδ δ≤ ′∀ ∈ ×Σ ∈ ≤
k‐Lookahead Delegation Model
( ) ( )
( )
10
0~
, , , , : the composite NFA #...#
How can we use M deterministically ?
a for is an equivalent -symbol lookaheadDFA , , , ,
delegato, with : ve i
rr fy
r
k
Q s F
kQ s F
M A A A
M kQ Q
δ
δ δ ≤
= ∩
′ ′ ×Σ ⎯
∑
−
⎯→∑
( ) ( ) ( )1 1 1
ing:
, ... : , ... , , ki iq a a Q q a a q a i kδ δ≤ ′∀ ∈ ×Σ ∈ ≤
k‐Lookahead Delegation Model
q
1q
1a ...
1a
jq
tq
...
1a
( ) ( ) ( )1 1 1, ... : , ... ,ki iq a a Q q a a q aδ δ≤ ′∀ ∈ ×Σ ∈
Interpretation:
q
1q
1a
1a
( )1, ...j iq q a aδ ′=
tq
1 2... ia a a
an NFA a delegator fo r k MM −
( )1,q aδ
⎫⎪⎪⎪⎪⎪⎬⎪⎪⎪⎪⎪⎭
Example: an unambiguous NFA
1
2
4 5
3
a
b
a
a
a
a
( ) ( )( )a b ab aa∗ ∗+
Example: a 2‐delegator
1
2
4 5
3
a
b
a
a
aa
aba
a
b
a
,b
,a,a
( ) ( )( )a b ab aa∗ ∗+
This unambiguous NFA has a 2‐delegator.
Example: an unambiguous NFA
1
2
4 5
3
a
a
a
a
a
a
( )a+
this unambigous NFA has no -delegator, .0k k∀ >
Example: no delegators
1
2
4 5
3
a
a
a
a
a
a
( )a+
This unambigous NFA has no -delegator, .0k k∀ >
Example: an ambiguous NFA
...0 1kp −2p
1p
1kq −2q ...
kp
kq
0 0
0 0 0
0
1( )10 0 1k− ∗ ∗+
Example: a k‐delegator, no (<k)‐delegator
...10 ,0k k− 1kp −2p
1p
1kq −2q ...
kp
kq
1 20 ,0 ,0k k k− −
10 1k−2 2 20 1,0 1k k− −
10 ,0 ,...,0k k−
11 ,1 ,...,1k k−
( )10 0 1k− ∗ ∗+
...
...
( )
( )
This NFA has a -delegator but no 1 - deleg
Note: -delegation
ators.
1 -delegationk k
k k
⇒ +
−
Example: an ambiguous NFA
0s 1s12s 3s1
0
0
0,1 0,1
( ) ( ) ( )0 1 1 0 00 1 0 1∗ ∗ ∗+ +
Example: no delegators
0s 1s12s 3s1
0
0
0,1 0,1
( ) ( ) ( )0 1 1 0 00 1 0 1∗ ∗ ∗+ +
-1 k-1 1idea: ta
This NFA has n
ke 10 0
o -delegator, for any
1 and
0
10 0 101
.
k k k
k k
+
>
Why Study NFA Delegation
• E‐Service Composition – given some specifications and a set of e‐services, implement an application which follows the specifications.
• Deterministic simulation of NFA: alternative to classical subset construction to simulate an NFA by a DFA. Linear blow‐up vs. exponential blow‐up.
• A theoretical metric for nondeterminism: if an NFA M has a 3‐delegator and M’ does not have a k‐delegator for, say k < 10, then M’ is “more nondeterministic” than M.
Language vs. Machine Property
Is delegation a language property or a machine
1'st Question:
(there exist infinitely many NFA for a given regular l
prope
angu
rty?
age)
Delegation as a Language Property
( )( )( )
( )( )( )
for 0
0 for
- regular language
1. is if has a d
weakly delegable
strongly delegab
elegator
1. is if has a delegato
ler
NFA L k
k NFA L
L
LM k M k
Lk M M k
>
>
∀ ∃ −
∃ ∀ −
Delegation as a Language Property
.
is strongly deleg. is weakly deleg. is finite
It is more interesting to see delegabilit
.
y a
Theorem
L L L
Consequence
⇐ ⇒⇔ ⇔
s a machine property.
Complexity of Finding a k‐Delegator
( )
( )
1
2
Problems:
P is an integer not part of the input. : an NFA : if has a , otherwise P : an NFA and an integer
delega
tor
kinput Moutput YES M NO
input M
k
k
−
( )3
: if has a , otherwise P : an NFA : if has a , otherwis
delegator
delegator e
output YES M NO
input Moutput YES M NO
k −
State Blindness
q
p
1a
...
1a
p′ 2... ka a v
2... ka a v
( ) ( )( ) ( )
1 2
1 1
2 2
1 2 1 2
is ... -blind if
, , , :
, ... , , ...
a state is -blind if there exists ... such that it is ... -blind
k
k k
k k
q a a a
p q a p q a v
p a a v F p a a v F
k a a a a a a
δ δ
δ δ
∗′∀ ∈ ∃ ∈ ∈ ∑
′∉ ∈
[ ]1 2... ka a a
State Blindness
q
p
1a
...
1a
p′ 2... ka a v
2... ka a v
( ) ( )( ) ( )
1 2
1 1
2 2
1 2 1 2
is if
, , , :
, ... , , ...
a state is -blind if there exists ... suc
... -blin
h that it is ... -blin
d
d
k
k
k
k k
q
p q a p q a v
p a a v F p a a v F
k a a a a a a
a a a
δ δ
δ φ δ φ
∗′∀ ∈ ∃ ∈ ∈ ∑
′∩ = ∩ ≠
[ ]1 2... ka a a
State‐blindness is computable
Recall that a string w is q‐blind if it is not possible in state q to find a deterministic choice given w as the look‐ahead.
Define Bq = { w | w is q‐blind }
Theorem: Let M be a DFA with n states, and over an alphabet of size m, and let q be a state of M. The language Bqis regular, and there is a DFA with at most (4n + 1)m that accepts Bq.
A Characterization for Unambiguous NFA
.
An unambiguous NFA has a -delegator iff none ofits states are -blind.
Consequently, an unambiguous NFA has a delegatoriff all its states have finite blindness.
Theorem
kk
Problem 1 for unambiguous NFA’s
Theorem: Let k be a fixed integer. There is a polynomial time algorithm that given an unambiguous NFA M determines if M has a k‐delegator.
Proof (sketch) The problem can be reduced to the problem of containment problem for unambiguous NFA’s.
From a result of Hunt and Stearns, this problem is known to be solvable in polynomial time.
Delegation for Unambiguous NFA
( ) ( ) ( )1 2 3
( ).
unambiguous NFA P co-NP PSPACE
Theorem s
P P P
The proof of co‐NP and PSPACE upper‐bounds for P2 and P3 are similar to that of Problem 1.
Arbitrary NFA
All 3 problems are significantly harder for general NFA:
- a delegator for a (trim) unambiguous NFA must use all its states: local properties (blindness) have a global impact;
- containment and equivalence problems are decidable in polynomial time for unamb. NFA.
Arbitrary NFA: Forbidden Words
( )
1 2
1 2
1
is ... -forbidden if one of the following two conditionsis satisfied recursively (intuitive def.) :
1. is ... -blind; 2. for every state , there exists such
k
k
p
q a a a
q a a ap q a bδ∈ ∈ ∑
2 that is ... -forbidden.k pp a a b
q
p
1a
...
1a
r 2... k ra a b
2... k pa a b[ ]1 2... ka a a
Arbitrary NFA: Forbidden Words
( )
1
1 2
1
2
(intuitive def.) is if one of the following two conditions
is satisfied recursively :
... -forbidden
blind 1. is ... - ;
2. for every state , there exists such
k
p
kq
q a a ap q
a
a b
a a
δ∈ ∈ ∑
2 that is . fo.. - .rbiddenk pp a a b
q
p
1a
...
1a
r 2... k ra a b
2... k pa a b[ ]1 2... ka a a
Arbitrary NFA: Delegation Characterization
( )( )
0
0
0
Notation: is the set of all forbidden words for .
.
An NFA , , , , has a -delegator iff
.
Consequently, an NFA has a delegator iff is finite.
q
q k M
q
F q
Theorem
M Q q F k
F pref L
F
δ
φ
= Σ
∩ =
Delegation for Unambiguous NFA
( ) ( ) ( )1 2 3
( ).
general NFA PSPACE-complete PSPACE-hard ?
Theorem s
P P P
Wrap‐up
• NFA delegation is a finite‐state model used in web service applications, task scheduling, NFA simulation, measure of nondeterminism, etc.
• NFA delegation is a machine property and its computational complexity is machine dependent:
( ) ( ) ( )1 2 3
unambiguous P co-NP PSPACE
general PSPACE-c
P P P
1(previous work: for
omplete PSPACE-h
1, in the ge
ard
neral case : EXPTIME
)
?
k P=
Direction for future workMain open problem:
• Investigate complexity matters for other families of NFA. For example, study NFA that are a shuffle product of DFA.
• Is delegation decidable for arbitrary NFA? Study the nature of .
Other Questions:
• The complexity result for Problem 1 (general case) was proven for a 4‐letter alphabet. Can the PSPACE‐completeness proof be extended to smaller alphabets?
• Is problem 2 complete for co‐NP for unambiguous NFA? Is problem 3 complete for PSPACE for unambiguous NFA?
0qF
References
Service‐oriented computing:
‐ R. Hull and J. Su. Tools for Design of Composite Web Services. In SIGMOD 2004, pp. 958‐961 (2004)
‐ M. Mecella and G. D. Giacomo. Service Composition: Technologies, Methods and Tools for Synthesis and Orchestration of Composite Services and Processes. Tutorial in ICSOC 2004.
‐ D. Berardi, D. Calvanese, G. D. Giacomo, M. Lenzerini, and M. Mecella. Automatic Composition of e‐Services that Export their Behaviour. In ICSOC 2003, LNCS 2910, pp. 43‐58, 2003.
Finite state models for e‐services:
‐ C. E. Gerede, O. H. Ibarra, B. Ravikumar, and J. Su. On‐line and Ad‐hoc Minimum Cost Delegation in e‐Service Composition. In IEEE SCC, pp. 103‐112, 2005.
‐ Z. Dang, O. H. Ibarra, and J. Su. Composability of Infinite‐State Activity Automata. In ISAAC 2004, LNCS 3341, pp. 377‐388.
‐ C. E. Gerede, R. Hull, O. H. Ibarra, and J. Su. Automated Composition of e‐Services: Lookaheads. In ISOC 2004, pp. 252‐262.
Design Methodology ‐ Example
d
d d
p
P
1: downloads and processes files sequentiallyeS 2: downloads 2 files at a time
and processes them in paralleleS
S - application specification:download and process, havingno more than 2 files in the systemat any time
d d
P
p p
2 2
2
1 1
1
3
3
Design Methodology – Step 1
1 2construct :eS eS#
[ ]1,1
[ ]2,1
[ ]1,2
d
d
p
[ ]2,2
[ ]1,3
d
d
[ ]2,3
p
d
dp
P
P
1 2it represents the shuffle behavior of and eS eS
Design Methodology – Step 2
1 2construct :S eS eS∩ #
[ ]1,1,1
[ ]2,2,1
[ ]2,1,2
2d
1d1p
[ ]3,2,2
[ ]3,1,3
2d
1d
1p
2P
it represents the nondeterministic behavior of the application ( )S
Design Methodology – Step 3
find a delegator :
2d d
1d p
1 1,p d p
2d P
1d p
1p d
2 2,P P d
it represents the design of S
d d p d P d p
1eS
2eS