mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 03:05:31 -05:00
fix(cc.model): model building needs special case for bool
This commit is contained in:
parent
c5f23e32b9
commit
1f79809644
2 changed files with 21 additions and 6 deletions
|
|
@ -597,9 +597,13 @@ let mk_model (cc:t) (m:Model.t) : Model.t =
|
||||||
let v = match Model.eval m t with
|
let v = match Model.eval m t with
|
||||||
| Some v -> v
|
| Some v -> v
|
||||||
| None ->
|
| None ->
|
||||||
Value.mk_elt
|
if same_class cc r (Lazy.force cc.true_) then Value.true_
|
||||||
(ID.makef "v_%d" @@ Term.id t)
|
else if same_class cc r (Lazy.force cc.false_) then Value.false_
|
||||||
(Term.ty r.n_term)
|
else (
|
||||||
|
Value.mk_elt
|
||||||
|
(ID.makef "v_%d" @@ Term.id t)
|
||||||
|
(Term.ty r.n_term)
|
||||||
|
)
|
||||||
in
|
in
|
||||||
if not @@ Ty.Tbl.mem ty_tbl (Term.ty t) then (
|
if not @@ Ty.Tbl.mem ty_tbl (Term.ty t) then (
|
||||||
Ty.Tbl.add ty_tbl (Term.ty t) v; (* also give a value to this type *)
|
Ty.Tbl.add ty_tbl (Term.ty t) v; (* also give a value to this type *)
|
||||||
|
|
@ -638,9 +642,19 @@ let mk_model (cc:t) (m:Model.t) : Model.t =
|
||||||
(m,Cst.Map.empty)
|
(m,Cst.Map.empty)
|
||||||
in
|
in
|
||||||
(* get or make a default value for this type *)
|
(* get or make a default value for this type *)
|
||||||
let get_ty_default (ty:Ty.t) : Value.t =
|
let rec get_ty_default (ty:Ty.t) : Value.t =
|
||||||
Ty.Tbl.get_or_add ty_tbl ~k:ty
|
match Ty.view ty with
|
||||||
~f:(fun ty -> Value.mk_elt (ID.makef "ty_%d" @@ Ty.id ty) ty)
|
| Ty_prop -> Value.true_
|
||||||
|
| Ty_atomic { def = Ty_uninterpreted _;_} ->
|
||||||
|
(* domain element *)
|
||||||
|
Ty.Tbl.get_or_add ty_tbl ~k:ty
|
||||||
|
~f:(fun ty -> Value.mk_elt (ID.makef "ty_%d" @@ Ty.id ty) ty)
|
||||||
|
| Ty_atomic { def = Ty_def d; args; _} ->
|
||||||
|
(* ask the theory for a default value *)
|
||||||
|
Ty.Tbl.get_or_add ty_tbl ~k:ty
|
||||||
|
~f:(fun _ty ->
|
||||||
|
let vals = List.map get_ty_default args in
|
||||||
|
d.default_val vals)
|
||||||
in
|
in
|
||||||
let funs =
|
let funs =
|
||||||
Cst.Map.map
|
Cst.Map.map
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ and ty_def =
|
||||||
| Ty_def of {
|
| Ty_def of {
|
||||||
id: ID.t;
|
id: ID.t;
|
||||||
pp: ty Fmt.printer -> ty list Fmt.printer;
|
pp: ty Fmt.printer -> ty list Fmt.printer;
|
||||||
|
default_val: value list -> value; (* default value of this type *)
|
||||||
card: ty list -> ty_card;
|
card: ty list -> ty_card;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue