sources for a benchmark for ocl engine accuracy ... · sources for a benchmark for ocl engine...

Post on 11-Aug-2020

2 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Sources for aBenchmark for OCL Engine

Accuracy, Determinateness, andEfficiency

Martin Gogolla, Mirco Kuhlmann, Fabian Buttner

May 20, 2008

Contents

I. Benchmark Categories Overview 5

1. Covered UML and OCL Elements 6

II. OCL Engine Implementation Accuracy 10

2. Core Benchmark (B1) 112.1. UML Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.2. Test State for Checking Invariants . . . . . . . . . . . . . . . . . . . . . 132.3. OCL Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

3. Extended Core Benchmark (B2) 273.1. UML Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273.2. System State Evolution for Checking Pre- and Postconditions . . . . . . 29

3.2.1. Test State A: Ada’s Birth . . . . . . . . . . . . . . . . . . . . . . 293.2.2. Test State B: Bob’s Birth . . . . . . . . . . . . . . . . . . . . . . 303.2.3. Test State C: Marriage of Ada and Bob . . . . . . . . . . . . . . 303.2.4. Test State D: Cyd’s Birth . . . . . . . . . . . . . . . . . . . . . . 313.2.5. Test State E: Ada’s and Bob’s Divorce . . . . . . . . . . . . . . . 313.2.6. Test State F: Marriage of Ada and Cyd . . . . . . . . . . . . . . 323.2.7. Test State G: Dan’s Birth . . . . . . . . . . . . . . . . . . . . . . 323.2.8. Test State H: Dan’s Birth . . . . . . . . . . . . . . . . . . . . . . 32

3.3. System States for Evaluating OCL Queries . . . . . . . . . . . . . . . . 343.3.1. Test State – Part 1 . . . . . . . . . . . . . . . . . . . . . . . . . . 343.3.2. Test State – Part 2 (continuation) . . . . . . . . . . . . . . . . . 35

3.4. OCL Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353.4.1. Queries Based On Test State – Part 1 . . . . . . . . . . . . . . . 353.4.2. Queries Based On Test State – Part 2 . . . . . . . . . . . . . . . 38

4. Advanced Modeling Benchmark (B3) 394.1. UML Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394.2. System States for Evaluating OCL Queries . . . . . . . . . . . . . . . . 404.3. Test State – Part 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404.4. Test State – Part 2 (continuation) . . . . . . . . . . . . . . . . . . . . . 414.5. Test State – Part 3 (continuation) . . . . . . . . . . . . . . . . . . . . . 42

2

4.6. OCL Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424.6.1. Queries Based On Test State – Part 1 . . . . . . . . . . . . . . . 424.6.2. Queries Based On Test State – Part 2 . . . . . . . . . . . . . . . 434.6.3. Queries Based On Test State – Part 2 . . . . . . . . . . . . . . . 44

5. Three-valued Logic Benchmark (B4) 465.1. OCL Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

6. OCL Laws Benchmark (B5) 496.1. OCL Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

6.1.1. Reject to Select . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496.1.2. Select to Reject . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556.1.3. Exists to ForAll . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616.1.4. ForAll to Exists . . . . . . . . . . . . . . . . . . . . . . . . . . . . 676.1.5. One to Exists and ForAll (extern) . . . . . . . . . . . . . . . . . 736.1.6. One to Exists and ForAll (intern) . . . . . . . . . . . . . . . . . . 806.1.7. Exists to Reject . . . . . . . . . . . . . . . . . . . . . . . . . . . . 866.1.8. Exists to Select . . . . . . . . . . . . . . . . . . . . . . . . . . . . 926.1.9. ForAll to Reject . . . . . . . . . . . . . . . . . . . . . . . . . . . 986.1.10. ForAll to Select . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1046.1.11. One to Reject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1106.1.12. One to Select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1166.1.13. Exists to Collect and Includes . . . . . . . . . . . . . . . . . . . . 1226.1.14. Exists to Collect and One . . . . . . . . . . . . . . . . . . . . . . 1286.1.15. ForAll to Collect and Excludes . . . . . . . . . . . . . . . . . . . 1346.1.16. ForAll to Collect and One . . . . . . . . . . . . . . . . . . . . . . 1406.1.17. One to Collect . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1486.1.18. Collect to Iterate . . . . . . . . . . . . . . . . . . . . . . . . . . . 1546.1.19. Exists to Iterate . . . . . . . . . . . . . . . . . . . . . . . . . . . 1616.1.20. ForAll to Iterate . . . . . . . . . . . . . . . . . . . . . . . . . . . 1666.1.21. One to Iterate . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1726.1.22. Reject to Iterate . . . . . . . . . . . . . . . . . . . . . . . . . . . 1816.1.23. Select to Iterate . . . . . . . . . . . . . . . . . . . . . . . . . . . 1896.1.24. Iterate to Iterate with let . . . . . . . . . . . . . . . . . . . . . . 1976.1.25. Singleton to Value . . . . . . . . . . . . . . . . . . . . . . . . . . 202

III. OCL Engine Determinateness Properties 211

7. OCL Queries 2127.1. Conversion to Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . 2127.2. Additional Determinateness Properties . . . . . . . . . . . . . . . . . . . 216

IV. OCL Engine Efficiency 231

3

8. UML Models 2328.1. Model A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2328.2. Model B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

9. System States for Evaluation OCL Queries 2359.1. Test State based on UML Model A . . . . . . . . . . . . . . . . . . . . . 2359.2. Test State based on UML Model B . . . . . . . . . . . . . . . . . . . . . 235

10.OCL Queries 23910.1. Queries based on UML Model A . . . . . . . . . . . . . . . . . . . . . . 23910.2. Queries based on UML Model B . . . . . . . . . . . . . . . . . . . . . . 241

4

Part I.

Benchmark Categories Overview

5

1. Covered UML and OCL Elements

B1 UMLB1 models (class diagram)

B2 enumerationsB2 namesB2 literals

B1 classes B1 operationsB1 names B1 namesB1 attributes B1 parameters

B1 primitive types B1 implicit self parameter onlyB1 String B2 explicit parametersB1 Boolean B1 return types

B2 enumeration types B2 no return typesB1 associations

B1 names B1 arityB1 multiplicities B1 binaryB1 explicit role names B3 ternaryB1 reflexiveness B3 properties (association class)

B1 states (object diagram)B1 objects B1 links

B1 creation B1 insertionB1 attribute values B2 deletion

B1 settingB2 changing

B1 OCLB1 definitions

B1 constraintsB2 pre- and postconditions B1 invariants

B2 @pre B1 namesB2 applied to objects B1 evaluation

B2 namesB2 evaluation

B1 queriesB2 state dependent B4 state independentB2 evaluation

B1 expressionsB1 constructors B1 types

B1 Set{}, Bag{}, Sequence{} B1 basicB1 literals B2 enumeration

6

B1 String, Boolean B1 objectB1 variables B2 OclAnyB2 object identifiers B2 TupleB2 tuples B1 collectionB1 nested constructors B1 Set, Bag, SequenceB1 range expressions B1 element types

B1 Integer B1 homogeneousB1 complex expressions B1 heterogeneous

B1 complex expressions B1 complexB2 Tuple{}

B2 component accessB1 literals

B1 Integer, String, BooleanB2 enumeration

B1 operationsB1 parameters

B1 collections B1 literalsB4 empty B1 variablesB4 singleton B2 object identifiers

B4 including undefined value B2 tuplesB1 excluding undefined value B1 complex expressions

B1 many elementsB4 including undefined valueB1 excluding undefined value

B1 typesB1 class B1 object

B1 allInstances B1 <>B1 parentheses B2 oclIsUndefinedB1 no parentheses B1 user-defined query operations

B2 enumeration B1 BooleanB2 =, <>, oclIsUndefined B1 predicates

B2 Integer B2 =, oclIsUndefinedB1 >= B1 connectivesB4 =, <, -, +, * B1 and, or, implies, not

B1 String B4 xorB1 =, <>, substring B1 bindingB1 size

B1 parenthesesB2 no parenthesis

B2 isUndefinedB1 Collection

B1 Set, Bag, SequenceB1 collection of objects

B1 user-defined query operations B1 =B1 excluding, flatten, includes, including

7

B4 asBag, asSequence, asSet, at, count, excludes, exists, first,B4 last, notEmpty, rejectB1 any B1 forAll

B1 (no) variable declaration B1 one iterator variableB1 (no) type declaration B1 two iterator variablesB1 literal false B1 type declarationsB4 literal true B1 no type declarations

B1 iterate B3 sizeB4 one iterator variableB1 two iterator variablesB1 type declarationsB4 no type declarations

B1 collect, isUnique, one, select B1 isEmptyB1 (no) variable declaration B1 parenthesesB1 (no) type declaration B2 no parentheses

B1 checked relationshipsB4 reject, select B4 exists, forAll B4 one, exists, forAllB4 exists, reject B4 forAll, reject B4 forAll, selectB4 one, reject B4 one, select B4 forAll, collect, oneB4 exists, collect B4 forAll, collect, B4 exists, collect,B4 one, B4 excludes B4 includesB4 collect, iterate B4 exists, iterate B4 forAll, iterateB4 one, iterate B4 reject, iterate B4 select, iterate

B1 other statements and conceptsB1 navigation B1 if-then-else-endif

B1 dot notation B1 letB1 sources B1 variables names

B1 objects B1 variables typesB1 collection constructors B1 collectionsB1 complex expressions B1 nested

B1 attribute access B1 selfB1 role name access B1 explicit

B1 directly B2 implicitB3 in role of [ ] ((2 + n)-ary reflexive association)

B1 operation callsB1 standard operationsB1 user-defined query operations

B1 implicit collect and flattenB1 undefined value

B1 provocationB1 navigation from undefined objectB5 invoking first/last on empty sequenceB1 any(false)

B1 handling (three-valued logic with equality)B1 equality (=)

8

B5 and, or, implies B5 if-then-else-endifB5 left argument B5 first argumentB5 right argument B5 second argument

B6 determinateness propertiesB6 order of elements (Sequence) arranged by

B6 asSequence, asBag->asSequence, iterate, any, flattenB7 evaluation efficiency

9

Part II.

OCL Engine ImplementationAccuracy

10

2. Core Benchmark (B1)

Checks basic properties of the following OCL features:

• basic boolean predicates (=, <>)

• boolean connectives (and, or, not, implies, if then else endif)

• data type operations (size, substring)

• user-defined operations (e.g., in the example domain CivilStatus the operationspouse)

• navigation in expressions with dot (.), arrow (->) and dot shortcut for collect(.)

• collection operations (select, collect, forAll, any, isEmpty, iterate, isUnique,one, includes, including, excluding, flatten)

• data type literals resp. constants (e.g., ’Ada’, 2, false) and collections literals(built with Set{...}, Bag{...}, or Sequence{...}), in particular nested collec-tion literals involving OclAny (e.g., ones having type Bag(Sequence(OclAny)))

• abbreviations (let)

• access to instances of a class (allInstances)

• range expressions (low..high)

Avoids features handled syntactically differently by OCL engines:

• enumerations, undefined value, empty collections

(workarounds for these features)Invariants are divided into two groups:

• proper invariants from the example domain CivilStatus

• query invariants, i.e., invariants simulating queries because not all OCL enginessupport evaluation of queries (checking query evaluation of an OCL engine byformulating query invariants: inv QueryTerm = QueryResult) such invariantshold only in particular system states

A single invariant can appear in 6 different syntactic forms:

• 2 choices for allInstances, 3 choices for collection variables

11

• Person.allInstances according to OCL 1Person.allInstances() according to OCL 2

suffix for invariant name P0 no parentheses for allInstancesP1 parentheses for allInstances

• Naming and typing of variables in collection operationsaPersonSet->select(p:Person|p.gender=’female’)aPersonSet->select(p|p.gender=’female’)aPersonSet->select(gender=’female’)

suffix for invariant name VT typed variableVN named variableVI implicit variable

(sometimes the VI form cannot be used)

The following invariants have to be checked without making any syntactic change tothe invariant text. Number of accepted invariants is a measure for the strength of thesyntax accurateness of the OCL engine.

2.1. UML Model

Figure 2.1.: Class Diagram of the Core Benchmark Model

model CivilStatusWorld

class Person

attributesname:Stringcivstat:Stringgender:Stringalive:Boolean

12

operationsspouse():Person=if self.gender=’female’ then self.husband else self.wife endif

end

association Marriage betweenPerson [0..1] role wifePerson [0..1] role husband

end

2.2. Test State for Checking Invariants

Figure 2.2.: Test State of the Core Benchmark Model

!create ada:Person

!set ada.name:=’Ada’!set ada.gender:=’female’!set ada.alive:=true!set ada.civstat:=’widowed’

!create bob:Person

!set bob.name:=’Bob’!set bob.gender:=’male’!set bob.alive:=true!set bob.civstat:=’divorced’

13

!create cyd:Person

!set cyd.name:=’Cyd’!set cyd.gender:=’male’!set cyd.alive:=false!set cyd.civstat:=’married’

!create dan:Person

!set dan.name:=’Dan’!set dan.gender:=’male’!set dan.alive:=true!set dan.civstat:=’married’

!create eve:Person

!set eve.name:=’Eve’!set eve.gender:=’female’!set eve.alive:=true!set eve.civstat:=’married’

!insert (eve,dan) into Marriage

2.3. OCL Constraints

constraints

-------------------------------------------------------------------------- Invariants from the domain ------------------------------------------------------------------------------------------------------------------

context Person inv enumCivilStatus:self.civstat=’single’ or self.civstat=’married’ orself.civstat=’divorced’ or self.civstat=’widowed’

------------------------------------------------------------------------

context Person inv enumGender:self.gender=’female’ or self.gender=’male’

------------------------------------------------------------------------

context Person inv aliveDefined:self.alive=true or self.alive=false

14

------------------------------------------------------------------------

context Person inv nameCapitalThenSmallLetters_VT:let small:Set(String)=Set{’a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,’k’,’l’,’m’,

’n’,’o’,’p’,’q’,’r’,’s’,’t’,’u’,’v’,’w’,’x’,’y’,’z’} inlet capital:Set(String)=Set{’A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’,’K’,’L’,’M’,

’N’,’O’,’P’,’Q’,’R’,’S’,’T’,’U’,’V’,’W’,’X’,’Y’,’Z’} incapital->includes(self.name.substring(1,1)) andSet{2..self.name.size()}->forAll(i:Integer|small->includes(self.name.substring(i,i))) and

