package lambdapi
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=d01e5f13db2eaba6e4fe330667149e0059d4886c651ff9d6b672db2dfc9765ed
sha512=33b68c972aca37985ed73c527076198e7d4961c7e27c89cdabfe4d1cff97cd41ccfb85ae9499eb98ad9a0aefd920bc55555df6393fc441ac2429e4d99cddafa8
doc/lambdapi.core/Core/Env/index.html
Module Core.Env
Source
Scoping environment for variables.
Type of an environment, used in scoping to associate names to corresponding Bindlib variables and types. Note that it cannot be implemented by a map as the order is important. The structure is similar to Term.ctxt
, a tuple (x,a,t)
is a variable x
, its type a
and possibly its definition t
. The typing environment x1:A1,..,xn:An
is represented by the list xn:An;..;x1:A1
in reverse order (last added variable comes first).
add v a t env
extends the environment env
by mapping the string Bindlib.name_of v
to (v,a,t)
.
find n env
returns the Bindlib variable associated to the variable name n
in the environment env
. If none is found, Not_found
is raised.
to_prod env t
builds a sequence of products/lets whose domains are the variables of the environment env
(from left to right), and whose body is the term t
. By calling to_prod [(xn,an,None);⋯;(x1,a1,None)] t
you obtain a term of the form Πx1:a1,..,Πxn:an,t
.
to_abst env t
builds a sequence of abstractions or let bindings, depending on the definition of the elements in the environment whose domains are the variables of the environment env
(from left to right), and which body is the term t
: to_abst [(xn,an,None);..;(x1,a1,None)] t = λx1:a1,..,λxn:an,t
.
vars env
extracts the array of the Bindlib variables in env
. Note that the order is reversed: vars [(xn,an);..;(x1,a1)] = [|x1;..;xn|]
.
to_tbox env
extracts the array of the variables in env
and injects them in tbox
. This is the same as Array.map _Vari (vars env)
. Note that the order is reversed: to_tbox [(xn,an);..;(x1,a1)] = [|x1;..;xn|]
.
val match_prod :
Term.ctxt ->
Term.term ->
(Term.term -> Term.term option -> Term.tbinder -> 'a) ->
'a
match_prod c t f
returns f a b
if t
matches Prod(a,b)
possibly after reduction.
of_prod c s t
returns a tuple (env,b)
where b
is constructed from the term t
by unbinding as much dependent products as possible in the head of t
. The free variables created by this process, prefixed by s
, are given (with their types) in the environment env
(in reverse order). For instance, if t
is of the form Πx1:a1, ⋯, Πxn:an, b
, then the function returns b
and the environment (xn,an); ⋯;(x1,a1)
.
of_prod_nth c n t
returns a tuple (env,b)
where b
is constructed from the term t
by unbinding n
dependent products. The free variables created by this process are given (with their types) in the environment env
(in reverse order). For instance, if t
is of the form Πx1:a1, ⋯, Πxn:an, b
then the function returns b
and the environment (xn,an); ⋯;(x1,a1)
. n
must be non-negative.