package lambdapi
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=d01e5f13db2eaba6e4fe330667149e0059d4886c651ff9d6b672db2dfc9765ed
sha512=33b68c972aca37985ed73c527076198e7d4961c7e27c89cdabfe4d1cff97cd41ccfb85ae9499eb98ad9a0aefd920bc55555df6393fc441ac2429e4d99cddafa8
doc/lambdapi.core/Core/LibTerm/index.html
Module Core.LibTerm
Source
Basic operations on terms.
to_tvar t
returns x
if t
is of the form Vari x
and fails otherwise.
NOTE the Array.map to_tvar
function is useful when working with multiple binders. For example, this is the case when manipulating pattern variables (Patt
constructor) or metatavariables (Meta
constructor). Remark that it is important for these constructors to hold an array of terms, rather than an array of variables: a variable can only be substituted when if it is injected in a term (using the Vari
constructor).
NOTE the result of to_tvar
can generally NOT be precomputed. A first reason is that we cannot know in advance what variable identifier is going to arise when working under binders, for which fresh variables will often be generated. A second reason is that free variables should never be “marshaled” (e.g., by the Sign
module), as this would break the freshness invariant of new variables.
Given a symbol s
, remove_impl_args s ts
returns the non-implicit arguments of s
among ts
.
iter f t
applies the function f
to every node of the term t
with bound variables replaced by Kind
. Note: f
is called on already unfolded terms only.
unbind_name b s
is like Bindlib.unbind b
but returns a valid variable name when b
binds no variable. The string s
is the prefix of the variable's name.
val unbind2_name :
string ->
Term.tbinder ->
Term.tbinder ->
Term.tvar * Term.term * Term.term
unbind2_name b1 b2 s
is like Bindlib.unbind2 b1 b2
but returns a valid variable name when b1
or b2
binds no variable. The string s
is the prefix of the variable's name.
distinct_vars ctx ts
checks that the terms ts
are distinct variables. If so, the variables are returned.
val nl_distinct_vars :
Term.term array ->
(Term.tvar array * Term.tvar Lplib.Extra.StrMap.t) option
If ts
is not made of variables or function symbols prefixed by '$'
only, then nl_distinct_vars ts
returns None
. Otherwise, it returns a pair (vs, map)
where vs
is an array of variables made of the linear variables of ts
and fresh variables for the non-linear variables and the symbols prefixed by '$'
, and map
records by which variable each linear symbol prefixed by '$'
is replaced.
The symbols prefixed by '$'
are introduced by infer.ml
which converts metavariables into fresh symbols, and those metavariables are introduced by sr.ml
which replaces pattern variables by metavariables.
sym_to_var m t
replaces in t
every symbol f
by a variable according to the map map
.
codom_binder n t
returns the n
-th binder of t
if t
is a product of arith >= n
.