self.name.size()>=1

context Person inv nameCapitalThenSmallLetters_VN:let small:Set(String)=Set{’a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,’k’,’l’,’m’,

’n’,’o’,’p’,’q’,’r’,’s’,’t’,’u’,’v’,’w’,’x’,’y’,’z’} inlet capital:Set(String)=Set{’A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’,’K’,’L’,’M’,

’N’,’O’,’P’,’Q’,’R’,’S’,’T’,’U’,’V’,’W’,’X’,’Y’,’Z’} incapital->includes(self.name.substring(1,1)) andSet{2..self.name.size()}->forAll(i|small->includes(self.name.substring(i,i))) and

self.name.size()>=1

------------------------------------------------------------------------

context Person inv uniqueNameForAll1_P0_VT:Person.allInstances->forAll(self2:Person|self<>self2 implies self.name<>self2.name)

context Person inv uniqueNameForAll1_P0_VN:Person.allInstances->forAll(self2|self<>self2 implies self.name<>self2.name)

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

context Person inv uniqueNameForAll1_P1_VT:Person.allInstances()->forAll(self2:Person|

self<>self2 implies self.name<>self2.name)

context Person inv uniqueNameForAll1_P1_VN:Person.allInstances()->forAll(self2|

15

self<>self2 implies self.name<>self2.name)

------------------------------------------------------------------------

context Person inv uniqueNameForAll2_P0_VT:Person.allInstances->forAll(p1,p2:Person|p1<>p2 implies p1.name<>p2.name)

context Person inv uniqueNameForAll2_P0_VN:Person.allInstances->forAll(p1,p2|p1<>p2 implies p1.name<>p2.name)

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

context Person inv uniqueNameForAll2_P1_VT:Person.allInstances()->forAll(p1,p2:Person|p1<>p2 implies p1.name<>p2.name)

context Person inv uniqueNameForAll2_P1_VN:Person.allInstances()->forAll(p1,p2|p1<>p2 implies p1.name<>p2.name)

------------------------------------------------------------------------

context Person inv uniqueNameIsUnique_P0_VT:Person.allInstances->isUnique(p:Person|p.name)

context Person inv uniqueNameIsUnique_P0_VN:Person.allInstances->isUnique(p|p.name)

context Person inv uniqueNameIsUnique_P0_VI:Person.allInstances->isUnique(name)

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

context Person inv uniqueNameIsUnique_P1_VT:Person.allInstances()->isUnique(p:Person|p.name)

context Person inv uniqueNameIsUnique_P1_VN:Person.allInstances()->isUnique(p|p.name)

context Person inv uniqueNameIsUnique_P1_VI:Person.allInstances()->isUnique(name)

------------------------------------------------------------------------

16

context Person inv uniqueNameOne_P0_VT:Person.allInstances->one(p:Person|self.name=p.name)

context Person inv uniqueNameOne_P0_VN:Person.allInstances->one(p|self.name=p.name)

context Person inv uniqueNameOne_P0_VI:Person.allInstances->one(self.name=name)

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

context Person inv uniqueNameOne_P1_VT:Person.allInstances()->one(p:Person|self.name=p.name)

context Person inv uniqueNameOne_P1_VN:Person.allInstances()->one(p|self.name=p.name)

context Person inv uniqueNameOne_P1_VI:Person.allInstances()->one(self.name=name)

------------------------------------------------------------------------

context Person inv uniqueNameOneNot_P0_VI:not Person.allInstances->one(name=name)

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

context Person inv uniqueNameOneNot_P1_VI:not Person.allInstances()->one(name=name)

------------------------------------------------------------------------

context Person inv femaleHasNoWife:self.gender=’female’ implies self.wife->isEmpty()

------------------------------------------------------------------------

context Person inv maleHasNoHusband:self.gender=’male’ implies self.husband->isEmpty()

-------------------------------------------------------------------------- Invariants encoding queries -----------------------------------------------------------------------------------------------------------------

17

context Person inv abcName_P0_VT:let ada=Person.allInstances->any(p:Person|p.name=’Ada’) inlet bob=Person.allInstances->any(p:Person|p.name=’Bob’) inlet cyd=Person.allInstances->any(p:Person|p.name=’Cyd’) inSet{ada,bob,cyd}->collect(p:Person|p.name)=Bag{’Ada’,’Bob’,’Cyd’}

context Person inv abcName_P0_VN:let ada=Person.allInstances->any(p|p.name=’Ada’) inlet bob=Person.allInstances->any(p|p.name=’Bob’) inlet cyd=Person.allInstances->any(p|p.name=’Cyd’) inSet{ada,bob,cyd}->collect(p|p.name)=Bag{’Ada’,’Bob’,’Cyd’}

context Person inv abcName_P0_VI:let ada=Person.allInstances->any(name=’Ada’) inlet bob=Person.allInstances->any(name=’Bob’) inlet cyd=Person.allInstances->any(name=’Cyd’) inSet{ada,bob,cyd}->collect(name)=Bag{’Ada’,’Bob’,’Cyd’}

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

context Person inv abcName_P1_VT:let ada=Person.allInstances()->any(p:Person|p.name=’Ada’) inlet bob=Person.allInstances()->any(p:Person|p.name=’Bob’) inlet cyd=Person.allInstances()->any(p:Person|p.name=’Cyd’) inSet{ada,bob,cyd}->collect(p:Person|p.name)=Bag{’Ada’,’Bob’,’Cyd’}

context Person inv abcName_P1_VN:let ada=Person.allInstances()->any(p|p.name=’Ada’) inlet bob=Person.allInstances()->any(p|p.name=’Bob’) inlet cyd=Person.allInstances()->any(p|p.name=’Cyd’) inSet{ada,bob,cyd}->collect(p|p.name)=Bag{’Ada’,’Bob’,’Cyd’}

context Person inv abcName_P1_VI:let ada=Person.allInstances()->any(name=’Ada’) inlet bob=Person.allInstances()->any(name=’Bob’) inlet cyd=Person.allInstances()->any(name=’Cyd’) inSet{ada,bob,cyd}->collect(name)=Bag{’Ada’,’Bob’,’Cyd’}

------------------------------------------------------------------------

context Person inv abcNameDotShortcutP0_VT:let ada=Person.allInstances->any(p:Person|p.name=’Ada’) inlet bob=Person.allInstances->any(p:Person|p.name=’Bob’) inlet cyd=Person.allInstances->any(p:Person|p.name=’Cyd’) inSet{ada,bob,cyd}.name=Bag{’Ada’,’Bob’,’Cyd’}

18

context Person inv abcNameDotShortcutP0_VN:let ada=Person.allInstances->any(p|p.name=’Ada’) inlet bob=Person.allInstances->any(p|p.name=’Bob’) inlet cyd=Person.allInstances->any(p|p.name=’Cyd’) inSet{ada,bob,cyd}.name=Bag{’Ada’,’Bob’,’Cyd’}

context Person inv abcNameDotShortcutP0_VI:let ada=Person.allInstances->any(name=’Ada’) inlet bob=Person.allInstances->any(name=’Bob’) inlet cyd=Person.allInstances->any(name=’Cyd’) inSet{ada,bob,cyd}.name=Bag{’Ada’,’Bob’,’Cyd’}

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

context Person inv abcNameDotShortcutP1_VT:let ada=Person.allInstances()->any(p:Person|p.name=’Ada’) inlet bob=Person.allInstances()->any(p:Person|p.name=’Bob’) inlet cyd=Person.allInstances()->any(p:Person|p.name=’Cyd’) inSet{ada,bob,cyd}.name=Bag{’Ada’,’Bob’,’Cyd’}

context Person inv abcNameDotShortcutP1_VN:let ada=Person.allInstances()->any(p|p.name=’Ada’) inlet bob=Person.allInstances()->any(p|p.name=’Bob’) inlet cyd=Person.allInstances()->any(p|p.name=’Cyd’) inSet{ada,bob,cyd}.name=Bag{’Ada’,’Bob’,’Cyd’}

context Person inv abcNameDotShortcutP1_VI:let ada=Person.allInstances()->any(name=’Ada’) inlet bob=Person.allInstances()->any(name=’Bob’) inlet cyd=Person.allInstances()->any(name=’Cyd’) inSet{ada,bob,cyd}.name=Bag{’Ada’,’Bob’,’Cyd’}

------------------------------------------------------------------------

context Person inv abcAttrs_P0_VT:let ada=Person.allInstances->any(p:Person|p.name=’Ada’) inlet bob=Person.allInstances->any(p:Person|p.name=’Bob’) inlet cyd=Person.allInstances->any(p:Person|p.name=’Cyd’) inSet{ada,bob,cyd}->collect(p:Person|Sequence{p.name,p.civstat,p.gender,p.alive})=

Bag{Sequence{’Ada’,’widowed’ ,’female’,true },Sequence{’Bob’,’divorced’,’male’ ,true },Sequence{’Cyd’,’married’ ,’male’ ,false}}

19

context Person inv abcAttrs_P0_VN:let ada=Person.allInstances->any(p|p.name=’Ada’) inlet bob=Person.allInstances->any(p|p.name=’Bob’) inlet cyd=Person.allInstances->any(p|p.name=’Cyd’) inSet{ada,bob,cyd}->collect(p|Sequence{p.name,p.civstat,p.gender,p.alive})=

Bag{Sequence{’Ada’,’widowed’ ,’female’,true },Sequence{’Bob’,’divorced’,’male’ ,true },Sequence{’Cyd’,’married’ ,’male’ ,false}}

context Person inv abcAttrs_P0_VI:let ada=Person.allInstances->any(name=’Ada’) inlet bob=Person.allInstances->any(name=’Bob’) inlet cyd=Person.allInstances->any(name=’Cyd’) inSet{ada,bob,cyd}->collect(Sequence{name,civstat,gender,alive})=

Bag{Sequence{’Ada’,’widowed’ ,’female’,true },Sequence{’Bob’,’divorced’,’male’ ,true },Sequence{’Cyd’,’married’ ,’male’ ,false}}

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

context Person inv abcAttrs_P1_VT:let ada=Person.allInstances()->any(p:Person|p.name=’Ada’) inlet bob=Person.allInstances()->any(p:Person|p.name=’Bob’) inlet cyd=Person.allInstances()->any(p:Person|p.name=’Cyd’) inSet{ada,bob,cyd}->collect(p:Person|Sequence{p.name,p.civstat,p.gender,p.alive})=

Bag{Sequence{’Ada’,’widowed’ ,’female’,true },Sequence{’Bob’,’divorced’,’male’ ,true },Sequence{’Cyd’,’married’ ,’male’ ,false}}

context Person inv abcAttrs_P1_VN:let ada=Person.allInstances()->any(p|p.name=’Ada’) inlet bob=Person.allInstances()->any(p|p.name=’Bob’) inlet cyd=Person.allInstances()->any(p|p.name=’Cyd’) inSet{ada,bob,cyd}->collect(p|Sequence{p.name,p.civstat,p.gender,p.alive})=

Bag{Sequence{’Ada’,’widowed’ ,’female’,true },Sequence{’Bob’,’divorced’,’male’ ,true },Sequence{’Cyd’,’married’ ,’male’ ,false}}

context Person inv abcAttrs_P1_VI:let ada=Person.allInstances()->any(name=’Ada’) inlet bob=Person.allInstances()->any(name=’Bob’) in

20

let cyd=Person.allInstances()->any(name=’Cyd’) inSet{ada,bob,cyd}->collect(Sequence{name,civstat,gender,alive})=

Bag{Sequence{’Ada’,’widowed’ ,’female’,true },Sequence{’Bob’,’divorced’,’male’ ,true },Sequence{’Cyd’,’married’ ,’male’ ,false}}

------------------------------------------------------------------------

context Person inv personsWithUndefinedHusband_P0_VT:Person.allInstances->select(p:Person|p.husband=Person.allInstances->any(p:Person|p.wife->isEmpty()).wife

)->collect(p:Person|p.name)=Bag{’Ada’,’Bob’,’Cyd’,’Dan’}

context Person inv personsWithUndefinedHusband_P0_VN:Person.allInstances->select(p|p.husband=Person.allInstances->any(p|p.wife->isEmpty()).wife

)->collect(p|p.name)=Bag{’Ada’,’Bob’,’Cyd’,’Dan’}

context Person inv personsWithUndefinedHusband_P0_VI:Person.allInstances->select(husband=Person.allInstances->any(wife->isEmpty()).wife

)->collect(name)=Bag{’Ada’,’Bob’,’Cyd’,’Dan’}

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

context Person inv personsWithUndefinedHusband_P1_VT:Person.allInstances()->select(p:Person|p.husband=Person.allInstances()->any(p:Person|p.wife->isEmpty()).wife

)->collect(p:Person|p.name)=Bag{’Ada’,’Bob’,’Cyd’,’Dan’}

context Person inv personsWithUndefinedHusband_P1_VN:Person.allInstances()->select(p|p.husband=Person.allInstances()->any(p|p.wife->isEmpty()).wife

)->collect(p|p.name)=Bag{’Ada’,’Bob’,’Cyd’,’Dan’}

21

context Person inv personsWithUndefinedHusband_P1_VI:Person.allInstances()->select(husband=Person.allInstances()->any(wife->isEmpty()).wife

)->collect(name)=Bag{’Ada’,’Bob’,’Cyd’,’Dan’}

------------------------------------------------------------------------

context Person inv personsWithUndefinedHusbandAnyFalse_P0_VT:Person.allInstances->select(p:Person|p.husband=Person.allInstances->any(p:Person|false)

)->collect(p:Person|p.name)=Bag{’Ada’,’Bob’,’Cyd’,’Dan’}

context Person inv personsWithUndefinedHusbandAnyFalse_P0_VN:Person.allInstances->select(p|p.husband=Person.allInstances->any(p|false)

)->collect(p|p.name)=Bag{’Ada’,’Bob’,’Cyd’,’Dan’}

