feat(tg-1): let-binding + de Bruijn substitution metatheory#44
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes TG-1: type safety extended to
let-binding, via the full de Bruijn substitution metatheory (the general weakening + substitution lemmas, not a closed-term shortcut).What landed
Expr.var(de Bruijn) +Expr.lett;tVar(context lookupΓ[i]?) +tLet; small-stepletStep(congruence) +letRed(β-substitution when the bound term is a value).shift/subst— capture-avoiding de Bruijn operations over all ~22Exprconstructors (shiftlifts free vars above a cutoff;substsubstitutes-and-decrements, shifting under binders).weakening—HasType (Γ₁ ++ Γ₂) e τ → HasType (Γ₁ ++ σ :: Γ₂) (shift 1 Γ₁.length e) τ.subst_preserves—HasType (Γ₁ ++ σ :: Γ₂) e τ → HasType (Γ₁ ++ Γ₂) s σ → HasType (Γ₁ ++ Γ₂) (subst Γ₁.length s e) τ.let;infer(+ soundness/completeness) extended, so decidability still holds.Note on the invariant
The substitution lemma's premise is
s : Γ₁ ++ Γ₂(the combined context), nots : Γ₂— the latter is false for a non-empty prefix (e.g.Γ₁=[α],s = var 0would point intoΓ₂underΓ₂but intoΓ₁underΓ₁++Γ₂). TheletRedconsumer instantiatesΓ₁ := [], where the two coincide, so β-substitution forlet v in eissubst_preserves (Γ₁:=[]) h₂ h₁.Verification
lean Tangle.lean→ 0 errors; nosorry/axiom/admit.#print axioms:weakening/subst_preserves/preservation/type_safetyuse onlypropext/Quot.sound;determinismuses none. NosorryAx.The let-free + echo-types + product/
echoAdd/echoEqwork is already inmain(#43); this adds binders on top.🤖 Generated with Claude Code
Generated by Claude Code