This page provides a detailed description of the set of declarations from the CPN for the Distributed database which is one of the example nets.
Explanation
val n = 4;
: Declares a value (i.e., a constant). In this case the constantn
is bound to the value4
.colset DBM = index d with 1..n;
: Declares an index color set namedDBM
. The color set consists of the set of elements {d(i)
| i = 1..n
}, i.e. the set {d(1)
,d(2)
,d(3)
,d(4)
}.colset PR = product DBM * DBM;
: Declares a product color set namedPR
. Each value (i.e. color) inPR
is a pair, where each element of the pair is of typeDBM
. The values inPR
have the form(d(i), d(j))
wherei
andj
are integers between 1 and 4. For example, the value(d(1),d(4))
is an element inPR
, but the value(d(1),d(10))
is not an element inPR
.fun diff(x,y) = (x<>y);
: Declares a function nameddiff
which has two formal parametersx
andy
. The function returnstrue
if the values bound tox
andy
are not equal, otherwise returnsfalse
.colset MES = subset PR by diff;
: Declares a subset color set namedMES
which is a subset of the color setPR
. The color setMES
consists of the values ofPR
that are mapped totrue
by the functiondiff
. For example, the value(d(1),d(2))
is inMES
, but the value(d(3),d(3))
is not inMES
.colset E = with e;
: Declares an enumerated color set namedE
. The only element inE
is the valuee
.fun Mes(s) = PR.mult(1`s, DBM.all()--1`s);
: Declares a function namedMes
which has one formal parameters
. The functionMes
returns a multiset of elements from the color setPR
.
The multiset that is returned byMes
is generated using the functionPR.mult
. The functionmult
is one of the color set functions that is available for product color sets. The two arguments for the functionPR.mult
are multisets of elements from the color setDBM
. The first argument consists of the multiset1`s
, i.e. the multiset consists of a single element, and the value of the element is determined by the binding of the parameters
.
The second multiset is generated using theDBM.all
function and multiset subtraction. Evaluating the color set functionDBM.all()
will result in the multiset with one of each element from the color setDBM
.
SupposeMes(d(2))
is called, in which case, the formal parameters
is bound to the valued(2)
. The results of evaluating subexpressions in the body of the functionMes
are described below:Expression Evaluates to 1`s 1`d(2) DBM.all() 1`d(1)++1`d(2)++1`d(3)++1`d(4) DBM.all()--1`s 1`d(1)++1`d(3)++1`d(4) PR.mult(1`s,DBM.all()--1`s) 1`(d(2),d(1))++1`(d(2),d(3))++1`(d(2),d(4)) Mes(d(2)) 1`(d(2),d(1))++1`(d(2),d(3))++1`(d(2),d(4)) var s,r : DBM;'
‘: Declares two variables,s
andr
, which have typeDBM
.
Size of color sets
All of the color sets in this example are small, i.e. they contain a finite number of elements. More information is available about the size and complexity of color sets.
You must be logged in to post a comment.