context Person inv personsWithUndefinedHusbandAnyFalse_P0_VI:Person.allInstances->select(husband=Person.allInstances->any(false)

)->collect(name)=Bag{’Ada’,’Bob’,’Cyd’,’Dan’}

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

context Person inv personsWithUndefinedHusbandAnyFalse_P1_VT:Person.allInstances()->select(p:Person|p.husband=Person.allInstances()->any(p:Person|false)

)->collect(p:Person|p.name)=Bag{’Ada’,’Bob’,’Cyd’,’Dan’}

context Person inv personsWithUndefinedHusbandAnyFalse_P1_VN:Person.allInstances()->select(p|p.husband=Person.allInstances()->any(p|false)

)->collect(p|p.name)=Bag{’Ada’,’Bob’,’Cyd’,’Dan’}

context Person inv personsWithUndefinedHusbandAnyFalse_P1_VI:Person.allInstances()->select(

22

husband=Person.allInstances()->any(false))->collect(name)=Bag{’Ada’,’Bob’,’Cyd’,’Dan’}

------------------------------------------------------------------------

context Person inv possiblePairs_P0_VT:let ada=Person.allInstances->any(p:Person|p.name=’Ada’) inlet emptySeq=Sequence{ada}->excluding(ada) inPerson.allInstances->iterate(w,h:Person;res:Bag(Sequence(Person))=Bag{emptySeq}->excluding(emptySeq)|if w.gender=’female’ and w.alive and w.civstat<>’married’ and

h.gender=’male’ and h.alive and h.civstat<>’married’then res->including(Sequence{w,h})else res endif)->

collect(pair:Sequence(Person)|pair->collect(p:Person|p.name))=Bag{Sequence{’Ada’,’Bob’}}

context Person inv possiblePairs_P0_VN:let ada=Person.allInstances->any(p|p.name=’Ada’) inlet emptySeq=Sequence{ada}->excluding(ada) inPerson.allInstances->iterate(w,h;res:Bag(Sequence(Person))=Bag{emptySeq}->excluding(emptySeq)|if w.gender=’female’ and w.alive and w.civstat<>’married’ and

h.gender=’male’ and h.alive and h.civstat<>’married’then res->including(Sequence{w,h})else res endif)->

collect(pair|pair->collect(p|p.name))=Bag{Sequence{’Ada’,’Bob’}}

context Person inv possiblePairs_P0_VI:let ada=Person.allInstances->any(name=’Ada’) inlet emptySeq=Sequence{ada}->excluding(ada) inPerson.allInstances->iterate(w,h;res:Bag(Sequence(Person))=Bag{emptySeq}->excluding(emptySeq)|if w.gender=’female’ and w.alive and w.civstat<>’married’ and

h.gender=’male’ and h.alive and h.civstat<>’married’then res->including(Sequence{w,h})else res endif)->

collect(pair|pair->collect(name))=Bag{Sequence{’Ada’,’Bob’}}

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

context Person inv possiblePairs_P1_VT:let ada=Person.allInstances()->any(p:Person|p.name=’Ada’) in

23

let emptySeq=Sequence{ada}->excluding(ada) inPerson.allInstances()->iterate(w,h:Person;res:Bag(Sequence(Person))=Bag{emptySeq}->excluding(emptySeq)|if w.gender=’female’ and w.alive and w.civstat<>’married’ and

h.gender=’male’ and h.alive and h.civstat<>’married’then res->including(Sequence{w,h})else res endif)->

collect(pair:Sequence(Person)|pair->collect(p:Person|p.name))=Bag{Sequence{’Ada’,’Bob’}}

context Person inv possiblePairs_P1_VN:let ada=Person.allInstances()->any(p|p.name=’Ada’) inlet emptySeq=Sequence{ada}->excluding(ada) inPerson.allInstances()->iterate(w,h;res:Bag(Sequence(Person))=Bag{emptySeq}->excluding(emptySeq)|if w.gender=’female’ and w.alive and w.civstat<>’married’ and

h.gender=’male’ and h.alive and h.civstat<>’married’then res->including(Sequence{w,h})else res endif)->

collect(pair|pair->collect(p|p.name))=Bag{Sequence{’Ada’,’Bob’}}

context Person inv possiblePairs_P1_VI:let ada=Person.allInstances()->any(name=’Ada’) inlet emptySeq=Sequence{ada}->excluding(ada) inPerson.allInstances()->iterate(w,h;res:Bag(Sequence(Person))=Bag{emptySeq}->excluding(emptySeq)|if w.gender=’female’ and w.alive and w.civstat<>’married’ and

h.gender=’male’ and h.alive and h.civstat<>’married’then res->including(Sequence{w,h})else res endif)->

collect(pair|pair->collect(name))=Bag{Sequence{’Ada’,’Bob’}}

------------------------------------------------------------------------

context Person inv flatten_P0_VT:let dan=Person.allInstances->any(p:Person|p.name=’Dan’) inlet eve=Person.allInstances->any(p:Person|p.name=’Eve’) inSet{Bag{eve},

Bag{eve.spouse()},Bag{eve.spouse().spouse()},Bag{eve.spouse().spouse().spouse()},Bag{eve.spouse().spouse().spouse().spouse()},Bag{eve.spouse().spouse().spouse().spouse().spouse()}}->

24

flatten()=Set{dan,eve}

context Person inv flatten_P0_VN:let dan=Person.allInstances->any(p|p.name=’Dan’) inlet eve=Person.allInstances->any(p|p.name=’Eve’) inSet{Bag{eve},

Bag{eve.spouse()},Bag{eve.spouse().spouse()},Bag{eve.spouse().spouse().spouse()},Bag{eve.spouse().spouse().spouse().spouse()},Bag{eve.spouse().spouse().spouse().spouse().spouse()}}->

flatten()=Set{dan,eve}

context Person inv flatten_P0_VI:let dan=Person.allInstances->any(name=’Dan’) inlet eve=Person.allInstances->any(name=’Eve’) inSet{Bag{eve},

Bag{eve.spouse()},Bag{eve.spouse().spouse()},Bag{eve.spouse().spouse().spouse()},Bag{eve.spouse().spouse().spouse().spouse()},Bag{eve.spouse().spouse().spouse().spouse().spouse()}}->

flatten()=Set{dan,eve}

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

context Person inv flatten_P1_VT:let dan=Person.allInstances()->any(p:Person|p.name=’Dan’) inlet eve=Person.allInstances()->any(p:Person|p.name=’Eve’) inSet{Bag{eve},

Bag{eve.spouse()},Bag{eve.spouse().spouse()},Bag{eve.spouse().spouse().spouse()},Bag{eve.spouse().spouse().spouse().spouse()},Bag{eve.spouse().spouse().spouse().spouse().spouse()}}->

flatten()=Set{dan,eve}

context Person inv flatten_P1_VN:let dan=Person.allInstances()->any(p|p.name=’Dan’) inlet eve=Person.allInstances()->any(p|p.name=’Eve’) inSet{Bag{eve},

Bag{eve.spouse()},Bag{eve.spouse().spouse()},Bag{eve.spouse().spouse().spouse()},Bag{eve.spouse().spouse().spouse().spouse()},

25

Bag{eve.spouse().spouse().spouse().spouse().spouse()}}->flatten()=Set{dan,eve}

context Person inv flatten_P1_VI:let dan=Person.allInstances()->any(name=’Dan’) inlet eve=Person.allInstances()->any(name=’Eve’) inSet{Bag{eve},

Bag{eve.spouse()},Bag{eve.spouse().spouse()},Bag{eve.spouse().spouse().spouse()},Bag{eve.spouse().spouse().spouse().spouse()},Bag{eve.spouse().spouse().spouse().spouse().spouse()}}->

flatten()=Set{dan,eve}

26

3. Extended Core Benchmark (B2)

3.1. UML Model

Figure 3.1.: Class Diagram of the Extended Core Benchmark Model

model CivilStatusWorld

enum CivilStatus {single, married, divorced, widowed}enum Gender {female, male}

class Person

attributesname:Stringcivstat:CivilStatusgender:Genderalive:Boolean

operations

birth(aName:String, aGender:Gender)

27

pre freshUnlinkedPerson: name.isUndefined and civstat.isUndefined andgender.isUndefined and alive.isUndefined andwife.isUndefined and husband.isUndefined

post nameAssigned: name=aName -- equivalent to ’aName=self.name’post civstatAssigned: civstat=#singlepost genderAssigned: gender=aGenderpost isAliveAssigned: alive=true -- equivalent to ’alive’

marry(aSpouse:Person)pre aSpouseDefined: aSpouse.isDefinedpre isAlive: alivepre aSpouseAlive: aSpouse.alivepre isUnmarried: civstat<>#marriedpre aSpouseUnmarried: aSpouse.civstat<>#marriedpre differentGenders: gender<>aSpouse.genderpost isMarried: civstat=#marriedpost femaleHasMarriedHusband: gender=#female implies

husband=aSpouse and husband.civstat=#marriedpost maleHasMarriedWife: gender=#male implies

wife=aSpouse and wife.civstat=#married

divorce()pre isMarried: civstat=#marriedpre isAlive: alivepre husbandAlive: gender=#female implies husband.alivepre wifeAlive: gender=#male implies wife.alivepost isDivorced: civstat=#divorcedpost husbandDivorced: gender=#female implies

husband.isUndefined and husband@pre.civstat=#divorcedpost wifeDivorced: gender=#male implies

wife.isUndefined and wife@pre.civstat=#divorced

death()pre isAlive: alivepost notAlive: not(alive)post husbandWidowed: gender=#female and husband.isDefined implies

husband@pre.wife.isUndefined and husband@pre.civstat=#widowedpost wifeWidowed: gender=#male and wife.isDefined implies

wife@pre.husband.isUndefined and wife@pre.civstat=#widowed

spouse():Person=if gender=#female then husband else wife endif

constraintsinv attributesDefined: name.isDefined and civstat.isDefined and

gender.isDefined and alive.isDefined

28

inv nameCapitalThenSmallLetters:let small:Set(String)=Set{’a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,’k’,’l’,’m’,

’n’,’o’,’p’,’q’,’r’,’s’,’t’,’u’,’v’,’w’,’x’,’y’,’z’} inlet capital:Set(String)=Set{’A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’,’K’,’L’,’M’,

’N’,’O’,’P’,’Q’,’R’,’S’,’T’,’U’,’V’,’W’,’X’,’Y’,’Z’} incapital->includes(name.substring(1,1)) andSet{2..name.size}->forAll(i |small->includes(name.substring(i,i)))

inv nameIsUnique: Person.allInstances->forAll(self2|self<>self2 implies self.name<>self2.name)

inv femaleHasNoWife: gender=#female implies wife.isUndefinedinv maleHasNoHusband: gender=#male implies husband.isUndefined

end

association Marriage betweenPerson [0..1] role wifePerson [0..1] role husband

end

3.2. System State Evolution for Checking Pre- andPostconditions

System evolution demonstrated with USE command sequences. Evolution initiated byoperation calls and execution/simulation.

3.2.1. Test State A: Ada’s Birth

