aboutsummaryrefslogtreecommitdiffstats
path: root/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql
diff options
context:
space:
mode:
Diffstat (limited to 'Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql')
-rw-r--r--Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql112
1 files changed, 112 insertions, 0 deletions
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql
new file mode 100644
index 00000000..982e6cec
--- /dev/null
+++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql
@@ -0,0 +1,112 @@
1package modes3.queries
2
3import "http://www.ece.mcgill.ca/wcet/modes3"
4
5@Constraint(message = "turnoutInSegments", severity = "error", key = { T })
6pattern turnoutInSegments(T : Turnout) {
7 Modes3ModelRoot.segments(_, T);
8}
9
10pattern connectedTo(S1 : Segment, S2 : Segment) {
11 Segment.connectedTo(S1, S2);
12}
13
14@Constraint(message = "connectedToNotSymmetric", severity = "error", key = { S1, S2 })
15pattern connectedToNotSymmetric(S1 : Segment, S2 : Segment) {
16 Segment.connectedTo(S1, S2);
17 neg find connectedTo(S2, S1);
18}
19
20@Constraint(message = "connectedToReflexive", severity = "error", key = { S })
21pattern connectedToReflexive(S : Segment) {
22 Segment.connectedTo(S, S);
23}
24
25pattern turnoutOutput(T : Turnout, S : Segment) {
26 Turnout.straight(T, S);
27} or {
28 Turnout.divergent(T, S);
29}
30
31@Constraint(message = "outputReflexive", severity = "error", key = { T })
32pattern outputReflexive(T : Turnout) {
33 find turnoutOutput(T, T);
34}
35
36@Constraint(message = "turnoutOutputsAreSame", severity = "error", key = { T })
37pattern turnoutOutputsAreSame(T : Turnout) {
38 Turnout.straight(T, S);
39 Turnout.divergent(T, S);
40}
41
42pattern turnout(T : Turnout) {
43 Turnout(T);
44}
45
46pattern output(S1 : Segment, S2 : Segment) {
47 Segment.connectedTo(S1, S2);
48} or {
49 find turnoutOutput(S1, S2);
50}
51
52//@Constraint(message = "noInputOfSegment", severity = "error", key = { S })
53//pattern noInputOfSegment(S : Segment) {
54// neg find turnout(S);
55// neg find output(_, S);
56//}
57
58@Constraint(message = "tooManyInputsOfSegment", severity = "error", key = { S })
59pattern tooManyInputsOfSegment(S : Segment) {
60 neg find turnout(S);
61 find output(I1, S);
62 find output(I2, S);
63 find output(I3, S);
64 I1 != I2;
65 I1 != I3;
66 I2 != I3;
67}
68
69@Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T })
70pattern turnoutConnectedToBothOutputs(T : Turnout) {
71 Turnout.straight(T, Straight);
72 Turnout.divergent(T, Divergent);
73 Segment.connectedTo(T, Straight);
74 Segment.connectedTo(T, Divergent);
75}
76
77pattern extraInputOfTurnout(T : Turnout, S : Segment) {
78 Turnout.straight(T, Straight);
79 Turnout.divergent(T, Divergent);
80 find output(S, T);
81 S != Straight;
82 S != Divergent;
83}
84
85@Constraint(message = "noExtraInputOfTurnout", severity = "error", key = { T })
86pattern noExtraInputOfTurnout(T : Turnout) {
87 neg find extraInputOfTurnout(T, _);
88}
89
90@Constraint(message = "tooManyExtraInputsOfTurnout", severity = "error", key = { T })
91pattern tooManyExtraInputsOfTurnout(T : Turnout) {
92 find extraInputOfTurnout(T, I1);
93 find extraInputOfTurnout(T, I2);
94 I1 != I2;
95}
96
97pattern adjacent(S1 : Segment, S2 : Segment) {
98 find output(S1, S2);
99} or {
100 find turnoutOutput(S2, S1);
101}
102
103pattern reachable(S1 : Segment, S2 : Segment) {
104 S1 == S2;
105} or {
106 find adjacent+(S1, S2);
107}
108
109@Constraint(message = "unreachable", severity = "error", key = { S1, S2 })
110pattern unreachable(S1 : Segment, S2 : Segment) {
111 neg find reachable(S1, S2);
112}