add helper in base

This commit is contained in:
Simon Cruanes 2021-07-04 01:29:23 -04:00
parent 9b43630990
commit 0368a29ada
2 changed files with 15 additions and 9 deletions

View file

@ -461,7 +461,8 @@ module Fun : sig
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 *)
eval: value IArray.t -> value; (* evaluate term *) eval: value IArray.t -> value; (* evaluate term *)
} } (** user defined function symbol.
A good example can be found in {!Form} for boolean connectives. *)
(** A function symbol *) (** A function symbol *)
type t = fun_ = { type t = fun_ = {
@ -809,16 +810,17 @@ module Term : sig
val bool : store -> bool -> t val bool : store -> bool -> t
val const : store -> fun_ -> t val const : store -> fun_ -> t
val app_fun : store -> fun_ -> t IArray.t -> t val app_fun : store -> fun_ -> t IArray.t -> t
val app_fun_l : store -> fun_ -> t list -> t
val eq : store -> t -> t -> t val eq : store -> t -> t -> t
val not_ : store -> t -> t val not_ : store -> t -> t
val ite : store -> t -> t -> t -> t val ite : store -> t -> t -> t -> t
val const_undefined_fun : store -> ID.t -> Ty.Fun.t -> t val app_undefined : store -> ID.t -> Ty.Fun.t -> t IArray.t -> t
(** [const_undefined_fun store f ty] is [const store (Fun.mk_undef f ty)]. (** [app_undefined store f ty args] is [app store (Fun.mk_undef f ty) args].
It builds a function symbol and turns it into a term immediately *) It builds a function symbol and applies it into a term immediately *)
val const_undefined_const : store -> ID.t -> Ty.t -> t val const_undefined : store -> ID.t -> Ty.t -> t
(** [const_undefined_const store f ty] is [const store (Fun.mk_undef_const f ty)]. (** [const_undefined store f ty] is [const store (Fun.mk_undef_const f ty)].
It builds a constant function symbol and makes it into a term It builds a constant function symbol and makes it into a term
immediately. *) immediately. *)
@ -947,6 +949,7 @@ end = struct
let cell = Term_cell.app_fun f a in let cell = Term_cell.app_fun f a in
make st cell make st cell
let app_fun_l st f l = app_fun st f (IArray.of_list l)
let[@inline] const st c = app_fun st c IArray.empty let[@inline] const st c = app_fun st c IArray.empty
let[@inline] eq st a b = make st (Term_cell.eq a b) let[@inline] eq st a b = make st (Term_cell.eq a b)
let[@inline] not_ st a = make st (Term_cell.not_ a) let[@inline] not_ st a = make st (Term_cell.not_ a)
@ -975,9 +978,9 @@ end = struct
let var st a : t = lra st (LRA_simplex_var a) let var st a : t = lra st (LRA_simplex_var a)
end end
let const_undefined_fun store id ty : t = let app_undefined store id ty args : t =
const store (Fun.mk_undef id ty) app_fun store (Fun.mk_undef id ty) args
let const_undefined_const store id ty : t = let const_undefined store id ty : t =
const store (Fun.mk_undef_const id ty) const store (Fun.mk_undef_const id ty)
(* might need to tranfer the negation from [t] to [sign] *) (* might need to tranfer the negation from [t] to [sign] *)

View file

@ -32,6 +32,9 @@ module Select = Base_types.Select
module Proof = Proof module Proof = Proof
module Form = Form module Form = Form
(* re-export *)
module IArray = IArray
(** Concrete implementation of {!Sidekick_core.TERM} (** Concrete implementation of {!Sidekick_core.TERM}
this module gathers most definitions above in a form this module gathers most definitions above in a form