Skip to content

Commit c497bd6

Browse files
feat: make slices and indices safe (#718)
1 parent de437f4 commit c497bd6

26 files changed

+2980
-73
lines changed

conjure_oxide/tests/integration/basic/matrix/01-indexing/input-expected-rule-trace-human.txt

+287-3
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,305 @@ such that
1212

1313
--
1414

15+
a[1],
16+
~~> index_to_bubble ([("Bubble", 6000)])
17+
{a[1] @ and([__inDomain(1,int(1..5));int(1..)])}
18+
19+
--
20+
21+
and([__inDomain(1,int(1..5));int(1..)]),
22+
~~> apply_eval_constant ([("Constant", 9001)])
23+
true
24+
25+
--
26+
27+
({a[1] @ true} = true),
28+
~~> bubble_up ([("Bubble", 8900)])
29+
{(a[1] = true) @ and([true;int(1..)])}
30+
31+
--
32+
33+
and([true;int(1..)]),
34+
~~> apply_eval_constant ([("Constant", 9001)])
35+
true
36+
37+
--
38+
39+
{(a[1] = true) @ true},
40+
~~> expand_bubble ([("Bubble", 8900)])
41+
and([(a[1] = true),true;int(1..)])
42+
43+
--
44+
45+
and([(a[1] = true),true;int(1..)]),
46+
~~> partial_evaluator ([("Base", 9000)])
47+
and([(a[1] = true);int(1..)])
48+
49+
--
50+
51+
and([(a[1] = true);int(1..)]),
52+
~~> remove_unit_vector_and ([("Base", 8800)])
53+
(a[1] = true)
54+
55+
--
56+
57+
a[2],
58+
~~> index_to_bubble ([("Bubble", 6000)])
59+
{a[2] @ and([__inDomain(2,int(1..5));int(1..)])}
60+
61+
--
62+
63+
and([__inDomain(2,int(1..5));int(1..)]),
64+
~~> apply_eval_constant ([("Constant", 9001)])
65+
true
66+
67+
--
68+
69+
({a[2] @ true} = true),
70+
~~> bubble_up ([("Bubble", 8900)])
71+
{(a[2] = true) @ and([true;int(1..)])}
72+
73+
--
74+
75+
and([true;int(1..)]),
76+
~~> apply_eval_constant ([("Constant", 9001)])
77+
true
78+
79+
--
80+
81+
{(a[2] = true) @ true},
82+
~~> expand_bubble ([("Bubble", 8900)])
83+
and([(a[2] = true),true;int(1..)])
84+
85+
--
86+
87+
and([(a[2] = true),true;int(1..)]),
88+
~~> partial_evaluator ([("Base", 9000)])
89+
and([(a[2] = true);int(1..)])
90+
91+
--
92+
93+
and([(a[2] = true);int(1..)]),
94+
~~> remove_unit_vector_and ([("Base", 8800)])
95+
(a[2] = true)
96+
97+
--
98+
99+
a[3],
100+
~~> index_to_bubble ([("Bubble", 6000)])
101+
{a[3] @ and([__inDomain(3,int(1..5));int(1..)])}
102+
103+
--
104+
105+
and([__inDomain(3,int(1..5));int(1..)]),
106+
~~> apply_eval_constant ([("Constant", 9001)])
107+
true
108+
109+
--
110+
111+
({a[3] @ true} = true),
112+
~~> bubble_up ([("Bubble", 8900)])
113+
{(a[3] = true) @ and([true;int(1..)])}
114+
115+
--
116+
117+
and([true;int(1..)]),
118+
~~> apply_eval_constant ([("Constant", 9001)])
119+
true
120+
121+
--
122+
123+
{(a[3] = true) @ true},
124+
~~> expand_bubble ([("Bubble", 8900)])
125+
and([(a[3] = true),true;int(1..)])
126+
127+
--
128+
129+
and([(a[3] = true),true;int(1..)]),
130+
~~> partial_evaluator ([("Base", 9000)])
131+
and([(a[3] = true);int(1..)])
132+
133+
--
134+
135+
and([(a[3] = true);int(1..)]),
136+
~~> remove_unit_vector_and ([("Base", 8800)])
137+
(a[3] = true)
138+
139+
--
140+
141+
a[4],
142+
~~> index_to_bubble ([("Bubble", 6000)])
143+
{a[4] @ and([__inDomain(4,int(1..5));int(1..)])}
144+
145+
--
146+
147+
and([__inDomain(4,int(1..5));int(1..)]),
148+
~~> apply_eval_constant ([("Constant", 9001)])
149+
true
150+
151+
--
152+
153+
({a[4] @ true} = true),
154+
~~> bubble_up ([("Bubble", 8900)])
155+
{(a[4] = true) @ and([true;int(1..)])}
156+
157+
--
158+
159+
and([true;int(1..)]),
160+
~~> apply_eval_constant ([("Constant", 9001)])
161+
true
162+
163+
--
164+
165+
{(a[4] = true) @ true},
166+
~~> expand_bubble ([("Bubble", 8900)])
167+
and([(a[4] = true),true;int(1..)])
168+
169+
--
170+
171+
and([(a[4] = true),true;int(1..)]),
172+
~~> partial_evaluator ([("Base", 9000)])
173+
and([(a[4] = true);int(1..)])
174+
175+
--
176+
177+
and([(a[4] = true);int(1..)]),
178+
~~> remove_unit_vector_and ([("Base", 8800)])
179+
(a[4] = true)
180+
181+
--
182+
183+
a[5],
184+
~~> index_to_bubble ([("Bubble", 6000)])
185+
{a[5] @ and([__inDomain(5,int(1..5));int(1..)])}
186+
187+
--
188+
189+
and([__inDomain(5,int(1..5));int(1..)]),
190+
~~> apply_eval_constant ([("Constant", 9001)])
191+
true
192+
193+
--
194+
195+
({a[5] @ true} = Not(a[4])),
196+
~~> bubble_up ([("Bubble", 8900)])
197+
{(a[5] = Not(a[4])) @ and([true;int(1..)])}
198+
199+
--
200+
201+
and([true;int(1..)]),
202+
~~> apply_eval_constant ([("Constant", 9001)])
203+
true
204+
205+
--
206+
207+
{(a[5] = Not(a[4])) @ true},
208+
~~> expand_bubble ([("Bubble", 8900)])
209+
and([(a[5] = Not(a[4])),true;int(1..)])
210+
211+
--
212+
213+
and([(a[5] = Not(a[4])),true;int(1..)]),
214+
~~> partial_evaluator ([("Base", 9000)])
215+
and([(a[5] = Not(a[4]));int(1..)])
216+
217+
--
218+
219+
and([(a[5] = Not(a[4]));int(1..)]),
220+
~~> remove_unit_vector_and ([("Base", 8800)])
221+
(a[5] = Not(a[4]))
222+
223+
--
224+
225+
a[4],
226+
~~> index_to_bubble ([("Bubble", 6000)])
227+
{a[4] @ and([__inDomain(4,int(1..5));int(1..)])}
228+
229+
--
230+
231+
and([__inDomain(4,int(1..5));int(1..)]),
232+
~~> apply_eval_constant ([("Constant", 9001)])
233+
true
234+
235+
--
236+
237+
Not({a[4] @ true}),
238+
~~> bubble_up ([("Bubble", 8900)])
239+
{Not(a[4]) @ and([true;int(1..)])}
240+
241+
--
242+
243+
and([true;int(1..)]),
244+
~~> apply_eval_constant ([("Constant", 9001)])
245+
true
246+
247+
--
248+
249+
{Not(a[4]) @ true},
250+
~~> expand_bubble ([("Bubble", 8900)])
251+
and([Not(a[4]),true;int(1..)])
252+
253+
--
254+
255+
and([Not(a[4]),true;int(1..)]),
256+
~~> partial_evaluator ([("Base", 9000)])
257+
and([Not(a[4]);int(1..)])
258+
259+
--
260+
261+
and([Not(a[4]);int(1..)]),
262+
~~> remove_unit_vector_and ([("Base", 8800)])
263+
Not(a[4])
264+
265+
--
266+
267+
(a[5] = Not(a[4])),
268+
~~> flatten_eq ([("Minion", 4200)])
269+
(__0 = __1)
270+
new variables:
271+
find __0: bool
272+
find __1: bool
273+
new constraints:
274+
__0 =aux a[5]
275+
__1 =aux Not(a[4])
276+
--
277+
278+
__1 =aux Not(a[4]),
279+
~~> bool_eq_to_reify ([("Minion", 4400)])
280+
Reify(Not(a[4]), __1)
281+
282+
--
283+
15284
Not(a[4]),
16-
~~> not_constraint_to_reify ([("Minion", 4090)])
17-
Reify(a[4], false)
285+
~~> flatten_generic ([("Minion", 4200)])
286+
Not(__2)
287+
new variables:
288+
find __2: bool
289+
new constraints:
290+
__2 =aux a[4]
291+
--
292+
293+
Not(__2),
294+
~~> not_literal_to_wliteral ([("Minion", 4100)])
295+
WatchedLiteral(__2,false)
18296

19297
--
20298

21299
Final model:
22300

23301
find a: matrix indexed by [[int(1..5)]] of bool
302+
find __0: bool
303+
find __1: bool
304+
find __2: bool
24305

25306
such that
26307

27308
(a[1] = true),
28309
(a[2] = true),
29310
(a[3] = true),
30311
(a[4] = true),
31-
(a[5] = Reify(a[4], false))
312+
(__0 = __1),
313+
__0 =aux a[5],
314+
Reify(WatchedLiteral(__2,false), __1),
315+
__2 =aux a[4]
32316

0 commit comments

Comments
 (0)