OAI/Computability/TypeSystem/Typing.lean
91 declarations, 0 contain sorry, 0 declared as axioms
Finite syntax-directed typing trees, with all generation witnesses retained; no functionality or unique sort choices are imposed.
- inductive
OAI.PureTypeSystem.Lookupline 10Source documentation
A declaration's type viewed in the full newest-first context.
inductive Lookup {S : Type u} : List (Expr S) → Nat → Expr S → Prop | zero (A Γ) : Lookup (A :: Γ) 0 (A.rename Nat.succ) | succ {Γ n A} (B) : Lookup Γ n A → Lookup (B :: Γ) (n + 1) (A.rename Nat.succ) namespace HasType variable {S : Type u} {P : Specification S}Mentions: OAI.PureTypeSystem.Expr, OAI.PureTypeSystem.HasType, OAI.PureTypeSystem.Specification
- theorem
OAI.PureTypeSystem.HasType.sort_of_validline 18 - theorem
OAI.PureTypeSystem.HasType.product_domainline 26Source documentation
Domain generation alone precedes substitution and does not need any exchange or context-substitution theorem.
theorem product_domain {Γ : List (Expr S)} {M T : Expr S} (h : HasType P Γ M T) : ∀ A B, M = .pi A B → ∃ s, HasType P Γ A (.sort s) := by …Mentions: OAI.PureTypeSystem.Expr, OAI.PureTypeSystem.HasType
- theorem
OAI.PureTypeSystem.Converts.substline 56 - theorem
OAI.PureTypeSystem.Converts.renameline 64 - def
OAI.PureTypeSystem.TypedSubstitutionline 76Source documentation
A simultaneous substitution respects each declared variable's exact type. This is a premise only of the substitution metatheorem, not of the main target.
def TypedSubstitution {S : Type u} (P : Specification S) (Γ Δ : List (Expr S)) (σ : Nat → Expr S) : Prop := …Mentions: OAI.PureTypeSystem.Specification, OAI.PureTypeSystem.Expr
- theorem
OAI.PureTypeSystem.TypedSubstitution.tailline 85 - theorem
OAI.PureTypeSystem.TypedSubstitution.liftline 91 - theorem
OAI.PureTypeSystem.HasType.substline 111 - theorem
OAI.PureTypeSystem.Expr.subst_var_renameline 138 - theorem
OAI.PureTypeSystem.Expr.subst_lift_singleline 142 - theorem
OAI.PureTypeSystem.HasType.lookupline 153 - theorem
OAI.PureTypeSystem.TypedSubstitution.identityline 168 - theorem
OAI.PureTypeSystem.TypedSubstitution.weakenline 173 - theorem
OAI.PureTypeSystem.TypedSubstitution.singleline 180 - theorem
OAI.PureTypeSystem.HasType.renameline 196 - theorem
OAI.PureTypeSystem.HasType.instantiateline 205 - theorem
OAI.PureTypeSystem.HasType.weaken_underline 210 - theorem
OAI.PureTypeSystem.HasType.context_head_conversionline 225 - def
OAI.PureTypeSystem.HasType.Generationline 244Source documentation
Generation is stated up to conversion, without any functionality premise.
def Generation (P : Specification S) (Γ : List (Expr S)) (M T : Expr S) : Prop := …Mentions: OAI.PureTypeSystem.Specification, OAI.PureTypeSystem.Expr
- theorem
OAI.PureTypeSystem.HasType.generationline 257 - theorem
OAI.PureTypeSystem.HasType.generation_piline 304 - theorem
OAI.PureTypeSystem.HasType.generation_lamline 310 - theorem
OAI.PureTypeSystem.HasType.generation_appline 315 - theorem
OAI.PureTypeSystem.HasType.regularityline 321Source documentation
Correctness of types, including the unsorted literal-sort alternative.
theorem regularity {Γ : List (Expr S)} {M A : Expr S} (h : HasType P Γ M A) : (∃ s, A = .sort s) ∨ (∃ s, HasType P Γ A (.sort s)) := by …Mentions: OAI.PureTypeSystem.Expr, OAI.PureTypeSystem.HasType
- theorem
OAI.PureTypeSystem.HasType.product_type_sortedline 339 - theorem
OAI.PureTypeSystem.Converts.piline 351 - theorem
OAI.PureTypeSystem.Converts.pi_not_sortline 357 - theorem
OAI.PureTypeSystem.Converts.sort_injline 364 - theorem
OAI.PureTypeSystem.Converts.instantiate_rightline 367 - theorem
OAI.PureTypeSystem.HasType.application_type_sorted_auxline 382 - theorem
OAI.PureTypeSystem.HasType.application_type_sortedline 407 - theorem
OAI.PureTypeSystem.HasType.abstraction_type_sortedline 411 - theorem
OAI.PureTypeSystem.HasType.conversion_from_sortline 421Source documentation
Reconstructing a sorted expression at its original expected type does not require a sorting of a terminal (unsorted) sort.
theorem conversion_from_sort {Γ : List (Expr S)} {M T : Expr S} {s : S} (h : HasType P Γ M (.sort s)) (hT : (∃ t, T = .sort t) ∨ ∃ t, HasType P Γ T (.sort t)) (hc : Converts T (.sort s)) : HasType P Γ M T := by …Mentions: OAI.PureTypeSystem.Expr, OAI.PureTypeSystem.HasType, OAI.PureTypeSystem.Converts
- theorem
OAI.PureTypeSystem.HasType.subject_reductionline 432Source documentation
Subject reduction at the exact original type, including binder annotations.
theorem subject_reduction {Γ : List (Expr S)} {M N T : Expr S} (h : HasType P Γ M T) (hr : Beta M N) : HasType P Γ N T := by …Mentions: OAI.PureTypeSystem.Expr, OAI.PureTypeSystem.HasType, OAI.PureTypeSystem.Beta
- theorem
OAI.PureTypeSystem.HasType.subject_reducesline 478 - theorem
OAI.PureTypeSystem.Normal.of_mapline 490 - theorem
OAI.PureTypeSystem.Normal.app_leftline 494 - theorem
OAI.PureTypeSystem.Normal.app_rightline 497 - theorem
OAI.PureTypeSystem.Normal.lam_domainline 500 - theorem
OAI.PureTypeSystem.Normal.lam_bodyline 503 - theorem
OAI.PureTypeSystem.Normal.pi_domainline 506 - theorem
OAI.PureTypeSystem.Normal.pi_bodyline 509 - theorem
OAI.PureTypeSystem.Normal.piline 512 - theorem
OAI.PureTypeSystem.Normal.lamline 518 - def
OAI.PureTypeSystem.Expr.normalFormline 532Source documentation
Choice of the unique full beta normal form when it exists. The fallback is irrelevant on legal syntax under the standing system-wide WN hypothesis.
noncomputable def normalForm (M : Expr S) : Expr S := by …
Mentions: OAI.PureTypeSystem.Expr
- theorem
OAI.PureTypeSystem.Expr.normalForm_specline 536 - theorem
OAI.PureTypeSystem.Expr.normalForm_eqline 541 - theorem
OAI.PureTypeSystem.Expr.normalForm_of_normalline 547 - theorem
OAI.PureTypeSystem.Expr.normalForm_convertsline 550 - theorem
OAI.PureTypeSystem.Expr.normalForm_piline 557 - theorem
OAI.PureTypeSystem.HasType.weaklyNormalizingline 569 - theorem
OAI.PureTypeSystem.HasType.type_weaklyNormalizingline 572 - theorem
OAI.PureTypeSystem.HasType.normalFormline 575 - theorem
OAI.PureTypeSystem.HasType.normalize_typeline 579 - inductive
OAI.PureTypeSystem.Neutralline 589Source documentation
The variable-headed spines used by the manuscript.
inductive Neutral {S : Type u} : Expr S → Prop | var (n) : Neutral (.var n) | app {f a} : Neutral f → Neutral (.app f a) namespace HasType variable {S : Type u} {P : Specification S} {Γ : List (Expr S)}Mentions: OAI.PureTypeSystem.Expr, OAI.PureTypeSystem.HasType, OAI.PureTypeSystem.Specification
- theorem
OAI.PureTypeSystem.HasType.sort_cannot_have_product_typeline 597 - theorem
OAI.PureTypeSystem.HasType.product_cannot_have_product_typeline 602 - theorem
OAI.PureTypeSystem.HasType.lambda_cannot_have_sort_typeline 607 - theorem
OAI.PureTypeSystem.HasType.neutral_uniqueline 614Source documentation
No functionality is needed for neutral uniqueness: the declaration fixes its head type, and product compatibility fixes every successive codomain.
theorem neutral_unique {M A B : Expr S} (hn : Neutral M) (hA : HasType P Γ M A) (hB : HasType P Γ M B) : Converts A B := by …Mentions: OAI.PureTypeSystem.Expr, OAI.PureTypeSystem.Neutral, OAI.PureTypeSystem.HasType, OAI.PureTypeSystem.Converts
- theorem
OAI.PureTypeSystem.HasType.normal_shapeline 635 - theorem
OAI.PureTypeSystem.HasType.sorted_normal_shapeline 651 - inductive
OAI.PureTypeSystem.TypingTreeline 665 - theorem
OAI.PureTypeSystem.TypingTree.typingline 686Source documentation
Root expected judgment, including the potentially unsorted final sort.
theorem typing (t : TypingTree P Γ M T) : HasType P Γ M T := by …
Mentions: OAI.PureTypeSystem.TypingTree, OAI.PureTypeSystem.HasType
- def
OAI.PureTypeSystem.TypingTree.retargetline 695Source documentation
Retarget only the root; all core data and all children are unchanged.
def retarget {T' : Expr S} (t : TypingTree P Γ M T) (ht : HasType P Γ M T') (hc : Converts T' T) : TypingTree P Γ M T' := by …Mentions: OAI.PureTypeSystem.Expr, OAI.PureTypeSystem.TypingTree, OAI.PureTypeSystem.HasType, OAI.PureTypeSystem.Converts
- theorem
OAI.PureTypeSystem.TypingTree.nonemptyline 706Source documentation
Generation proves existence of finite stored trees without eliminating a Prop-valued typing derivation into data or assuming unique formation triples.
theorem nonempty (h : HasType P Γ M T) : Nonempty (TypingTree P Γ M T) := by …
Mentions: OAI.PureTypeSystem.HasType, OAI.PureTypeSystem.TypingTree
- def
OAI.PureTypeSystem.TypingTree.ofTypingline 725 - def
OAI.PureTypeSystem.TypingTree.DeclRenamingline 729Source documentation
A genuine variable renaming sends declarations to declarations, rather than merely to terms that happen to have convertible types.
def DeclRenaming (Γ Δ : List (Expr S)) (ρ : Nat → Nat) : Prop := …
Mentions: OAI.PureTypeSystem.Expr
- theorem
OAI.PureTypeSystem.TypingTree.DeclRenaming.typedline 734 - theorem
OAI.PureTypeSystem.TypingTree.DeclRenaming.liftline 738 - def
OAI.PureTypeSystem.TypingTree.renameline 751Source documentation
Thinning/reindexing transports every stored witness and preserves the whole tree shape. Binder annotations are transported too.
noncomputable def rename (t : TypingTree P Γ M T) {Δ : List (Expr S)} (hΔ : ValidContext P Δ) (ρ : Nat → Nat) (hρ : DeclRenaming Γ Δ ρ) : TypingTree P Δ (M.rename ρ) (T.rename ρ) := by …Mentions: OAI.PureTypeSystem.TypingTree, OAI.PureTypeSystem.Expr, OAI.PureTypeSystem.ValidContext, OAI.PureTypeSystem.TypingTree.DeclRenaming
- theorem
OAI.PureTypeSystem.TypingTree.DeclRenaming.weakenline 771 - abbrev
OAI.PureTypeSystem.TypingTree.StoredSubstitutionline 776Source documentation
Substitution carries stored trees at all declaration occurrences.
abbrev StoredSubstitution (P : Specification S) (Γ Δ : List (Expr S)) (σ : Nat → Expr S) : Type u := …Mentions: OAI.PureTypeSystem.Specification, OAI.PureTypeSystem.Expr
- theorem
OAI.PureTypeSystem.TypingTree.StoredSubstitution.typedline 782 - def
OAI.PureTypeSystem.TypingTree.StoredSubstitution.liftline 785 - def
OAI.PureTypeSystem.TypingTree.substline 813Source documentation
Capture-avoiding substitution grafts the given trees at variables. It retains core choices and recurses through the annotation at each binder.
noncomputable def subst (t : TypingTree P Γ M T) {Δ : List (Expr S)} (hΔ : ValidContext P Δ) (σ : Nat → Expr S) (ts : StoredSubstitution P Γ Δ σ) : TypingTree P Δ (M.subst σ) (T.subst σ) := by …Mentions: OAI.PureTypeSystem.TypingTree, OAI.PureTypeSystem.Expr, OAI.PureTypeSystem.ValidContext, OAI.PureTypeSystem.TypingTree.StoredSubstitution
- def
OAI.PureTypeSystem.Expr.ProperPartline 835 - theorem
OAI.PureTypeSystem.Expr.ProperPart.childline 838 - theorem
OAI.PureTypeSystem.Expr.ProperPart.subtermline 839 - theorem
OAI.PureTypeSystem.Expr.ProperPart.trans_rightline 842 - theorem
OAI.PureTypeSystem.Expr.ProperPart.trans_leftline 846 - theorem
OAI.PureTypeSystem.Expr.Subterm.apps_headline 852 - theorem
OAI.PureTypeSystem.Expr.ProperPart.apps_argline 859 - theorem
OAI.PureTypeSystem.Expr.subst_appsline 867 - theorem
OAI.PureTypeSystem.HasType.spine_shapeline 876 - theorem
OAI.PureTypeSystem.HasType.app_spineline 892 - theorem
OAI.PureTypeSystem.HasType.apps_headline 904 - theorem
OAI.PureTypeSystem.HasType.apps_argline 913 - theorem
OAI.PureTypeSystem.stronglyNormalizing_of_applicationline 928Source documentation
The syntactic application principle implying strong normalization. This principle is proved from candidate interfaces, not assumed on the PTS normalization theorem.
theorem stronglyNormalizing_of_application {S : Type u} {P : Specification S} (applySN : ∀ {Γ f a D E}, HasType P Γ f (.pi D E) → HasType P Γ a D → StronglyNormalizing f → StronglyNormalizing a → StronglyNormalizing (.app f a)) : SystemStronglyNormalizing P := by …Mentions: OAI.PureTypeSystem.Specification, OAI.PureTypeSystem.HasType, OAI.PureTypeSystem.StronglyNormalizing, OAI.PureTypeSystem.SystemStronglyNormalizing
- theorem
OAI.PureTypeSystem.exists_bad_applicationline 960Source documentation
A failed full-normalization theorem has an exact, well-typed application counterexample whose two children are already strongly normalizing.
theorem exists_bad_application {S : Type u} {P : Specification S} (h : ¬ SystemStronglyNormalizing P) : ∃ Γ f a D E, HasType P Γ f (.pi D E) ∧ HasType P Γ a D ∧ StronglyNormalizing f ∧ StronglyNormalizing a ∧ ¬ StronglyNormalizing (.app f a) := by …Mentions: OAI.PureTypeSystem.Specification, OAI.PureTypeSystem.SystemStronglyNormalizing, OAI.PureTypeSystem.HasType, OAI.PureTypeSystem.StronglyNormalizing
- theorem
OAI.PureTypeSystem.Normal.renameline 976