Skip to content

Commit f4ade94

Browse files
LucianoXustrub
authored andcommitted
Add checks to ensure post-execution memory independence in pr-rewrite
1 parent 7035747 commit f4ade94

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/phl/ecPhlPrRw.ml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,18 @@ let t_pr_rewrite_low (s, (dof: (_ -> _ -> _ -> ss_inv) option)) tc =
250250
let (resv, k) = map_ss_inv_destr2 destr_eq pr.pr_event in
251251
let k_id = EcEnv.LDecl.fresh_id hyps "k" in
252252
let d = (oget dof) tc torw (EcTypes.tdistr k.inv.f_ty) in
253-
(* FIXME: Ensure that d.inv does not use d.m *)
254-
(* FIXME: Ensure that k.inv does not use k.m *)
253+
(* Check that k and d do not reference the post-execution memory.
254+
Otherwise the rewrite is unsound: the event `res = k` would use
255+
k from the post-state, but `mu1 d k` treats k as a constant. *)
256+
let post_mem = Mid.singleton k.m () in
257+
if not (Mid.set_disjoint k.inv.f_fv post_mem) then
258+
tc_error !!tc
259+
"Pr-rewrite: the value compared to res must not depend on \
260+
the post-execution memory";
261+
if not (Mid.set_disjoint d.inv.f_fv post_mem) then
262+
tc_error !!tc
263+
"Pr-rewrite: the distribution must not depend on \
264+
the post-execution memory";
255265
(pr_mu1_le_eq_mu1 pr_mem pr_fun pr_args resv k.inv k_id d.inv, 2)
256266

257267
| (`MuEq | `MuSub as kind) -> begin

0 commit comments

Comments
 (0)