Skip to content

Commit 6669be1

Browse files
committed
ecall: avoid internal name collision in abstract_pvs
Thread hyps through the per-memory fold so each pass reserves its freshly minted `<symbol>_' names before the next memory is processed. Previously both sides freshened against the original hyps, so a contract argument naming the same program variable on both sides produced two identically-named idents, and t_intros_i rejected the second.
1 parent c64f7a3 commit 6669be1

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/phl/ecPhlExists.ml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,17 @@ let abstract_pvs
235235
| [ml; mr] -> fun inv -> Inv_ts { ml; mr; inv; }
236236
| _ -> assert false in
237237

238-
let for_memory (subst : EcPV.PVM.subst) (m : memory) =
238+
let for_memory ((subst, hyps) : EcPV.PVM.subst * LDecl.hyps) (m : memory) =
239239
let pvs = EcIdent.Mid.find_def [] m pvs in
240240

241241
let ids = List.map (fun (pv, ty) ->
242242
(Format.sprintf "%s_" (EcTypes.symbol_of_pv pv)), ty) pvs in
243-
let ids =
244-
List.combine
245-
(LDecl.fresh_ids hyps (List.fst ids))
246-
(List.snd ids) in
243+
let fresh = LDecl.fresh_ids hyps (List.fst ids) in
244+
let hyps =
245+
List.fold_left2 (fun hyps id (_, ty) ->
246+
LDecl.add_local id (LD_var (ty, None)) hyps)
247+
hyps fresh ids in
248+
let ids = List.combine fresh (List.snd ids) in
247249

248250
let pvs_as_inv = List.map (fun (pv, ty) ->
249251
mkinv (f_pvar pv ty m).inv
@@ -252,11 +254,11 @@ let abstract_pvs
252254
EcPV.PVM.add env pv m (f_local x ty) subst
253255
) subst (List.combine pvs (List.fst ids)) in
254256

255-
(subst, (ids, pvs, pvs_as_inv))
257+
((subst, hyps), (ids, pvs, pvs_as_inv))
256258
in
257259

258-
let subst, ids =
259-
List.fold_left_map for_memory EcPV.PVM.empty ms in
260+
let (subst, _), ids =
261+
List.fold_left_map for_memory (EcPV.PVM.empty, hyps) ms in
260262

261263
let ids = List.map proj3_1 ids
262264
and pvs = List.map proj3_2 ids

0 commit comments

Comments
 (0)