Skip to content

Commit 04d4d4d

Browse files
authored
Minor fixes for sim
- handle M.f(x, y) vs M.f((x, y)) cases - allow matching local operators
1 parent b1ec3df commit 04d4d4d

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/ecPV.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,8 @@ module Mpv2 = struct
942942
let local = enter_local env local bds1 bds2 in
943943
add_eqs_loc env local eqs e1 e2
944944
| Eint i1, Eint i2 when EcBigInt.equal i1 i2 -> eqs
945-
| Elocal x1, Elocal x2 when
945+
| Elocal x1, Elocal x2
946+
when EcIdent.id_equal x1 x2 ||
946947
opt_equal EcIdent.id_equal (Some x1) (Mid.find_opt x2 local) -> eqs
947948
| Evar pv1, Evar pv2
948949
when EcReduction.EqTest.for_type env e1.e_ty e2.e_ty ->

src/phl/ecPhlEqobs.ml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,30 @@ and i_eqobs_in il ir sim local (eqo:Mpv2.t) =
218218
| Sasgn(lvl,el), Sasgn(lvr,er) | Srnd(lvl,el), Srnd(lvr,er) ->
219219
sim, add_eqs sim local (remove sim lvl lvr eqo) el er
220220

221-
| Scall(lvl,fl,argsl), Scall(lvr,fr,argsr)
222-
when List.length argsl = List.length argsr ->
221+
| Scall(lvl,fl,argsl), Scall(lvr,fr,argsr) ->
223222
let eqo = oremove sim lvl lvr eqo in
224223
let env = sim.sim_env in
225224
let modl, modr = f_write env fl, f_write env fr in
226225
let eqnm = Mpv2.split_nmod env modl modr eqo in
227226
let outf = Mpv2.split_mod env modl modr eqo in
228227
Mpv2.check_glob outf;
229228
let sim, eqi = f_eqobs_in fl fr sim outf in
229+
230+
let argsl, argsr =
231+
match argsl, argsr with
232+
| _, _ when List.length argsl = List.length argsr -> argsl, argsr
233+
| [al], _ -> begin
234+
match al.e_node with
235+
| Etuple argsl -> argsl, argsr
236+
| _ -> raise EqObsInError
237+
end
238+
| _, [ar] -> begin
239+
match ar.e_node with
240+
| Etuple argsr -> argsl, argsr
241+
| _ -> raise EqObsInError
242+
end
243+
| _ -> raise EqObsInError
244+
in
230245
let eqi = List.fold_left2 (add_eqs sim local) (Mpv2.union eqnm eqi) argsl argsr in
231246
sim, eqi
232247

0 commit comments

Comments
 (0)