Documentation

GaudisCrypt.Language.ModuleExpressionNormalization

Normalization for module expressions #

Weak normalization: every well-typed module expression terminates. Split off from ModuleExpressionBasics.lean (which develops syntax, typing, reduction and normal forms without it) so that this — the other deep open fact besides confluence — stands on its own; ModuleExpression.lean collects the consequences.

The proof is Tait's reducibility (logical relations) in its Kripke form: Red T Γ m says that m is a well-typed weakly normalizing term of type T in context Γ, hereditarily so under every elimination the type allows. The function case quantifies over all renamings Γ → Γ', which is what makes the relation stable under weakening (Red.rename) — needed because the abs case of the fundamental lemma goes under a binder.

The three candidate properties are Red.weaklyNormalizing/Red.hasType (CR1), Red.of_step/Red.of_multiStep (backward closure, CR2) and Red.of_neutral (CR3, here in the sharp form "a normal neutral term is reducible", since Neutral in this development already means normal neutral). HasType.red_substituteSimultaneously is the fundamental lemma and HasType.terminating its corollary at the identity substitution.

Renaming preserves reduction and normal forms #

A de Bruijn renaming touches only variables, so every syntactic notion of the reduction theory is stable under it. These are the facts the Kripke clause of Red needs.

Being a procedure tuple is a property of the term's shape, not of its variables, so a renaming cannot create one.

Normal forms are stable under renaming.

Neutral forms are stable under renaming.

Weak normalization #

Terminating asks for a stuck reduct; the reducibility argument needs the sharper "reduces to a normal form", which is stable under renaming (a stuck term need not stay stuck under a renaming for any obvious syntactic reason, whereas a normal term visibly does). For well-typed terms the two agree — Stuck.normal — and that is how Terminating is recovered at the end.

m reduces to a normal form. Refines Terminating.

Equations
Instances For

    Weak normalization is closed under expansion by a single step.

    Weak normalization is closed under expansion along a multi-step reduction.

    Renamings compose #

    theorem GaudisCrypt.ModuleExpression.HasType.IsRenaming.comp {Δ Γ Ξ : ModuleContext} {ρ ρ' : ℕ → ℕ} (h : IsRenaming Δ Γ ρ) (h' : IsRenaming Γ Ξ ρ') :
    IsRenaming Δ Ξ (ρ' ∘ ρ)

    The reducibility relation #

    Tait's reducibility candidates, Kripke-style. Red T Γ m says: m has type T in Γ and is weakly normalizing, and hereditarily so under the eliminations T allows — projections at a product type, and application to a reducible argument (in any context reachable from Γ by a renaming) at a function type.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      CR1, typing half.

      theorem GaudisCrypt.ModuleExpression.Red.of_step {T : ModuleTypeRep} {Γ : ModuleContext} {m m' : ModuleExpression} :
      m.HasType Γ T → m.ReductionStep m' → Red T Γ m' → Red T Γ m

      CR2: reducibility is closed under expansion by a single step.

      theorem GaudisCrypt.ModuleExpression.Red.of_multiStep {T : ModuleTypeRep} {Γ : ModuleContext} {m m' : ModuleExpression} (hred : m.MultiStepReduction m') (h : Red T Γ m') :
      m.HasType Γ T → Red T Γ m

      CR2 along a multi-step reduction.

      CR3: a well-typed normal neutral term is reducible. (Neutral already implies Normal in this development, so no reasoning about the term's reducts is needed.)

      theorem GaudisCrypt.ModuleExpression.Red.rename {T : ModuleTypeRep} {Γ Γ' : ModuleContext} {m : ModuleExpression} {ρ : ℕ → ℕ} :
      Red T Γ m → HasType.IsRenaming Γ Γ' ρ → Red T Γ' (ModuleExpression.rename ρ m)

      Reducibility is stable under weakening (any renaming of the context).

      The fundamental lemma #

      A substitution all of whose values are reducible at the type their index carries.

      Equations
      Instances For
        theorem GaudisCrypt.ModuleExpression.RedSubst.lift {Δ Γ : ModuleContext} {A : ModuleTypeRep} {σ : ℕ → ModuleExpression} (h : RedSubst Δ Γ σ) :
        RedSubst (A :: Δ) (A :: Γ) (liftSubst σ)

        Lifting a reducible substitution under a binder keeps it reducible.

        The fundamental lemma of the reducibility argument: a well-typed term is reducible under every reducible substitution.

        Weak normalization #

        Weak normalization: every well-typed module expression reduces to a normal form, hence terminates. Instantiate the fundamental lemma at the identity substitution, which is reducible because a variable is a normal neutral term.