Module Logtk.InnerTerm
Inner Terms
type t= private{term : view;ty : type_result;mutable id : int;mutable payload : exn;}Abstract type of term
type view= private|Var of t HVar.tFree variable
|DB of int|Bind of Binder.t * t * tType, sub-term
|Const of ID.tConstant
|App of t * t listUncurried application
|AppBuiltin of Builtin.t * t listFor representing special constructors
type type_result=|NoType|HasType of ttype term= t
val ty : t -> type_resultType of the term, if any
val ty_exn : t -> tSame as
ty, but fails if the term has no type- raises Invalid_argument
if the type is
NoType
val hash_mod_alpha : t -> intHash invariant w.r.t variable renaming
val same_l : t list -> t list -> boolPhysical equality on lists of terms, roughly the same as
List.forall2 (==)
Constructors
Some constructors, such as record, may raise IllFormedTermif the arguments are ill-formed (several occurrences of a key), or, for variables, if the number is negative
val const : ty:t -> ID.t -> tval app : ty:t -> t -> t list -> tval bind : ty:t -> varty:t -> Binder.t -> t -> tval var : t HVar.t -> tval bvar : ty:t -> nat -> tval app_builtin : ty:t -> Builtin.t -> t list -> tval builtin : ty:t -> Builtin.t -> tval tType : tThe root of the type system. It doesn't have a type. It has kind
Kind.Type
Payload
val payload : t -> exnval set_payload : t -> exn -> unitSet payload.
- raises Invalid_argument
if there is already a payload
val set_payload_erase : t -> exn -> unitSet payload, ignoring the previous payload.
Containers
De Bruijn indices handling
module DB : sig ... endIterators
module Seq : sig ... endPositions
module Pos : sig ... endVariables
val bind_vars : ty:t -> Binder.t -> t HVar.t list -> t -> tbind_vars ~ty b vars tbinds eachv in varswith the binderb, with bodyt, and each intermediate result has typety(not suitable for functions)
val close_vars : ty:t -> Binder.t -> t -> tClose all free variables of the term using the binding symbol
val fun_ : t -> t -> tval fun_l : t list -> t -> tval fun_of_fvars : t HVar.t list -> t -> tBuild a function from a list of free vars + the body. This performs the De Bruijn transformation, and shifts the body.
val open_fun : t -> t list * topen_fun ty"unrolls" function arrows from the left, so thatopen_fun (a -> (b -> (c -> d)))returns[a;b;c], d.- returns
the return type and the list of all its arguments
val open_poly_fun : t -> int * t list * topen_poly_fun ty"unrolls" polymorphic function arrows from the left, so thatopen_fun (forall a b. f a -> (g b -> (c -> d)))returns2; [f a;g b;c], d.- returns
the return type, the number of type variables, and the list of all its arguments
val expected_ty_vars : t -> int- returns
the number of type variables that a type requires.
val open_bind : Binder.t -> t -> t list * tval open_bind_fresh : Binder.t -> t -> t HVar.t list * topen_bind_fresh λ (λxy. F)returns[v1,v2], F[v1/x,v2/y]wherev1andv2are fresh variables usingHVar.fresh
val open_bind_fresh2 : ?eq_ty:(t -> t -> bool) -> Binder.t -> t -> t -> t HVar.t list * t * topen_bind_free2 λ (λxy. F) (λxyz. G)returns[v1,v2], F[v1/x,v2/y], λz.G[v1/x,v2/y]wherev1andv2are fresh variables usingHVar.fresh- parameter eq_ty
checks whether type of bound variables are compatible
val open_fun : t -> t list * topen_fun ty"unrolls" function arrows from the left, so thatopen_fun (a -> (b -> (c -> d)))returns[a;b;c], d.- returns
the return type and the list of all its arguments
val open_poly_fun : t -> int * t list * topen_poly_fun ty"unrolls" polymorphic function arrows from the left, so thatopen_fun (forall a b. f a -> (g b -> (c -> d)))returns2; [f a;g b;c], d.- returns
the return type, the number of type variables, and the list of all its arguments
val open_bind : Binder.t -> t -> t list * tval open_bind2 : Binder.t -> t -> t -> t list * t * t list * tval mk_fun : ty_l:t list -> t -> tmk_fun ~ty_l bodycloses over body for DB indices of typety_l
val is_ground : t -> booltrueif the term contains no free variables
Misc
val size : t -> intval depth : t -> intval head : t -> ID.t optionHead symbol, or None if the term is a (bound) variable
val type_is_unifiable : t -> boolCan we (syntactically) unify terms of this type?
val type_non_unifiable_tags : t -> Builtin.Tag.t listTheory tags that justify this type not being unifiable
val type_is_prop : t -> boolIs is equal to
prop
IO
val print_hashconsing_ids : bool Pervasives.refif enabled, every term will be printed with its unique ID
include Interfaces.PRINT with type t := t
include Interfaces.PRINT_DE_BRUIJN with type t := t and type term := t
type ttype termtype print_hook= int -> term CCFormat.printer -> Format.formatter -> term -> boolUser-provided hook that can be used to print terms (for composite cases) before the default printing occurs. The int argument is the De Bruijn depth in the term. A hook takes as arguments the depth and the recursive printing function that it can use to print subterms. A hook should return
trueif it fired,falseto fall back on the default printing.
val pp_depth : ?hooks:print_hook list -> int -> t CCFormat.printer
val pp_var : t HVar.t CCFormat.printerval add_default_hook : print_hook -> unitAdd a print hook that will be used from now on
val default_hooks : unit -> print_hook listval debugf : t CCFormat.printerval pp_zf : t CCFormat.printerval pp_in : Output_format.t -> t CCFormat.printer