refactor(term): notion of is_value, which are kept as representatives

This commit is contained in:
Simon Cruanes 2018-08-18 17:19:50 -05:00
parent 04eea28cfc
commit 162b6fad98
6 changed files with 14 additions and 1 deletions

View file

@ -72,6 +72,7 @@ and cst_view =
do_cc: bool; (* participate in congruence closure? *) do_cc: bool; (* participate in congruence closure? *)
relevant : 'a. ID.t -> 'a IArray.t -> int -> bool; (* relevant argument? *) relevant : 'a. ID.t -> 'a IArray.t -> int -> bool; (* relevant argument? *)
ty : ID.t -> term IArray.t -> ty; (* compute type *) ty : ID.t -> term IArray.t -> ty; (* compute type *)
is_value: bool; (* value constructor *)
eval: value IArray.t -> value; (* evaluate term *) eval: value IArray.t -> value; (* evaluate term *)
} }
(** Methods on the custom term view whose arguments are ['a]. (** Methods on the custom term view whose arguments are ['a].

View file

@ -60,6 +60,7 @@ let create ?(size=1024) () : state =
st st
let[@inline] all_terms st = Term_cell.Tbl.values st.tbl let[@inline] all_terms st = Term_cell.Tbl.values st.tbl
let[@inline] is_value t = Term_cell.is_value t.term_view
let app_cst st f a = let app_cst st f a =
let cell = Term_cell.app_cst f a in let cell = Term_cell.app_cst f a in

View file

@ -40,6 +40,9 @@ val all_terms : state -> t Sequence.t
val pp : t Fmt.printer val pp : t Fmt.printer
val is_value : t -> bool
(** Values are special terms that behave specially wrt congruence/equality *)
(** {6 Views} *) (** {6 Views} *)
val is_true : t -> bool val is_true : t -> bool

View file

@ -50,6 +50,11 @@ include Make_eq(struct
let true_ = Bool true let true_ = Bool true
let false_ = Bool false let false_ = Bool false
let is_value = function
| Bool _ -> true
| App_cst ({cst_view=Cst_def r;_}, _) -> r.is_value
| If _ | App_cst _ -> false
let app_cst f a = App_cst (f, a) let app_cst f a = App_cst (f, a)
let const c = App_cst (c, IArray.empty) let const c = App_cst (c, IArray.empty)

View file

@ -17,6 +17,8 @@ val const : cst -> t
val app_cst : cst -> term IArray.t -> t val app_cst : cst -> term IArray.t -> t
val if_ : term -> term -> term -> t val if_ : term -> term -> term -> t
val is_value : t -> bool
val ty : t -> Ty.t val ty : t -> Ty.t
(** Compute the type of this term cell. Not totally free *) (** Compute the type of this term cell. Not totally free *)

View file

@ -93,7 +93,8 @@ module C = struct
let mk_cst ?(do_cc=false) id : Cst.t = let mk_cst ?(do_cc=false) id : Cst.t =
{cst_id=id; {cst_id=id;
cst_view=Cst_def { pp=None; abs; ty=get_ty; relevant; do_cc; eval=eval id; }; } cst_view=Cst_def {
pp=None; abs; ty=get_ty; relevant; is_value=false; do_cc; eval=eval id; }; }
let not = mk_cst id_not let not = mk_cst id_not
let and_ = mk_cst id_and let and_ = mk_cst id_and