Module Logtk.Subst
Substitutions
type term= InnerTerm.ttype var= InnerTerm.t HVar.t
Renamings
A 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 ... endBasics
type subst= t
val empty : tThe identity substitution
val is_empty : t -> boolIs the substitution empty?
Operations on Substitutions
val find_exn : t -> var Scoped.t -> term Scoped.tLookup variable in substitution.
- raises Not_found
if variable not bound.
val find : t -> var Scoped.t -> term Scoped.t optionval deref : t -> term Scoped.t -> term Scoped.tderef t s_tdereferencestas long astis a variable bound insubst
val get_var : t -> var Scoped.t -> term Scoped.t optionLookup recursively the var in the substitution, until it is not a variable anymore, or it is not bound.
- returns
None if the variable is not bound,
Some (deref (t, sc_t))ifvis bound tot, sc_t
val bind : t -> var Scoped.t -> term Scoped.t -> tAdd
v->tto the substitution. Both terms have a context. It is important that the bound term is De-Bruijn-closed (assert).- raises InconsistentBinding
if
vis already bound in the same context, to another term.
val update : t -> var Scoped.t -> term Scoped.t -> tReplace
v-> ? byv->tin the substitution. Both terms have a context. It is important that the bound term is De-Bruijn-closed (assert).- raises InconsistentBinding
if
vis not yet bound in the same context.
val merge : t -> t -> tmerge s1 s2is the substitution that mapstto(s1 t)or to(s2 t).- raises InconsistentBinding
if the substitutions disagree.
val remove : t -> var Scoped.t -> tRemove the given binding. No other variable should depend on it...
val filter_scope : t -> Scoped.scope -> tOnly keep bindings from this scope
Set operations
val introduced : t -> var Scoped.t Iter.tVariables introduced by the substitution (ie vars of codomain)
val normalize : t -> tNormalize bindings that are in the same scope. E.g.
x0 -> f(y0), y0 -> g(z0), z0->abecomesx0->f(g(a))0, y0->g(a)0, z0->g(z0)
val is_renaming : t -> boolCheck whether the substitution is a variable renaming
include Interfaces.PRINT with type t := t
val pp_bindings : t CCFormat.printerOnly print the bindings, no box
val fold : ('a -> var Scoped.t -> term Scoped.t -> 'a) -> 'a -> t -> 'aval iter : (var Scoped.t -> term Scoped.t -> unit) -> t -> unitval to_seq : t -> (var Scoped.t * term Scoped.t) Iter.tval to_list : t -> (var Scoped.t * term Scoped.t) listval of_seq : ?init:t -> (var Scoped.t * term Scoped.t) Iter.t -> tval of_list : ?init:t -> (var Scoped.t * term Scoped.t) list -> t
Applying a substitution
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)}(withdb0the De Bruijn index0) to the termforall. p(X)will yieldforall. p(f(db0))(capturing) and notforall. p(f(db1)).- parameter renaming
used to desambiguate free variables from distinct scopes
Specializations
module type SPECIALIZED = sig ... endmodule Ty : SPECIALIZED with type term = Type.tmodule FO : sig ... endProjections for proofs
module Projection : sig ... end