Model/Soundness: soundness of typing up to conversion — a well-typed term is well-denoted and its meaning lies in the meaning of a well-denoted witness W ≈ T, in every environment satisfying a convertible semantic context. Model/Consistency: no closed term of zero ≡ suc zero or of ∀ (A : Set) → A, for every instance of the set-theory interface. Re-exported in Theorems; README and TODO describe the model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q7dfaHQ3dYSfqcxR7V5UrJ
8.6 KiB
TODO
Design decisions are in README.md; this file tracks the work.
Level equality (chosen approach)
~ is level equality lifted to whole terms; ≈ is conversion.
- Separate level syntax.
Tmindexed by a sort (Term,Lvl), coercions`lvl/`latomwith`latom (`lvl l) ↪ l, level well-formedness_⊢ₗ_(see README). Ordinary terms no longer carry level equations. - Equational theory.
_~_as the congruence closure of the level equations (Specification/LevelEquality.agda). - Structure of
~on terms.~→≋: one layer of matching constructors; injectivity of every term constructor; different constructors are never~-equal (Metatheory/Levels/Equality.agda). - Stability.
~is stable under renaming and substitution (~-ren,~-sub,~σ-sub,~-[]). - Commutation with complete development.
u ~ u' → u⁺ ~ u'⁺(Metatheory/Confluence/Modulo.agda). - Church–Rosser modulo
~._↪~*_is confluent, via the triangle property of~ ; ↪ₚ ; ~(Metatheory/Confluence/Modulo.agda). - Conversion.
≈is a common reduct under_↪~*_; equivalence, congruence, renaming, substitution (Metatheory/Confluence/Conversion.agda). - Downstream proofs.
Metatheory/Typing/Inversion.agda,Metatheory/Typing/Substitution.agda,Metatheory/Typing/SubjectReduction.agda(subject reduction holds for the full system). - Level normal forms.
nf,compareand its order laws, soundness and completeness, ported to the separate level syntax (Metatheory/Levels/NormalForm.agda,Metatheory/Levels/NormalForm/). - Decidability.
_~?_ : Dec (u ~ u')inMetatheory/Levels/Decision.agda, tested by computation. Reference for the algebra: Bezem & Coquand, Loop-checking and the uniform word problem for join-semilattices with an inflationary endomorphism (TCS 2022). - Injectivity of
lsuc:~-lsuc-inj : lsuc l ~ lsuc l' → l ~ l'via the normaliser (Metatheory/Levels/Decision.agda). - η for the coercions (optional, only if an example needs it):
`lvl (`latom e)andeare not convertible (only`latom (`lvl l) ↪ lholds). This matters when level-typed terms are compared as terms, e.g.F (lvl (latom x ⊔ lzero))vsF xforF : Level → Set, or in≡. - As a reduction rule`lvl (`latom e) ↪ e: left-linear, its only overlap withβ-latomis trivial, and subject reduction needs onlyT ≈ Levelfrom inverting⊢-lvl(plusLevel≉Setn). - Cost:~hides η-redexes (`lvl (`latom e `⊔ `latom e) ~ `lvl (`latom e) ↪ e), so~-⁺fails.⁺would have to contract`lvl lwhenevernf l ≡latom e, makingMetatheory/Confluence/Modulodepend on the normaliser's soundness and completeness. - As an equation in→≋instead: breaks(different heads become~`-equal), so not recommended.
Universe hierarchy (typing)
- Cumulativity: lifting rules
⊢-Set≤Setωand⊢-Setω≤. ⊢-∀split into⊢-∀,⊢-∀ωand⊢-∀-dep(result level determined by the premises; level-dependent codomains only inSet, so∀ (l : Level) → Setω lis rejected). Checked with example derivations, e.g.∀ (l : Level) → Set l : Setω lzero.⊢-Setnand⊢-Setωrequire the level to be well formed (Γ ⊢ₗ l).⊢-λrequires the domain to be a type:Γ ⊢ t₁ ⦂ Setω l(small domains reachSetω lzerovia⊢-Set≤Setω).⊢-∃mirrors⊢-∀:⊢-∃,⊢-∃ω,⊢-∃-dep.⊢-≡requiresΓ ⊢ t ⦂ Set land lives inSet l; the motive of⊢-substis inSet (ren wk l).⊢-,requires its codomain to be a type,Γ , t₁ ⊢ t₂ ⦂ Setω l, as in Agda. Without it,(λz. Unit , tt) : ∃[x⦂ ∀ (z : Level) → Setω 0 ] (x · x)is derivable, althoughx · xis not a type, so no reducible type is convertible to the pair's type (see the decidability section).- Unit type:
`Unit : Set(⊢-Unit) with`tt : `Unit(⊢-tt); both are values, inert under reduction and~, and covered by confluence, the level normaliser, subject reduction and progress. - Proofs for the new rules:
≈-Γ-⊢,⊢ren/⊢sub(weakened levels realigned withwk-extᵣ-fusion/wk-extₛ-fusion), inversion through the lifting rules (universes are never convertible to∀,∃or≡), subject reduction. - Natural numbers:
`ℕ : Set,`zero,`suc, and`natrec P z s twith the motive as a function term, atSet l(⊢-natrec) orSetω m(⊢-natrecω). Covered by level equality (~-suc,~-natrec), confluence, the level normaliser, subject reduction, progress and the decidability proofs;Tests/Nat.agdatypes plus, times and factorial.
Values
val-SetωrequiresValue l, asval-Setndoes.val-lrenamed toval-lzero.val-⊔:_⊔_of values is a value (⊔does not reduce; level equality is handled by conversion).val-lvl,val-latom(`latom eis a value ifeis neutral).Valuedescribes normal forms (values under binders), matching the full reduction relation;Neutralthe stuck terms.- Progress for open terms:
progress : Γ ⊢ e ⦂ t → Value e ⊎ ∃[ e' ] e ↪ e'(withprogressₗfor levels), andvalue-normal : Value e → ¬ (e ↪ e')(Metatheory/Typing/Progress.agda).
Decidability of conversion
-
Decidability of conversion for well-typed terms in well-formed contexts:
decidable-≈ : Decidable-≈anddecidable-≈ₗ : Decidable-≈ₗ(Decidability/Fundamental.agda). Existing theorems are unchanged;⊢-,gained the premise that its codomain is a type (see above). The proof is described in the README, "Decidability of conversion". -
Normalisation by
↪*alone:normalisation/normalisationₗ(Fundamental.agda); inductive SN has no~clause (it was never needed). -
Strong normalisation (accessibility of
↪):strong-normalisation/strong-normalisationₗ(Decidability/SN/Strong.agda), by soundness of inductive SN; the core is backward closure under weak head expansion. -
Canonicity: closed terms reduce to introduction forms (
canonicity), closed natural numbers to numerals (canonicity-ℕ) (Decidability/Canonicity.agda). Not computational, since the substitution lemmas usefun-ext.
Consistency via a set-theoretic model (branch con-leche)
Following con-leche (Breitner, Lean FRO): give every well-typed term a
meaning in set theory and prove soundness, so that types denoting ∅ are
uninhabited. Relative to ZFC with ω·2 inaccessibles.
- Annotated λ:
λ[x⦂ A ] e, so that a λ denotes the graph of its body over its domain. Reduction also reduces the annotation (ξ-λ₁); β discards it (inductive SN gets the side condition). Targets of: not needed. Soundness is stated up to conversion (a well-denoted witness⊢-≈are typesW ≈ T), so junk targets of⊢-≈never need a meaning.- Codomain levels are well formed:
⊢-∀/⊢-∃requireΓ ⊢ₗ l₂; over an empty domain the codomain says nothing about it. - Set-theory interface (a module parameter, no postulate): carrier,
membership,
∅, pairs, dependent function and pair sets,ω, and cumulative universesU : Stratum → Vforfin kandω+ m. - Interpretation: levels to ℕ (
⊔ ↦ max,lsuc ↦ suc, atoms viaω);Set l ↦ U (fin ⟦l⟧),Setω k ↦ U (ω+ k);∀/∃as dependent function / pair sets;≡as{∅}or∅;Unitas{∅};ℕandLevelasω;natrecby recursion on ω; contexts as sets of environments. - Lemmas: interpretation commutes with renaming and substitution;
~preserves meaning (semilattice laws in ℕ); reduction of well-typed terms preserves meaning. - Soundness, up to conversion:
Γ ⊢ e ⦂ Tgives a well-denoted witnessW ≈ Twith⟦e⟧ ρ ∈ ⟦W⟧ ρ(Model/Soundness.agda). - Consistency: no closed term of
zero ≡ suc zeroor of∀ (A : Set) → A(Model/Consistency.agda).