Figure 3.2.: Test State A: ada birth(’Ada’,#female)

!create ada:Person

!openter ada birth(’Ada’,#female)

29

read Person_birth.cmd!opexit

Code of Person_birth.cmd:

-- Person::birth(aName:String,aGender:Gender)!set self.name:=aName!set self.civstat:=#single!set self.gender:=aGender!set self.alive:=true

3.2.2. Test State B: Bob’s Birth

Figure 3.3.: Test State B: bob birth(’Bob’,#male)

!create bob:Person

!openter bob birth(’Bob’,#male)read Person_birth.cmd!opexit

3.2.3. Test State C: Marriage of Ada and Bob

Figure 3.4.: Test State C: ada marry(bob)

!openter ada marry(bob)read Person_marry.cmd!opexit

30

Code of Person_marry.cmd:

-- Person::marry(aSpouse:Person)!set self.civstat:=#married!set aSpouse.civstat:=#married!insert (if self.gender=#female then self else aSpouse endif,

if self.gender=#female then aSpouse else self endif) into Marriage

3.2.4. Test State D: Cyd’s Birth

Figure 3.5.: Test State D: cyd birth(’Cyd’,#male)

!create cyd:Person

!openter cyd birth(’Cyd’,#male)read Person_birth.cmd!opexit

3.2.5. Test State E: Ada’s and Bob’s Divorce

Figure 3.6.: Test State E: ada divorce()

31

!openter ada divorce()read Person_divorce.cmd!opexit

Code of Person_divorce.cmd:

-- Person::divorce()!set self.civstat:=#divorced!set self.spouse().civstat:=#divorced!delete (if self.gender=#female then self else self.wife endif,

if self.gender=#female then self.husband else self endif) from Marriage

3.2.6. Test State F: Marriage of Ada and Cyd

Figure 3.7.: Test State F: cyd marry(ada)

!openter cyd marry(ada)read Person_marry.cmd!opexit

3.2.7. Test State G: Dan’s Birth

!create dan:Person

!openter dan birth(’Dan’,#male)read Person_birth.cmd!opexit

3.2.8. Test State H: Dan’s Birth

!openter cyd death()

32

Figure 3.8.: Test State G: dan birth(’Dan’,#male)

Figure 3.9.: Test State H: dan death()

read Person_death_married.cmd!opexit

Code of Person_death_married.cmd:

-- Person::death() -- for married Person objects!set self.alive:=false!set self.spouse().civstat:=#widowed!delete (if self.gender=#female then self else self.wife endif,

if self.gender=#female then self.husband else self endif) from Marriage

33

3.3. System States for Evaluating OCL Queries

3.3.1. Test State – Part 1

This state equals Test State H in Sect 3.2.8.

!create ada:Person

!set ada.name:=’Ada’!set ada.civstat:=#single!set ada.gender:=#female!set ada.alive:=true

!create bob:Person

!set bob.name:=’Bob’!set bob.civstat:=#single!set bob.gender:=#male!set bob.alive:=true

!set ada.civstat:=#married!set bob.civstat:=#married!insert (ada,bob) into Marriage

!create cyd:Person

!set cyd.name:=’Cyd’!set cyd.civstat:=#single!set cyd.gender:=#male!set cyd.alive:=true

!set ada.civstat:=#divorced!set bob.civstat:=#divorced!delete (ada,bob) from Marriage

!set cyd.civstat:=#married!set ada.civstat:=#married!insert (ada,cyd) into Marriage

!create dan:Person

!set dan.name:=’Dan’!set dan.civstat:=#single!set dan.gender:=#male!set dan.alive:=true

34

!set cyd.alive:=false!set ada.civstat:=#widowed!delete (ada,cyd) from Marriage

3.3.2. Test State – Part 2 (continuation)

Figure 3.10.: Test State – Part 2 of the Extended Benchmark Model

!set dan.civstat:=#married!set ada.civstat:=#married!insert (ada,dan) into Marriage

3.4. OCL Queries

3.4.1. Queries Based On Test State – Part 1

?Set{ada,bob,cyd,dan}.name

Expected Result:Bag{’Ada’,’Bob’,’Cyd’,’Dan’} : Bag(String)

. . . . . . . . . . . . . . . . . . . . . . . .

?Person.allInstances.name

Expected Result:Bag{’Ada’,’Bob’,’Cyd’,’Dan’} : Bag(String)

. . . . . . . . . . . . . . . . . . . . . . . .

35

?Set{ada,bob,cyd,dan}->collect(name)

Expected Result:Bag{’Ada’,’Bob’,’Cyd’,’Dan’} : Bag(String)

. . . . . . . . . . . . . . . . . . . . . . . .

?Set{ada,bob,cyd,dan}->collect(p|p.name)

Expected Result:Bag{’Ada’,’Bob’,’Cyd’,’Dan’} : Bag(String)

. . . . . . . . . . . . . . . . . . . . . . . .

?Set{ada,bob,cyd,dan}->collect(Sequence{name,civstat,gender,alive})

Expected Result:Bag{Sequence{’Ada’,#widowed, #female,true },

Sequence{’Bob’,#divorced,#male, true },Sequence{’Cyd’,#married, #male, false},Sequence{’Dan’,#single, #male, true }} : Bag(Sequence(OclAny))

. . . . . . . . . . . . . . . . . . . . . . . .

?Set{ada,bob,cyd,dan}->collect(p|Sequence{p.name,p.civstat,p.gender,p.alive})

Expected Result:Bag{Sequence{’Ada’,#widowed, #female,true },

Sequence{’Bob’,#divorced,#male, true },Sequence{’Cyd’,#married, #male, false},Sequence{’Dan’,#single, #male, true }} : Bag(Sequence(OclAny))

. . . . . . . . . . . . . . . . . . . . . . . .

?Person.allInstances->forAll(p1,p2|p1<>p2 implies p1.name<>p2.name)

Expected Result:true : Boolean

. . . . . . . . . . . . . . . . . . . . . . . .

?Person.allInstances->isUnique(p|p.name)

Expected Result:

36

true : Boolean

. . . . . . . . . . . . . . . . . . . . . . . .

?Person.allInstances->forAll(p|(p.gender=#female implies p.wife->isEmpty) and(p.gender=#male implies p.husband->isEmpty))

Expected Result:true : Boolean

. . . . . . . . . . . . . . . . . . . . . . . .

?Person.allInstances->select(p|p.alive and p.civstat<>#widowed).civstat

Expected Result:Bag{#divorced,#single} : Bag(CivilStatus)

. . . . . . . . . . . . . . . . . . . . . . . .

?let p1=Person.allInstances->any(true) inlet p2=Person.allInstances->excluding(p1)->any(true) inlet p3=Person.allInstances->excluding(p1)->excluding(p2)->any(true) inlet p4=Person.allInstances->excluding(p1)->excluding(p2)->excluding(p3)->any(true) inSequence{p1,p2,p3,p4}=Person.allInstances->asSequence()

Expected Result:true : Boolean

. . . . . . . . . . . . . . . . . . . . . . . .

?let o:OclAny=ada in o

Expected Result:ada : Person

. . . . . . . . . . . . . . . . . . . . . . . .

?Person.allInstances->iterate(w,h:Person;res:Set(Tuple(bride:Person,bridegroom:Person))=

oclEmpty(Set(Tuple(bride:Person,bridegroom:Person)))|if w.gender=#female and h.gender=#male and

37

w.alive and h.alive andw.civstat<>#married and h.civstat<>#married thenres->including(Tuple{bride:w,bridegroom:h})else res endif)

Expected Result:Set{Tuple{bride:ada,bridegroom:bob},

Tuple{bride:ada,bridegroom:dan}} :Set(Tuple(bride:Person,bridegroom:Person))

. . . . . . . . . . . . . . . . . . . . . . . .

?Sequence{ada.name,ada.civstat,ada.alive,ada.gender,dan.name,dan.civstat,dan.alive,dan.gender}

Expected Result:Sequence{’Ada’,#widowed,true,#female,’Dan’,#single,true,#male} :Sequence(OclAny)

3.4.2. Queries Based On Test State – Part 2

?Sequence{ada,ada.spouse(),dan,dan.spouse()}

Expected Result:Sequence{ada,dan,dan,ada} : Sequence(Person)

. . . . . . . . . . . . . . . . . . . . . . . .

?Sequence{ada,ada.spouse(),ada.spouse().spouse(),ada.spouse().spouse().spouse()}

Expected Result:Sequence{ada,dan,ada,dan} : Sequence(Person)

. . . . . . . . . . . . . . . . . . . . . . . .

?Person.allInstances->select(husband=Person.allInstances->any(wife->isEmpty).wife)

Expected Result:Set{bob,cyd,dan} : Set(Person)

38

4. Advanced Modeling Benchmark(B3)

4.1. UML Model

Figure 4.1.: Class Diagram of the Advanced Core Benchmark Model

model TernExam

class Personattributes

name:Stringend

associationclass Exam betweenPerson[0..*] role examineePerson[0..*] role examinerPerson[0..*] role recorder

attributesdate:Integer

end

constraints

context Exam inv threeParticipants:self.examinee<>self.examiner and

39

self.examinee<>self.recorder andself.examiner<>self.recorder

context Exam inv threeParticipants2:Set{self.examinee,self.examiner,self.recorder}->size()=3

4.2. System States for Evaluating OCL Queries

4.3. Test State – Part 1

Figure 4.2.: Test State 1 of the Advanced Benchmark Model

!create ada,bob,cyd,dan,eve:Person!set ada.name:=’Ada’!set bob.name:=’Bob’!set cyd.name:=’Cyd’!set dan.name:=’Dan’

40

!set eve.name:=’Eve’

-- Exam(examinee,examiner,recorder)!create ada_bob_cyd:Exam between (ada,bob,cyd)!set ada_bob_cyd.date:=20001023

4.4. Test State – Part 2 (continuation)

Figure 4.3.: Test State 2 of the Advanced Benchmark Model

!create dan_bob_ada:Exam between (dan,bob,ada)!set dan_bob_ada.date:=20040817

!create eve_ada_dan:Exam between (eve,ada,dan)!set eve_ada_dan.date:=20080331

41

4.5. Test State – Part 3 (continuation)

Figure 4.4.: Test State 3 of the Advanced Benchmark Model

!create flo:Person!set flo.name:=’Flo’!create flo_ada_dan:Exam between (flo,ada,dan)!set flo_ada_dan.date:=20080331

4.6. OCL Queries

4.6.1. Queries Based On Test State – Part 1

?ada_bob_cyd.examinee

Expected Result:@ada : Person

42

. . . . . . . . . . . . . . . . . . . . . . . .

?ada_bob_cyd.examiner

Expected Result:@bob : Person

. . . . . . . . . . . . . . . . . . . . . . . .

?ada_bob_cyd.recorder

Expected Result:@cyd : Person

4.6.2. Queries Based On Test State – Part 2

?Exam.allInstances->select(e|e.examinee=ada)

Expected Result:Set{@ada_bob_cyd} : Set(Exam)

. . . . . . . . . . . . . . . . . . . . . . . .

?Exam.allInstances->select(e|e.recorder=ada)

Expected Result:Set{@dan_bob_ada} : Set(Exam)

. . . . . . . . . . . . . . . . . . . . . . . .

?Exam.allInstances->select(e|e.examiner=ada)

Expected Result:Set{@eve_ada_dan} : Set(Exam)

. . . . . . . . . . . . . . . . . . . . . . . .

?ada.examinee[examiner]

Expected Result:Set{@eve} : Set(Person)

. . . . . . . . . . . . . . . . . . . . . . . .

?ada.examinee[recorder]

43

Expected Result:Set{@dan} : Set(Person)

. . . . . . . . . . . . . . . . . . . . . . . .

?ada.examiner[examinee]

Expected Result:Set{@bob} : Set(Person)

. . . . . . . . . . . . . . . . . . . . . . . .

?ada.examiner[recorder]

Expected Result:Set{@bob} : Set(Person)

. . . . . . . . . . . . . . . . . . . . . . . .

?ada.recorder[examinee]

Expected Result:Set{@cyd} : Set(Person)

4.6.3. Queries Based On Test State – Part 2

?ada.recorder[examiner]

Expected Result:Set{@dan} : Set(Person)

. . . . . . . . . . . . . . . . . . . . . . . .

?ada.recorder[examiner]

Expected Result:Set{@dan} : Set(Person)

. . . . . . . . . . . . . . . . . . . . . . . .

?Exam.allInstances->select(e|e.examiner=ada)->collect(e|e.recorder)

Expected Result:

44

Bag{@dan,@dan} : Bag(Person)

45

5. Three-valued Logic Benchmark(B4)

For further Logic Tests see Sect. IV.

5.1. OCL Queries

-- or

?true or Sequence{true}->excluding(true)->last()

Expected Result:true : Boolean

. . . . . . . . . . . . . . . . . . . . . . . .

?Sequence{true}->excluding(true)->last() or true

Expected Result:true : Boolean

. . . . . . . . . . . . . . . . . . . . . . . .

?let B=Set{Sequence{true}->excluding(true)->last(),false,true} inB->iterate(b1,b2:Boolean;r:Sequence(Boolean)=oclEmpty(Sequence(Boolean))|r->including(b1 or b2))

Expected Result:Sequence{Undefined, Undefined, true,

Undefined, false, true,true, true, true} : Sequence(Boolean)

. . . . . . . . . . . . . . . . . . . . . . . .

-- and

?false and Sequence{true}->excluding(true)->last()

46

Expected Result:false : Boolean

. . . . . . . . . . . . . . . . . . . . . . . .

?Sequence{true}->excluding(true)->last() and false

Expected Result:false : Boolean

. . . . . . . . . . . . . . . . . . . . . . . .

?let B=Set{Sequence{true}->excluding(true)->last(),false,true} inB->iterate(b1,b2:Boolean;r:Sequence(Boolean)=oclEmpty(Sequence(Boolean))|r->including(b1 and b2))

Expected Result:Sequence{Undefined, false, Undefined,

false, false, false,Undefined, false, true} : Sequence(Boolean)

. . . . . . . . . . . . . . . . . . . . . . . .

-- implies

?false implies Sequence{true}->excluding(true)->last()

Expected Result:false : Boolean

. . . . . . . . . . . . . . . . . . . . . . . .

?Sequence{true}->excluding(true)->last() implies true

Expected Result:true : Boolean

. . . . . . . . . . . . . . . . . . . . . . . .

?let B=Set{Sequence{true}->excluding(true)->last(),false,true} inB->iterate(b1,b2:Boolean;r:Sequence(Boolean)=oclEmpty(Sequence(Boolean))|r->including(b1 implies b2))

47

Expected Result:Sequence{Undefined, Undefined, true,

true, true, true,Undefined, false, true} : Sequence(Boolean)

. . . . . . . . . . . . . . . . . . . . . . . .

-- if then else endif

?if true then false else Sequence{true}->excluding(true)->last() endif

Expected Result:false : Boolean

. . . . . . . . . . . . . . . . . . . . . . . .

?if false then Sequence{true}->excluding(true)->last() else true endif

Expected Result:true : Boolean

. . . . . . . . . . . . . . . . . . . . . . . .

-- oclIsUndefined

?Sequence{true}->excluding(true)->last().oclIsUndefined()

Expected Result:true : Boolean

48

6. OCL Laws Benchmark (B5)

6.1. OCL Queries

6.1.1. Reject to Select

-- Collection Operations

-- -- DB related

-- -- -- reject to select

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- Singleton

49

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

50

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 2, 3} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:

51

true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

52

?let c = Set{1, 2, 3} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 1} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 1} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

53

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{2, 3, 4, 5} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{2, 3, 4, 5, 4} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Bag{2, 3, 4, 5, 2} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{2, 3, 4, 5} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{2, 3, 4, 5, 4} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

54

?let c = Sequence{2, 3, 4, 5, 2} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{2, 3, 4, 5} inc->reject(i|i<4) = c->select(i|not(i<4))

Expected Result:true : Boolean

6.1.2. Select to Reject

-- Collection Operations

-- -- DB related

-- -- -- select to reject

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->select(i|i<4) = c->reject(i|not(i<4))

55

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)}in c->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} in c->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

56

?let c = Bag{1} in c->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} in c->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} in c->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} in c->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} in c->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 2, 3} inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:

57

true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3} inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3} inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

58

?let c = Set{1, 2, 3} in c->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 1} inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3} in c->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 1} inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3} inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

59

?let c = Set{2, 3, 4, 5} inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{2, 3, 4, 5, 4} inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Bag{2, 3, 4, 5, 2} inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{2, 3, 4, 5} inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{2, 3, 4, 5, 4} inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{2, 3, 4, 5, 2} in

60

c->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{2, 3, 4, 5} inc->select(i|i<4) = c->reject(i|not(i<4))

Expected Result:true : Boolean

6.1.3. Exists to ForAll

-- Collection Operations

-- -- Logic

-- -- -- exists to forAll

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:

61

true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} in

62

c->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

63

?let c = Set{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 2, 3, 4,oclUndefined(Integer)} in

c->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 2, 3, 4,oclUndefined(Integer)} in

c->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

64

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 3, 4} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 4, 1} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3, 4} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 4, 1} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3, 4} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:

65

true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4, 5, 6} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{4, 5, 6, 4} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{4, 5, 6} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{4, 5, 6, 4} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{4, 5, 6} inc->exists(i|i<4) = not c->forAll(i|not(i<4))

