Skip to content

Commit 3f8f739

Browse files
committed
Fix issue 1243
The fix consists in using `declared_ids` to guarantee that we never define symbols that have not been declared at the current assertion level in models. A proper fix requires a lot of work as we need to rework the push/pop mechanism of CDCL. This PR is rebased OCamlPro#1280 to ensure we won't mix identifiers from different assertion levels as it could happen with string-based identifiers.
1 parent 8150259 commit 3f8f739

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/lib/reasoners/uf.ml

+16-3
Original file line numberDiff line numberDiff line change
@@ -1117,12 +1117,25 @@ let is_suspicious_symbol = function
11171117
| Symbols.Name { id; _ } when Id.is_suspicious id -> true
11181118
| _ -> false
11191119

1120-
let terms env =
1120+
module ConstSet = Set.Make (Dolmen.Std.Expr.Term.Const)
1121+
1122+
let terms ~declared_ids env =
1123+
let declared =
1124+
List.fold_left
1125+
(fun acc (tcst, _, _) -> ConstSet.add tcst acc)
1126+
ConstSet.empty declared_ids
1127+
in
11211128
ME.fold
11221129
(fun t r ((terms, suspicious) as acc) ->
11231130
let Expr.{ f; _ } = Expr.term_view t in
11241131
match f with
1125-
| Name { id = Term_cst { defined = true; _ }; _ } ->
1132+
| Name { id = Term_cst { tcst; _ }; _ }
1133+
when not @@ ConstSet.mem tcst declared ->
1134+
(* XXX: the current push/pop mechanism of CDCL is insufficient
1135+
to guarantee that only identifiers declared at the current
1136+
assertion level reach this point.
1137+
The [declared_ids] argument does not have this issue.
1138+
See issue https://github.com/OCamlPro/alt-ergo/issues/1243. *)
11261139
(* We do not store names defined by the user. *)
11271140
acc
11281141
| _ ->
@@ -1256,7 +1269,7 @@ let extract_concrete_model cache =
12561269
let compute_concrete_model_of_val = compute_concrete_model_of_val cache in
12571270
let get_abstract_for = Cache.get_abstract_for cache.abstracts
12581271
in fun ~prop_model ~declared_ids env ->
1259-
let terms, suspicious = terms env in
1272+
let terms, suspicious = terms ~declared_ids env in
12601273
let model, mrepr =
12611274
MED.fold (fun t _mk acc -> compute_concrete_model_of_val env t acc)
12621275
terms (ModelMap.empty ~suspicious declared_ids, ME.empty)

0 commit comments

Comments
 (0)