Skip to content

Commit 34545e5

Browse files
committed
Fix bug in SMT translation (abstraction of non-translatable constructions)
When abstracting out a construction that is not translatable into SMT, make the abstraction symbol depends on the local variables. If not, the translation is unsound by making the translated constructions a constant. For example, the following (where G will be abtracted): ``` fun x => G x ``` is translated into ``` fun x => fresh-constant ```
1 parent 508436e commit 34545e5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/ecSmt.ml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -913,17 +913,25 @@ and trans_pr ((genv,lenv) as env) {pr_mem; pr_fun; pr_args; pr_event} =
913913
in WTerm.t_app_infer fs_mu [d; wev]
914914

915915
(* -------------------------------------------------------------------- *)
916-
and trans_gen ((genv, _) as env : tenv * lenv) (fp : form) =
916+
and trans_gen ((genv, lenv) as env : tenv * lenv) (fp : form) =
917917
match Hf.find_opt genv.te_gen fp with
918918
| None ->
919919
let name = WIdent.id_fresh "x" in
920+
let argsty, args =
921+
let fv = Mid.keys fp.f_fv in
922+
let fv = List.pmap (fun x -> Mid.find_opt x lenv.le_lv) fv in
923+
(
924+
List.map (fun v -> v.WTerm.vs_ty) fv,
925+
List.map WTerm.t_var fv
926+
) in
927+
920928
let wty =
921929
if EcReduction.EqTest.is_bool genv.te_env fp.f_ty
922930
then None
923931
else Some (trans_ty env fp.f_ty) in
924932

925-
let lsym = WTerm.create_lsymbol name [] wty in
926-
let term = WTerm.t_app_infer lsym [] in
933+
let lsym = WTerm.create_lsymbol name argsty wty in
934+
let term = WTerm.t_app_infer lsym args in
927935

928936
genv.te_task <- WTask.add_param_decl genv.te_task lsym;
929937
Hf.add genv.te_gen fp term;

0 commit comments

Comments
 (0)