Higher Order TermsBoth higher order formulas and terms are represented by terms.
Termtype view = private
| Var of int
| BVar of int
bound variable (De Bruijn index)
| Lambda of LogtkType.t * t
lambda abstraction over one variable.
| Forall of LogtkType.t * t
Forall quantifier (commutes with other forall)
| Exists of LogtkType.t * t
Exists quantifier (commutes with other exists)
| Const of symbol
| At of t * t
| TyLift of LogtkType.t
| Multiset of LogtkType.t * t list
a multiset of terms, and their common type
| Record of (string * t ) list * t option
LogtkComparison, equality, containersOpen application recursively so as to gather all type arguments
val subterm : sub :t -> t -> bool
checks whether sub
is a (non-strict) subterm of t
Only on lambda terms: returns the type of the function argument.
Change the type. Only works for variables and bound variables.
ConstructorsThe constructors take care of type-checking. They may raise LogtkType.Error in case of type error.
Use lambda
rather than __mk_lambda
, and try not to create bound variables by yourself.
Create a variable. Providing a type is mandatory. The index must be non-negative,
Create a bound variable. Providing a type is mandatory. Warning : be careful and try not to use this function directly
Curried application. The first term must have a function type with the same argument as the type of the second term. Note that at t1 t2
and app t1 [t2]
are not the same term.
val at_list : t -> t list -> t
Curried application to several terms, left-parenthesing.
tylift ty
makes a term out of ty
. It has type ty
tyat t ty
is the same as at t (tylift ty)
Application to a list of types
val record : (string * t ) list -> rest :t option -> t
Build a record. All terms in the list must have the same type, and the rest (if present) must have a record() type.
Build a multiset. The ty
argument is the type of the elements, in case the multiset is empty.
constructors with free variables. The first argument is the list of variables that is bound, then the quantified/abstracted term.
val lambda : t list -> t -> t
val forall : t list -> t -> t
val exists : t list -> t -> t
val is_tylift : t -> bool
val is_lambda : t -> bool
val is_forall : t -> bool
val is_exists : t -> bool
val is_multiset : t -> bool
val is_record : t -> bool
Sequencesval var_occurs : var :t -> t -> bool
var_occurs ~var t
true iff var
in t
val is_ground : t -> bool
var_occurs ~var t
true iff var
in t
is the term ground? (no free vars)
val monomorphic : t -> bool
is the term ground? (no free vars)
true if the term contains no type var
val max_var : Set.t -> int
true if the term contains no type var
find the maximum variable index, or 0
val min_var : Set.t -> int
find the maximum variable index, or 0
minimum variable, or 0 if ground
val add_vars : unit Tbl.t -> t -> unit
minimum variable, or 0 if ground
add variables of the term to the set
add variables of the term to the set
compute variables of the terms
val vars_prefix_order : t -> t list
compute variables of the terms
variables in prefix traversal order
variables in prefix traversal order
depth of the term
depth of the term
head symbol (or Invalid_argument)
head symbol (or Invalid_argument)
Size (number of nodes)
Set of free type variables
Subterms and LogtkPositionsval replace : t -> old :t -> by :t -> t
replace t ~old ~by
syntactically replaces all occurrences of old
in t
by the term by
.
High-level operationsLogtkSymbols of the term (keys of signature)
Does the term contain this given symbol?
VisitorVisitor that maps the subterms into themselves
Un-curry all subterms. If some subterms are not convertible to first-order * terms then None
is returned.
Check whether the term is convertible to a first-order term (no binders, no variable applied to something...)
Various operationsval close_forall : t -> t
Universally quantify all free variables
val close_exists : t -> t
Existentially quantify all free variables
val open_forall : ?offset :int -> t -> t
open_forall t
removes all prenex "forall" quantifiers with fresh variables
IOFirst, full functions with the amount of surrounding binders; then helpers in the case this amount is 0 (for instance in clauses)
include LogtkInterfaces.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.
TPTPmodule TPTP : sig ... end
debug printing, with sorts