66

Expected Result:true : Boolean

6.1.4. ForAll to Exists

-- Collection Operations

-- -- Logic

-- -- -- forAll to exists

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

67

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

68

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

69

?let c = Bag{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 3} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

70

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 1} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 1} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{2, 3, 4, 5} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:

71

true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{2, 3, 4, 5, 4} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Bag{2, 3, 4, 5, 2} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{2, 3, 4, 5} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{2, 3, 4, 5, 4} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{2, 3, 4, 5, 2} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

72

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{2, 3, 4, 5} inc->forAll(i|i<4) = not c->exists(i|not(i<4))

Expected Result:true : Boolean

6.1.5. One to Exists and ForAll (extern)

-- Collection Operations

-- -- Logic

-- -- -- one to exists and forAll (extern)

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

73

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------------

?let c = Set{1} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

74

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:

75

true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, 4, 5,oclUndefined(Integer)} in

c->one(i|i<4) =(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 4, 5,oclUndefined(Integer)} in

c->one(i|i<4) =(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

76

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 4, 5} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 4, 5, 4} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 4, 5} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

77

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 4, 5, 4} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 4, 5} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 5} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (violating)

?let c = Bag{1, 2, 5, 1} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (not violating)

?let c = Bag{1, 2, 5, 5} in

78

c->one(i|i<4) =(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 5} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{1, 2, 5, 1} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{1, 2, 5, 5} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 5} inc->one(i|i<4) =

(c->exists(i|i<4) and c->forAll(x,y|x<4 and y<4 implies x = y))

Expected Result:true : Boolean

79

6.1.6. One to Exists and ForAll (intern)

-- Collection Operations

-- -- Logic

-- -- -- one to exists and forAll (intern)

-- -- -- -- Empty

-- -- -- -- -- Set ---------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->one(i|i<4) =

c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->one(i|i<4) =

80

c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

81

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->one(i|i<4) =

c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 4, 5} in

82

c->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, 4, 5,oclUndefined(Integer)} in

c->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 4, 5,oclUndefined(Integer)} in

c->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

83

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 4, 5} inc->one(i|i<4) =

c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 4, 5, 4} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 4, 5} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 4, 5, 4} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:

84

true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 4, 5} inc->one(i|i<4) =

c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 5} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (violating)

?let c = Bag{1, 2, 5, 1} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (not violating)

?let c = Bag{1, 2, 5, 5} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 5} in

85

c->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{1, 2, 5, 1} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{1, 2, 5, 5} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 5} inc->one(i|i<4) =c->exists(x | x<4 and c->forAll(y|y<4 implies x = y))

Expected Result:true : Boolean

6.1.7. Exists to Reject

-- Collection Operations

-- -- Interdisciplinary

-- -- -- exists to reject

-- -- -- -- Empty

86

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

87

?let c = Sequence{oclUndefined(Integer)} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

88

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 2, 3, 4,oclUndefined(Integer)} in

c->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:

89

true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 2, 3, 4,oclUndefined(Integer)} in

c->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 3, 4} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 4, 1} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

90

?let c = Bag{1, 2, 3, 4} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 4, 1} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3, 4} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4, 5, 6} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{4, 5, 6, 4} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

91

?let c = Bag{4, 5, 6} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{4, 5, 6, 4} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{4, 5, 6} inc->exists(i|i<4) = c->reject(i|i<4)->size()<c->size()

Expected Result:true : Boolean

6.1.8. Exists to Select

-- Collection Operations

-- -- Interdisciplinary

-- -- -- exists to select

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- Bag

92

?let c = oclEmpty(Bag(Integer)) inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

93

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

94

?let c = Sequence{4} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 2, 3, 4,oclUndefined(Integer)} in

c->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 2, 3, 4,oclUndefined(Integer)} in

c->exists(i|i<4) = c->select(i|i<4)->notEmpty()

95

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 3, 4} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 4, 1} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3, 4} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

96

?let c = Sequence{1, 2, 3, 4, 1} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3, 4} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4, 5, 6} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{4, 5, 6, 4} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{4, 5, 6} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

97

?let c = Sequence{4, 5, 6, 4} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{4, 5, 6} inc->exists(i|i<4) = c->select(i|i<4)->notEmpty()

Expected Result:true : Boolean

6.1.9. ForAll to Reject

-- Collection Operations

-- -- Interdisciplinary

-- -- -- forAll to reject

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

98

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

99

?let c = Bag{1} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

100

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

101

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 3} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 1} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 1} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

102

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{2, 3, 4, 5} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{2, 3, 4, 5, 4} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Bag{2, 3, 4, 5, 2} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{2, 3, 4, 5} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{2, 3, 4, 5, 4} in

103

c->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{2, 3, 4, 5, 2} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{2, 3, 4, 5} inc->forAll(i|i<4) = c->reject(i|i<4)->isEmpty()

Expected Result:true : Boolean

6.1.10. ForAll to Select

-- Collection Operations

-- -- Interdisciplinary

-- -- -- forAll to select

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:

104

true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} in

105

c->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set -------------------------------------------

?let c = Set{4} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:

106

true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

107

?let c = Sequence{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 3} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 1} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 1} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:

108

true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{2, 3, 4, 5} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{2, 3, 4, 5, 4} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Bag{2, 3, 4, 5, 2} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{2, 3, 4, 5} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

109

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{2, 3, 4, 5, 4} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{2, 3, 4, 5, 2} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{2, 3, 4, 5} inc->forAll(i|i<4) = (c->select(i|i<4) = c)

Expected Result:true : Boolean

6.1.11. One to Reject

-- Collection Operations

-- -- Interdisciplinary

-- -- -- one to reject

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

110

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

111

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

112

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, 4, 5,oclUndefined(Integer)} in

c->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 4, 5,oclUndefined(Integer)} in

113

c->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 4, 5} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 4, 5, 4} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 4, 5} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

114

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 4, 5, 4} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 4, 5} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 5} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (violating)

?let c = Bag{1, 2, 5, 1} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (not violating)

?let c = Bag{1, 2, 5, 5} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

115

?let c = Bag{1, 2, 5} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{1, 2, 5, 1} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{1, 2, 5, 5} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 5} inc->one(i|i<4) = (c->reject(i|i<4)->size() = c->size()-1)

Expected Result:true : Boolean

6.1.12. One to Select

-- Collection Operations

-- -- Interdisciplinary

-- -- -- one to select

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

116

?let c = oclEmpty(Set(Integer)) inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} in

117

c->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

118

?let c = Bag{4} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, 4, 5,oclUndefined(Integer)} in

c->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

119

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 4, 5,oclUndefined(Integer)} in

c->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 4, 5} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 4, 5, 4} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 4, 5} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

120

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 4, 5, 4} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 4, 5} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 5} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (violating)

?let c = Bag{1, 2, 5, 1} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (not violating)

?let c = Bag{1, 2, 5, 5} in

121

c->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 5} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{1, 2, 5, 1} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{1, 2, 5, 5} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 5} inc->one(i|i<4) = (c->select(i|i<4)->size() = 1)

Expected Result:true : Boolean

6.1.13. Exists to Collect and Includes

-- Collection Operations

-- -- Collect

122

-- -- -- exists to collect and includes

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

123

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

124

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 2, 3, 4,oclUndefined(Integer)} in

c->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

125

?let c = Bag{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 2, 3, 4,oclUndefined(Integer)} in

c->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 3, 4} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 4, 1} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:

126

true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3, 4} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 4, 1} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3, 4} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4, 5, 6} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{4, 5, 6, 4} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

127

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{4, 5, 6} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{4, 5, 6, 4} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{4, 5, 6} inc->exists(i|i<4) = c->collect(i|i<4)->includes(true)

Expected Result:true : Boolean

6.1.14. Exists to Collect and One

-- Collection Operations

-- -- Collect

-- -- -- exists to collect and one

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:

128

true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

129

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{4} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:

130

true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 2, 3, 4,oclUndefined(Integer)} in

c->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

131

?let c = Sequence{oclUndefined(Integer), 2, 3, 4,oclUndefined(Integer)} in

c->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 3, 4} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 4, 1} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3, 4} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

132

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 4, 1} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3, 4} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4, 5, 6} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{4, 5, 6, 4} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{4, 5, 6} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

133

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{4, 5, 6, 4} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{4, 5, 6} inc->exists(i|i<4) = c->collect(i|i<4)->asSet()->one(e|e)

Expected Result:true : Boolean

6.1.15. ForAll to Collect and Excludes

-- Collection Operations

-- -- Collect

-- -- -- forAll to collect and excludes

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

134

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

135

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

136

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3} in

137

c->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 3} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 1} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 1} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

138

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{2, 3, 4, 5} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{2, 3, 4, 5, 4} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Bag{2, 3, 4, 5, 2} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{2, 3, 4, 5} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

139

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{2, 3, 4, 5, 4} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{2, 3, 4, 5, 2} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{2, 3, 4, 5} inc->forAll(i|i<4) = c->collect(i|i<4)->excludes(false)

Expected Result:true : Boolean

6.1.16. ForAll to Collect and One

-- Collection Operations

-- -- Collect

-- -- -- forAll to collect and one

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

140

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

141

?let c = Sequence{oclUndefined(Integer)} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

142

-- -- -- -- -- -- -- Set -------------------------------------------

?let c = Set{4} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

143

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->forAll(i|i<4) =(let s = c->collect(i|i<4)->asSet() in

c->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->forAll(i|i<4) =(let s = c->collect(i|i<4)->asSet() in

c->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

144

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 3} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 1} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 1} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

145

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{2, 3, 4, 5} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{2, 3, 4, 5, 4} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Bag{2, 3, 4, 5, 2} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:

146

true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{2, 3, 4, 5} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{2, 3, 4, 5, 4} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{2, 3, 4, 5, 2} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{2, 3, 4, 5} inc->forAll(i|i<4) =

(let s = c->collect(i|i<4)->asSet() inc->notEmpty() implies s->one(true) and s->one(e|e))

Expected Result:true : Boolean

147

6.1.17. One to Collect

-- Collection Operations

-- -- Collect

-- -- -- one to collect

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

148

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

149

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, 4, 5,oclUndefined(Integer)} in

c->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

150

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 4, 5,oclUndefined(Integer)} in

c->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 4, 5} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

151

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 4, 5, 4} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 4, 5} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 4, 5, 4} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 4, 5} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 5} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

152

-- -- -- -- -- -- -- -- Equal Values (violating)

?let c = Bag{1, 2, 5, 1} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (not violating)

?let c = Bag{1, 2, 5, 5} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 5} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{1, 2, 5, 1} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{1, 2, 5, 5} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

153

?let c = Sequence{1, 2, 5} inc->one(i|i<4) = (c->collect(i|i<4)->count(true) = 1)

Expected Result:true : Boolean

6.1.18. Collect to Iterate

-- Collection Operations

-- -- Iterate

-- -- -- collect

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->collect(i|i*i) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->collect(i|i*i) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- Sequence A

?let c = oclEmpty(Sequence(Integer)) inc->collect(i|i*i) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(i*i))

Expected Result:

154

true : Boolean

-- -- -- -- -- Sequence B

?let c = oclEmpty(Sequence(Integer)) inc->collect(i|i*i) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->append(i*i))

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->collect(i|i*i) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->collect(i|i*i) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence A

?let c = Sequence{oclUndefined(Integer)} inc->collect(i|i*i) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(i*i))

155

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence B

?let c = Sequence{oclUndefined(Integer)} inc->collect(i|i*i) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->append(i*i))

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{2} inc->collect(i|i*i) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{2} inc->collect(i|i*i) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence A

?let c = Sequence{2} inc->collect(i|i*i) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(i*i))

Expected Result:

156

true : Boolean

-- -- -- -- -- -- Sequence B

?let c = Sequence{2} inc->collect(i|i*i) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->append(i*i))

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 0, 1, 2} inc->collect(i|i*i) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 0, 1, 2,oclUndefined(Integer)} in

c->collect(i|i*i) =c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |

r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 0, 1, 2} inc->collect(i|i*i) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |

157

r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence A

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 0, 1, 2,oclUndefined(Integer)} in

c->collect(i|i*i) =c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 0, 1, 2} inc->collect(i|i*i) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence B

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 0, 1, 2,oclUndefined(Integer)} in

c->collect(i|i*i) =c->iterate(i;

r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |r->append(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

158

?let c = Sequence{oclUndefined(Integer), 0, 1, 2} inc->collect(i|i*i) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->append(i*i))

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{-1, 0, 1, 2} inc->collect(i|i*i) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{-1, 0, 1, 2, 1} inc->collect(i|i*i) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{-1, 0, 1, 2} inc->collect(i|i*i) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence A

159

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{-1, 0, 1, 2, 1} inc->collect(i|i*i) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{-1, 0, 1, 2} inc->collect(i|i*i) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence B

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{-1, 0, 1, 2, 1} inc->collect(i|i*i) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->append(i*i))

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{-1, 0, 1, 2} inc->collect(i|i*i) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->append(i*i))

Expected Result:true : Boolean

160

6.1.19. Exists to Iterate

-- Collection Operations

-- -- Iterate

-- -- -- exists

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

161

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

162

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{4} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 2, 3, 4,oclUndefined(Integer)} in

c->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

163

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 2, 3, 4,oclUndefined(Integer)} in

c->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 2, 3, 4} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 3, 4} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

164

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 4, 1} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3, 4} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 4, 1} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3, 4} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{4, 5, 6} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

165

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{4, 5, 6, 4} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{4, 5, 6} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{4, 5, 6, 4} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{4, 5, 6} inc->exists(i|i<4) = c->iterate(i;r:Boolean = false|r or i<4)

Expected Result:true : Boolean

6.1.20. ForAll to Iterate

-- Collection Operations

-- -- Iterate

-- -- -- forAll

-- -- -- -- Empty

166

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

167

?let c = Sequence{oclUndefined(Integer)} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

168

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:

169

true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 3} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 1} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

170

?let c = Bag{1, 2, 3} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 1} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{2, 3, 4, 5} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{2, 3, 4, 5, 4} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

171

