Logtk.SubstSubstitutions map (scoped) variables to terms/types.
They work on free variables (within a scope, so that the same variable can live within several scopes).
The concept of scope is to allow the same free variable to be used in several contexts without being renamed. A scope is kind of a namespace, where variables from distinct namespaces are always distinct.
type term = InnerTerm.ttype var = InnerTerm.t HVar.tA renaming is used to disambiguate variables that come from distinct scopes but have the same index. It is used to merge together several scopes, in a sound way, by ensuring variables from those scopes are mapped to distinct variables of the new scope. For instance, a given renaming applied to (X,0) and (X,1) will return two different variables, as if one of the X had been renamed prior to unification/binding.
module Renaming : sig ... endtype subst = tval empty : tThe identity substitution
val is_empty : t -> boolIs the substitution empty?
deref t s_t dereferences t as long as t is a variable bound in subst
Lookup recursively the var in the substitution, until it is not a variable anymore, or it is not bound.
Add v -> t to the substitution. Both terms have a context. It is important that the bound term is De-Bruijn-closed (assert).
Replace v -> ? by v -> t in the substitution. Both terms have a context. It is important that the bound term is De-Bruijn-closed (assert).
Remove the given binding. No other variable should depend on it...
val filter_scope : t -> Scoped.scope -> tOnly keep bindings from this scope
Variables introduced by the substitution (ie vars of codomain)
Normalize bindings that are in the same scope. E.g. x0 -> f(y0), y0 -> g(z0), z0->a becomes x0->f(g(a))0, y0->g(a)0, z0->g(z0)
val is_renaming : t -> boolCheck whether the substitution is a variable renaming
val hash : t -> intval pp_bindings : t CCFormat.printerOnly print the bindings, no box
val apply : ?shift_vars:int -> Renaming.t -> t -> term Scoped.t -> termApply the substitution to the given term. This function assumes that all terms in the substitution are closed, and it will not perform De Bruijn indices shifting. For instance, applying {X -> f(db0)} (with db0 the De Bruijn index 0) to the term forall. p(X) will yield forall. p(f(db0)) (capturing) and not forall. p(f(db1)).
module type SPECIALIZED = sig ... endmodule Ty : SPECIALIZED with type term = Type.tmodule FO : sig ... endmodule Projection : sig ... end