Module InnerTerm.DB

type env = t DBEnv.t
val closed : t -> bool

check whether the term is closed (all DB vars are bound within the term). If this returns true then the term doesn't depend on its environment.

val contains : t -> int -> bool

Does t contains the De Bruijn variable of index n?

val shift : ?⁠depth:int -> int -> t -> t

shift the non-captured De Bruijn indexes in the term by n

val unshift : ?⁠depth:int -> int -> t -> t

unshift n t unshifts the term t's bound variables by n. In other words it decrements indices of all free De Bruijn variables inside by n. Variables bound within t are left untouched.

val replace : t -> sub:t -> t

replace t ~sub replaces sub by a fresh De Bruijn index in t. Shifts other De Bruijn indices by 1

val replace_l : t -> l:t list -> t

N-ary version of replace Shifts other De Bruijn indices by length t

val from_var : t -> var:t -> t

db_from_var t ~var replace var by a De Bruijn symbol in t. Same as replace.

val eval : env -> t -> t

Evaluate the term in the given De Bruijn environment, by replacing De Bruijn indices by their value in the environment.