?let c = Bag{2, 3, 4, 5, 2} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{2, 3, 4, 5} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{2, 3, 4, 5, 4} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{2, 3, 4, 5, 2} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{2, 3, 4, 5} inc->forAll(i|i<4) = c->iterate(i;r:Boolean = true|r and i<4)

Expected Result:true : Boolean

6.1.21. One to Iterate

-- Collection Operations

172

-- -- Iterate

-- -- -- one

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->one(i|i<4) =c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |

if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->one(i|i<4) =c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |

if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

173

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->one(i|i<4) =

174

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

175

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

176

?let c = Bag{oclUndefined(Integer), 1, 4, 5,oclUndefined(Integer)} in

c->one(i|i<4) =c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |

if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 4, 5,oclUndefined(Integer)} in

c->one(i|i<4) =c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |

if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 4, 5} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,

177

(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 4, 5} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 4, 5, 4} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 4, 5} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:

178

true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 4, 5, 4} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 4, 5} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1, 2, 5} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

179

?let c = Bag{1, 2, 5, 1} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Bag{1, 2, 5, 5} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 5} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{1, 2, 5, 1} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

180

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{1, 2, 5, 5} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 5} inc->one(i|i<4) =

c->iterate(i; r:Sequence(Boolean) = Sequence{false,false} |if r->first() then Sequence{true,false}else Sequence{r->last() and i<4,(r->last() and i<4) xor (r->last() or i<4)} endif)->last()

Expected Result:true : Boolean

6.1.22. Reject to Iterate

-- Collection Operations

-- -- Iterate

-- -- -- reject

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->reject(i|i<4) =

c->iterate(i; r:Set(Integer) = oclEmpty(Set(Integer)) |if i<4 then r else r->including(i) endif)

