Skip to content

Commit

Permalink
Fix issue 1212
Browse files Browse the repository at this point in the history
During model extraction, we only should store accesses to arrays whose the
representative elements are names. Indeed, if the representative is not
a name, this array cannot appear in a model.

The embedded case is correctly managed because we generate fresh names
that will become the representative elements.
  • Loading branch information
Halbaroth committed Nov 13, 2024
1 parent 9eb059d commit 23bdf82
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/lib/reasoners/uf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1158,11 +1158,12 @@ end

type cache = {
array_selects: Expr.t E.Table.t E.Table.t;
(** Stores all the get accesses to arrays. *)
(** Stores all the get accesses to array names. *)

abstracts: Expr.t Shostak.HX.t;
(** Stores all the abstract values generated. This cache is necessary
to ensure we don't generate twice an abstract value for a given symbol. *)
to ensure we do not generate twice an abstract value for a given
symbol. *)
}

let is_destructor = function
Expand Down Expand Up @@ -1224,8 +1225,13 @@ let compute_concrete_model_of_val cache =

| Sy.Op Sy.Get, [a; i], _ ->
begin
store_array_select a i ret_rep;
acc
let E.{ f = fa; _ } = E.term_view a in
match fa with
| Sy.Name _ ->
store_array_select a i ret_rep;
acc
| _ ->
acc
end

| Sy.Name { hs = id; _ }, _, _ ->
Expand Down Expand Up @@ -1273,8 +1279,7 @@ let extract_concrete_model cache =
| Sy.Name { hs; ns = User; _ } -> hs, true
| Sy.Name { hs; _ } -> hs, false
| _ ->
(* We only store array declarations as keys in the cache
[array_selects]. *)
(* Excluded in [compute_concrete_model_of_val] *)
assert false
in
let mdl =
Expand Down
6 changes: 6 additions & 0 deletions tests/issues/1212.default.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

unknown
(
(define-fun a () (Array Int Int) (as @a3 (Array Int Int)))
(define-fun b () (Array Int Int) (as @a2 (Array Int Int)))
)
7 changes: 7 additions & 0 deletions tests/issues/1212.default.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(set-option :produce-models true)
(set-logic ALL)
(declare-const a (Array Int Int))
(declare-const b (Array Int Int))
(assert (= (store a 0 0) (store b 0 0)))
(check-sat)
(get-model)

0 comments on commit 23bdf82

Please sign in to comment.