Contents lists available atScienceDirect
Theoretical
Computer
Science
www.elsevier.com/locate/tcs
Bigraphs
with
sharing
Michele Sevegnani
∗
,
Muffy Calder
School of Computing Science, Sir Alwyn Williams Building, Lilybank Gardens, University of Glasgow, G12 8RZ, Glasgow, United Kingdom
a
r
t
i
c
l
e
i
n
f
o
a
b
s
t
r
a
c
t
Article history: Received2August2013
Receivedinrevisedform27January2015 Accepted4February2015
Availableonline19February2015 CommunicatedbyU.Montanari Keywords: Bigraphs Matching Spatialmodels Semantics Rewriting
Bigraphical Reactive Systems (BRS) were designed by Milner as a universal formalism for modellingsystemsthat evolveintime, locality, co-locality andconnectivity. Butthe underlying model of location (the place graph) is a forest, which means there is no straightforward representation of locations that can overlap or intersect. This occurs in many domains, for example in wireless signalling, social interactions and audio communications. Here,wedefinebigraphswithsharing,whichsolvesthisproblembyan extensionofthebasicformalism:wedefinetheplacegraphas adirectedacyclicgraph, thus allowinganaturalrepresentationof overlappingorintersecting locations.We give acomplete presentationof thetheory ofbigraphs withsharing, includinga categorical semantics,algebraicproperties,andseveralessentialproceduresforcomputation:bigraph withsharingmatching,aSATencodingofmatching,andcheckingafragmentofthelogic BiLog.Weshowthatmatchingisaninstanceofthe NP-completesub-graphisomorphism problem and our approach based on a SAT encoding is also efficient for standard bigraphs.Wegiveanoverviewof BigraphER (BigraphEvaluator& Rewriting),anefficient implementation of bigraphs with sharing that provides manipulation, simulation and visualisation.ThematchingengineisbasedontheSATencodingofthematchingalgorithm. Examplesfromthe802.11CSMA/CARTS/CTSprotocolandanetworkmanagementsupport systemillustratetheapplicabilityofthenewtheory.
©2015TheAuthors.PublishedbyElsevierB.V.Thisisanopenaccessarticleunderthe CCBYlicense(http://creativecommons.org/licenses/by/4.0/).
1. Introduction
BigraphicalReactiveSystems[1]weredesignedbyMilnerasauniversalformalismformodellinginteractingsystemsthat evolveintimeandspace.Theyprovideintuitive representationsforsystemswithevolvinglocality,co-locality,and connec-tivity.Inthecourseofworkingwithpracticalapplicationsofbigraphsformodellingdifferentaspectsofwirelessnetworking protocolsandmanagement,wediscoveredtherewasnostraightforwardwaytorepresentoverlappingorintersectingspatial locationsinbigraphs.But,overlapsarefundamentaltowirelesssignallingandtootherdomainssuchassocialinteractions andaudiocommunications.Consider forinstance,the wireless networkdrawn inFig. 1a. Aspatial modelbased ontrees cannotrepresentthefactthatmachineAiscurrentlyoccupyingaspacelocation coveredby bothA’ssignalandB’ssignal, butnotbyC’ssignal.
Wehavetherefore extendedstandardbigraphsto bigraphswithsharing, whichallowforoverlapping locations.This re-quiresdefiningtheplacegraphsofBRSasdirectedacyclicgraphs(DAGs),insteadofforests.Anexampleplacegraphwith sharingrepresentingthetopologyofthewireless networkinFig. 1aisgiveninFig. 1b.Thethreestations aredenotedby A, B,andC,whileSindicateswirelesssignalranges.Wewilldescribeindetailthisnotationinthefollowingsection.
*
Correspondingauthor.E-mail addresses:[email protected](M. Sevegnani),[email protected](M. Calder). http://dx.doi.org/10.1016/j.tcs.2015.02.011
0304-3975/©2015TheAuthors.PublishedbyElsevierB.V.ThisisanopenaccessarticleundertheCCBYlicense (http://creativecommons.org/licenses/by/4.0/).
Fig. 1. Diagram of a wireless network of three stations (a) and a place graph with sharing representing its topology (b).
Fig. 2. Example bigraph B (a) and its constituents: place graph BP(b) and link graph BL(c).
Inthispaperwegiveacompletepresentationofthetheoryofbigraphswithsharing,includingacategoricalsemantics, algebraic properties,andseveralessentialprocedures forcomputation:bigraph withsharingmatching,aSAT encoding of matching,andcheckingafragmentofthelogic BiLog.Ineachcasewebuildontheexistingresultsfor(standard)bigraphs andourextensionsareconservativeinthesensethattheystillapplytostandardbigraphs.Wealsogiveanoverviewofour implementation,called BigraphER,whichprovidesanefficientimplementationofcomputation,simulation,andvisualisation forbigraphswithsharing.
Whenitisnecessarytodistinguishthedifferenttypesofbigraphs,werefertobigraphsasdefinedbyMilnerasstandard bigraphs.Wedonotrepeattheformaldefinitionshere,butreferthereaderto[1].
The paper is organised as follows. In the next Section we give an informal overview of bigraphs with sharing and discusswhyan explicitrepresentationofsharingisrequired.InSection 3weshow thatthe newcomposition andtensor productoperatorsretainthesamepropertiesasthestandardoperators,andthenwegiveacategoricalsemanticsandresults concerning algebraicformsandnormalisation.InSection 4wedefinea matchingalgorithmforbigraphswithsharingand give anoverviewofaSATencoding.Ourapproachleads toamoreefficientsolutionforstandardbigraphs,comparedwith the standardapproachthatisbasedon inference.InSection 5weshow howcheckinga substantialfragment ofthelogic
BiLog canbereducedtoourmatching,andinSection6wegiveanoverviewof BigraphER,ourimplementationofBRSwith sharing.Finally,in Section7we discussapplicationsofbigraphswithsharing andinSections 8and9wediscussrelated workandourconclusionsandplansforfuturework.
2. Bigraphswithsharing
2.1. Informaloverviewofstandardbigraphsandbigraphswithsharing
ThegraphicalformofanexamplestandardbigraphB isdrawninFig. 2a.Entities,realorvirtual,areencodedbynodes, represented asovals andcircles.Theirspatial placement is described by node nesting. Nodesare assigneda type, called control, denoted hereby the labels A, B and C.A set of controls identifies a signature. Interactionsbetween agents are represented bylinks like,forinstance,the edgeconnectingthe B-nodeandthe C-node.Eachnode can havezero,oneor manyports,indicatedbybullets.Nodesofthesamecontrolhavealsothesamenumberofports.Dashedrectanglesdenote regions,alsocalledroots.Therôleofaregionistospecifyadjacentpartsofthesystem.Shadedsquaresarecalledsites.They encode partsofthesystemthathavebeenabstractedaway.Notethatthereisnosignificanceinwherealinkcrossesthe boundaryofanodeinabigraph.Abigraphcanhaveinnernames andouternames.Inourexample, y isan outername.By conventioninthegraphicalform,innernamesandouternamesaredrawnbelowandabovethebigraph,respectively.They encode links(or potential links)to other bigraphsrepresentingthe externalenvironment orcontext. Elementsforminga bigraph, namelynodesandedges, canbe assigneduniqueidentifiers,collectivelycalledthesupport ofa bigraph.When a bigraphicalstructureisassignedasupport,itiscalledconcrete.
Fig. 3. Example bigraph with sharing G (a) and its place graph GP(b).
Fig. 4. An example bigraph with sharing (a) and two possible encodings (b) and (c).
Summarising,locality isrepresented bynode placing whileconnectivity isencodedby thelinksofthe bigraph.Thisis madeexplicitbydefiningbigraphsintermsoftheconstituentnotionsofplacegraph andlinkgraph.Aplacegraphisaforest whose rootsare the regions ofthe corresponding bigraph and leavesare its sites andatomic nodes(i.e. nodes withno children).Alinkgraphisastructuredescribingthelinkageofabigraph.Itconsistsofahypergraphwhoseverticesarethe namesandnodesofthecorrespondingbigraphandhyperedgesareitslinks.Placegraph BP andlinkgraph BL ofexample
bigraph B aredrawninFigs. 2band2c,respectively.
The capabilitiesof a bigraph to interactwiththe external environment are recordedin its interface.For example,we write B
:
1,
∅
→
1,
{
y}
to indicatethat B has one site, one region,no inner namesand{
y}
is its setofouter names. Informally,thecomposition oftwobigraphs F (oftencalledthecontext) andG,written F◦
G,isobtainedby insertingG’s regionsin F ’ssitesandbymerginglinksoncommonnames,i.e.innernamesinF thatarethesameasouternamesinG. Theotherfundamentaloperationonbigraphsistensorproduct,denotedby⊗
.Itisonlydefinedoverbigraphswithdisjoint interfacesanditconsistsofputtingtwobigraphsside-by-side.The dynamicaltheory of bigraphsisdefinedin termsofrewrite rules, calledreactionrules. Areaction rule R
R consistsofapairofbigraphsthatcanbeinsertedintothesamehostbigraph.Left-hand sideR (alsocalledredex)specifies thepatterntobechanged,whileright-handside(orreactum)R specifiesthechangedpattern.Asetofbigraphsandaset ofreaction rulesthat define how thebigraphscan evolveover time forma BigraphicalReactiveSystem(BRS).Thereaction relation onbigraphsinducedbythereactionrulesofaBRSiswrittenwithanarrowthus: .Wehaveextendedstandardbigraphstobigraphswithsharing,sothatspatiallocationscanoverlap.Thisinducesalocality modelbasedondirectedacyclicgraphsinsteadofforests.AnexamplebigraphwithsharingG isgiveninFig. 3a.Theonly differencecomparedwithstandardbigraph B inFig. 2aisthatthenodeofcontrol C isnowplacedwithintheintersection ofthetwo A-nodes, i.e. C isshared.Thiscanalsobe seeninthe DAGforplacegraph GP drawninFig. 3binwhichtwo
edgesfrom A to C arepresent.Thedefinitionoflinkgraphisunaffectedbytheintroductionofsharing,thus GL
=
BL (see Fig. 2c).2.2. Whyextendbigraphstorepresentsharingexplicitly
The explicitintroduction ofsharing is justified by considering thedisadvantages of encoding sharing within standard bigraphs.Weconsidertwopossibleencodings.
The firstencoding consistsof theintroduction ofdummycontrolsto representintersections ofnodes.Forinstance, if nodesAandBareoverlapping,theirintersectionisrepresentedasaseparatenodeofcontrolA
∩
B.Agraphical representa-tionisgiveninFig. 4b.Theimmediateconsequenceofthisapproachisthat placegraphsarestillrepresentable byforests. However, a major disadvantage is that the numberof dummynodes to be addedgrows exponentially with thenumber ofintersectingnodes.Moreover,thisencoding isnotcompletebecauseitcannotrepresentsharingwhennonodesare in-volved. Toprove this, considerthe exampleof aC-node shared by two regions.It is possibleto createa dummyregion containing C,howeverwecannot assignacontrol toit.Hence,welosetrackofwhowassharingthenode. Thiscanbea limitingfactorespeciallyinthedefinitionofreactionrules.AnothershortcomingisthatanodesharedbetweenAandBis placedinsidethedummynodeA∩
B,thusbothAandBappearasiftheydonothaveachild.Thesecond encodingconsistsofkeepingacopyofasharednode insideeach ofitsparentsandconnectingthecopies witha speciallink.Forexample,when anode C issharedbetween AandB, bothA andB containa node ofcontrol C andthetwoCsarelinked together.This isdrawninFig. 4c.NotethatcontrolCisdefinedexactlyasCbutwithanextra
porttohandlethespeciallink.However,thisapproachdoesnotallowonetoexpresssharingwithoutnodes,e.g.twonodes sharingasite,andnodesorsiteswithnoparents.Anotherdisadvantageofthisapproachisthatlinksareusedtorepresent localityinsteadofconnectivity,goingagainstthespiritofbigraphs,inwhichthetwonotionsarekeptdistinct.
Although other encodings are possible, they all present similar problems. In conclusion, our simple extension yields several advantages. First, its completeness allows for the representation of arbitrary place graphs with sharing. Second, the modellingphase ismorenaturalandimmediate,becausenoadditionallinks, copiesofnodesandcontrolshavetobe introduced. Third, thestructure ofplacegraphs withsharingappears tohavemanysimilarities withstandard categorical notionsaswewillshowinthenextsection.Inparticular,itmakesplacegraphsself-dual.
2.3. Definitions
In thefollowing weintroduce formal definitionsofbigraphswithsharing, theirconstituents andtheir operations.We establishsomenotationalconventionsbelow.
Wefrequentlyinterpretanaturalnumberasafiniteordinal,namelym
= {
0,
. . . ,
m−
1}
.Wewrite ST toindicatethe unionofsetsknownorassumedtobedisjoint.Ifafunction f hasdomain S andS⊆
S,then fS denotestherestriction of f to S .Fortwofunctions f and g withdisjointdomains S andT wewrite fg forthefunctionwithdomain ST such that(
fg)
S=
f and(
fg)
T=
g.We writeIdS fortheidentity functionontheset S.Givenabinary relationrel
⊆
A×
B,wedenotethedomainrestrictionofrel overS⊆
A bySrel.Similarly,wewriterelS fortherangerestriction ofrel overS⊆
B.Wealsoindicateset{
b| (
a,
b)
∈
rel}
,thetransitiveclosureandtheinverseofrel bywritingrel(
a)
,rel+and rel−1, respectively. Indefining bigraphswe assume that names,node-identifiers, edge-identifiers andcontrolsare drawn from fourinfinitesets, respectivelyX
,V
,E
andK
,disjointfromeach other.We denote identifiersby lower-case letter: x, y,z fornames, v,u fornodes,ande0,
e1,
. . .
foredges.Upper-caseletters A,
B,
. . .
areusedtodenotebigraphsandtheirconstituents.Wewrite X
,
Y,
. . .
toindicatesetsofnames.Weuseasashorthandforinterface0
,
∅
. 2.3.1. PlacegraphsPlacegraphs withsharing are DAGstructuresasin Fig. 3b.Their formal definitionisa generalisation ofthestandard formulationbasedonforestsgivenin[1].
Definition1(Concrete placegraphwithsharing).Aconcreteplacegraphwithsharing
F
= (
VF,
ctrlF,
prntF)
:
m→
nis a triple having an inner interface m and an outer interface n. These index the sites andregions of the place graph, respectively. F hasafinitesetVF
⊂
V
ofnodes,acontrolmapctrlF:
VF→
K
,andaparentrelationprntF
⊆ (
mVF)
× (
VFn)
thatisacyclici.e.
(
v,
v)
∈
/
prnt+F foranyv∈
VF.TheonlydifferencewithMilner’sdefinitionisthatprntF isnowabinaryrelationinsteadofafunction.Thismodification is sufficienttoallowforsitesandnodestohavezeroormoreparents.Specialplacegraphs calledidentities,idm
:
m→
m,andsymmetries,
γm
,n:
m+
n→
n+
m,aredefinedasinstandardbigraphs(seeFig. 7).Compositionandtensorproductaretheoperationsthatallowcombinationofplacegraphs.Theyaredefinedasfollows:
Definition2 (Composition forplacegraphswithsharing).If F
:
k→
m and G:
m→
n aretwo concrete place graphs with sharingwithVF∩
VG= ∅
,theircompositeG
◦
F= (
V,
ctrl,
prnt)
:
k→
nhasnodesV
=
VFVG andcontrolmapctrl=
ctrlFctrlG.Itsparentrelationprnt⊆ (
kV)
× (
Vn)
isgivenby: prntdef=
prntG prnt◦prntFwhere
prntF
=
prntFVF prntG=
VGprntG prnt◦= (
mprntG)
◦ (
prntFm) .
Definition3(Tensor productforplacegraphs).IfG0
:
m0→
n0 andG1:
m1→
n1 aretwoconcreteplacegraphswithsharingwithVF
∩
VG= ∅
,theirtensorproducthasnodesV
=
VG0VG1 andcontrolmapctrldef
=
ctrlG0ctrlG1.Itsparentrelationprnt⊆ ((
m0+
m1)
V)
× (
V(
n0+
n1))
isdefinedasfollows: prntG0prnt(m0,n0) G1 where, prnt(m0,n0) G1= {(
v,
w)
| (
v,
w)
∈
prntG1and v,
w∈
VG1}
{(
m0+
i,
w)
| (
i,
w)
∈
prntG1, w∈
VG1and i∈
m1}
{(
v,
n0+
i)
| (
v,
i)
∈
prntG1, v∈
VG1and i∈
n1}
{(
m0+
i,
n0+
j)
| (
i,
j)
∈
prntG1, i∈
m1and j∈
n1} .
2.3.2. LinkgraphsHere we recall the standard definition oflink graphs given in [1]. The arity ofa control K is the numberof portsa K-nodecanhave.Itisindicatedbyar
(
K)
=
n.Definition4(Concrete linkgraph).Aconcretelinkgraph
F
= (
VF,
EF,
ctrlF,
linkF)
:
X→
Yisaquadruplehavinganinnerface X andanouterfaceY ,bothfinitesubsetsof
X
,calledrespectivelytheinnerandouter namesofthelinkgraph.F hasfinitesets VF⊂
V
ofnodesand EF⊂
E
ofedges,a controlmapctrlF:
VF→
K
anda linkmap
linkF
:
XPF→
EFYwhere PF def
= {(
v,
i)
|
i∈
ar(
ctrlF(
v))
}
isthesetofportsof F .Thus(
v,
i)
istheithportofnode v.Weshallcall XPF thepoints ofF ,andEF
Y itslinks.Thesetsofpointsandthesetofportsofalinkl aredefinedby
pointsF
(
l)
def= {
p|
linkF(
p)
=
l}
portsF(
l)
def
=
pointsF(
l)
\
X.
Anedgeisidle ifithasnopoints.IdentitiesovernamesetsaredefinedbyidX
= (∅,
∅,
∅,
IdX)
:
X→
X .2.3.3. Bigraphswithsharing
Likeastandardbigraph,abigraph withsharingissimplythepairofitsconstituents:aplacegraphwithsharinganda linkgraph.
Definition5(Concrete bigraphwithsharing).Aconcretebigraph
F
= (
VF,
EF,
ctrlF,
prntF,
linkF)
:
k,
X→
m,
Yconsists of a concrete place graph with sharing FP
= (
VF
,
ctrlF,
prntF)
:
k→
m and a concrete link graph FL=
(
VF,
EF,
ctrlF,
linkF)
:
X→
Y .Wewritetheconcretebigraphwithsharingas F=
FP,
FL.Thecompositionoftwoconcretebigraphswithsharing A and B isobtainedbyseparatelycomposingtheirplacegraphs withsharingandlinkgraphs.Formally, A
◦
B=
AP◦
BP,
AL◦
BL.Thesameholdsforthedefinitionoftensorproduct,i.e.
A
⊗
B=
AP⊗
BP,
AL⊗
BL.Thesupportofaconcretebigraph F ,is
|
F|
=
VF
EF.Theidentifiersofnodesandedgescanbe variedinadisciplined waybymeans ofa supporttranslation.Milner’sdefinitionalsoapplies tobigraphswithsharing. Werecallithere.
Definition6(Support translation).GiventwobigraphswithsharingF
,
G:
k,
X→
m,
Y,asupporttranslationρ
: |
F|
→ |
G|
fromF toG consistsofapairofbijectionsρV
:
VF→
VG andρE
:
EF→
EG thatrespectstructureasfollows:1.
ρ
preservescontrols, i.e.ctrlG◦
ρ
V=
ctrlF.It follows thatρ
induces a bijectionρP
:
PF→
PG on ports, definedbyρ
P((
v,
i))
def
= (
ρ
V(
v),
i)
.2.
ρ
commuteswiththestructuralmapsasfollows:prntG
◦ (
Idmρ
V)
= (
Idnρ
V)
◦
prntF linkG◦ (
IdXρ
P)
= (
IdYρ
E)
◦
linkF.
Fig. 5. Graphicalformsforbigraph
B
:→ 1,{y}:nestingdiagram (a)andstratifieddiagram (c).ThecorrespondingplacegraphB
P:0→1 isgivenin (b).Given F andthebijection
ρ
,theseconditionsuniquelydetermineG.WethereforedenoteG byρ
F , andcallitthesupport translationofF byρ
.WecallF andG supportequivalent,andwewriteFG,ifsuchatranslationexists.Supporttranslation isdefinedsimilarlyforplacegraphsandlinkgraphs.Since thedefinition oflinkgraph isnot affectedby the introductionofsharing intheplace graph,alsothe following standarddefinitionappliestobigraphswith sharing:
Definition7(Lean-supportequivalence). Twobigraphswithsharing F and G arelean-supportequivalent,written F
G,if theyaresupportequivalentignoringtheiridleedges.An abstract bigraphwithsharingcanbe viewedasalean-support equivalenceclassofconcretebigraphswithsharing. Informally,aproceduretoturnaconcretebigraphwithsharingintoanabstractbigraphwithsharing,consistsofdiscarding all its identifiers andidle edges.1 It is also possible to do the reverse, namelyfrom abstract to concrete bigraphswith sharing:
Definition8(Concretion,abstraction).IfG isanabstractbigraphwithsharing,thenaconcretebigraphwithsharing
G ,called aconcretion ofG,isobtainedbyassigningtoeachnodeauniqueidentifierv∈
V
andtoeachedgeauniqueidentifiere∈
E
. Dually,bigraphG iscalledtheabstraction ofG.Observethatanytwoconcretions
A,B ofthesamebigrapharealwayslean-supportequivalent. 2.4. GraphicalnotationBigraphswithsharingcanberepresentedgraphicallybyusingamodifiedversion ofthenesting diagramsforstandard bigraphsinwhichintersectingnodesandregionsareallowed.
Twoexamples aregivenin Fig. 3aandFig. 5a.Thisnotation isbased onVenndiagramsanditis adequateto quickly specifysimplemodels.However,itcanbedifficulttodrawallthepossibleintersectionswhenthereareseveral(e.g.more thanthree)intersectingnodes.Moreover,thereareothertwomajordrawbacks:
•
Emptyintersectionsaremeaningless.Theseoftenarisewhentherearemorethantwonodesoverlapping.Forinstance, thepartoftheintersectionbetweentheAandC-nodesnotinB(i.e.(
A∩
C)
\
B)inFig. 5aisempty.•
Itisimpossibletorepresentanodesharingaplacewithoneofitsancestors.Toovercometheselimitations,weintroduceanewgraphicalform,calledstratifiednotation.Inthisnotation,weexplicitly represent the underlyingDAG structure of theplacing graph by specifyinghow places are shared. An examplestratified
1 Inourimplementation,weslightlymodifiedMilner’sdefinitionofcompositionforconcretelinkgraphsinordertoavoidthecreationofidleedges.In thisway,supportequivalenceissufficienttorepresentabstractbigraphs.
representation of bigraph B
:
→
1,
{
y}
is given in Fig. 5c. Note the similarities with the graphical representation of corresponding place graph BP:
0→
1 inFig. 5b.In the stratifiedrepresentation,nodes are organisedin differentlayers.Inthe example,we havetwolayers. Thebottom one contains thechildren (nodesandsites), whilethetop one contains their parents(nodes andregions).ThesearenodesD,E, F,G andA,B,C,respectively. Eachnodein thebottomlayeris placedintoadifferentregion.Thisallowsthenodestobesharedbydifferentcombinationsofparents.Eachparentnodein thetop layercontains asite. Thenesting ofthenodesisspecifiedby thedashededges connectingthetwo layers.Inthe example,thefirstregioncontainingtheD-nodeisconnectedtothesitesintheBandC-nodes.ThismodelsthefactthatD issharedbyBandC.TheorphannodeGhasaplaceclosure,hencetherearenoedgesconnectingitsregiontothetoplayer. Therepresentationoflinksisnot changed.Notethat withthisnotation meaninglessintersectionsare notrepresented.In particulartheydonotarisebecauseemptyregionsarenotallowedtooccurinthebottomlayer.Notethatwhenabigraph hasamorecomplexnestingstructure,itispossibletousemorethantwolayers.
ThestratifiednotationiscloselyrelatedtothenormalformforbigraphswithsharingwewillintroduceinProposition 15. Moreover,theautomateddrawingroutinesforbigraphswithsharingimplementedinourtool BigraphER arebasedonthis notation(refertoSection6formoredetails).
In the remainder ofthis document it isassumed that bigraphsallow sharing, unless statedotherwise. Therefore, we oftenwrite“bigraph”tomean“bigraphwithsharing”.
3. Propertiesofbigraphswithsharing
In this section we list some propertiesof bigraphs withsharing. We begin by showing that composition andtensor productforplacegraphswithsharingenjoythesamepropertiesofthecorrespondingoperationsforstandardplacegraphs.
Lemma1(Associativity ofcomposition).IfA
:
m→
n,B:
k→
m,C:
h→
k arethreeconcreteplacegraphswithsharingwithdisjoint nodesets,thenA◦ (
B◦
C)
= (
A◦
B)
◦
C .Lemma2(Neutral elementsforcomposition).ForanyconcreteplacegraphwithsharingG
:
m→
n,G◦
idm=
G=
idn◦
G.Lemma3(Associativity oftensorproduct).If A
:
m0→
n0,B:
m1→
n1,C:
m2→
n2arethreeconcreteplacegraphswithsharingwithdisjointnodesets,thenA
⊗ (
B⊗
C)
= (
A⊗
B)
⊗
C .Lemma4(Neutral elementfortensorproduct).ForanyconcreteplacegraphwithsharingG
:
m→
n thefollowingholdsG⊗
id0=
G
=
id0⊗
G.Wenowpresentsomepropertiescharacterisingcompositionofconcreteplacegraphs.Theywillbeusefulforthe defini-tionofthematchingalgorithmforbigraphswithsharinginSection4.Thefirstpropertystatesthatallthedescendantsofa node v inF arealsoin F .
Lemma5.GiventwoplacegraphsG
:
m→
n andF:
k→
m suchthatB
:
k→
n=
G◦
F.
Foranynodev
∈
VF,if(
v,
v)
∈
prnt+B,thenv∈ (
kVF)
.Anotherpropertyspecifies that inanyvalidcomposition G
◦
F , when anode orsite v in F hasaparent setoverlapping withG,then G providesasetofsitessothat v’sparentsetcanbe constructedinthecomposition.Thedualpropertyon thechildrensetofanodeorregioninG alsoholds.Lemma6.GiventwoplacegraphsG
:
m→
n andF:
k→
m suchthatB
:
k→
n=
G◦
F.
Foranynodeorsitev
∈ (
kVF)
suchthat(
prntB(
VGn))(
v)
=
P ,withP= ∅
,thereexistsasetS⊆
m suchthat(
prntFm)(
v)
=
Ss ∈S
prntG
(
s)
=
PLemma7.GiventwoplacegraphsG
:
m→
n andF:
k→
m suchthatB
:
k→
n=
G◦
F.
Foranynodeorregionv
∈ (
VGn)
suchthat(
prnt−B1(
kVF))(
v)
=
C ,withC= ∅
,thereexistsasetR⊆
m suchthat(
prnt−G1m)(
v)
=
Rr ∈R
3.1. Categoricalsemantics
Bigraphswithsharingandtheiroperationscanbedefinedinthegeneralframeworkofcategorytheory.Letusrecallhere thedefinitionsoftwonon-standardkindsofcategoriesintroducedbyMilnerin[1]todefinestandardabstractandconcrete bigraphswithinacategoricalsemantics.
Definition9(Spm category).Apartialmonoidalcategoryissymmetric(spm) if,wheneverX
⊗
Y isdefined,thereisanarrowγ
X,Y:
X⊗
Y→
Y⊗
X calledasymmetry,satisfyingthefollowingequationswhenthecompositionsandproductsaredefined:1.
γ
X,=
idX2.
γ
Y,X◦
γ
X,Y=
idX⊗Y3.
γ
X1,Y1◦ (
f⊗
g)
= (
g⊗
f)
◦
γ
X0,Y0 for f:
X0→
X1andg:
Y0→
Y1 4.γ
X⊗Y,Z= (
γ
X,Z⊗
idY)
◦ (
idX⊗
γ
Y,Z)
Afunctorbetweenspmcategoriespreservesunit,productandsymmetries.
Definition10 (s-category). An s-category
C is a precategory inwhich each arrow f is assigned a finite support|
f|
⊂
S
. Further,C possessesapartialtensorproduct,unitandsymmetries,asinanspmcategory.TheidentitiesidIandsymmetriesγ
I,J areassignedemptysupport.Inaddition:•
For f:
I→
J and g:
J→
K ,thecomposition g◦
f isdefinediff J=
J and|
f|
∩ |
g|
= ∅
;then|
g◦
f|
= |
g|
|
f|
.•
For f:
I0→
I1 and g:
J0→
J1,thetensorproduct f⊗
g is definediff Ii⊗
Ji isdefined(i=
0,
1)and|
f|
∩ |
g|
= ∅
;then
|
f⊗
g|
= |
f|
|
g|
.Weadoptthefollowingnotationalconventions.Givenasignature
K
,wewriteBg(
K)
andBg(
K)
toindicatethe precat-egoryofconcretebigraphsandthecategoryofabstractbigraphs,respectively.Similarly,Pg(K)
(Lg(K)
)andPg(K)
(Lg(K)
) denotetheprecategoryofconcreteplace(link)graphsandthecategoryofabstractplace(link)graphs,respectively.We beginbyshowingthatconcreteplacegraphswithsharingformans-category.Todoso,wehavetointerpretthem asaprecategory.
Proposition8(Precategory ofconcreteplacegraphswithsharing).Givenasignature
K
,SPg(
K)
istheprecategorywhosearrowsare concreteplacegraphswithsharingasgiveninDefinition 1andobjectsarefiniteordinals.Identitiesareplacegraphsidm:
m→
m andcompositionissetoutinDefinition 2.
Beforepresentingthemainresult,weprovebifunctorialityoftensorproductforconcreteplacegraphswithsharing.
Lemma9(Bifunctoriality 1).If A0
:
n0→
n1,A1:
n1→
n2,B0:
m0→
m1andB1:
m1→
m2arefourconcreteplacegraphswithsharingwithdisjointnodesets,then
(
A1⊗
B1)
◦ (
A0⊗
B0)
= (
A1◦
A0)
⊗ (
B1◦
B0)
.Lemma10(Bifunctoriality 2).Ifidmandidnaretwoplacegraphswithsharingthenidm
⊗
idn=
idm⊗n.Wenowcancastconcreteplacegraphswithsharingtos-categories:
Proposition11.Givenasignature
K
,precategorySPg(
K)
equippedwithafinitesupportVF foreveryarrowF:
m→
n,apartialtensorproductlikeinDefinition 3andsymmetries
γm
,n,isans-category.We proved that concreteplace graphswith sharingbelong to thesamekind ofcategory ofPg
(
K)
.Therefore, SPg(
K)
togetherwithLg
(K)
canbeusedtoforms-categorySBg(K)
ofconcretebigraphswithsharing.Thespmcategoryofabstract bigraphs withsharing isthen obtained by applyinga lean-support quotientfunctor[·]
:
SBg(K)
→
SBg(K)
defined asin standard bigraphs. Usualprojection functorslikeF
P:
SBg(
K)
→
SPg(
K)
andF
L:
SBg(
K)
→
Lg(
K)
can alsobedefinedby dropping thelinkgraphandtheplacegraph,respectively.Since functionsarebinary relations,Pg(K)
isa sub-categoryofSPg
(
K)
.ThisrelationshipbetweenthetwocategoriesismadeexplicitbyinclusionfunctorI
:
Pg(
K)
→
SPg(
K)
.Following the same argument, Pg(K)
is a sub-category of SPg(K)
withI
acting as inclusion functor. The relationships betweenSPg
(K)
andothercategoriesaresummarisedinFig. 6.Byanabuseofnotation,wewriteI
,I
toindicateinclusionfunctors,F
P,F
Pforfunctorsprojectingintoplacegraphs,and[·]
todenotelean-supportquotientfunctors.Wenowshowthatbigraphswithsharingformawidecategory,i.e.thereexistsafunctorwidthwhichallowstointerpret any bigraphwithsharing asafunction betweenfiniteordinals. First,we define functor
W
:
SPg(
K)
→
Rel to movefrom bigraphswithsharingtothecategoryofbinaryrelationsbetweenordinals.Itactsastheidentityonobjectsandisdefined oneveryarrowGP:
m→
n asfollows:Fig. 6. Bigraphical categories.
Note that Rel corresponds tothe class ofnode-free placegraphs withsharing. Second,we define functor width to move directlyto Finord by mappingevery siteof abigraph withsharing tothe setof itsregion ancestors.In moredetail, for everyarrowGP
:
m→
n andforeverysitei∈
m wedefinewidth
(
G)(
i)
=
j such that j∈
2nand∀
x∈
j.(
i,
x)
∈
prnt+G.
ApropertyenjoyedbySPg
(K)
isself-duality.Thiscanbeprovedbyshowingthattheinverseofanyarrowisstillaplace graphwithsharing.Inmoredetail,foreveryarrowG:
m→
n wecanconstructitsinversearrowGop:
n→
m inwhichsitesandregions areswapped, prntGop
=
prnt−G1,andGop is itselfan arrowofSPg(K)
. Notethatplace graphswithoutsharing arenotself-dual.Forexample,ifwetrytoconstructtheinverseofjoin:
2→
1,weobtainprnt−1(
0)
=
0 andprnt−1(
0)
=
1, whichisnotafunction.ThereforejoinopisnotanarrowofPg(K)
.Finally,wecharacteriseepimorphisms(epis)andmonomorphisms(monos)inSPg
(K)
.Therearetwoconsiderationsthat help understanding their definitions. The first one is that epis are the inversearrows of monos, and vice versa, dueto self-dualityofplacegraphs withsharing. Notethatthisisnot thecaseinstandard bigraphs.The second considerationis thatepis(monos)instandardplacegraphsarealsoepis(monos)inplacegraphswithsharing,sincePg(K)
isasub-category ofSPg(K)
.Letusintroducesometerminology.Aregionisidle ifithasnochildrenwhereasasiteisanorphan ifithasnoparents. Twositeswiththesameparentsarecalledsiblings and,dually,tworegionswiththesamechildrenarecalledpartners.
Proposition12(Epis forplacegraphswithsharing).Aconcreteplacegraphwithsharingisepiiffnoregionisidleandnotworegions arepartners.
Proposition13(Monos forplacegraphswithsharing).Aconcreteplacegraphwithsharingismonoiffnotwositesaresiblingsand nositeisanorphan.
EpisandmonosinSBg
(K)
arethearrowsinwhichboththeplacegraphandthelinkgraphareepiandmono, respec-tively.3.2. Algebraandnormalform
Wenowshowthat bigraphswithsharingcanbeexpressedbymeansofcomposition andtensorproductstartingfrom a minimal set ofelementary building blocks. Thisresults in an algebraic form similar to the one for standard bigraphs introduced byMilnerin[1].Alsoinbigraphswithsharing, nodesareintroduced byonlyone kindofelementarybigraph calledions. ForeachcontrolK withar
(
K)
=
n,an ionconsistsofasingleK-nodethat iswithinone region,contains asite andhasportslinkedbijectivelyton distinctnamesx.NotationKx:
1→
1,
{
x}
expressesthisbigraph.Thecorrespondingelementary place graph is indicated by K
:
1→
1. Two additional elementary place graphs are required: 0:
1→
0 and split:
1→
2.Theyarethedualbigraphsof1:
0→
1 and join:
2→
1,respectively.Theyareessentialtorepresentorphans andsharedplaces.TheentiresetofelementaryplacegraphsissummarisedinFig. 7.Node-freeplacegraphswithsharing,againcalledplacings,arerangedoverby
φ,
ψ,
. . .
.Aplacingwithoneregionand n sitesisdenotedbymergen,wheremerge0=
1,merge1=
id1 andmerge2=
join.Dually,weindicateaplacingwithonesiteandn regionsbysharen.Notethatshare0
=
0,share1=
id1andshare2=
split.Inthefollowing,B,G,
ω
,ψ
,etc. aretreatedasexpressionsforbigraphs,butequality‘=
’issemantical,i.e.B=
B means that B and B denotethe samebigraph andnot that they areidentical expressions.Formally,thisis ashorthand forthe moreverbose|
B=
B .Proposition14.Everyplacegraphwithsharingcanbeexpressedasanexpressioncontainingonlytheelementaryplacegraphsgiven inFig. 7asconstantsandcompositionandtensorproductasoperators.
Fig. 7. Elementary place graphs. The additional elementary place graphs required to express sharing are split:1→2 and 0:1→0.
Proof. Weprovethepropositionbyinductiononthenumberofnodesoftheplacegraphwithsharing.Forthebasecase weshowthatnode-freeplacegraphs,i.e.placings,satisfytheproposition.Aplacing
ψ
:
m→
n maybeexpressedasψ
= (
mergen0⊗ · · · ⊗
mergenn−1)
π
(
sharem0⊗ · · · ⊗
sharemm−1)
(1) whereimi=
m,ini
=
n andπ
:
n→
n isapermutation.Sinceapermutation maybegeneratedbycompositionandtensorproductofsymmetries
γm
,n,thepropositionholds.Now,letB
:
m→
n beaplacegraphwithsharingwithk+
1 nodes.Then,ithasaconcretionB:
m→
n withsupportV . Letv∈
V beanodeinwhichnoneofitschildrenarenodes(wecallitaleaf ).SuchanodemustexistbyacyclicityofprntB.Notethat v canstillhavem
≤
m sitesaschildren.Formally,(
u,
v)
∈
prntB ifandonlyifu∈
m .Withoutlossofgenerality weassumectrl(
v)
=
K.LetB1:
m+
1→
n betheplacegraphobtainedfromB byremovingnode v andsubstitutingitwithasite.Furthermore,let
B0:
m→
m+
1 betheplacegraphcontainingthesitesinB andv.ThenwehavethatB=
B1◦
B0.Bydroppingthesupportswecanwrite B
=
B1◦
B0.ButB0 canbedefinedintermsofelementaryplacegraphsasfollows: B0= ψ ◦ (
idm⊗
K)
◦ φ
withψ
:
m+
1→
m+
1φ
:
m→
m+
1.
Therefore,thestatementfollowsbyinductivehypothesisonB1 sinceithask nodes.
2
The constructionpresented intheproof abovecan beadoptedto definea normalformforplace graphswithsharing. Intuitively,aplacegraphwithsharing B canbeexpressedbyiterativelyapplyingtheprocedurefortheconstructionofB0,
untilallitsnodesareconsumed.Theonlydifferenceisthatalltheleafsareremovedinonegoinsteadofremovingonlya singleleafateachstep.Wemakethisprecisebyintroducingthenotionofnormalisedlevels.
Definition11(Level).Alevel L
:
m→
n isaplacegraphwithsharingthatcanbeexpresseduniquely,uptopermutations,asL
= (
i<n−lKi
⊗
idl)
◦ φ ,
withplacing
φ
:
m→
n expressedasin(1).Definition12(Normalised levels).Taketwolevels L1
:
m1→
m2andL0:
m0→
m1 givenby L1= (
K1⊗
K⊗
idl1)
◦ φ
1 L0= (
K0⊗
idl0)
◦ φ
0 K1=
i<m2−l1−1 Ki K0=
i<m1−l0 Kiwith
φ
0:
m0→
m1 andφ
1:
m1→
m2 placings.Wesaythat L1 andL0arenormalised if((
K1⊗
idl1+1)
◦ φ
1)
◦ ((
K0⊗
K⊗
idl0)
◦ φ
0)
=
L1◦
L0,
foranyK andanyplacings
φ
0:
m0→
m1+
1φ
1:
m1+
1→
m2.
In words,thismeans thatK isnot aleaf.Thus, itcannot bepushed downa levelandL0 isalreadyamaximal setof
leafsinL1
◦
L0.Whenconsideringseverallevels Ln◦ · · · ◦
L0,wesaythatthelevelsarenormalisedifeverypairofadjacentFig. 8. Graphical representation of SNF for place graph with sharing B.
Proposition15(SNFforplacegraphswithsharing).EveryplacegraphwithsharingB
:
m→
n canbeexpresseduniquely,upto permutations,asB
= ψ ◦
Ll−1◦ · · · ◦
L0where
ψ
isaplacingandeachLiisanormalisedlevel.AgraphicalexplanationofthedefinitionisshowninFig. 8.
Example1.WenowuseSNFtoexpressplacegraphBP
:
0→
1 giveninFig. 5b: BP=
merge3
◦
L1◦
L0 L1= (
A⊗
B⊗
C⊗
id0)
◦ φ
φ
= (
id1⊗
merge2⊗
merge3)
◦ (
id2⊗
γ
1,1⊗
id2)
◦ (
share3⊗
share2⊗
id1⊗
0)
L0= (
E⊗
D⊗
F⊗
G⊗
id0)
◦ (
1⊗
1⊗
1⊗
1) .
Thisnormalformcanalsobeextendedtorepresentbigraphswithsharing.Sincenodesaretheonlystructureincommon betweenlinkgraphsandplacegraphs,itsufficestoreplacethenodegeneratordescribedabovewiththeionKx
:
1→
1,
{
x}
definedforstandardbigraphs.Hence,extendedlevels L
:
m→
n,
Xaredefinedasfollows:L
= (
i<n−lK{ xi}
⊗
idl)
◦ φ ,
where X
=
i{
xi}
.Since normalisationisdefinedoverplace graphs,thedefinitionofnormalised levelsisnot affectedbytheintroductionofions.
Proposition16(SNFforbigraphswithsharing).EverybigraphwithsharingG
:
m,
X→
n,
Ymaybeexpressed,uptopermutations andrenaming,asG
= (ψ ⊗
ω
)
◦
Sl−1◦ · · · ◦
S0 Si=
Li⊗
idXiwhere
ψ
isaplacingwithouterinterfacen,ω
isalinkingwithouterinterfaceY ,andeachLiisanormalisedextendedlevel.AlsotheinnerfaceofL0ism andX0
=
X .The algebraic operators defined forstandard bigraphs(e.g. merge product (_
_), parallel product (_|
_)and nesting (_.
_))canalsobeusedtoexpressbigraphswithsharing.However,anadditionaloperatorcapableofexpressingsharingis required.Wedefineshareexpressions asshare F by
φ
in Gdef=
G◦ (φ ⊗
idX)
◦
Fwhere
φ
isaplacingandalltheoperationsareassumeddefined.3.2.1. Axiomsforbigraphicalequality
Wenowintroduce asetofaxiomsthat allowproof ofeveryvalidequationbetweenbigraphicalexpressions. Wewrite
B=
B toindicateequalityinferredfromtheaxioms.Recallthattheexistence offunctorW
:
SPg(
K)
→
Rel assuresthat anyplacingφ
:
m→
n isalsoarelationbetweenfiniteordinalsm andn.Thus,φ
canalsobeviewedasanarrowincategoryRel.In[2,Theorem7],Mimramprovesthatacompleteaxiomatisation ofRel isgivenbytheequationaltheoryofqualitative bicommutative bialgebrae. Thisallows us todefine a completeaxiomatisation for placings withsharing asa supersetof
Table 1
Axiomsfor(standard)placegraphequality. Categoricalaxioms: A◦id= A=id◦A (cat1) A◦ (B◦C)= (A◦B)◦C (cat2) A⊗id= A=id⊗A (cat3) A⊗ (B⊗C)= (A⊗B)⊗C (cat4) idI⊗idJ=idI⊗J (cat5) (A1◦A0)⊗ (B1◦B0)= (A1⊗B1)◦ (A0⊗B0) (cat6) γI,=idI (cat7) γJ,I◦γI,J=idI⊗J (cat8) γI,K◦ (A⊗B)= (B⊗A)◦γH,J (A:H→I,B:J→K) (cat9) Placeaxioms:
join◦ (join⊗id1)=join◦ (id1⊗join) (plc1) join◦ (1⊗id1)=id1 (plc2)
join◦γ1,1=join (plc3)
Table 2
Additionalaxiomsforplacegraphswithsharingequality. Co-monoidaxioms:
(split⊗id1)◦split= (id1⊗split)◦split (co-plc1)
(0⊗id1)◦split=id1 (co-plc1)
γ1,1◦split=split (co-plc1)
Bialgebraaxioms:
split◦join= (join⊗join)◦ (id1⊗γ1,1⊗id1)◦ (split⊗split) (bia1)
0◦join=0⊗0 (bia2)
split◦1=1⊗1 (bia3)
0◦1=id0 (bia4)
join◦split=id1 (bia5)
the axioms for Pg
(K)
introduced by Milner. These are reported in Table 1. The additional axiomsthat are required to obtaincompletenessoverplacegraphswithsharingformthequalitativebialgebra(
{
0},
join,
1,
split,
0,
γ
1,1)
.TheyaregiveninTable 2.
Proposition17(Completeness).ThesetofaxiomsinTables 1 and2iscompleteforexpressionsdenotingplacegraphswithsharing. Formally,B
=
B impliesB=
B forallexpressionsB,B .Proof(Outline). First,weshowthat
B=
E andB=
E ,whereE andE areSNFexpressions.ObservethatProposition 15assures thatsuch expressionsexistforanyplacegraphwithsharing.Second,we showthat thetwonormalformscanbe provenequal,i.e.
E=
E .Thisamountstoshowingthatthetwoexpressionsonlydifferbypermutationsoftheionsinthe levels: Eψ
◦
Ll−1◦ · · · ◦
L0=
Eψ
◦
L l−1◦ · · · ◦
L 0ψ ◦
Ll−1(
i Ki⊗
idl)
◦ φ ◦ · · · ◦
L0= ψ
◦
L l−1(
i Kπ(i)⊗
idl)
◦ φ
◦ · · · ◦
L 0Table 3
Axiomsforlinkgraphequality. Linkaxioms: x/x=idx (lnk1) z/(Yy)◦ (idY⊗y/X)=z/YX (lnk2) /y◦y/x=/x (lnk3) /y◦y/=id (lnk4) Nodeaxiom: (id1⊗α)◦Kx=Kα(x) (node)
E=
ψψ
◦ (
π
⊗
idl)
◦(
i Ki⊗
idl)
◦ (
π
⊗
idl)
◦ φ
◦ · · · ◦
L 0..
.
whereequalitybetweenexpressionsforplacings(e.g.
ψ = ψ
◦ (
π
⊗
idl)
)canbeprovedbycompletenessoftheaxiomsin Tables 1 and2forexpressionsofplacingswithsharing.2
Example2.Considerthefollowingexpressionsofplacingswithsharing:
φ
= (
id1⊗
join)
◦ (
split⊗
id1)
φ
= (
join⊗
join)
◦ (
share3⊗
id1) .
WenowshowhowtheadditionalaxiomsinTable 2arerequiredtoproveequalitybetween
φ
andφ
:φ = φ
φ = (
join⊗
join)
◦ (((
split⊗
id1)
◦
split)
⊗
id1)
by definition of share3φ = (
join⊗
join)
◦ (((
split⊗
id1)
◦
split)
⊗ (
id1◦
id1))
by(cat1)φ = (
join⊗
join)
◦ (
split⊗
id1⊗
id1)
◦ (
split⊗
id1)
by(cat6)φ = (
join⊗
join)
◦ (
split⊗
id2)
◦ (
split⊗
id1)
by(cat5)φ = ((
join◦
split)
⊗ (
join◦
id2))
◦ (
split⊗
id1)
by(cat6)φ = ((
join◦
split)
⊗
join)
◦ (
split⊗
id1)
by(cat1)Atthispoint,theonlywaytoreducetheright-handsideisbyinvokinganadditionalaxiomasfollows:
φ = (
id1⊗
join)
◦ (
split⊗
id1)
by(bia5).ThisresultcanbeextendedtoSBg
(K)
byincludingMilner’saxiomsforexpressionsoverlinkingsgiveninTable 3.Recall thatelementaryclosures andelementarysubstitutions aredenotedby/
x: {
x}
→ ∅
and y/
X:
X→ {
y}
,respectively.4. Matchingofbigraphswithsharing
ThebigraphmatchingproblemisacomputationaltaskinwhichabigraphP ,calledpattern,andabigraphT ,calledtarget, aregivenasinput,andonemustdeterminewhetherP occursinT .Thisproblemplaysafundamentalrôleinthedefinition ofBRSasan instanceoftheproblemariseseverytime areactionruleisapplied,inparticularwhentheoccurrencesofa redexneedtobecomputed.Moreover,wewillshowinSection5thatitispossibletoreducetheverificationofpredicates expressedin afragment of BiLog to one ormoreinstances ofbigraphmatching. Letusformally define an occurrenceas follows:
Definition13(Occurrence,matching).Abigraph P occurs inabigraph T iftheequation T
=
C◦ (
P⊗
idI)
◦
D holdsforsomeinterface I
=
m,
XandbigraphsC andD.Twooccurrencesaredefinedtobethesameiftheydifferonlybyapermutation on C ’ssitesand D’srootsorby abijectiverenamingon theinnernamesof C andtheouter namesof D.We saythat P matches T or P isamatch in T whenP occursinT .Fig. 9. Match T=C◦ (P⊗idI)◦D.
Identifying matchesinvolvingrenamingsandpermutationsontheinterfacesisessential tocountcorrectlythenumber ofmatches. Further,inastochasticsettingthisallows forthecomputation ofstochasticrates [3].Wecall bigraphsC and D thecontext and theparameter (of P ), respectively. Thedecomposition ofabigraph T inducedby occurrence P canbe describedconvenientlybymeansofdiagramsasinFig. 9.ObservethatidentityidI isnecessarytoallownodesinC tohave
childrenalsoinD,andtoallowC andD tosharelinksthatdonotinvolveP .Thisistheonlydifferencewiththedefinition ofmatchingforstandardbigraphsintroducedbyMilner,inwhich I
=
0,
X.Whenconsideringconcretebigraphs,thesupportsof
T andP havetobecompatibleinordertofindavalidoccurrence.Definition14(Concrete occurrence).Let
P andT betwoconcretebigraphs.Wesaythereisaconcreteoccurrence ofP inT if P occursinT ,withP andT theabstractionsofP andT ,respectively.Thedefinitionaboveimpliesthatwhen
P occursinT ,thereexistsasupporttranslationρ
suchthatT=
C◦ (
P⊗
idI)
◦
Dand
P=
ρ
P .Moreover,-equivalentoccurrencesareregardedasthesame.Thedecompositioninducedbyanoccurrence canbedescribedbyapair(ι,
η
)
,inwhichthefirstelementisasupporttranslationfromVP to VP⊆
VT (i.e.ι
=
ρ
V)andη
isa mappingfromthelinksof P to thelinksofT . NotethatρE
⊆
η
becauseunlikeρE
,η
mapsbothouternamesand edges.4.1. Algorithm
We nowpresentagraph-theoreticmatchingalgorithmforconcretebigraphswithsharing,afterintroducingsome defi-nitionsandnotationalconventions.Equivalentlinksaredefinedasfollows:
Definition15.Taketwolinksl
,
k inabigraph F:
m,
X→
n,
Y.Equivalencerelation=
.
isdefinedasfollowsl
=
.
k iff count(
l)
=
count(
k)
andτ
(
l)
=
τ
(
k)
where
τ
(
l)
=
name if l
∈
Yedge if l
∈
EFand points(
l)
⊆
PF open-edge otherwiseandcount
(
l)
def= {{
v| (
v,
i)
∈
ports(
l)
}}
isamultiset.WealsodefineanexplicittransformationfromconcreteplacegraphstoDAGsasfollows.
Definition16(Underlying graph).Let F
= (
VF,
ctrlF,
prntF)
:
m→
n beaconcreteplacegraph.DirectedgraphG
F= (
V,
E)
iscalledtheunderlyinggraph ofF .ThesetofnodesisV
=
VF andthesetofedgesisE=
VF,VFprntFVF.The transformation consists of dropping all the roots and sites from bigraph F . An important property is that any control-preserving graph isomorphism
ι
betweentwo underlying graphs is a support translationρV
between the corre-spondingplacegraphswhensitesandrootsareignored.Formally,ι
:
G
F→
G
G isabijectionsuchthatctrlF(
u)
=
ctrlG(ι(
u))
,ctrlF
(
v)
=
ctrlG(ι(
v))
and(
u,
v)
∈
prntF iff(
ι
(
u),
ι
(
v))
∈
prntG.
Thisisequivalenttowriting
(
VGprntGVG)
◦
ι
=
ι
◦ (
VFprntFVF) .
Hence,
ι
satisfies Definition 6 when roots and sites are ignored. This correspondence betweenι
andρV
motivates the reductionofthematchingproblemtothesub-graphisomorphismproblem.Graphisomorphismsandmapsbetweenlinksareindicatedby
ι
andη
,respectively.WewriteG
T todenotethesub-graphof
G
T thatisisomorphic viaι
toG
P.Therefore,VT⊆
VT istherangeofι
.When anisomorphismisappliedtoaport weFig. 10. Example wireless network of three stations (a) and its bigraphical representation (b).
Fig. 11. Example reaction rule R R modelling a station moving to a space location not covered by other signals.
not considered.Inthefollowing,we assumethepatternandthetargetare P
:
m,
X→
n,
YandT:
m,
X→
n,
Y , respectively.Finally,thesetofidlelinksofconcretebigraph P isdefinedbyPL idle
def
= {
l∈
EPY|
pointsP(
l)
= ∅} .
We are now ready to presentthe matching algorithm. We begin with an informal outline. The inputsof the algorithm are twoconcretebigraphs: thefirstbeingthepatternwhilethe secondis thetarget.The outputis thesetofpairs
(ι,
η
)
specifyingalltheoccurrencesofthepatterninthetarget.Thefirstphaseofthealgorithmconsistsofinvokingaprocedure that solves thesub-graph isomorphismproblem. Theunderlyinggraphs ofthe patternandthetarget areused asinputs. Theoutputisasetofgraphisomorphisms.Inthenextphase,thealgorithmchecksthateveryisomorphismobtainedinthe previousphasesatisfiesthefollowingcompatibility conditions:
•
Nodecontrolsarepreserved.•
Thepatternhassitesandrootsallowingfortheconstructionofacontextandaparameterbydecomposingthetarget.•
Nonodeinthecontexthasanancestorinthepattern.Alltheisomorphismsfailingtopassanyofthechecksabovearediscarded.Finally,outputpairsarecomputedbyassociating every compatibleisomorphismwitha mappingfromthepatternlinkstothe targetlinks. Eachmappingensuresthat the linkgraphofthepatterncanbecomposedwiththelinkgraphofacontextandthelinkgraphofaparameter,bothobtained bydecomposingthetarget.Iftheprocedurefailstobuildsuchamapping,thenthecorrespondingisomorphismisdiscarded. Beforepresentingthefullspecificationofthealgorithm,weillustratewithasimpleexamplehowthealgorithmcomputes theoccurrencesinamatchinginstance.
Example3.ConsiderthewirelessnetworkgiveninFig. 10aanditsbigraphicalencodingB
:
→
1,
{
aA,
aB,
aC}
describedin Fig. 10b.Inthismodel,nodesofcontrolMandSencodestationsandwirelesssignals,respectively.Moreover,eachstation islinkedtoitssignalandanouternameencodingitsuniquenetworkaddress.Nowtakereactionrule R R described bythediagraminFig. 11whichmodelsastationmovingtoaspacelocationnotcoveredbyothersignals.Ontheleft-hand side,theregioncontainingtheM-noderepresentsthefactthatthestationmaybewithintherangeofzeroormoresignals (besidesitsownsignal).Ontheright-handside,themachinecanonlybeintherangeofitssignal.Inordertocomputeall thebigraphsthatcanbegeneratedbyapplyingrule R R to B,wehavetocomputealltheoccurrencesof R inB.Accordingtothealgorithmoutlinedabove,thefirststepconsistsofcomputingconcretions
B andR.Thenasetofgraph isomorphisms between the underlyinggraphs of the pattern andthe target are computed. In thiscase, there are seven possibleisomorphisms andall ofthemsatisfy thethree compatibilityconditions.Intuitively,each isomorphismassociates theedgewithformS