Skip to content

Commit c2eb5bd

Browse files
Cameron-Lowstrub
authored andcommitted
Use reductive equality tests, and destruct the last matching operator
1 parent feb688f commit c2eb5bd

2 files changed

Lines changed: 48 additions & 3 deletions

File tree

src/phl/ecPhlEager.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ let destruct_on_op id_op tc =
9696
let env = FApi.tc1_env tc and es = tc1_as_equivS tc in
9797
let s =
9898
try
99-
let s, _ = split_at_cpos1 env (-1, `ByMatch (None, id_op)) es.es_sl
99+
let s, _ = split_at_cpos1 env (-1, `ByMatch (Some (-1), id_op)) es.es_sl
100100
(* ensure the right statement also contains an [id_op]: *)
101101
and _, _ = split_at_cpos1 env (1, `ByMatch (None, id_op)) es.es_sr in
102102
s
@@ -237,7 +237,7 @@ let t_eager_while_r i tc =
237237
subst_expr (add_memory empty mr ml)
238238
in
239239

240-
if (not (e_equal e (sub_to_left_mem _e))) then
240+
if (not (ER.EqTest.for_expr env e (sub_to_left_mem _e))) then
241241
tc_error !!tc "eager: both while guards must be syntactically equal";
242242

243243
let eqMem1 = eq_on_form_and_stmt env i c' and eqI = eq_on_sided_form env i in
@@ -317,7 +317,7 @@ let t_eager_fun_def_r tc =
317317
let t_eager_fun_abs_r i tc =
318318
let env, _, _ = FApi.tc1_eflat tc and eg = tc1_as_eagerF tc in
319319

320-
if not (s_equal eg.eg_sl eg.eg_sr) then
320+
if not (ER.EqTest.for_stmt env eg.eg_sl eg.eg_sr) then
321321
tc_error !!tc "eager: both swapping statements must be identical";
322322

323323
if not (ensure_eq_shape tc i.ml i.mr i.inv) then

tests/eager-lastop.ec

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module DoubleIf = {
2+
proc f() = {
3+
var x: int;
4+
5+
if ((fun x => x) true) {}
6+
x <- 0;
7+
if (false) {}
8+
}
9+
proc g() = {
10+
var x: int;
11+
12+
if (false) {}
13+
if (true) {}
14+
x <- 0;
15+
}
16+
}.
17+
18+
equiv dif: DoubleIf.f ~ DoubleIf.g: true ==> true.
19+
proof.
20+
proc.
21+
eager if; expect 4.
22+
abort.
23+
24+
module DoubleWhile = {
25+
proc f() = {
26+
var x: int;
27+
28+
x <- 0;
29+
while ((fun x => x) true) {}
30+
while (false) {}
31+
}
32+
proc g() = {
33+
var x: int;
34+
35+
while (false) {}
36+
x <- 0;
37+
while (true) {}
38+
}
39+
}.
40+
41+
equiv dwl: DoubleWhile.f ~ DoubleWhile.g: true ==> true.
42+
proof.
43+
proc.
44+
eager while (true); expect 6.
45+
abort.

0 commit comments

Comments
 (0)