-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fresh names in polymorphic model #1213
Comments
This should be the job of |
Of course, I tried to fix this bug by modifying |
Quick proof of concept (the code for array models needs to be adapted): diff --git a/src/lib/reasoners/records.ml b/src/lib/reasoners/records.ml
index cb8e1170..b14b3d56 100644
--- a/src/lib/reasoners/records.ml
+++ b/src/lib/reasoners/records.ml
@@ -390,12 +390,12 @@ module Shostak (X : ALIEN) = struct
| Record (_, ty) ->
if List.exists (fun (t,_) -> Expr.is_model_term t) eq
then None
- else Some (Expr.fresh_name ty, false)
+ else Some (Expr.mk_abstract ty, false)
| Other (_,ty) ->
match ty with
| Ty.Trecord { Ty.lbs; _ } ->
- let rev_lbs = List.rev_map (fun (_, ty) -> Expr.fresh_name ty) lbs in
+ let rev_lbs = List.rev_map (fun (_, ty) -> Expr.mk_abstract ty) lbs in
let s = E.mk_term (Symbols.Op Symbols.Record) (List.rev rev_lbs) ty in
Some (s, false) (* false <-> not a case-split *)
| _ -> assert false
diff --git a/src/lib/reasoners/shostak.ml b/src/lib/reasoners/shostak.ml
index 8b308859..bd7df537 100644
--- a/src/lib/reasoners/shostak.ml
+++ b/src/lib/reasoners/shostak.ml
@@ -579,13 +579,6 @@ struct
| _, Ty.Treal -> ARITH.assign_value r distincts eq
| _, Ty.Trecord _ -> RECORDS.assign_value r distincts eq
| _, Ty.Tbitv _ -> BITV.assign_value r distincts eq
- | Term t, Ty.Tfarray _ ->
- begin
- if List.exists (fun (t,_) -> Expr.is_model_term t) eq then None
- else
- Some (Expr.fresh_name (Expr.type_info t), false)
- end
-
| _, Ty.Tadt _ when not (Options.get_disable_adts()) ->
ADT.assign_value r distincts eq
@@ -610,7 +603,7 @@ struct
| Term t, ty -> (* case disable_adts() handled here *)
if Expr.is_model_term t ||
List.exists (fun (t,_) -> Expr.is_model_term t) eq then None
- else Some (Expr.fresh_name ty, false) (* false <-> not a case-split *)
+ else Some (Expr.mk_abstract ty, false) (* false <-> not a case-split *)
| _ ->
(* There is no model-generation support for the AC symbols yet.
The function [AC.assign_value] always returns [None]. *)
diff --git a/src/lib/structures/expr.ml b/src/lib/structures/expr.ml
index b9bd5fc4..b9d95b1b 100644
--- a/src/lib/structures/expr.ml
+++ b/src/lib/structures/expr.ml
@@ -927,8 +927,16 @@ let mk_trigger ?user:(from_user = false) ?depth ?(hyp = []) content =
let mk_term s l ty =
assert (match s with Sy.Lit _ | Sy.Form _ -> false | _ -> true);
let d = match l with
- | [] ->
- 1 (*no args ? depth = 1 (ie. current app s, ie constant)*)
+ | [] -> (
+ match s with
+ | Sy.Name { ns = Abstract; _ } ->
+ (* make sure abstract constants are smaller than other terms, since
+ they are used as values in models. *)
+ 0
+ | _ ->
+ (* no args ? depth = 1 (ie. current app s, ie constant) *)
+ 1
+ )
| _ ->
(* if args, d is 1 + max_depth of args (equals at least to 1 *)
1 + List.fold_left (fun z t -> max z t.depth) 1 l
@@ -1114,7 +1122,8 @@ let rec is_model_term e =
| Op Div, [{ f = Real _; _ }; { f = Real _; _ }] -> true
| Op Minus, [{ f = Real q; _ }; { f = Real _; _ }] -> Q.equal q Q.zero
| Op Minus, [{ f = Int i; _ }; { f = Int _; _ }] -> Z.equal i Z.zero
- | (True | False | Name _ | Int _ | Real _ | Bitv _), [] -> true
+ | Name { ns = Abstract; _ }, [] -> true
+ | (True | False | Int _ | Real _ | Bitv _), [] -> true
| _ -> false
let[@inline always] is_value_term e =
|
I think we have to accept |
Basically, that was my patch but I changed |
I don't think so (and I think that is the source of the bug). |
Uhm I see. I thought it was okay to use a User defined term as a value. |
Consider the following input file (which is a polymorphic version of our
list.models.smt2
):Alt-Ergo outputs:
which is not correct as
.k2
is defined (and as it starts by a dot, it should not appear in models). We expect to get an abstract value instead of.k2
.I tried to fix this bug but it is actually very annoying. A simple fix consists in replace
fresh_name
bymk_abstract
at some places in relation modules but it makes sense to usefresh_name
here. Most of the times, there are not supposed to appear in models!I think that a decent fix consists in applying a substitution on representative terms before generating model terms. This substitution replaces fresh leaves by abstract ones and we have to ensure that we never generate two different abstract values for the same fresh ones.
The text was updated successfully, but these errors were encountered: