Signature Operations
In section Composition of Bigraphs, methods are introduced to combine bigraphs in arbitrary ways via operators (e.g., composition, parallel product, or merge).
Signatures can be defined using similar operations, which are useful when combining bigraphs that adhere to different signatures. Additionally, we can build signatures incrementally, starting from a singleton signature. A singleton signature contains a single control and can be regarded as a notational convenience.
Some operations for signature are formally defined in [1] and implemented in Bigraph Framework. Variations of signature composition are discussed in [2]. Below are some examples.
Signature Consistency​
Some operations on signatures require the notion of signature consistency.
Two signatures and are consistent if and only if for every control that is present in both signatures:
- The control has the same arity in both signatures.
- The control is either active in both signatures, passive, or atomic in both (i.e., they have the same status).
note
Signature consistency is automatically checked when composing signatures.
Signature Composition​
Signature composition is commutative and associative iff signatures are consistent as defined above:
Signature composition can be performed via the method org.bigraphs.framework.core.utils.BigraphUtil#composeSignatures.
note
If signatures are not consistent, the exception SignatureNotConsistentException
will be thrown.
Example
DefaultDynamicSignature sig1 = pureSignatureBuilder()
.addControl("A", 1)
.addControl("B", 1)
.addControl("C", 1)
.addControl("D", 1)
.create();
DefaultDynamicSignature sig3 = pureSignatureBuilder()
.addControl("E", 2)
.addControl("F", 3)
.addControl("G", 4)
.create();
DefaultDynamicSignature sigComp_1_3 = BigraphUtil.composeSignatures(sig1, sig3);
assert sigComp_1_3.getControls().size() == 7;
Signature Merge​
When signatures are non-consistent, a variant of signature composition can still be performed, where we need to agree on the arity and status of either side. That is, at least one duplicate control can be found among two signatures. Therefore, we define a left-side and right-side merge operator [2].
Merging signatures can be performed via the method org.bigraphs.framework.core.utils.BigraphUtil#mergeSignatures
Example
DefaultDynamicSignature sig1 = pureSignatureBuilder()
.addControl("A", 1)
.addControl("B", 1)
.addControl("C", 1)
.addControl("D", 1)
.create();
DefaultDynamicSignature sig2 = pureSignatureBuilder()
.addControl("A", 2)
.addControl("B", 2)
.addControl("C", 2)
.addControl("D", 2)
.create();
// The last argument specifies the left-side merging (0), or the right-side merging (1)
DefaultDynamicSignature sigMerge_1_2 = BigraphUtil.mergeSignatures(sig1, sig2, 0);
assert sigMerge_1_2.getControls().size() == 4;