Module Logtk__Type
Types
Main Type representation
Types are represented using InnerTerm, with kind Type. Therefore, they are hashconsed and scoped.
Common representation of types, including higher-order and polymorphic types. All type variables are assumed to be universally quantified in the outermost possible scope (outside any other quantifier).
See TypeInference for inferring types from terms and formulas, and Signature to associate types with symbols.
TODO: think of a good way of representating AC operators (+, ...)
type t= private Logtk.InnerTerm.tType is a subtype of the term structure (itself a subtype of InnerTerm.t), with explicit conversion
type ty= ttype builtin=|TType|Prop|Term|Rat|Int
val pp_builtin : builtin CCFormat.printerval builtin_conv : builtin -> Logtk.Builtin.t
type view= private|Builtin of builtin|Var of t Logtk.HVar.t|DB of int|App of Logtk.ID.t * t listparametrized type
|Fun of t list * tFunction type (left to right, no left-nesting)
|Forall of texplicit quantification using De Bruijn index
val view : t -> viewType-centric view of the head of this type.
- raises Assert_failure
if the argument is not a type
Constructors
val tType : tval prop : tval term : tval int : tval rat : tval var : t Logtk.HVar.t -> tval var_of_int : int -> tBuild a type variable.
val app : Logtk.ID.t -> t list -> tParametrized type
val builtin : builtin -> tval const : Logtk.ID.t -> tConstant sort
val forall_fvars : t Logtk.HVar.t list -> t -> tforall_fvars vars bodymakes the De Bruijn conversion before quantifying onvars
val bvar : int -> tbound variable
val (==>) : t list -> t -> tGeneral function type.
l ==> xis the same asxiflis empty. Invariant: the return type is never a function type.
val of_term_unsafe : Logtk.InnerTerm.t -> tNOTE: this can break the invariants and make
viewfail. Only use with caution.
val of_terms_unsafe : Logtk.InnerTerm.t list -> t listval cast_var_unsafe : Logtk.InnerTerm.t Logtk.HVar.t -> t Logtk.HVar.t
Definition
type def=|Def_unin of int|Def_data of int * ty list
val def : Logtk.ID.t -> def optionAccess the definition of a type
val def_exn : Logtk.ID.t -> defUnsafe version of
def- raises Not_found
if not a proper constant
val set_def : Logtk.ID.t -> def -> unitSet definition of an ID
Containers
module Seq : sig ... endUtils
module VarSet : CCSet.S with type VarSet.elt = t Logtk.HVar.tmodule VarMap : CCMap.S with type VarMap.key = t Logtk.HVar.tmodule VarTbl : CCHashtbl.S with type VarTbl.key = t Logtk.HVar.tval vars : t -> t Logtk.HVar.t listList of free variables
val arity : t -> arity_resultNumber of arguments the type expects. If
arity tyreturnsArity (a, b)that means that it expectsaarguments to be used as arguments of Forall, andbarguments to be used for function application. If it returnsNoAritythen the arity is unknown (variable)
val expected_args : t -> t listTypes expected as function argument by
ty. The length of the listexpected_args tyis the same assnd (arity ty).
val expected_ty_vars : t -> intNumber of type parameters expected. 0 for monomorphic types.
val needs_args : t -> boolneeds_args tyiffexpected_ty_vars ty>0 || expected_args ty<>[]
val order : t -> intNumber of left-nested function types (1 for constant and variables).
order (a->b) = 1order ((a->b)->c) = 2order (((a->b)->c)->d) = 2
val size : t -> intSize of type, in number of "nodes"
val depth : t -> intDepth of the type (length of the longest path to some leaf)
- since
- 0.5.3
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_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 returns : t -> treturned type (going through foralls and arrows).
returns ais likelet _, _, ret = open_poly_fun a in retNOTE caution, not always closed
exceptionApplyError of stringError raised when
applyfails
val apply : t -> t list -> tGiven a function/forall type, and arguments, return the type that results from applying the function/forall to the arguments. No unification is done, types must check exactly.
- raises ApplyError
if the types do not match
val apply_unsafe : t -> Logtk.InnerTerm.t list -> tSimilar to
apply, but assumes its arguments are well-formed types without more ado.- raises ApplyError
if types do not match
- raises Assert_failure
if the arguments are not proper types
val is_unifiable : t -> boolAre terms of this type syntactically unifiable? See
InnerTerm.type_is_unifiable
IO
include Logtk.Interfaces.PRINT_DE_BRUIJN with type term := t and type t := 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
include Logtk.Interfaces.PRINT with type t := t
val pp_surrounded : t CCFormat.printerval pp_typed_var : t Logtk.HVar.t CCFormat.printerval mangle : t -> stringval pp_mangle : t CCFormat.printer
TPTP
specific printer and types
module TPTP : sig ... endmodule ZF : sig ... endval pp_in : Logtk.Output_format.t -> t CCFormat.printer
Conversions
module Conv : sig ... end