package rocq-runtime

  1. Overview
  2. Docs
The Rocq Prover -- Core Binaries and Tools

Install

dune-project
 Dependency

Authors

Maintainers

Sources

rocq-9.2.0.tar.gz
sha256=a45280ab4fbaac7540b136a6b073b4a6db15739ec1e149bded43fa6f4fc25f20

doc/rocq-runtime.kernel/Esubst/index.html

Module EsubstSource

Explicit substitutions

Sourcetype 'a subs

Explicit substitutions for some type of terms 'a.

Assuming terms enjoy a notion of typability Γ ⊢ t : A, where Γ is a telescope and A a type, substitutions can be typed as Γ ⊢ σ : Δ, where as a first approximation σ is a list of terms [u₁; ...; uₙ] s.t. Δ := (x₁ : A₁), ..., (xₙ : Aₙ) and Γ ⊢ uᵢ : Aᵢ{u₁...uᵢ₋₁} for all 1 ≤ i ≤ n.

Substitutions can be applied to terms as follows, and furthermore if Γ ⊢ σ : Δ and Δ ⊢ t : A, then Γ ⊢ t{σ} : A{σ}.

We make the typing rules explicit below, but we omit the explicit De Bruijn fidgetting and leave relocations implicit in terms and types.

Derived constructors granting basic invariants

Sourceval subs_id : int -> 'a subs

Assuming |Γ| = n, Γ ⊢ subs_id n : Γ

Sourceval subs_cons : 'a -> 'a subs -> 'a subs

Assuming Γ ⊢ σ : Δ and Γ ⊢ t : A{σ}, then Γ ⊢ subs_cons t σ : Δ, A

Sourceval subs_shft : (int * 'a subs) -> 'a subs

Assuming Γ ⊢ σ : Δ and |Ξ| = n, then Γ, Ξ ⊢ subs_shft (n, σ) : Δ

Sourceval subs_liftn : int -> 'a subs -> 'a subs

Assuming Γ ⊢ σ : Δ and |Ξ| = n, then Γ, Ξ ⊢ subs_liftn n σ : Δ, Ξ

Sourceval subs_lift : 'a subs -> 'a subs

Unary variant of subst_liftn.

Sourceval expand_rel : int -> 'a subs -> (int * 'a, int * int option) Util.union

expand_rel k subs expands de Bruijn k in the explicit substitution subs. The result is either Inl (lams, v) when the variable is substituted by value v under lams binders (i.e. v *has* to be shifted by lams), or Inr (k', p) when the variable k is just relocated as k'; p is None if the variable points inside subs and Some k if the variable points k bindings beyond subs (cf argument of ESID).

Sourceval is_subs_id : 'a subs -> bool

Tests whether a substitution behaves like the identity

Sourcetype lift = private
  1. | ELID
  2. | ELSHFT of lift * int
  3. | ELLFT of int * lift

Compact representation of explicit relocations

  • ELID: identity relocation id
  • ELSHFT (σ, n): shift of n, then σ; ↑^n ∘ σ in sigma calculi
  • ELLFT (n, σ): apply σ to de Bruijn > n, i.e under n binders; ⇑^n(σ) in sigma calculi

Invariant ensured by the private flag: no lift contains an ELLFT of ELID, two consecutive ELLFT or two consecutive ELSHFT.

Relocations are a particular kind of substitutions that only contain variables. In particular, el_* enjoys similar typing rules as the equivalent substitution function subs_*.

Sourceval el_id : lift

For arbitrary Γ, Γ ⊢ el_id : Γ

Sourceval el_shft : int -> lift -> lift

Assuming Γ ⊢ σ : Δ, Ξ and |Ξ| = n, then Γ ⊢ el_shft n σ : Δ

Sourceval el_liftn : int -> lift -> lift

Assuming Γ ⊢ σ : Δ and |Ξ| = n, then Γ, Ξ ⊢ el_liftn n σ : Δ, Ξ

Sourceval el_lift : lift -> lift

Unary variant of el_liftn.

Sourceval reloc_rel : int -> lift -> int

Assuming Γ₁, A, Γ₂ ⊢ σ : Δ₁, A, Δ₂ and Δ₁, A, Δ₂ ⊢ n : A, then Γ₁, A, Γ₂ ⊢ reloc_rel n σ : A

Sourceval is_lift_id : lift -> bool
Sourceval lift_subst : (lift -> 'a -> 'b) -> lift -> 'a subs -> 'b subs

Lift applied to substitution: lift_subst mk_clos el s computes a substitution equivalent to applying el then s. Argument mk_clos is used when a closure has to be created, i.e. when el is applied on an element of s.

That is, if Γ ⊢ e : Δ and Δ ⊢ σ : Ξ, then Γ ⊢ lift_subst mk e σ : Ξ.

Sourceval eq_lift : lift -> lift -> bool

Structural equality for lifts

Sourcemodule Internal : sig ... end

Debugging utilities