TermsThose terms provide a direct presentation of higher-order terms with lambdas in the sense that they make currying possible (as well as applying functions to other terms).
This is as if terms had an `apply` symbol everywhere, but more lightweight.
Types and terms are mixed because it makes application much easier (applying to a type and to a term are the same thing). It might also make dependent typing possible some day.
TermVariables are typed with Type.t
type view = private
| AppBuiltin of Builtin.t * t list
| DB of int
Bound variable (De Bruijn index)
| Var of var
| Const of ID.t
| App of t * t list
Application to a list of terms (cannot be left-nested)
| Fun of Type.t * t
val subterm : sub :t -> t -> bool
checks whether sub
is a (non-strict) subterm of t
Obtain the type of a term..
module IntMap : Stdlib .Map.S with type key = int
val hash_mod_alpha : t -> int
Hash invariant w.r.t variable renaming
val same_l : t list -> t list -> bool
same_l l1 l2
returns true
if terms of l1
and l2
are pairwise equal, false
otherwise. Precondition: both lists have the same length
val same_l_gen : t list -> t list -> bool
same_l l1 l2
returns true
if terms of l1
and l2
are pairwise equal, false
otherwise. Precondition: both lists have the same length
Constructorsval var_of_int : ty :Type.t -> int -> t
Create a bound variable. Providing a type is mandatory. Warning : be careful and try not to use this function directly.
val app : t -> t list -> t
Apply a term to a list of terms
Apply a term to a list of terms
val app_full : t -> Type.t list -> t list -> t
Apply the term to types, then to terms
val fun_of_fvars : var list -> t -> t
Build a function from a list of free vars + the body. This performs the De Bruijn transformation, and shifts the body.
val open_fun_offset : offset :int -> t -> var list * t * int
open_fun ~offset (λxy. F)
returns [v1,v2], F[v1/x,v2/y], offset+2
where v1
and v2
are fresh variables starting from offset
grounding ty
is a unique constant of type ty
val is_appbuiltin : t -> bool
val is_app_var : t -> bool
val in_pfho_fragment : t -> bool
val in_lfho_fragment : t -> bool
val is_fo_term : t -> bool
val is_true_or_false : t -> bool
val as_const : t -> ID.t option
val as_const_exn : t -> ID.t
val as_var : t -> var option
val as_var_exn : t -> var
val as_bvar_exn : t -> int
val as_app : t -> t * t list
as_app t
decomposes t
into a head (non-application) and arguments, such as (let f,l = as_app t in app f l) = t
head_term t = fst (as_app t)
val head_term_mono : t -> t
head term, but still with type arguments
NOTE : this can break the invariants and make view
fail. Only apply with caution.
val mk_tmp_cst : counter :int Stdlib .ref -> ty :Type.t -> t
Itersval var_occurs : var :var -> t -> bool
var_occurs ~var t
true iff var
in t
val is_ground : t -> bool
is the term ground? (no free vars)
val is_linear : t -> bool
is the term ground? (no free vars)
is the term linear? (no vars occuring multiple times)
val monomorphic : t -> bool
is the term linear? (no vars occuring multiple times)
true if the term contains no type var
val is_beta_reducible : t -> bool
val has_lambda : t -> bool
find the maximum variable
add variables of the term to the set
compute variables of the terms
val vars_prefix_order : t -> var list
variables in prefix traversal order
val head : t -> ID.t option
head ID.t (or Invalid_argument)
val simplify_bools : t -> t
val normalize_bools : t -> t
val cover_with_terms :
?depth :int ->
?recurse :bool ->
t ->
t option list ->
t list
val max_cover : t -> t option list -> t
val weight : ?var :int -> ?sym :(ID.t -> int) -> t -> int
Compute the weight of a term, given a weight for variables and one for ID.ts.
Set of free type variables
val is_ho_var : t -> bool
val is_ho_app : t -> bool
is_ho_app (F t1…tn)
is true, when F
is a variable (of any function type)
as_ho_app (F t1…tn) = Some (F, [t1…tn])
val is_ho_pred : t -> bool
is_ho_pred (F t1…tn)
is true, when F
is a predicate variable
val is_ho_at_root : t -> bool
is_ho_at_root t
returns true
if the term t
is a higher-order variable, possibly applied (i.e. is_ho_var t || is_ho_app t
)
Subterms and Positionsval replace : t -> old :t -> by :t -> t
replace t ~old ~by
syntactically replaces all occurrences of old
in t
by the term by
.
replace t m
syntactically replaces all occurrences of bindings of the map in t
, starting from the root
High-level operationsSymbols of the term (keys of signature)
val contains_symbol : ID.t -> t -> bool
Does the term contain this given ID.t?
FoldHigh level fold-like combinators
val all_positions :
?vars :bool ->
?ty_args :bool ->
?var_args :bool ->
?fun_bodies :bool ->
?pos :Position.t ->
t ->
t Position.With.t Iter .t
Iterate on all sub-terms with their position.
Some AC-utils Printing/parsingval print_all_types : bool Stdlib .ref
If true, pp
will print the types of all annotated terms
include Interfaces.PRINT_DE_BRUIJN with type t := t and type term := t
User-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 true
if it fired, false
to fall back on the default printing.
Hook used by default for printing
val debugf : Stdlib .Format.formatter -> t -> unit
debugf printing, with sorts
Arithmodule Arith : sig ... end
val has_ho_subterm : t -> bool
TPTPmodule TPTP : sig ... end
module Conv : sig ... end