AREQUIPA PERÚ
CONCEPTO DE PROFESIÓN, PROFESIONISTA Y DISCIPLINA
Occurrence representation for sets works on sets of integers. It uses a matrix of booleans indexed by the possible elements of the set. Membership is denoted by atrueassignment to the corresponding position in the matrix. i’th position of the matrix istrueiffiis a member of the set, andfalseif it is not. Set cardinality is not stored separately as it can easily be calculated using asumover all the booleans. One advantage of the occurrence representation is its uniform applicability to integer sets independent of the size attributes of a set. It can
be applied to both those sets with a known cardinality and those with a variable cardinality.
Figure 6.1gives the rule used by Conjureto implement representation selection for the
Occurrence representation. The first line gives a name to the representation. The second line gives the output domain: when applied, this rule always generates a domain of the form
matrix indexed by [&tau] of bool. In this domain,&tauis a meta-variable and its value is not known yet. Line 3 is a condition: this rule is only applicable if&tauhas an integer type. After this preamble 5 cases are listed. Each case has a domain pattern and optionally structural constraints.
The first case contains a set domain without any size attributes. In such a case no structural constraints can be posted: any assignment to the matrix domain gives a valid assignment to the set domain. The second case contains a set domain with asizeattribute. The pattern also contains a ‘..’ next to thesize attribute, this syntax indicates that the pattern should ignore other attributes of this domain if there are any. The ‘..’ syntax can be used in this case because once a size attribute is given, other attributes of a set domain are irrelevant. The third and forth cases contain set domains with aminSizeand
maxSizeattribute respectively. They post appropriate structural constraints to constrain the cardinality of the set. The fifth and the final case contains a set domain with both the
minSizeand themaxSizeattributes. In this case, a conjunction of two constraints are posted to constrain the cardinality of the set from both ends.
6.1.1.1 Vertical rules
The rule given inFigure 6.2is used when refining a quantified expression over set decision variables or parameters that are represented using the Occurrence representation. It matches all three kinds of quantified expressions in Essence: forAll,existsandsum. The quantifier
keyword is bound to the meta variable&quan. It replaces a quantified expression over a set decision variable into a simple quantified expression, one quantifying over an integer domain. The quantified variable&irepresents elements in the set in the original expression, and it represents indices of the matrix in the output expression. Indices of a set with the
1 [ 1 0 0 0 ] 2
3 &quan &i i n &s , &g . &k
4 ;
5 &quan &i : &tau , &g /\ &m[&i]
6 . &k
7
8 where &s hasDomain ‘ s e t ( . . ) o f &tau‘ 9 where &s hasRepr S e t ~Occurrence
10
11 l e t t i n g &m be r e f n (&s)
Figure 6.2: Vertical rule for Quantified expressions and Occurrence representation of sets
1 [ 9 0 0 ] 2
3 &x i n &s ; r e f n (&s) [&x] = t r u e 4
5 where &s hasRepr S e t ~Occurrence
Figure 6.3: Vertical rule for membership operator and Occurrence representation of sets
occurrence representation correspond to elements of the set if the matrix contains atrue
value in the corresponding position. A new guard is added to the output expression so the bodyof the quantified expression is only active for those values that are in the set.
This vertical rule is the only rule required for representations of set domains. All other set operators can be refined using horizontal rules. These horizontal rules are given in
Section 6.6.1.
For example the expression «forAll i in a , i > 3 . i in b» will be refined to «forAll i : int(..) , i > 3 /\ a’[i] . i in b» using this rule, wherea’is the
refinement of a.
Figure 6.3defines a vertical rule which is not necessary for completeness. If this rule was left out, Conjurewould use a horizontal rule (Figure 6.37) to rewrite expressions using
theinoperator into expressions using anexistsquantified expression to be further refined using the existing vertical rule for quantified expressions: Figure 6.2.
1 ; S e t ~ E x p l i c i t
2 ; matrix indexed by [ i n t ( 1 . .&size_) ] o f &tau 3 ; a l l D i f f ( r e f n )
4
5 ∗∗∗ s e t ( s i z e &size_, . . ) o f &tau
Figure 6.4: Explicit representation for set domains with fixed cardinality.
For example the expression «3 in s» will be refined to «s’[3]» using this rule, where
s’is the refinement of s.