181

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->reject(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->reject(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->reject(i|i<4) =

c->iterate(i; r:Set(Integer) = oclEmpty(Set(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->reject(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r else r->including(i) endif)

182

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->reject(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->reject(i|i<4) =

c->iterate(i; r:Set(Integer) = oclEmpty(Set(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->reject(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->reject(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r else r->including(i) endif)

183

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{4} inc->reject(i|i<4) =

c->iterate(i; r:Set(Integer) = oclEmpty(Set(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->reject(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->reject(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 2, 3} inc->reject(i|i<4) =

184

c->iterate(i; r:Set(Integer) = oclEmpty(Set(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->reject(i|i<4) =c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |

if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3} inc->reject(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->reject(i|i<4) =c->iterate(i;

r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

185

?let c = Sequence{oclUndefined(Integer), 1, 2, 3} inc->reject(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{1, 2, 3} inc->reject(i|i<4) =

c->iterate(i; r:Set(Integer) = oclEmpty(Set(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 1} inc->reject(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3} inc->reject(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

186

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 1} inc->reject(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3} inc->reject(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{2, 3, 4, 5} inc->reject(i|i<4) =

c->iterate(i; r:Set(Integer) = oclEmpty(Set(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{2, 3, 4, 5, 4} inc->reject(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r else r->including(i) endif)

187

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Bag{2, 3, 4, 5, 2} inc->reject(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{2, 3, 4, 5} inc->reject(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{2, 3, 4, 5, 4} inc->reject(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{2, 3, 4, 5, 2} inc->reject(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r else r->including(i) endif)

Expected Result:

188

true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{2, 3, 4, 5} inc->reject(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r else r->including(i) endif)

Expected Result:true : Boolean

6.1.23. Select to Iterate

-- Collection Operations

-- -- Iterate

-- -- -- select

-- -- -- -- Empty

-- -- -- -- -- Set ------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->select(i|i<4) =

c->iterate(i; r:Set(Integer) = oclEmpty(Set(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->select(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

189

?let c = oclEmpty(Sequence(Integer)) inc->select(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->select(i|i<4) =

c->iterate(i; r:Set(Integer) = oclEmpty(Set(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->select(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->select(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

190

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{1} inc->select(i|i<4) =

c->iterate(i; r:Set(Integer) = oclEmpty(Set(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

?let c = Bag{1} inc->select(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{1} inc->select(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{4} inc->select(i|i<4) =

c->iterate(i; r:Set(Integer) = oclEmpty(Set(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

191

-- -- -- -- -- -- -- Bag

?let c = Bag{4} inc->select(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

?let c = Sequence{4} inc->select(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, 2, 3} inc->select(i|i<4) =

c->iterate(i; r:Set(Integer) = oclEmpty(Set(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->select(i|i<4) =c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |

if i<4 then r->including(i) else r endif)

192

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, 2, 3} inc->select(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3,oclUndefined(Integer)} in

c->select(i|i<4) =c->iterate(i;

r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 1, 2, 3} inc->select(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Expression e fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

193

?let c = Set{1, 2, 3} inc->select(i|i<4) =

c->iterate(i; r:Set(Integer) = oclEmpty(Set(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, 1} inc->select(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3} inc->select(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, 1} inc->select(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

194

?let c = Sequence{1, 2, 3} inc->select(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- Expression e not fulfilled

-- -- -- -- -- -- -- Set ------------------------------------------

?let c = Set{2, 3, 4, 5} inc->select(i|i<4) =

c->iterate(i; r:Set(Integer) = oclEmpty(Set(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Bag

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Bag{2, 3, 4, 5, 4} inc->select(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Bag{2, 3, 4, 5, 2} inc->select(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

195

?let c = Bag{2, 3, 4, 5} inc->select(i|i<4) =

c->iterate(i; r:Bag(Integer) = oclEmpty(Bag(Integer)) |if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- -- Equal Values (both violating)

?let c = Sequence{2, 3, 4, 5, 4} inc->select(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- Equal Values (both not violating)

?let c = Sequence{2, 3, 4, 5, 2} inc->select(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

-- -- -- -- -- -- -- -- No Equal Values

?let c = Sequence{2, 3, 4, 5} inc->select(i|i<4) =

c->iterate(i;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

if i<4 then r->including(i) else r endif)

Expected Result:true : Boolean

196

6.1.24. Iterate to Iterate with let

-- Technical Relationships

-- -- iterate with let

-- -- -- Empty

-- -- -- -- Set ---------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- Singleton

197

-- -- -- -- Includes Undefined

-- -- -- -- -- Set ------------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- -- Excludes Undefined

-- -- -- -- -- Set ------------------------------------------------

?let c = Set{2} inc->iterate(elem; r:Bag(Integer) = Bag{1} |

198

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = Bag{2} inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = Sequence{2} inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- Many Elements

-- -- -- -- Includes Undefined

-- -- -- -- -- Set ------------------------------------------------

?let c = Set{oclUndefined(Integer), 2, 3, -10} inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

199

Expected Result:true : Boolean

-- -- -- -- -- Bag

-- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 2, 3, -10,oclUndefined(Integer)} in

c->iterate(elem; r:Bag(Integer) = Bag{1} |r->including(r->size()+elem))

=c->iterate(elem; r:Bag(Integer) = Bag{1} |

let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 2, 3, -10} inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

-- -- -- -- -- -- Equal Values

?let c = Sequence{oclUndefined(Integer), 2, 3, -10,oclUndefined(Integer)} in

c->iterate(elem; r:Bag(Integer) = Bag{1} |r->including(r->size()+elem))

=c->iterate(elem; r:Bag(Integer) = Bag{1} |

let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

200

-- -- -- -- -- -- No Equal Values

?let c = Sequence{oclUndefined(Integer), 2, 3, -10} inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- -- Excludes Undefined

-- -- -- -- -- Set ------------------------------------------------

?let c = Set{1, 2, 3, -10} inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- -- -- Bag

-- -- -- -- -- -- Equal Values

?let c = Bag{1, 2, 3, -10, 1} inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- -- -- -- No Equal Values

?let c = Bag{1, 2, 3, -10} inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))

201

= c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

-- -- -- -- -- -- Equal Values

?let c = Sequence{1, 2, 3, -10, 1} inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

-- -- -- -- -- -- No Equal Values

?let c = Sequence{1, 2, 3, -10} inc->iterate(elem; r:Bag(Integer) = Bag{1} |

r->including(r->size()+elem))=

c->iterate(elem; r:Bag(Integer) = Bag{1} |let res = r->including(r->size()+elem) in res)

Expected Result:true : Boolean

6.1.25. Singleton to Value

-- Technical Relationships

-- -- Singleton to Value

-- -- -- Empty

-- -- -- -- Set ---------------------------------------------------

?let c = oclEmpty(Set(Integer)) inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

202

if c->size() = 1 thenc->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

Expected Result:true : Boolean

?let c = oclEmpty(Set(Integer)) inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:true : Boolean

-- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =if c->size() = 1 then

c->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

Expected Result:true : Boolean

?let c = oclEmpty(Bag(Integer)) inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:true : Boolean

-- -- -- -- Sequence

?let c = oclEmpty(Sequence(Integer)) inif c->size() = 1 then c->any(true)

203

else oclUndefined(Integer) endif =if c->size() = 1 then

c->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

Expected Result:true : Boolean

?let c = oclEmpty(Sequence(Integer)) inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:true : Boolean

-- -- -- Singleton

-- -- -- -- Includes Undefined

-- -- -- -- -- Set ------------------------------------------------

?let c = Set{oclUndefined(Integer)} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =if c->size() = 1 then

c->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

Expected Result:true : Boolean

?let c = Set{oclUndefined(Integer)} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:true : Boolean

204

-- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =if c->size() = 1 then

c->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

Expected Result:true : Boolean

?let c = Bag{oclUndefined(Integer)} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer)} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =if c->size() = 1 then

c->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

Expected Result:true : Boolean

?let c = Sequence{oclUndefined(Integer)} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:

205

true : Boolean

-- -- -- -- Excludes Undefined

-- -- -- -- -- Set ------------------------------------------------

?let c = Set{2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =if c->size() = 1 then

c->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

Expected Result:true : Boolean

?let c = Set{2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = Bag{2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =if c->size() = 1 then

c->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

Expected Result:true : Boolean

?let c = Bag{2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}

206

else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = Sequence{2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =if c->size() = 1 then

c->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

Expected Result:true : Boolean

?let c = Sequence{2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:true : Boolean

-- -- -- Many Elements

-- -- -- -- Includes Undefined

-- -- -- -- -- Set ------------------------------------------------

?let c = Set{oclUndefined(Integer), 2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =if c->size() = 1 then

c->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

Expected Result:true : Boolean

?let c = Set{oclUndefined(Integer), 2} in

207

if c->size() = 1 then c->any(true) elseoclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer), 2} inif c->size() = 1 then c->any(true) elseoclUndefined(Integer) endif =if c->size() = 1 then

c->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

Expected Result:true : Boolean

?let c = Bag{oclUndefined(Integer), 2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = Sequence{oclUndefined(Integer), 2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =if c->size() = 1 then

c->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

Expected Result:true : Boolean

208

?let c = Sequence{oclUndefined(Integer), 2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:true : Boolean

-- -- -- -- Excludes Undefined

-- -- -- -- -- Set ------------------------------------------------

?let c = Set{1, 2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =if c->size() = 1 then

c->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

Expected Result:true : Boolean

?let c = Set{1, 2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:true : Boolean

-- -- -- -- -- Bag

?let c = Bag{1, 2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =if c->size() = 1 then

c->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

209

Expected Result:true : Boolean

?let c = Bag{1, 2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:true : Boolean

-- -- -- -- -- Sequence

?let c = Sequence{1, 2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =if c->size() = 1 then

c->iterate(elem; r:Integer = oclUndefined(Integer) | elem)else oclUndefined(Integer) endif

Expected Result:true : Boolean

?let c = Sequence{1, 2} inif c->size() = 1 then c->any(true)else oclUndefined(Integer) endif =

c->iterate(elem;r:Sequence(OclAny) = Sequence{oclUndefined(Integer),false} |if r->at(2) = false then Sequence{elem,true}else Sequence{oclUndefined(Integer),true} endif)->at(1)

Expected Result:true : Boolean

210

Part III.

OCL Engine DeterminatenessProperties

211

7. OCL Queries

7.1. Conversion to Sequence

-- Technical Relationships

-- -- Conversion to Sequences

-- -- -- Empty

-- -- -- -- Set ---------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->asSequence() = c->asBag()->asSequence()

Expected Result:true : Boolean

?let c = oclEmpty(Set(Integer)) inc->asSequence() =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))

Expected Result:true : Boolean

?let c = oclEmpty(Set(Integer)) inc->asSequence() =

c->iterate(u;r:Tuple(theSet:Set(Integer), theSeq:Sequence(Integer)) =Tuple{theSet:c,theSeq:oclEmpty(Sequence(Integer))} |

let e = r.theSet->any(true) inTuple{theSet:r.theSet->excluding(e),

theSeq:r.theSeq->including(e)}).theSeq

Expected Result:true : Boolean

212

?let c = oclEmpty(Set(Integer)) inc->asSequence() = Sequence{c}->flatten()

Expected Result:true : Boolean

-- -- -- Singleton

-- -- -- -- Includes Undefined

-- -- -- -- -- Set ------------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->asSequence() = c->asBag()->asSequence()

Expected Result:true : Boolean

?let c = Set{oclUndefined(Integer)} inc->asSequence() =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))

Expected Result:true : Boolean

?let c = Set{oclUndefined(Integer)} inc->asSequence() =

c->iterate(u;r:Tuple(theSet:Set(Integer),theSeq:Sequence(Integer)) =Tuple{theSet:c,theSeq:oclEmpty(Sequence(Integer))} |

let e = r.theSet->any(true) inTuple{theSet:r.theSet->excluding(e),

theSeq:r.theSeq->including(e)}).theSeq

Expected Result:true : Boolean

?let c = Set{oclUndefined(Integer)} inc->asSequence() = Sequence{c}->flatten()

Expected Result:true : Boolean

213

-- -- -- -- Excludes Undefined

-- -- -- -- -- Set ---------------------------------------------

?let c = Set{1} in c->asSequence() = c->asBag()->asSequence()

Expected Result:true : Boolean

?let c = Set{1} inc->asSequence() =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))

Expected Result:true : Boolean

?let c = Set{1} inc->asSequence() =

c->iterate(u;r:Tuple(theSet:Set(Integer),theSeq:Sequence(Integer)) =Tuple{theSet:c,theSeq:oclEmpty(Sequence(Integer))} |

let e = r.theSet->any(true) inTuple{theSet:r.theSet->excluding(e),

theSeq:r.theSeq->including(e)}).theSeq

Expected Result:true : Boolean

?let c = Set{1} in c->asSequence() = Sequence{c}->flatten()

Expected Result:true : Boolean

-- -- -- Many Elements

-- -- -- -- Includes Undefined

-- -- -- -- -- Set ---------------------------------------------

?let c = Set{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->asSequence() = c->asBag()->asSequence()

Expected Result:

214

true : Boolean

?let c = Set{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->asSequence() =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))

Expected Result:true : Boolean

?let c = Set{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->asSequence() =

c->iterate(u;r:Tuple(theSet:Set(Integer),theSeq:Sequence(Integer)) =Tuple{theSet:c,theSeq:oclEmpty(Sequence(Integer))} |

let e = r.theSet->any(true) inTuple{theSet:r.theSet->excluding(e),

theSeq:r.theSeq->including(e)}).theSeq

Expected Result:true : Boolean

?let c = Set{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->asSequence() = Sequence{c}->flatten()

Expected Result:true : Boolean

-- -- -- -- Excludes Undefined

-- -- -- -- -- Set ---------------------------------------------

?let c = Set{1, -1, 3, 2, 0} inc->asSequence() = c->asBag()->asSequence()

Expected Result:true : Boolean

?let c = Set{1, -1, 3, 2, 0} inc->asSequence() =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))

215

Expected Result:true : Boolean

?let c = Set{1, -1, 3, 2, 0} inc->asSequence() =

c->iterate(u;r:Tuple(theSet:Set(Integer),theSeq:Sequence(Integer)) =Tuple{theSet:c,theSeq:oclEmpty(Sequence(Integer))} |

let e = r.theSet->any(true) inTuple{theSet:r.theSet->excluding(e),

theSeq:r.theSeq->including(e)}).theSeq

Expected Result:true : Boolean

?let c = Set{1, -1, 3, 2, 0} inc->asSequence() = Sequence{c}->flatten()

Expected Result:true : Boolean

7.2. Additional Determinateness Properties

-- Technical Relationships

-- -- Determinateness Constraints

-- -- -- In Addition to the Ocl4All 2007 equivalences

-- -- -- -- Empty

-- -- -- -- -- Set -----------------------------------------------------

?let c = oclEmpty(Set(Integer)) inc->any(true) = c->asBag()->any(true)

Expected Results:true : Boolean

?let c = oclEmpty(Set(Integer)) inc->any(true) = c->asSequence()->any(true)

Expected Results:true : Boolean

216

?let c = oclEmpty(Set(Integer)) inc->any(true) = c->asBag()->asSequence()->any(true)

Expected Results:true : Boolean

?let c = oclEmpty(Set(Integer)) inc->any(true) = c->asSequence()->first()

Expected Results:true : Boolean

?let c = oclEmpty(Set(Integer)) inc->any(true) = c->asSequence()->last()

Expected Results:true : Boolean

?let c = oclEmpty(Set(Integer)) inc->any(true) = c->asBag()->asSequence()->first()

Expected Results:true : Boolean

?let c = oclEmpty(Set(Integer)) inc->any(true) = c->asBag()->asSequence()->last()

Expected Results:true : Boolean

?let c = oclEmpty(Set(Integer)) inc->any(true) =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))->first()

Expected Results:true : Boolean

?let c = oclEmpty(Set(Integer)) inSequence{c}->flatten() = c->asSequence()

Expected Results:true : Boolean

217

?let c = oclEmpty(Set(Integer)) inSequence{c}->flatten() = c->asBag()->asSequence()

Expected Results:true : Boolean

-- -- -- -- -- Bag

?let c = oclEmpty(Bag(Integer)) inc->asSequence() =c->iterate(elem;

r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |r->including(elem))

Expected Results:true : Boolean

?let c = oclEmpty(Bag(Integer)) inc->any(true) = c->asSequence()->any(true)

Expected Results:true : Boolean

?let c = oclEmpty(Bag(Integer)) inc->any(true) = c->asSequence()->first()

Expected Results:true : Boolean

?let c = oclEmpty(Bag(Integer)) inc->any(true) = c->asSequence()->last()

Expected Results:true : Boolean

?let c = oclEmpty(Bag(Integer)) inc->any(true) =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))->first()

Expected Results:true : Boolean

218

?let c = oclEmpty(Bag(Integer)) inSequence{c}->flatten() = c->asSequence()

Expected Results:true : Boolean

-- -- -- -- -- Sequence

-- -- -- -- Singleton

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set --------------------------------------------------

?let c = Set{oclUndefined(Integer)} inc->any(true) = c->asBag()->any(true)

Expected Results:true : Boolean

?let c = Set{oclUndefined(Integer)} inc->any(true) = c->asSequence()->any(true)

Expected Results:true : Boolean

?let c = Set{oclUndefined(Integer)} inc->any(true) = c->asBag()->asSequence()->any(true)

Expected Results:true : Boolean

?let c = Set{oclUndefined(Integer)} inc->any(true) = c->asSequence()->first()

Expected Results:true : Boolean

?let c = Set{oclUndefined(Integer)} inc->any(true) = c->asSequence()->last()

Expected Results:true : Boolean

?let c = Set{oclUndefined(Integer)} in

219

c->any(true) = c->asBag()->asSequence()->first()

Expected Results:true : Boolean

?let c = Set{oclUndefined(Integer)} inc->any(true) = c->asBag()->asSequence()->last()

Expected Results:true : Boolean

?let c = Set{oclUndefined(Integer)} inc->any(true) =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))->first()

Expected Results:true : Boolean

?let c = Set{oclUndefined(Integer)} inSequence{c}->flatten() = c->asSequence()

Expected Results:true : Boolean

?let c = Set{oclUndefined(Integer)} inSequence{c}->flatten() = c->asBag()->asSequence()

Expected Results:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{oclUndefined(Integer)} inc->asSequence() =c->iterate(elem;

r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |r->including(elem))

Expected Results:true : Boolean

?let c = Bag{oclUndefined(Integer)} inc->any(true) = c->asSequence()->any(true)

220

Expected Results:true : Boolean

?let c = Bag{oclUndefined(Integer)} inc->any(true) = c->asSequence()->first()

Expected Results:true : Boolean

?let c = Bag{oclUndefined(Integer)} inc->any(true) = c->asSequence()->last()

Expected Results:true : Boolean

?let c = Bag{oclUndefined(Integer)} inc->any(true) =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))->first()

Expected Results:true : Boolean

?let c = Bag{oclUndefined(Integer)} inSequence{c}->flatten() = c->asSequence()

Expected Results:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Set -----------------------------------------------

?let c = Set{1} inc->any(true) = c->asBag()->any(true)

Expected Results:true : Boolean

?let c = Set{1} inc->any(true) = c->asSequence()->any(true)

221

Expected Results:true : Boolean

?let c = Set{1} inc->any(true) = c->asBag()->asSequence()->any(true)

Expected Results:true : Boolean

?let c = Set{1} inc->any(true) = c->asSequence()->first()

Expected Results:true : Boolean

?let c = Set{1} inc->any(true) = c->asSequence()->last()

Expected Results:true : Boolean

?let c = Set{1} inc->any(true) = c->asBag()->asSequence()->first()

Expected Results:true : Boolean

?let c = Set{1} inc->any(true) = c->asBag()->asSequence()->last()

Expected Results:true : Boolean

?let c = Set{1} inc->any(true) =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))->first()

Expected Results:true : Boolean

?let c = Set{1} inSequence{c}->flatten() = c->asSequence()

222

Expected Results:true : Boolean

?let c = Set{1} inSequence{c}->flatten() = c->asBag()->asSequence()

Expected Results:true : Boolean

-- -- -- -- -- -- Bag

?let c = Bag{1} inc->asSequence() =c->iterate(elem;

r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |r->including(elem))

Expected Results:true : Boolean

?let c = Bag{1} inc->any(true) = c->asSequence()->any(true)

Expected Results:true : Boolean

?let c = Bag{1} inc->any(true) = c->asSequence()->first()

Expected Results:true : Boolean

?let c = Bag{1} inc->any(true) = c->asSequence()->last()

Expected Results:true : Boolean

?let c = Bag{1} inc->any(true) =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))->first()

223

Expected Results:true : Boolean

?let c = Bag{1} inSequence{c}->flatten() = c->asSequence()

Expected Results:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- Many Elements

-- -- -- -- -- Includes Undefined

-- -- -- -- -- -- Set --------------------------------------------------

?let c = Set{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->any(true) = c->asBag()->any(true)false : Boolean

?let c = Set{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->any(true) = c->asSequence()->any(true)

Expected Results:true : Boolean

?let c = Set{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->any(true) = c->asBag()->asSequence()->any(true)false : Boolean

?let c = Set{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->any(true) = c->asSequence()->first()

Expected Results:true : Boolean

?let c = Set{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->any(true) = c->asSequence()->last()false : Boolean

?let c = Set{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->any(true) = c->asBag()->asSequence()->first()false : Boolean

224

?let c = Set{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->any(true) = c->asBag()->asSequence()->last()

Expected Results:true : Boolean

?let c = Set{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->any(true) =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))->first()

Expected Results:true : Boolean

?let c = Set{oclUndefined(Integer), 1, -1, 3, 2, 0} inSequence{c}->flatten() = c->asSequence()

Expected Results:true : Boolean

?let c = Set{oclUndefined(Integer), 1, -1, 3, 2, 0} inSequence{c}->flatten() = c->asBag()->asSequence()

false : Boolean

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{oclUndefined(Integer), 1, -1, 3, 2, 0,oclUndefined(Integer)} in

c->asSequence() =c->iterate(elem;

r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |r->including(elem)

)

Expected Results:true : Boolean

?let c = Bag{oclUndefined(Integer), 1, -1, 3, 2, 0,oclUndefined(Integer)} in

c->any(true) = c->asSequence()->any(true)

Expected Results:

225

true : Boolean

?let c = Bag{oclUndefined(Integer), 1, -1, 3, 2, 0,oclUndefined(Integer)} in

c->any(true) = c->asSequence()->first()

Expected Results:true : Boolean

?let c = Bag{oclUndefined(Integer), 1, -1, 3, 2, 0,oclUndefined(Integer)} in

c->any(true) = c->asSequence()->last()false : Boolean

?let c = Bag{oclUndefined(Integer), 1, -1, 3, 2, 0,oclUndefined(Integer)} in

c->any(true) =c->iterate(elem;

r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |r->including(elem))->first()

Expected Results:true : Boolean

?let c = Bag{oclUndefined(Integer), 1, -1, 3, 2, 0,oclUndefined(Integer)} in

Sequence{c}->flatten() = c->asSequence()

Expected Results:true : Boolean

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->asSequence() =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))

Expected Results:true : Boolean

?let c = Bag{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->any(true) = c->asSequence()->any(true)

226

Expected Results:true : Boolean

?let c = Bag{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->any(true) = c->asSequence()->first()

Expected Results:true : Boolean

?let c = Bag{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->any(true) = c->asSequence()->last()

false : Boolean

?let c = Bag{oclUndefined(Integer), 1, -1, 3, 2, 0} inc->any(true) =c->iterate(elem;

r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |r->including(elem))->first()

Expected Results:true : Boolean

?let c = Bag{oclUndefined(Integer), 1, -1, 3, 2, 0} inSequence{c}->flatten() = c->asSequence()

Expected Results:true : Boolean

-- -- -- -- -- -- Sequence

-- -- -- -- -- -- -- Equal Values

-- -- -- -- -- -- -- No Equal Values

-- -- -- -- -- Excludes Undefined

-- -- -- -- -- -- Set -----------------------------------------------

?let c = Set{1, -1, 3, 2, 0} inc->any(true) = c->asBag()->any(true)false : Boolean

?let c = Set{1, -1, 3, 2, 0} inc->any(true) = c->asSequence()->any(true)

227

Expected Results:true : Boolean

?let c = Set{1, -1, 3, 2, 0} inc->any(true) = c->asBag()->asSequence()->any(true)

false : Boolean

?let c = Set{1, -1, 3, 2, 0} inc->any(true) = c->asSequence()->first()

Expected Results:true : Boolean

?let c = Set{1, -1, 3, 2, 0} inc->any(true) = c->asSequence()->last()false : Boolean

?let c = Set{1, -1, 3, 2, 0} inc->any(true) = c->asBag()->asSequence()->first()false : Boolean

?let c = Set{1, -1, 3, 2, 0} inc->any(true) = c->asBag()->asSequence()->last()

Expected Results:true : Boolean

?let c = Set{1, -1, 3, 2, 0} inc->any(true) =c->iterate(elem;

r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |r->including(elem))->first()

Expected Results:true : Boolean

?let c = Set{1, -1, 3, 2, 0} inSequence{c}->flatten() = c->asSequence()

Expected Results:true : Boolean

?let c = Set{1, -1, 3, 2, 0} inSequence{c}->flatten() = c->asBag()->asSequence()

false : Boolean

228

-- -- -- -- -- -- Bag

-- -- -- -- -- -- -- Equal Values

?let c = Bag{1, -1, 3, 2, 0, 1} inc->asSequence() =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))

Expected Results:true : Boolean

?let c = Bag{1, -1, 3, 2, 0, 1} inc->any(true) = c->asSequence()->any(true)

Expected Results:true : Boolean

?let c = Bag{1, -1, 3, 2, 0, 1} inc->any(true) = c->asSequence()->first()

Expected Results:true : Boolean

?let c = Bag{1, -1, 3, 2, 0, 1} inc->any(true) = c->asSequence()->last()

false : Boolean

?let c = Bag{1, -1, 3, 2, 0, 1} inc->any(true) =c->iterate(elem;

r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |r->including(elem))->first()

Expected Results:true : Boolean

?let c = Bag{1, -1, 3, 2, 0, 1} inSequence{c}->flatten() = c->asSequence()

Expected Results:true : Boolean

229

-- -- -- -- -- -- -- No Equal Values

?let c = Bag{1, -1, 3, 2, 0} inc->asSequence() =

c->iterate(elem;r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |

r->including(elem))

Expected Results:true : Boolean

?let c = Bag{1, -1, 3, 2, 0} inc->any(true) = c->asSequence()->any(true)

Expected Results:true : Boolean

?let c = Bag{1, -1, 3, 2, 0} inc->any(true) = c->asSequence()->first()

Expected Results:true : Boolean

?let c = Bag{1, -1, 3, 2, 0} inc->any(true) = c->asSequence()->last()

false : Boolean

?let c = Bag{1, -1, 3, 2, 0} inc->any(true) =c->iterate(elem;

r:Sequence(Integer) = oclEmpty(Sequence(Integer)) |r->including(elem))->first()

Expected Results:true : Boolean

?let c = Bag{1, -1, 3, 2, 0} inSequence{c}->flatten() = c->asSequence()

Expected Results:true : Boolean

230

Part IV.

OCL Engine Efficiency

231

8. UML Models

8.1. Model A

Figure 8.1.: Class Diagram of Efficiency Benchmark Model 1

model StringReal

class MathLiboperations----------------------------------------------------------------------root(arg:Real,precision:Real):Real=if arg>0 thenrootAux(arg,

precision,if arg>=1 then 1.0 else arg endif,if arg>=1 then arg else 1.0 endif)

else 0.0 endifrootAux(arg:Real,precision:Real,low:Real,high:Real):Real=let new:Real=(low+high)/2 inif (arg-new*new).abs<=precisionthen newelse rootAux(arg,

precision,if new*new<arg then new else low endif,if new*new<arg then high else new endif)

endif----------------------------------------------------------------------isPrime(arg:Integer):Boolean=if arg<=1 then false else

232

if arg=2 then true else isPrimeAux(arg,2,arg div 2) endif endifisPrimeAux(arg:Integer,cur:Integer,top:Integer):Boolean=

if arg.mod(cur)=0 then false elseif cur+1<=top then isPrimeAux(arg,cur+1,top) else true endif

endif----------------------------------------------------------------------

end

8.2. Model B

Figure 8.2.: Class Diagram of Efficiency Benchmark Model 2

model MapWorld

class Townattributesname:String -- key attribute

operationsconnect():Set(Town)=fst->union(snd)

connectPlus():Set(Town)=connectPlusAux(connect())

connectPlusAux(aSet:Set(Town)):Set(Town)=let oneStep:Set(Town)=aSet->collect(t|t.connect())->flatten()->asSet() inif oneStep->exists(t|aSet->excludes(t)) thenconnectPlusAux(aSet->union(oneStep))else aSet endif

end

association Road betweenTown[0..*] role fstTown[0..*] role snd

end

233

constraints

context Town inv uniqueName: Town.allInstances->isUnique(t|t.name)

234

9. System States for Evaluation OCLQueries

9.1. Test State based on UML Model A

Figure 9.1.: Test State of the Efficiency Benchmark Model A

!create m:MathLib

9.2. Test State based on UML Model B

!create Town1,Town2,Town3,Town4,Town5,Town6,Town7,Town8,Town9,Town10,Town11,Town12,Town13,Town14,Town15,Town16,Town17,Town18,Town19,Town20,Town21,Town22,Town23,Town24,Town25,Town26,Town27,Town28,Town29,Town30,Town31,Town32,Town33,Town34,Town35,Town36,Town37,Town38,Town39,Town40,Town41,Town42 : Town

!set Town1.name := ’Mild Goosemont north of the Ford’!set Town2.name := ’Foggy Horseport close to the Lake’!set Town3.name := ’Great Gooseport behind the Castle’!set Town4.name := ’Mild Bearport under the River’!set Town5.name := ’Windy Bearville west of the Hill’!set Town6.name := ’Hot Dogport above the Cave’!set Town7.name := ’Mild Cowmont east of the Mountain’!set Town8.name := ’Windy Gooseharbour next to the Cave’!set Town9.name := ’Rainy Gooseharbour under the Ford’!set Town10.name := ’Windy Sparrowport next to the Ford’!set Town11.name := ’Great Horseharbour above the Lake’!set Town12.name := ’Snowy Lionharbour close to the Desert’!set Town13.name := ’Foggy Cowmont east of the Mountain’

235

!set Town14.name := ’Great Lionville west of the Castle’!set Town15.name := ’Great Dogfield east of the Cave’!set Town16.name := ’Small Cowfield behind the Creek’!set Town17.name := ’Great Cowharbour next to the Castle’!set Town18.name := ’Hot Dogport under the Castle’!set Town19.name := ’Hot Lionville north of the Mountain’!set Town20.name := ’Sunny Chickenford close to the Cave’!set Town21.name := ’Hot Cowwood behind the Lake’!set Town22.name := ’Rainy Eagleport east of the Hill’!set Town23.name := ’Foggy Bearburg north of the Hill’!set Town24.name := ’Rainy Eaglemont above the Mountain’!set Town25.name := ’Mild Falconfield close to the Hill’!set Town26.name := ’Snowy Bearview north of the River’!set Town27.name := ’Rainy Bearmont under the Creek’!set Town28.name := ’Cold Lionharbour far from the Castle’!set Town29.name := ’Hot Horseport far from the Mountain’!set Town30.name := ’Mild Falconwood behind the River’!set Town31.name := ’Great Eagleford west of the Mountain’!set Town32.name := ’Cold Sparrowwood south of the Lake’!set Town33.name := ’Hot Falconharbour above the Hill’!set Town34.name := ’Rainy Eaglegreen next to the River’!set Town35.name := ’Small Horseharbour north of the Desert’!set Town36.name := ’Rainy Cowmont west of the Mountain’!set Town37.name := ’Rainy Gooseville under the Mountain’!set Town38.name := ’Snowy Lionharbour east of the Sea’!set Town39.name := ’Hot Bearfield east of the Cave’!set Town40.name := ’Hot Bearview above the Desert’!set Town41.name := ’Small Horsegreen north of the Sea’!set Town42.name := ’Hot Sparrowville south of the Desert’

!insert (Town31,Town8) into Road!insert (Town38,Town2) into Road!insert (Town36,Town16) into Road!insert (Town32,Town7) into Road!insert (Town17,Town6) into Road!insert (Town32,Town17) into Road!insert (Town19,Town23) into Road!insert (Town9,Town16) into Road!insert (Town31,Town17) into Road!insert (Town15,Town30) into Road!insert (Town1,Town38) into Road!insert (Town11,Town9) into Road!insert (Town27,Town35) into Road!insert (Town4,Town33) into Road!insert (Town25,Town21) into Road

236

!insert (Town6,Town35) into Road!insert (Town8,Town7) into Road!insert (Town24,Town7) into Road!insert (Town4,Town29) into Road!insert (Town17,Town12) into Road!insert (Town1,Town3) into Road!insert (Town42,Town17) into Road!insert (Town9,Town26) into Road!insert (Town38,Town41) into Road!insert (Town14,Town18) into Road!insert (Town14,Town28) into Road!insert (Town2,Town18) into Road!insert (Town8,Town42) into Road!insert (Town28,Town2) into Road!insert (Town5,Town13) into Road!insert (Town16,Town29) into Road!insert (Town29,Town1) into Road!insert (Town40,Town13) into Road!insert (Town15,Town10) into Road!insert (Town16,Town13) into Road!insert (Town24,Town37) into Road!insert (Town13,Town22) into Road!insert (Town1,Town39) into Road!insert (Town34,Town31) into Road!insert (Town19,Town39) into Road!insert (Town36,Town9) into Road!insert (Town11,Town18) into Road

237

Figure 9.2.: Test State of the Efficiency Benchmark Model B

238

10. OCL Queries

10.1. Queries based on UML Model A

--------------------------------------------------------------------- Identifiers in this file have been shortened ---------------------------------------------------------------------------------------- Build truth tables for boolean connectives ----------------------------------------------------------------------------------------?Sequence{1..16}->iterate(i:Integer;

res:Sequence(Sequence(Boolean))=Set{false,true,oclUndefined(Boolean)}->iterate(b1,b2:Boolean;res:Sequence(Sequence(Boolean))=oclEmpty(Sequence(Sequence(Boolean)))|res->including(Sequence{b1,b2,not(b1),b1 and b2,b1 or b2,b1 xor b2,b1 implies b2,b1=b2,b1<>b2}))|res)

Expected Result:Sequence{Sequence{Undef,Undef,Undef,Undef,Undef,Undef,Undef,true, false},Sequence{Undef,false,Undef,false,Undef,Undef,Undef,false,true },Sequence{Undef,true, Undef,Undef,true, Undef,true, false,true },Sequence{false,Undef,true, false,Undef,Undef,true, false,true },Sequence{false,false,true, false,false,false,true, true, false},Sequence{false,true, true, false,true, true, true, false,true },Sequence{true, Undef,false,Undef,true, Undef,Undef,false,true },Sequence{true, false,false,false,true, true, false,false,true },Sequence{true, true, false,true, true, false,true, true, false}} :

Sequence(Sequence(Boolean))

--------------------------------------------------------------------- Invert a long string --------------------------------------------------------------------------------------------------------------?let base:String=’0123456789’.concat(’abcdefghijklmnopqrstuvwxyz’).

concat(’ABCDEFGHIJKLMNOPQRSTUVWXYZ’) inlet count:Integer=16 inlet longstr:String=Set{1..count}->iterate(i:Integer;res:String=’’|res.concat(base)) in

Set{1..longstr.size()}->iterate(i:Integer;res:String=’’|

239

res.concat(longstr.substring(longstr.size()+1-i,longstr.size()+1-i)))

Expected Result:’ZYX ... 210’ : String

--------------------------------------------------------------------- Compute all prime numbers up to a given upper bound -------------------------------------------------------------------------------

?Sequence{1..2048}->iterate(i:Integer;res:Sequence(Integer)=oclEmpty(Sequence(Integer))|if m.isPrime(i) then res->including(i) else res endif)

Expected Result:Sequence{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,

73,79,83,89,97, ..., 2003,2011,2017,2027,2029,2039} :Sequence(Integer)

?Sequence{1..16}->iterate(i;res:Sequence(Sequence(OclAny))=oclEmpty(Sequence(Sequence(OclAny)))|res->including(Sequence{i,m.isPrime(i)}))->select(last()=true)

Expected Result:Sequence{Sequence{2,true},Sequence{3,true},Sequence{5,true},

Sequence{7,true},Sequence{11,true},Sequence{13,true}} :Sequence(Sequence(OclAny))

--------------------------------------------------------------------- Compute the root of 10.89 with precision 1/10^16 ----------------------------------------------------------------------------------

?Set{1..16}->iterate(i;res:Real=m.root(10.89,

1/(10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10))|res)

Expected Result:3.300000000066939 : Real

--------------------------------------------------------------------- USE and Java are already bad in computing 3.3*3.3=10.89 ---------------------------------------------------------------------------?3.3*3.3

Expected Result:

240

10.889999999999999 : Real

10.2. Queries based on UML Model B

?Town.allInstances->collect(t|t.connectPlus()->size())->asSet()

Expected Result:Set{0,2,3,13,23} : Set(Integer)

. . . . . . . . . . . . . . . . . . . . . . . .

?Set{1..1024*1024}->iterate(i;res:Bag(Set(Town))=Town.allInstances->collect(t|t.connectPlus())|res)

Expected Result:Bag{Set{},Set{Town21,Town25}, ...

Set{Town1,Town11,Town13,Town14,Town16,Town18,Town19,Town2,Town22,Town23,Town26,Town28,Town29,Town3,Town33,Town36,Town38,Town39,Town4,Town40,Town41,Town5,Town9}} :

Bag(Set(Town))

. . . . . . . . . . . . . . . . . . . . . . . .

?Town.allInstances->select(t|t.connectPlus()->size()=0)

Expected Result:Set{Town20} : Set(Town)

. . . . . . . . . . . . . . . . . . . . . . . .

?Town.allInstances->select(t|t.connectPlus()->size()=2)

Expected Result:Set{Town21,Town25} : Set(Town)

. . . . . . . . . . . . . . . . . . . . . . . .

?Town.allInstances->select(t|t.connectPlus()->size()=3)

Expected Result:Set{Town10,Town15,Town30} : Set(Town)

. . . . . . . . . . . . . . . . . . . . . . . .

241

?Town.allInstances->select(t|t.connectPlus()->size()=13)

Expected Result:Set{Town12,Town17,Town24,Town27,Town31,Town32,Town34,Town35,

Town37,Town42,Town6,Town7,Town8} : Set(Town)

. . . . . . . . . . . . . . . . . . . . . . . .

?Town.allInstances->select(t|t.connectPlus()->size()=23)

Expected Result:Set{Town1,Town11,Town13,Town14,Town16,Town18,Town19,Town2,Town22,

Town23,Town26,Town28,Town29,Town3,Town33,Town36,Town38,Town39,Town4,Town40,Town41,Town5,Town9} : Set(Town)

. . . . . . . . . . . . . . . . . . . . . . . .

?Town.allInstances->collect(t|Seq{t,t.connect()->size()})->

sortedBy(s|s->last()->oclAsType(Integer))

Expected Result:Seq{Seq{Town20,0},Seq{Town10,1},Seq{Town12,1},Seq{Town21,1},

Seq{Town22,1},Seq{Town23,1},Seq{Town25,1},Seq{Town26,1},Seq{Town27,1},Seq{Town3 ,1},Seq{Town30,1},Seq{Town33,1},Seq{Town34,1},Seq{Town37,1},Seq{Town40,1},Seq{Town41,1},Seq{Town5 ,1},Seq{Town11,2},Seq{Town14,2},Seq{Town15,2},Seq{Town19,2},Seq{Town24,2},Seq{Town28,2},Seq{Town32,2},Seq{Town35,2},Seq{Town36,2},Seq{Town39,2},Seq{Town4 ,2},Seq{Town42,2},Seq{Town6 ,2},Seq{Town18,3},Seq{Town2 ,3},Seq{Town29,3},Seq{Town31,3},Seq{Town38,3},Seq{Town7 ,3},Seq{Town8 ,3},Seq{Town1 ,4},Seq{Town13,4},Seq{Town16,4},Seq{Town9 ,4},Seq{Town17,5}} : Seq(Seq(OclAny))

242

top related