Hierarhial Message Sequene Charts
BlaiseGenest andAnaMusholl
LIAFA,UniversitéParis VII2,pl.Jussieu,ase7014 F-75251Paris edex05e-mail:
{genest,musholl}liafa.jussieu.fr
Abstrat. Several formalisms and tools for software development use
hierarhy for system design, for instane stateharts and diagrams in
UML.Messagesequeneharts(MSCs) areastandardizednotationfor
asynhronouslyommuniatingproesses.ThenormZ.120inludesalso
hierarhialHMSCsinformofHigh-levelMSCs(HMSC).Algorithmson
MSCsrarelytakeinto aountall possibilities overedby thenorm. In
partiular,hierarhyis not takeninto aount sine the modelusually
onsidered are MSC-graphs that orrespond to the unfolding of (hier-
arhial) HMSCs. However, omplexity an inrease exponentially by
unfolding.Theaimofthispaperistoshowthatbasialgorithmsanbe
designedsuhthattheyavoidtheostlyunfoldingofhierarhialMSCs
and HMSCs. We onsider the membership and the pattern mathing
problemtoillustratethewaytoproeed.Weshowthatthemembership
problem for hierarhial HMSCs is PSPACE-omplete.Seond,we de-
sribeapolynomial-timealgorithmforthepattern-mathingproblemon
hierarhialMSCs.
1 Introdution
It isommonto usemaros towrite aprogramortospeifythe behaviorofa
system.Marosorhierarhialspeiationsallowamodulardesignofomplex
systemsandhavetheadvantageofbeingmoresuintanduser-friendly.Several
formalismsandtoolsforsoftwaredevelopmentusehierarhyforsystemdesign.
Oneofthemostprominentexamplesistheformalismofstateharts[11℄,whihis
aomponentofseveralobjet-orientednotations,suhastheUniedModeling
Language (UML). Besides stateharts, UML widely uses several kinds of dia-
grams(ativity,interationdiagramset),allbasedontheITUstandardZ.120
of message sequene harts (MSCs). Whilestateharts extendnite state ma-
hinesbyhierarhyandommuniationmehanisms,MSCsareavisualnotation
forasynhronouslyommuniatingproesses.TheusualappliationofMSCsin
teleommuniationisforapturingrequirementsofommuniationprotoolsin
formofsenariosinearlydesignstages.MSCsusuallyrepresentinompletespe-
iations, obtainedfrom apreliminary viewofthe systemthat abstrats away
severaldetailssuhasvariablesormessageontents.High-levelMSCs(HMSCs)
ombinebasiMSCsusinghoieanditeration,thusdesribingpossiblyinnite
olletions of senarios. For abstrat speiations aswith HMSCs, hierarhy
whihanbeveryabstrat,adesigner should be ableto merge dierentspei-
ation asesyielding thesameabstrat senarioandto use thissenarioasa
maro.Byusing marosdesignersmayidentify subsenarioswhihhaveto be
renedatalaterstage.
Algorithms on MSCs rarely take into aount the whole spetrum of the
HMSC standard denition. In partiular, hierarhy is not taken into aount
sinethemodelsusuallyonsideredareMSC-graphs,thatorrespondtotheun-
foldingof(hierarhial)HMSCs.However,omplexityaninreaseexponentially
by unfolding. Theaim of this paper is to show that this exponential blow-up
is avoidablein many ases,by avoiding theexpensive unfoldingand using the
hierarhyforomputingthedesiredresultsinamodularway.Weusetehniques
stemmingfromombinatorisonompressedtexts,sinehierarhialMSCde-
nitionsanbeseenasakindofompressionbymeansofStraight-LinePrograms
(SLP).
In this paper we onsider two fundamental problems for hierarhial HM-
SCs,that arealledherenestedhigh-level MSCs(nHMSCsforshort): member-
shipproblemandpatternmathing.However,wethinkthetehniquesdesribed
herean beused to solveotheralgorithmiproblems onnHMSCs aswell.The
membershipproblemisabasiquestion,askingforinstanewhetheranegative
senarioours inasystemspeiation,oraskingwhether apositive senario
isredundant,sinealreadyoveredbythespeiation.Withouthierarhy,the
membership problem for HMSCshas been shown to be NP-omplete,[1℄. The
reasonfor this omplexity blow-up (ompared to nite-state mahines) is that
MSCsarepartial-ordermodels.We showthathierarhyyieldsasmallinrease
in omplexity, preiselyweshowthat the membership problem fornHMSCs is
PSPACE-omplete. Surprisingly, hierarhyalone is the soure of theomplex-
ity.Weshownamelythat themembershipproblemforhierarhialautomatais
alreadyPSPACE-omplete.Thisresultshowsadierenebetweenmembership
and reahability,sinereahabilityforommuniatinghierarhialautomata is
alreadyEXPSPACE-omplete[12℄.
TheseondproblemonsideredinthispaperispatternmathingfornMSCs.
GiventwonMSCs
M, N
,wewanttoknowwhetherM
oursasapatternofN
.Apolynomialtimesolutionforthisproblemisnotimmediate.Weapplysomenie
ombinatorialtehniquesstemmingfrompatternmathingonompressedtexts
andweobtainanalgorithmoftime
O(|C M | 2 · |M | 2 · |N | 2 )
,where|M |, |N|
denotethesizes of thedesriptionof
M
andN
, and|C M |
is the numberof onnetedomponentsintheommuniationgraphof
M
.ThisquestionsubsumesthetestofequalityoftwonMSC,andshowsthatequalityisdeidableinPTIMEaswell.
Related work. Regarding the omplexity of extended nite state mahines,
[12℄ onsidersthereahabilityandtraeequivaleneproblemsfor ommuniat-
ing FSMs(Finite States Mahines). Model-hekinghierarhialFSMsagainst
LTL and CTL properties is the topi of [4℄. The paper [3℄ ombines hierar-
hyandonurreny,analyzingtheomplexityofseveralproblems(reahability,
equivaleneet.)forommuniating,hierarhialFSMs.
reently,e.g. deteting raes[2,18℄, model-heking[5℄, pattern mathing with
gaps[19℄,inferene[1℄andrealizability[17,9,14℄,model-hekingagainstpartial-
order logis[16,21℄.HierarhialMSCshavebeenalso onsideredin [5℄forthe
model-hekingproblem.WenotehoweverthatourdenitionofnestedHMSCs
apturesalargerlassofMSCspeiationsthan[5℄.
An extendedabstrat of this paper waspresentedat LATIN'02 [8℄.As ad-
ditional resultweshowherehowto extend thepolynomialtime algorithm for
patternmathingnMSCsto theasewherethepatternisnotonneted.
2 Syntax and Semantis of Nested MSCs
Weadoptthedenition of(basi)messagesequeneharts (MSCforshort), as
desribedin theITU-standard[13℄.
Denition1. (Message Sequene Charts.) A messagesequene hart isa
tuple
M = hP, E, C, ℓ, m, <i
where:
P
isaniteset ofproesses,
E
isaniteset ofevents,
C
isanitesetof names formessages andloal ations,
ℓ : E → T = {i!j(a), i?j(a), i(a) | i 6= j ∈ P, a ∈ C}
labels eah event withits type: on proess
i ∈ P
,the type iseither a sendi!j(a)
of messagea
toproess
j
,or a reeivei?j(a)
of messagea
from proessj
,or a loal eventi(a)
. The labelingℓ
partitions the set of events by type (send, reeive, orloal),
E = S S · R S ·
L
,andbyproess,E = S ·
i∈P E i
.Wedenote byP (e)
theproessof event
e
(i.e.,P (e) = i
ie ∈ E i
).
m : S → R
isabijetion mathingeahsendtotheorresponding reeive.Ifm(s) = r
, thenℓ(s) = i!j(a)
andℓ(r) = j?i(a)
for some proessesi, j ∈ P
andsomemessagename
a ∈ C
.Wedenotetheeventss, r
asmathingeventsandthepair
(s, r)
asmessage.
< ⊆ E × E
isanaylirelationbetween eventsonsistingof:•
atotalorder onE i
,for everyproessi ∈ P
,and• s < r
,wheneverm(s) = r
.Theupperleft partofFigure 1depitsanMSC Monthree proesseswith
twomessagesandfourevents.Eahvertialline orrespondstoaproess,with
timeinreasingfromtoptobottom.
Forthequestionsonsideredhere,messagenamesareirrelevant.Thus,send
eventswillbeoftype
i!j
andreeiveeventsoftypei?j
.Moreover,wheneverwereferto anMSC in this paper, we meanatually its isomorphismlass, where
anisomorphismonthesetofevents
E
isabijetionthatisompatible withthetypefuntion
ℓ
and themessagefuntionm
.For ommuniationprotoolsit isnaturalto assumethateahommunia-
tion hannel delivers messages rst-in-rst-out (FIFO). We assume the FIFO
onditionthroughoutthepaper.Thatis,forallmessages
(e k , f k )
,k = 1, 2
,suhthat
ℓ(e 1 ) = ℓ(e 2 )
andℓ(f 1 ) = ℓ(f 2 )
we requirethate 1 < e 2
if 1 < f 2
. Thereexive-transitivelosure
≤
of the aylirelation<
is apartial orderalledvisual order.Everytotalorder on
E
extending≤
isthenalled linearizationofM
. A onguration (prex)C
of an MSCM
is a downward losed subset ofevents,thatis,if
e < f ∈ E
withf ∈ C
,thene ∈ C
.Notethat with the FIFOmessageorder,anytotalorder on aset of events
E
denes at mostoneMSC. We obtainthis MSCfrom theeventsequene bymathing the
n
-th sendfromi
toj
with then
-th reeiveonj
fromi
, foreahpairofdistintproesses
i, j
.Aspeialaseofthepatternmathingproblemonsideredinthepaperisthe
equalitytestoftwo(nested)MSCs.Inorderto hektheequalityoftwoMSCs
M, N
(i.e.,uptoisomorphism)oneanhooseanylinearizationofM
andhekwhether it is a linearization of
N
, too. An alternative approah, that will be used inouralgorithms,is tohekequalityoneahproess.Thus,foranMSCM = hP, E, C, ℓ, m, <i
and a proessi ∈ P
we letM | i
denote the projetionof
M
on the setE i
of events loated oni
. We haveM = N
if and only ifM
andN
have thesame set of proesses,that isP(M ) = P(N ) = P
, and iftheirprojetiononanyproessisequal,thatis
M | i = N | i
foreahi ∈ P
(uptoisomorphism).NotethatbothtestsrelyontheFIFOorderofmessages.Without
theFIFOorder,alinearization(ortheprojetionsonproesses)doesnotsue
forreoveringtheMSC.Forexample,thelinearization
s 1 s 2 r 1 r 2
wheres 1 , s 2
aresendsand
r 1 r 2
arereeivesfrom proess1toproess2,anproduetwoMSCs,onewhere
m(s 1 ) = r 1 , m(s 2 ) = r 2
andonewherem(s 1 ) = r 2 , m(s 2 ) = r 1
.Wefollowthe ITU norm and dene nestedMSCs (nMSC for short) by al-
lowing the reuse of an already dened MSC in adenition. Thedenition we
givebelowaimsatpreservingthevisualharaterofMSCs(seealsoFigure1).
Denition2. (Nested MSC, nMSC.) A nested MSC
M = (M q ) n q=1
is anite sequene ofmarosof the form
M q = hP q , E q , B q , ϕ q , C, ℓ q , m q , < q i
.Eahmaro
M q
onsistsof:Anite set
E q
ofevents.Anite set
P q
of proesses.Anite set
B q
of referenes (boxes)usedbyM q
.A funtion
ϕ q
that assoiates eah refereneb ∈ B q
with an indexq <
ϕ q (b) ≤ n
. Thus, refereneb
refers to the maroM ϕ q (b)
.We require thatP ϕ q (b) ⊆ P q
.The type funtion
ℓ q : E q −→ T
, that assoiates eah event with a typei!j, i?j
ori(a)
, withi, j ∈ P q
,i 6= j
anda ∈ C
. The labelingℓ
partitionsthe set of events by type (send, reeive, or loal),
E q = S q S ·
R q S ·
L q
, andbyproess,
E q = S ·
i∈P E q,i
.Wedenote byP (e)
the proess ofevente
(i.e.,P(e) = i
ie ∈ E q,i
).The messagefuntion
m q : S q −→ R q
that maps eah (send) event of typei!j
with a(reeive)event oftypej?i
,foralli 6= j
.Theaylirelation
< q
overthesetofeventsandreferenesE q ∪ B q
,denedby:
•
Foreahproessk ∈ P q
,therelation< q
isatotalorderoverthesetE q,k
of eventsloated on
k
andthe setof referenesb ∈ B q
withk ∈ P ϕ q (b)
.• e < q f
wheneverm q (e) = f
inM q
.The nesting depth of
M
isthe maximald
suh that thereexists somesequeneq 1 < · · · < q d+1
withϕ q j (b) = q j+1
for someb ∈ B q j
,for all1 ≤ j ≤ d
.We dene the indies suhthat the lowest levels of hierarhy, whih stands
forlevelswhihdonotusereferenestootherlevel,orrespondstosmallindies.
M S
S
S M S
S M
S
P
M M h
h g
g g
b 5
b 2
b 3 b 1
b 4 1 2 3
1 2 3 1 2 3
1 2 3
k
k
k
e
f
Fig.1.AnnMSC
P
usingtworeferenes,S
andM
.Example 1. Consider thenMSC
P
in Figure 1.It uses three referenes,B P = {b 1 , b 2 , b 3 }
that orrespond toϕ P (b 1 ) = ϕ P (b 3 ) = S
andϕ P (b 2 ) = M
. Thenesting depth of
P
is 2. The visual order< P
ofP
requires on proess 1 theorder
b 1 < P e < P b 2 < P b 3
.Notiethat thedenition ofanMSC forbids(f, e)
to beamessage,with
f
thesendande
thereeive,sinethiswouldontradittheayliityof
< P
, evenintheasewhereM
wouldbeempty.Thesemantisof annMSC is theMSC dened byreplaing eah referene
of
M
bytheorrespondingMSC.Indutivelyitsuesto denethesemantis of nMSCs of nesting depth one. LetM = (M q ) n q=1
be an nMSC of nestingdepthone,with
M q = hP q , E q , B q , ϕ q , C, ℓ q , m q , < q i
.Forsimplifyingthenotation below,wewriteinsteadofϕ 1 (b)
justb
.The MSC
hP, E, C, ℓ, m, <i
dened byM = (M q ) n q=1
is given byP = P 1
,E = S ·
b∈B 1 E b S ·
E 1
,ℓ = ∪ n q=1 ℓ q
andm = ∪ n q=1 m q
.Thevisualorder<
isdenedby
e < f
ifandonlyifeitherm(e) = f
,orP (e) = P (f )
andoneofthefollowingonditionsholds:
e, f ∈ E 1
ande < 1 f
,
e, f ∈ E b
ande < b f
,
e ∈ E 1 , f ∈ E b
ande < 1 b
,
e ∈ E b , f ∈ E 1
andb < 1 f
,
e ∈ E b , f ∈ E b ′
andb < 1 b ′
,where
b, b ′ ∈ B 1
.Forsimpliity, wedenote the MSCdened byM = (M q ) n q=1
as
M
,too.Example 2. For the nMSC
P
in Figure 1, the lower right part of the pitureshowstheMSCdened by
S
.Note that eventg ∈ E M
ourstwieinS
forsimpliity,wedenotebothourrenesas
g
.Notealso that thesemantis requires that
b 1 < 1 e
, but this doesnotmeanthat all events of
S = ϕ P (b 1 )
must happen beforee ∈ E P
. Forinstane, therst ourrene of
g
inS
preedes evente
ofP
, but the seond ourrene isonurrentwith
e
.Obviously,asyntatiallyorretnMSC
M
mightnotyieldanMSCbeauseoftheFIFOorder.Forexample,themessage
(e, f )
ofP
wouldviolatetheFIFOonditionif
M
wouldontainamessagefromproess1toproess3.Fortunately, itanbeveriedeasily(polynomialtime)whether annMSCsatisestheFIFOondition. To test for the FIFO ondition, it sues to test that there is no
e < g < h < f
and noe < b < f
withb
ontainingasend fromi
toj
, where(e, f ), (g, h)
aretwomessagesfromi
toj
.Size of nMSC. For omplexity estimations we will denote by
℘
the overallnumberof proesses.The size ofan nMSC
M
is denoted as|M |
. It representsthe size of thesyntatial desription of
M
, where anevent is ofsize oneandthesizeofarefereneisthenumberofitsproesses.
3 Nested High-Level MSC
AnMSCanonlydesribeanitesenario.Forspeifyingmoreomplexbehav-
iors,in partiularinnitesetsof senarios,the ITUnorm proposesto ompose
MSCsinform ofMSC-graphs,byusing hoieanditeration.
Denition3. (MSC-graph)AnMSC-graphisgivenasatuple
G = hV, E, s, f, ϕi
,where:
(V, E)
isadiretedgraph withstartingvertexs ∈ V
andnalvertexf ∈ V
.Eahvertex
v
is labeledbythe MSCϕ(v)
.eralizeMSC-graphstohierarhial HMSCs(ornestedhigh-levelMSCs,nHMSC
forshort).
Denition4. (Nested high-level MSC.) An nHMSC is a nite sequene
G = (G q ) n q=1
, where eahG q
is either a labeled graph or an nMSC. A labeledgraph
G q
isatuplehV q , E q , ϕ q , s q , f q i
onsistingof:Adiretedgraph
(V q , E q )
withstarting vertexs q
andnalvertexf q
.Afuntion
ϕ q
thatassoiateseahvertexv
witharefereneq < ϕ q (v) ≤ n
,representing
G ϕ q (v)
.Thus, a node in an nHMSC anbemapped either to some graphorto an
nMSC.Thisdenitionombineshierarhialautomataasdenedin[4℄withour
denition of nMSC. The speial ase where there is only one proess (i.e., no
onurreny)yields thehierarhialautomata usedin[4℄
1
.
We rst need to dene the omposition of two MSCs
N 1 N 2
withN k = hP k , E k , C k , ℓ k , m k , < k i
.Intuitively,wejustgluetogetherthetwodiagramsproess- wise.LetN 1 N 2 = hP, E, C, ℓ, m, <i
withE = E 1 S ·
E 2
,P = P 1 ∪P 2
,C = C 1 ∪ C 2
,ℓ = ℓ 1 ∪ ℓ 2
,m = m 1 ∪ m 2
and< = < 1 ∪ < 2 ∪ [
i∈P
E 1,i × E 2,i .
ThesemantisofannHMSC
G = (G q ) n q=1
isa(possiblyinnite)setofMSCsL(G)
denedreursively.IfG q
isannMSC,thenL(G q )
isasingletononsistingof theMSCdened by
G q
. Letus onsider alabeledgraphG q
. ThenL(G q )
isthesetofMSCsassoiatedwiththeaeptingpathsof
G q
,thatis,pathsstartingin
s q
andendinginf q
.With apathv 1 , . . . , v n
inG q
weassoiatetheset ofallMSCs
M 1 · · · M n
,whereM i ∈ L(G ϕ q (v i ) )
forall1 ≤ i ≤ n
.Thesetofexeutionsof
G
isdenedasL(G) = L(G 1 )
.Asin[1℄wealsoonsideraweakersemantisfornHMSCs,thatdoesnotuse
the omposition of MSCs (alled weak losure in [1℄). This semantisis based
on taking the produt of the sequential behaviors of single proesses. Several
algorithmiproblemsanbesolvedmoreeientlyfortheweaklosureofMSC-
graphs.Thismakesitinterestingtoompareitwiththeusualsemantisalsoin
thesettingofnHMSCs.
WeaklosureofnHMSC.Let
G
beannHMSC.ThenL w (G)
denotesthesetofMSCs
M
suhthatforeahproessi
thereissomeMSCN ∈ L(G)
suhthatM | i
isequaltoN | i
.NotethatL(G) ⊆ L w (G)
andthattheinlusionisstrit,ingeneral(see[1℄).
1
Atually, [4℄ allows several nal nodes in eah automaton, whih ounts for the
omplexityoftheiralgorithms.
a b G i
G i
Fig.2.AnnHMSC
G i+1
generating(a + b) 2 i − 1
withG 1 = ǫ
.4 Membership Problem
ChekingthemembershipofanMSC
M
inanMSC-graphG
isusedtypiallyforhekingthatnobadsenarioanourinagivenspeiation.Anotherapplia-
tionishekingwhetheragoodsenarioisalreadyoveredbythespeiation.
Cheking membership is notan easy task already beause of the onurreny
impliedbytheMSComposition,allthemorein thepreseneofhierarhy.The
MSC membership problem
M ∈ ? L(G)
withM
anMSC andG
an MSC-graphwasonsideredin[1℄,togetherwiththeweakmembershipproblem
M ∈ ? L w (G)
.Theresultsof[1℄anbesummarizedasfollows:
TheMSCmembership problem isNP-omplete. Adeterministi algorithm
oftime
O(|G| · |M | ℘ )
solvesit2,where℘
isthenumberofproesses.Theweak MSCmembershipproblemissolvablein time
O(|G| · |M |)
.SotheMSCmembershipproblemissolvableinpolynomialtimeifwexthe
numberofproesses.
4.1 Hierarhial MembershipProblem
Themembershipproblemseemsapriori morediultforannMSC
M
againstan nHMSC
G
, sinethe naive approah of guessing apath ofG
and hekingequality with
M
is too expensive (both the path ofG
and the MSC denedby
M
anbeofexponentialsize).However,itis easyto showthat weantest membershipinpolynomialspae:Theorem1(Hierarhial MSC MembershipProblem) Given an nMSC
M
andannHMSCG
,wean deide whetherM ∈ ? L(G)
inpolynomialspae.2
Thisisaslightlyimprovedruntimeomparedtotheresultstatedin[1℄.
L(G)
andwemathitagainstthenMSCM
,howeverexpandingneitherM
norG
.Reall thatfor testingequalityoftwoMSCsM, N
,itsuesto hooseonelinearizationof
N
and hekwhether it isalinearizationofM
. Hene,weanhoose the linearization of the MSC in
G
(as long as we do not exlude anyMSC in
L(G)
, that is as longas we do notexlude every linearizationof one MSC).WeonsideronlythelinearizationsinLin 0 (G)
,whereLin 0 (G)
isdenedreursively.If
G q
is annMSC, thenLin 0 (G q )
is theset oflinearization ofG q
.With apath
v 1 , . . . , v n
inG q
weassoiatethesetof alllinearizationsu 1 · · · u n
,where
u i ∈ Lin 0 (G ϕ q (v i ) )
forall1 ≤ i ≤ n
.Letus onsideralabeledgraphG q
.Then
Lin 0 (G q )
isthesetoflinearizationsassoiatedwiththeaeptingpathsofG q
,thatis,pathsstartingins q
andendinginf q
.WedeneLin 0 (G) = Lin 0 (G 1 )
.Intuitively,itmeansthatwedonotonsiderlinearizations
uavbw
ofpathv 1 · · · v n
where
a
belongstoanodev i
andb
tov j
withj < i
,thatiseverynodeneedstobefully exeutedbeforethenextnodeanbeonsidered.
Weneedto storeaongurationof
M
,orrespondingto theeventsalready mathedwiththeeventsfromG
.Sineaongurationisadownwardlosedsetofevents,itanbestoredasatupleof
℘
events(remindthat℘
isthenumberofproesses),representingthelasteventoftheongurationoneahproess.Suh
atupleisoflinearsizew.r.t.thesizeof
M
.Eahevente
ofM = (M q ) n q=1
willberepresentedbyasequene
b 1 , . . . , b m
ofreferenesorrespondingtotheunfolding ofreferenesyieldinge
.Thatis,weindutivelyremindb m
fore ∈ E ϕ(b m )
whereb m
isarefereneofϕ(b m−1 )
,plustheposition ofe
inM ϕ(b m )
.Thus,eaheventanbestoredusinglinear-sizememory.Inourgure1,therstourreneof
g
in
P
orrespondsto(b 1 , b 4 , g)
,theseondourreneto(b 1 , b 5 , g)
,andsoon.Similarly,weanstoretheurrentongurationofthelinearizationin
Lin 0 (G)
inspaepolynomialin
|G|
(aneventofG
isrepresentedbyasequeneofnodes thenofreferenes).Sineanewnodeisstartedonlywhenthepreviousnodeisfully exeuted, thelast eventfor everyproess belongsto thesamenode. The
non-deterministialgorithmonsistsin guessingasuessorongurationof
G
,obtainedbyextendingtheurrentongurationbyanevent
e
suhthatthenewonguration is still aprex of somelinearizationin
Lin 0 (G)
. Then we hekthat
e
an extendthe urrent linearizationofM
as well. Thealgorithm stopswhentheongurationthatorrespondstothepathbeingguessedin
G
isequalto
M
andthepathofG
isaepting.2
Theorem2belowshowsthatPSPACEisthelowestomplexityweanobtain
forthehierarhialmembershipproblem.Thelowerboundholdsevenifthereis
onlyoneproess(Theorem2),orifthegraph
G
isnothierarhial(Theorem3),but notboth(Theorem4).Thisshowsalsothat xingthenumberofproesses
doesnotlowertheomplexityoftheproblem,unlikeinthenonhierarhialase.
WeshowthePSPACElowerboundforthefollowingproblem:givenastraight-
line program
W
(see below) and a hierarhial automatonA
, test whetherW ∈ L(A)
.This questionorrespondsto thehierarhialmembership problemwithasingleproess.Notiealsothattheweakmembershipproblem
M ∈ ? L w (G)
[1℄anbereduedto thisquestion.
Straight-line programs. A straight-line program (SLP for short) over the
alphabet
Σ
is aontext-freegrammar withvariablesV = {X 1 , . . . , X k }
, initialvariable
X 1
and rules fromV × (V ∪ Σ) +
. The rules are suh that there isexatlyoneruleforeahleft-hand side variableand if
X i −→ α
, theneahX j
in
α
satisesj > i
.Theonstraintsontherules makethat anyvariable
X i
generatesauniqueword.For onveniene, we denote the word generated by the variable
X i
alsoas
X i
. ThelengthofavariableX i
representsthelengthofthewordgeneratedby
X i
andisdenotedas||X i ||
.Clearly,||X i ||
anbeatmostexponentialinthe number of rules. The size|X i |
of an SLP is the sumof thesizes of the rules.Withoutlossofgenerality,weanassumethatrulesareofsize2,thatisofthe
form
X −→ Y Z
withY, Z ∈ V ∪ Σ
.SineanyMSC
M
is determinedby itsprojetions(M | i ) i∈P
, annMSCM
anbeidentiedwith
℘
SLPsL 1 , . . . , L ℘
.TheSLPL i
generatestheprojetionM | i
ofM
onthe set of eventsof proessi ∈ P
. We denotethe variables usedby
L i
asX | i
, whereX ∈ {M q | q = 1 · · · n}
. The initial variable of eahL i
is
M n | i
. Atually, the SLPs are not in Chomsky normal form to preserve thisrepresentationofnMSCs.
Example 3. ForthenMSC
P
isFigure1wehavethefollowingSLPgeneratingtheprojetiononproess1:
P | 1 → S| 1 eM| 1 S| 1
,S| 1 → M | 1 hM | 1
andM | 1 → k
.Theorem2 ItisPSPACE-ompletetohekwhether
W ∈ L(A)
forsomeSLPW
andhierarhialautomatonA
.Ifthe alphabetisunary,thenthemembershipproblem isNP-omplete.
Remark1 TheNP-hardnessresultintheunaryasefollowsalsofrom [23℄.
Proof.Werstredue(1-in-3)SATtotheunarymembershipproblem,sine
weusethisredutioninthegeneralase,too.ThisproblemisNP-omplete,see
[24,6℄.
Let
ϕ = ∧ m j=1 C(α j , β j , γ j )
be an instane of (1-in-3) SAT overn
variables(x i ) i=1,n
.Here,alauseC(α j , β j , γ j )
istrueiexatlyoneoftheliteralsα j , β j , γ j
istrue.Weusetheunaryalphabet
{a}
.Note thatanywordx ∈ a ∗
isuniquelydened byitslength.
Weassoiatewitheahlause
C j = C(α j , β j , γ j )
thewordw j ∈ a ∗
oflength4 j
.ThiswordanbedenedbyanSLPofpolynomialsize.LetW = w 1 · · · w m ∈ a ∗
be theword oflengthP m
j=1 4 j
. TheautomatonA
onsists ofasequene ofhoies with transitions labeledby
t i
andf i
, fori
varying from 1ton
, wheret i = P
j∈R i 4 j
andR i = {j | x i ∈ {α j , β j , γ j }}
.Inthesameway,f i = P
j∈S i 4 j
and
S i = {j | (¬x i ) ∈ {α j , β j , γ j }}
.t
f
A t
f
1
1
n
n
Anypath
ρ
ofA
orrespondstoavaluationσ
where eahvariablex i
istrueifthepathhooses
t i
,andfalseifithoosesf i
.Letn j
bethenumberofliteralsof
C j
that areset truebyσ
. Reallthatσ
satisestheformulaϕ
in j = 1
forall
j
.Itiseasytoseethatρ
islabeledbythewordL ∈ a ∗
oflengthP m j=1 n j 4 j
.Notie that sine eah lause hasthree literals,
n j ∈ {0, 1, 2, 3}
for allj
. Thelengthof
L
inbase4isthus(n m n m−1 . . . n 1 0) 4
.WehaveW = L
i(11 . . . 10) 4
=(n m n m−1 . . . n 1 0) 4
,thusin j = 1
forallj
.Thatis,thereisapathinA
labeledby
W
i there is avaluation satisfyingϕ
, whih implies that the membershipproblemforhierarhialautomatononaunaryalphabet isNP-hard.
WenowshowtherststatementofTheorem2.Wereduethe(1-in-3)QBF
(one-in-threequantiedboolean formula)to thehierarhialmembershipprob-
lem. Let
ϕ
be an instane of (1-in-3) QBF of the formϕ = Q n x n · · · Q 1 x 1 ψ
,where
Q i ∈ {∃, ∀}
andtheformulaψ
isoftheform∧ m j=1 C(α j , β j , γ j )
.Asbefore,alause
C(α j , β j , γ j )
istrueiexatlyoneliteralistrue.ThePSPACE-hardness ofthisproblemisshownin[24,6℄.Theidea is to makethe valuations of thevariables orrespondto pathsin
the hierarhial automaton
(A i ) i=0,n
and to validate the valuations using theSLPs
(W i ) i=0,n
.WedenetheautomataA i
and theSLPsW i
byindution oni = 0, . . . , n
.Here,weusethebinaryalphabet{a, b}
.Thelettera
will havethesamemeaning asin theNP-ase, and the letter
b
will be used asadelimitingsymbol.
We dene the words
w j , t i , f i ∈ a ∗
with respet toψ
as before. That is,eah
w j
is assoiated with lauseC j
andt i , f i
are assoiated withvariablex i
.Moreover, we assoiate with eah variable
x i
the wordw i+m ∈ a ∗
of length4 i+m
. LetW 0 = w 1 · · · w n+m
bethewordofa ∗
oflengthP n+m
j=1 4 j
,andletA 0
beanautomatononsisting ofone
ǫ
-transition from itsinitial statetoits nal state.LetalsoS 0
beanautomatononsistingofonetransitionlabeledbyb
.TheSLP-ompressedwords
(W i ) i=1,n
,aredenedby:
W i −→ W i−1
, ifQ i = ∃
,
W i −→ W i−1 b W i−1
,ifQ i = ∀
.Thereursive denition of the automata
(A i ) i=1,n
and(S i ) i=0,n−1
is illus-tratedinthegurebelow.Transitionsareeitherlabeledby
ǫ
,orbyxti = t i w i+m
orxf
i = f i w i+m
. The automatonon theleft denesA i
whenQ i = ∀
, theau-tomatoninthemiddledenes
A i
whenQ i = ∃
,andtheautomatonontherightdenes
S i
.Notethatthesymbolb
isonlygeneratedbyS 0
.Inthegurewereallitspositionbymarkinga
b
asideeahS i
.A i A i-1
xt i
xf i
A i xt i
A i-1 xf i
Sn-i
n-i-1
S S n-i-1
xt i+1
xf i+1
b b
A i-1
b S n-i
Theoverall ideaisasfollows.Thevaluesof
x i+1 , . . . , x n
arealreadyhosenwhenanautomatonalls
A i
(fromahigherhierarhylevel).TheautomatonA i
ontheleftsets
x i
true,thenusesS n−i
toreoverthexedvaluesofx i+1 , . . . x n
,andnallyitsets
x i
false.TheautomatonA i
inthemiddleguesseswhetherx i
istrue(bytakingthetransitionlabeledbyxt
i
)orfalse(byhoosingthetransitionlabeledbyxf
i
).Ifithoosesbothtransitionslabeledbyxti ,
xfi
ornoneofthem,then thewordlabeling thispathwill notbeequalto
W n
beauseW n
ontainsexatlyoneourreneof
w i+m
betweenanytwoonseutiveb
's.Weillustratehow
A i
works on gure 3, that shows the unfolding of the automatonA 2
forϕ = ∀x 2 ∀x 1 ψ
ontheleftandforϕ = ∃x 2 ∀x 1 ψ
ontheright.Toillustratehow
S n−i
reoversthevaluesofx i+1 , . . . , x n
,weshowS n−i
forn = 9, i = 7
inthegurebelow.S 2
xf 9 b
b
xf 8
xt 9
xf 9
xt 8
b b
xt 9
S 1 S 0
A i
andS i
aredesignedsothatanypathofA i
islabeledbyatmostonexti
andatmostonexf
i
betweenanytwoonseutiveb
's,foreahi
(foronveniene,we suppose that eah automaton starts and ends with a tive
b
transition).Thatis,apathanbelabeledbyxt
i
andxfi
,butnotbytwoxfi
ortwoxti
.Byontradition,assumethattherearetwoonseutive
b
'sinA i
suhthatthereisapathfrom onetoanotherlabeledbytwoxt
j
(the asexfj
issymmetri).Wetaketheminimal
A i
whihensuresthis. BytheminimalityofA i
,this anonlyhappeneitherbeauseoftherstxt
j
transitionofA i
,orbetweenS n−i
andoneofthetwo
A i−1
.SineinS n−i
allxtk
ourafterthe(unique)b
,there isnoxtj
A 2
xt 2
xf 2 b b
xt 2
xf 2
b xt 1
xf 1
A
1
xt 2
xf 2 b b
xt 1
xf 1
A 1 xt
2
xf 2 b b
xt 1
xf 1
A 1
A 2
xt 2
xf 2 S 1
Fig.3.Unfoldingof
A 2
forQ 2 x 2 Q 1 x 1 = ∀ x 2 ∀ x 1
ontheleft,andontheright,unfoldingof
A 2
forQ 2 x 2 Q 1 x 1 = ∃ x 2 ∀ x 1
in
A i−1
before its rstb
(if any).It alreadyshowsaontraditionin thease whereQ i = ∃
. Considernow the aseQ i = ∀
. Forthe samereason asbefore,there an beat mostonext
j
betweenthelastb
ofA i−1
and theb
inS n−i
,forall
k < i
.Finally,betweentheb
ofS n−i
andtherstb
oftheseondA i−1
thereanbeat mostonext
k
withk > i
(fromS n−i
)andatmostonextk
withk < i
(from
A i−1
).Thus,in allasesweontradittheassumptiononA i
.Letusprovethat
W n ∈ L(A n )
ithereexistsasatisfyingvaluationtreeV T
for
ϕ
. A valuation treeV T
is a binary tree of heightn + 1
suh that its root(level
n
)islabeledbyx n
andallnodesonlevell
arelabeledbyx l
.Theleavesareonlevel
0
,andareunlabeled.Anodev
labeledbyx i
orrespondstoavaluationσ(v)
ofthevariablesx i+1 , . . . , x n
.Forinstane,ifthevaluationforanodeisx n
istrue, thenitshildrenmustevaluate
x n
totrue,and evaluatex n−1
either totrueorfalse.Moreover,anodeonlevel
k
havetwohildrenifx k
is universally quantied (one hild evaluatex k
to trueand theother oneto false),and onehildif
x k
isexistentiallyquantied.WesaythatavaluationtreesatisesaQBF formulaϕ = Q n x n · · · Q 1 x 1 ψ
ifforeveryvaluationofeveryleaf,ψ
istrue.Usingthepropertywejustshowed,weannote that betweenanytwoon-
seutive
b
'sofanypathofA n
,thereareatmostthreew j
andtwow i+m
forany1 ≤ j ≤ m, 1 ≤ i ≤ n
. Thus ouroding in base fourfordetermining whetheralauseis true,isstill appliable.Hene,apath
ρ
ofA n
islabeledbyW n
iforall
1 ≤ k ≤ n + m
thereisexatlyonew k
betweenanytwoonseutiveb
's.Assumethat
V T
isavaluationtreeshowingthatϕ
istrue.Avaluationσ(v)
denes twowords
T (v), F (v)
asfollows: thewordT (v)
isthe onatenationof allxtj
wherej > i
andx j
istrueinσ(v)
. ThewordF (v)
istheonatenation of all xfj
wherej > i
andx j
is false inσ(v)
. Letv
be anode ofV T
labeledby
x i
. Wedene the wordρ(v) = T −1 (v)W i F −1 (v)
. Wereall thatT (v), F (v)
arewordsover
a ∗
,heneT −1 (v)W i F −1 (v)
is thewordthatresultsfromW i
bydeleting
|T (v)|
many a's in the prex and by deleting|F (v)|
many a'sin thesux.
Letusshowbyindution on level
i
thatρ(v)
is inL(A i )
foranynodev
ofV T
onleveli
.If
v
is a leaf ofV T
, then it denes an aepting valuation forψ
, heneT (v)F (v) = W 0
using the sameargumentas in the NP-hardness ase. Heneρ(v) = W 0 W 0 −1 = ǫ ∈ L(A 0 )
.Consideran internal node
v
labeled byx i
withQ i = ∀
. Letv 1 , v 2
be thehildrenof
v
,withv 1
orrespondingtox i
true,andv 2
tox i
false.Byindutionletussupposethat
ρ(v 1 )
,ρ(v 2 )
areinL(A i−1 )
.Then,ρ(v) = T −1 (v)W i F −1 (v) = T −1 (v)W i−1 bW i−1 F −1 (v)
= T −1 (v)T (v 1 )ρ(v 1 )F (v 1 )bT (v 2 )ρ(v 2 )F(v 2 )F −1 (v)
=
xti ρ(v 1 )F (v 1 )bT (v 2 )ρ(v 2 )
xfi
Weusedintheequationsabove
T −1 (v)T (v 1 ) =
xti
forthepositivehildv 1
ofv
andF −1 (v)F(v 2 ) =
xfi
forthenegativehildv 2
ofv
.Moreover,F (v 1 )bT (v 2 ) =
F (v)bT (v) ∈ L(S n−i )
sine the indies of false variables inσ(v 1 )
and of truevariablesin
σ(v 2 )
formapartitionof{i+1, . . . , n}
.Thisshowsthatρ(v) ∈ L(A i )
.Consideraninternal node
v
that islabeledbyx i
withQ i = ∃
. Assume bysymmetry that
v 1
is the hild ofv
inV T
(thus,x i
is true).By indution weassumethat
ρ(v 1 )
isinL(A i−1 )
.Itiseasytoshownowthatρ(v) ∈ L(A i )
using:ρ(v) = T −1 (v)W i F −1 (v) = T −1 (v)W i−1 F −1 (v)
= T −1 (v)T (v 1 )ρ(v 1 )F (v 1 )F −1 (v)
=
xti ρ(v 1 )
Forthereversediretiontheargumentsaresimilar.Fromaword
W = W n
ofA = A n
,weobtainsubwordsρ(v)
inL(A i )
asabove,labeledbyT −1 (v)W i F −1 (v)
.Foreah leaf
v
thismeansthatσ(v)
satisesexatlyone literalperlause.2
Theorem2showsimmediatelythat thehierarhialmembership problemis
PSPACE-hard evenwith oneproess,byenodingthe alphabet
{a, b}
by loalationsonasingleproess.Similarargumentsanbeusedfortheasewhere
G
isanMSC-graphwithnohierarhy,asshowninthefollowingtheorem.
Theorem3 ThehierarhialMSCmembershipproblem
M ∈ ? L(G)
isPSPACE-omplete. The lower boundholdseven if
G
isan MSC-graph, orifthere isonlyoneproess.
Proof.Theproblemweredue fromis(1-in-3)QBF.Let
F
beaninstaneof(1-in-3)QBF of the form
F = (Q n x n ) . . . (Q 1 x 1 )ϕ
, whereQ i ∈ {∃, ∀}
and theformula
ϕ
isoftheform∧ j=1...m R(α j,1 , α j,2 , α j,3 )
,withα j,k
literals.Theideaistoletvaluationsofthevariablestoorrespondtopathsof
G
andto validate thevaluationsusing the nMSC
M
. Wedene thegraphG
andthenMSC
M
byindutiononF = F n
.LetF i = (Q i x i ) F i−1
,withF 0 = ϕ
.EahF i
willdetermine
G i , M i
.TheproessesusedintheonstrutionareSC
1 , . . . ,
SCm
andRC1 , . . . ,
RCm
,plusVY
1 , . . . ,
VNn
andVN1 , . . . ,
VNn
.HereV
meansavariableandC
alause,S
standsforsend,R
forreeive,Y
foryesandN
forno.For all
i
, let MYi
be the MSC onsisting of amessage from VYi
to VNi
,then bak from VN
i
to VYi
, and a message from SCj
to RCj
for allj
suhthat
x i ∈ {α j,1 , α j,2 , α j,3 }
. Symmetrially,letMNi
be theMSConsisting ofamessagefromVN
i
toVYi
,thenbakfromVYi
toVNi
,andamessagefromSCj
toRC
j
forallj
suhthat¬x i ∈ {α j,1 , α j,2 , α j,3 }
.M 0
is an MSC onsisting of one message from SCj
to RCj
, for allj
. TheMSC-graph
G 0
onsists of4n
verties,labeledby MYi
, MNi
,or∅
. ThegraphhoosesbetweenMY
i
andMNi
foralli
,asdepitedbelow:MY
MN
G 0 MY
MN
1
1
n
n
Notethatallmessagesdened aboveommute,exeptfortheonesbetween
VY
i
andVNi
.Leta i
bethemessagefromVYi
toVNi
,andb i
themessagefromVN
i
toVYi
. Wewillusetheorderbetweena i
,b i
asfollows:Thesequenea i b i
meansthat
x i
istrue,whileb i a i
meansthatx i
isfalse.Assumenowthat
G i−1 , M i−1
arealreadydened,andthat therearef
uni-versalquantiersin
F i−1
.Forsimpliity,wedenotea = a i
andb = b i
.Notethatinavaluationtreefor
F
showingthatF
istrue,eahvalue0or1assignedtothevariable
x i
isusedby2 f
leaves.Avaluationtreeisdenedasusual,byassigningeah universally quantied variable two hildren labeled 0 and 1, respetively
eahexistentiallyquantiedvariableonehildlabeled0or1.
If
F i = ∀x i F i−1
, then letM i = (ab) 2 f M i−1 S i (ba) 2 f M i−1
(see Figure 4.1).The MSC
S i
is used for synhronizing proesses ourring inM i
. It ontainsa message between eah (ordered) pair of proesses of
M i
(in some arbitraryorder). Note that using thehierarhywe andesribe
(ab) 2 f
, andthusM i
, byanexpressionofpolynomialsize.
Let
G i = (V i , E i )
,whereV i = V i−1 ∪{e 0 }
andE i = E i−1 ∪{(
Fin, e 0 ), (e 0 ,
In)}
.The initial node In (the nal node Fin , respetively) of
G i
is the sameas forG i−1
.Thevertexe 0
islabeledbythesynhronizationMSCS i
.G i
G i-1
M
VY VN
i
M i-1
ba
S S
VY VN
M i-1
e 0
i i i i
i i
ab
Thedenition of
M i , G i
anbe explainedintuitivelyasfollows.Letρ
beapathof
G i
labeledbyM i
.Note thattheMSCS i
ourringinM i
hasto maththeMSC
S i
ofe 0
.Thusρ = ρ 1 e 0 ρ 2
,withρ 1
anaeptingpathofG i−1
labeledby(ab) 2 f M i−1
andρ 2
anaeptingpathofG i−1
labeledby(ba) 2 f M i−1
.Eahtimeρ j
goes throughG 0
(whih happens2 f
times),ρ j
onsumes eitherab
of MYi
or
ba
of MNi
, soρ j
onsumesallourrenesofa, b
in(ab) 2 f
. Inpartiular,allourrenesonsumedby
ρ 1
areoftheformab
,whihensuresthatthevaluationof