diff options
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.vql | 295 |
1 files changed, 295 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..d22bdd8b --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/src/modes3/queries/Modes3Queries.vql | |||
@@ -0,0 +1,295 @@ | |||
1 | package modes3.queries | ||
2 | |||
3 | import "http://www.ece.mcgill.ca/wcet/modes3" | ||
4 | |||
5 | pattern connectedTo(S1 : Segment, S2 : Segment) { | ||
6 | Segment.connectedTo(S1, S2); | ||
7 | } | ||
8 | |||
9 | @Constraint(message = "connectedToNotSymmetric", severity = "error", key = { S1, S2 }) | ||
10 | pattern connectedToNotSymmetric(S1 : Segment, S2 : Segment) { | ||
11 | Segment.connectedTo(S1, S2); | ||
12 | neg find connectedTo(S2, S1); | ||
13 | } | ||
14 | |||
15 | @Constraint(message = "connectedToReflexive", severity = "error", key = { S }) | ||
16 | pattern connectedToReflexive(S : Segment) { | ||
17 | Segment.connectedTo(S, S); | ||
18 | } | ||
19 | |||
20 | pattern turnoutOutput(T : Turnout, S : Segment) { | ||
21 | Turnout.straight(T, S); | ||
22 | } or { | ||
23 | Turnout.divergent(T, S); | ||
24 | } | ||
25 | |||
26 | @Constraint(message = "outputReflexive", severity = "error", key = { T }) | ||
27 | pattern outputReflexive(T : Turnout) { | ||
28 | find turnoutOutput(T, T); | ||
29 | } | ||
30 | |||
31 | @Constraint(message = "turnoutOutputsAreSame", severity = "error", key = { T }) | ||
32 | pattern turnoutOutputsAreSame(T : Turnout) { | ||
33 | Turnout.straight(T, S); | ||
34 | Turnout.divergent(T, S); | ||
35 | } | ||
36 | |||
37 | pattern output(S1 : Segment, S2 : Segment) { | ||
38 | Segment.connectedTo(S1, S2); | ||
39 | } or { | ||
40 | find turnoutOutput(S1, S2); | ||
41 | } | ||
42 | |||
43 | @Constraint(message = "tooManyInputsOfSegment", severity = "error", key = { S }) | ||
44 | pattern tooManyInputsOfSegment(S : SimpleSegment) { | ||
45 | find output(I1, S); | ||
46 | find output(I2, S); | ||
47 | find output(I3, S); | ||
48 | I1 != I2; | ||
49 | I1 != I3; | ||
50 | I2 != I3; | ||
51 | } | ||
52 | |||
53 | @Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) | ||
54 | pattern turnoutConnectedToBothOutputs(T : Turnout) { | ||
55 | Turnout.straight(T, Straight); | ||
56 | Turnout.divergent(T, Divergent); | ||
57 | Segment.connectedTo(T, Straight); | ||
58 | Segment.connectedTo(T, Divergent); | ||
59 | } | ||
60 | |||
61 | pattern adjacent(S1 : Segment, S2 : Segment) { | ||
62 | find output(S1, S2); | ||
63 | } or { | ||
64 | find turnoutOutput(S2, S1); | ||
65 | } | ||
66 | |||
67 | @Constraint(message = "turnoutConnectedToBothOutputs", severity = "error", key = { T }) | ||
68 | pattern tooManyInputsOfTurnout(T : Turnout) { | ||
69 | find adjacent(I1, T); | ||
70 | find adjacent(I2, T); | ||
71 | find adjacent(I3, T); | ||
72 | find adjacent(I4, T); | ||
73 | I1 != I2; | ||
74 | I1 != I3; | ||
75 | I1 != I4; | ||
76 | I2 != I3; | ||
77 | I2 != I4; | ||
78 | I3 != I4; | ||
79 | } | ||
80 | |||
81 | pattern inputsOfTurnout(T : Turnout) { | ||
82 | find adjacent(I1, T); | ||
83 | find adjacent(I2, T); | ||
84 | find adjacent(I3, T); | ||
85 | I1 != I2; | ||
86 | I1 != I3; | ||
87 | I2 != I3; | ||
88 | } | ||
89 | |||
90 | @Constraint(message = "tooFewInputsOfTurnout", severity = "error", key = { T }) | ||
91 | pattern tooFewInputsOfTurnout(T : Turnout) { | ||
92 | neg find inputsOfTurnout(T); | ||
93 | } | ||
94 | |||
95 | pattern reachable(S1 : Segment, S2 : Segment) { | ||
96 | S1 == S2; | ||
97 | } or { | ||
98 | find adjacent+(S1, S2); | ||
99 | } | ||
100 | |||
101 | @Constraint(message = "unreachable", severity = "error", key = { S1, S2 }) | ||
102 | pattern unreachable(S1 : Segment, S2 : Segment) { | ||
103 | neg find reachable(S1, S2); | ||
104 | } | ||
105 | |||
106 | // | ||
107 | // closeTrains | ||
108 | // | ||
109 | |||
110 | pattern closeTrains_step_2(in train : Train) { | ||
111 | // frame->t1 = model->trains[i0]; | ||
112 | // frame->start = frame->t1->location; | ||
113 | // if(frame->start != 0){ | ||
114 | // ... | ||
115 | // } | ||
116 | // + OUTER FOR LOOP COUNTER INCREMENT | ||
117 | Train(train); | ||
118 | } | ||
119 | |||
120 | pattern closeTrains_step_3(in train : Train, in start : Segment) { | ||
121 | // int loop_bound1 = frame->start->connected_to_count; | ||
122 | // for (int i1 = 0; i1 < loop_bound1; i1++) { LOOP COUNTER INCREMENT IS NOT INCLUDED HERE | ||
123 | // ... | ||
124 | // } | ||
125 | Train.location(train, start); | ||
126 | } | ||
127 | |||
128 | pattern closeTrains_step_4(in train : Train, in start : Segment, in middle : Segment) { | ||
129 | // frame->middle = frame->start->connected_to[i1]; | ||
130 | // int loop_bound2 = frame->middle->connected_to_count; | ||
131 | |||
132 | // for (int i2 = 0; i2 < loop_bound2; i2++) { LOOP COUNTER INCREMENT IS NOT INCLUDED HERE | ||
133 | // ... | ||
134 | // } | ||
135 | // + OUTER FOR LOOP COUNTER INCREMENT | ||
136 | Train.location(train, start); | ||
137 | Segment.connectedTo(start, middle); | ||
138 | } | ||
139 | |||
140 | pattern closeTrains_step_5(in train : Train, in start : Segment, in middle : Segment, in end : Segment) { | ||
141 | // frame->end = frame->middle->connected_to[i2]; | ||
142 | // if (frame->start != frame->end) { | ||
143 | // ... | ||
144 | // } | ||
145 | // + OUTER FOR LOOP COUNTER INCREMENT | ||
146 | Train.location(train, start); | ||
147 | Segment.connectedTo(start, middle); | ||
148 | Segment.connectedTo(middle, end); | ||
149 | } | ||
150 | |||
151 | pattern closeTrains_step_6(in train : Train, in start : Segment, in middle : Segment, in end : Segment) { | ||
152 | // frame->t2 = frame->end->train; | ||
153 | // if (frame->t2 != 0) { | ||
154 | // ... | ||
155 | // } | ||
156 | Train.location(train, start); | ||
157 | Segment.connectedTo(start, middle); | ||
158 | Segment.connectedTo(middle, end); | ||
159 | start != end; | ||
160 | } | ||
161 | |||
162 | pattern closeTrains_step_7(in train : Train, in start : Segment, in middle : Segment, in end : Segment, in otherTrain : Train) { | ||
163 | // results->matches[match_cntr].start = frame->start; | ||
164 | // results->matches[match_cntr++].end = frame->end; | ||
165 | Train.location(train, start); | ||
166 | Segment.connectedTo(start, middle); | ||
167 | Segment.connectedTo(middle, end); | ||
168 | start != end; | ||
169 | Segment.occupiedBy(end, otherTrain); | ||
170 | } | ||
171 | |||
172 | // | ||
173 | // trainLocations | ||
174 | // | ||
175 | |||
176 | pattern trainLocations_step_2(in train : Train) { | ||
177 | // frame->train = model->trains[i0]; | ||
178 | // frame->location = frame->train->location; | ||
179 | // if (frame->location != NULL) { | ||
180 | // ... | ||
181 | // } | ||
182 | |||
183 | Train(train); | ||
184 | } | ||
185 | |||
186 | pattern trainLocations_step_3(in train : Train, in location : Segment) { | ||
187 | // results->matches[match_cntr].location = frame->location; | ||
188 | // results->matches[match_cntr++].train = frame->train; | ||
189 | Train(train); | ||
190 | Train.location(train, location); | ||
191 | } | ||
192 | |||
193 | // | ||
194 | // misalignedTurnout | ||
195 | // | ||
196 | |||
197 | pattern misalignedTurnout_step_2(in turnout : Turnout) { | ||
198 | // frame->turnout = model->turnouts[i0]; | ||
199 | // frame->location = frame->turnout->straight; | ||
200 | // if (frame->location != NULL) { | ||
201 | // ... | ||
202 | // } | ||
203 | Turnout(turnout); | ||
204 | } | ||
205 | |||
206 | pattern misalignedTurnout_step_3(in turnout : Turnout, in location : Segment) { | ||
207 | // Segment *disconnected = ((Segment *)frame->turnout); | ||
208 | // if (disconnected->connected_to[0] != frame->location && | ||
209 | // disconnected->connected_to[1] != frame->location) { | ||
210 | // ... | ||
211 | // } | ||
212 | Turnout(turnout); | ||
213 | Turnout.straight(turnout, location); | ||
214 | } | ||
215 | |||
216 | pattern misalignedTurnout_step_4(in turnout : Turnout, in location : Segment) { | ||
217 | // frame->train = frame->location->train; | ||
218 | // if (frame->train != NULL) { | ||
219 | // ... | ||
220 | // } | ||
221 | Turnout(turnout); | ||
222 | Turnout.straight(turnout, location); | ||
223 | neg find connectedSegmentsDirected(turnout, location); | ||
224 | } | ||
225 | |||
226 | pattern misalignedTurnout_step_5(in turnout : Turnout, in location : Segment, in train : Train) { | ||
227 | // results->matches[match_cntr].start = frame->start; | ||
228 | // results->matches[match_cntr++].end = frame->end; | ||
229 | Turnout(turnout); | ||
230 | Turnout.straight(turnout, location); | ||
231 | neg find connectedSegmentsDirected(turnout, location); | ||
232 | Segment.occupiedBy(location, train); | ||
233 | } | ||
234 | |||
235 | pattern connectedSegmentsDirected(s1 : Segment, s2 : Segment) { | ||
236 | Segment.connectedTo(s1, s2); | ||
237 | } | ||
238 | |||
239 | // | ||
240 | // endOfSiding | ||
241 | // | ||
242 | |||
243 | pattern endOfSiding_step_2(in train : Train) { | ||
244 | // frame->train = model->trains[i0]; | ||
245 | // frame->location = frame->train->location; | ||
246 | // if (frame->location != NULL) { | ||
247 | // ... | ||
248 | // } | ||
249 | |||
250 | Train(train); | ||
251 | } | ||
252 | |||
253 | pattern endOfSiding_step_3(in train : Train, in location : Segment) { | ||
254 | // int loop_bound1 = frame->location->connected_to_count; | ||
255 | // for (int i1 = 0; i1 < loop_bound1; i1++) { | ||
256 | // ... | ||
257 | // } | ||
258 | Train(train); | ||
259 | Train.location(train, location); | ||
260 | } | ||
261 | |||
262 | pattern endOfSiding_step_4(in train : Train, in location : Segment, in end : Segment) { | ||
263 | // frame->end = frame->location->connected_to[i1]; | ||
264 | // if (frame->end != NULL && | ||
265 | // frame->end->connected_to[1] == frame->location && | ||
266 | // frame->end->connected_to[0] == NULL) { | ||
267 | // ... | ||
268 | // } | ||
269 | // if (frame->end != NULL && | ||
270 | // frame->end->connected_to[0] == frame->location && | ||
271 | // frame->end->connected_to[1] == NULL) { | ||
272 | // ... | ||
273 | // } | ||
274 | Train(train); | ||
275 | Train.location(train, location); | ||
276 | Segment.connectedTo(location, end); | ||
277 | } | ||
278 | |||
279 | pattern endOfSiding_step_5(in train : Train, in location : Segment, in end : Segment) { | ||
280 | // results->matches[match_cntr].location = frame->location; | ||
281 | // results->matches[match_cntr++].train = frame->train; | ||
282 | // ...OR... | ||
283 | // results->matches[match_cntr].location = frame->location; | ||
284 | // results->matches[match_cntr++].train = frame->train; | ||
285 | Train(train); | ||
286 | Train.location(train, location); | ||
287 | Segment.connectedTo(location, end); | ||
288 | neg find multipleConnectedTo(end); | ||
289 | } | ||
290 | |||
291 | pattern multipleConnectedTo(s : Segment) { | ||
292 | Segment.connectedTo(s, n1); | ||
293 | Segment.connectedTo(s, n2); | ||
294 | n1 != n2; | ||
295 | } | ||