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.

The Declarations
Explanation
val n = 4;: Declares a value (i.e., a constant). In this case the constantnis 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) inPRis a pair, where each element of the pair is of typeDBM. The values inPRhave the form(d(i), d(j))whereiandjare 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 nameddiffwhich has two formal parametersxandy. The function returnstrueif the values bound toxandyare not equal, otherwise returnsfalse.colset MES = subset PR by diff;: Declares a subset color set namedMESwhich is a subset of the color setPR. The color setMESconsists of the values ofPRthat are mapped totrueby 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 inEis the valuee.fun Mes(s) = PR.mult(1`s, DBM.all()--1`s);: Declares a function namedMeswhich has one formal parameters. The functionMesreturns a multiset of elements from the color setPR.
The multiset that is returned byMesis generated using the functionPR.mult. The functionmultis one of the color set functions that is available for product color sets. The two arguments for the functionPR.multare 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.allfunction 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 parametersis bound to the valued(2). The results of evaluating subexpressions in the body of the functionMesare 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,sandr, 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.