diff options
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.run/queries/familyTreeConstraintsNumUB.vql')
-rw-r--r-- | Tests/MODELS2020-CaseStudies/case.study.pledge.run/queries/familyTreeConstraintsNumUB.vql | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/queries/familyTreeConstraintsNumUB.vql b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/queries/familyTreeConstraintsNumUB.vql new file mode 100644 index 00000000..f8650073 --- /dev/null +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/queries/familyTreeConstraintsNumUB.vql | |||
@@ -0,0 +1,47 @@ | |||
1 | package queries | ||
2 | |||
3 | import "http://www.example.org/familytree" | ||
4 | |||
5 | @Constraint(message="memberIsItsOwnParent", severity="error", key={m}) | ||
6 | pattern memberIsItsOwnParent(m: Member) = { | ||
7 | FamilyTree.members(_, m); | ||
8 | Member.parents(m, p); | ||
9 | m == p; | ||
10 | } | ||
11 | |||
12 | @Constraint(message="twoMembersHaveNoParent", severity="error", key={m1, m2}) | ||
13 | pattern twoMembersHaveNoParent(m1:Member, m2:Member) = { | ||
14 | neg find memberHasParent(m1); | ||
15 | neg find memberHasParent(m2); | ||
16 | m1 != m2; | ||
17 | } | ||
18 | |||
19 | pattern memberHasParent(m: Member) = { | ||
20 | Member.parents(m, _); | ||
21 | } | ||
22 | |||
23 | @Constraint(message="negativeAge", severity="error",key={m}) | ||
24 | pattern negativeAge(m: Member) { | ||
25 | Member.age(m,mage); | ||
26 | check(mage<0); | ||
27 | } | ||
28 | |||
29 | @Constraint(message="realisticAge", severity="error",key={m}) | ||
30 | pattern realisticAge(m: Member) { | ||
31 | Member.age(m,mage); | ||
32 | check(mage>120); | ||
33 | } | ||
34 | |||
35 | @Constraint(message="parentTooYoung", severity="error", key={c, p}) | ||
36 | pattern parentTooYoung(c: Member, p: Member) = { | ||
37 | FamilyTree.members(_, c); | ||
38 | Member.parents(c, p); | ||
39 | Member.age(c, cAge); | ||
40 | Member.age(p, pAge); | ||
41 | check (pAge <= (cAge + 12)); | ||
42 | } | ||
43 | |||
44 | |||
45 | |||
46 | |||
47 | |||