# 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. - [x] **Separate level syntax.** `Tm` indexed by a sort (`Term`, `Lvl`), coercions `` `lvl `` / `` `latom `` with `` `latom (`lvl l) ↪ l ``, level well-formedness `_⊢ₗ_` (see README). Ordinary terms no longer carry level equations. - [x] **Equational theory.** `_~_` as the congruence closure of the level equations (`Specification/LevelEquality.agda`). - [x] **Structure of `~` on terms.** `~→≋`: one layer of matching constructors; injectivity of every term constructor; different constructors are never `~`-equal (`LevelEqualityProperties.agda`). - [x] **Stability.** `~` is stable under renaming and substitution (`~-ren`, `~-sub`, `~σ-sub`, `~-[]`). - [x] **Commutation with complete development.** `u ~ u' → u⁺ ~ u'⁺` (`ConfluenceModulo.agda`). - [x] **Church–Rosser modulo `~`.** `_↪~*_` is confluent, via the triangle property of `~ ; ↪ₚ ; ~` (`ConfluenceModulo.agda`). - [x] **Conversion.** `≈` is a common reduct under `_↪~*_`; equivalence, congruence, renaming, substitution (`ConversionProperties.agda`). - [x] **Downstream proofs.** `Inversion.agda`, `SubstitutionPreservesTyping.agda`, `SubjectReduction.agda` (subject reduction holds for the full system). - [x] **Level normal forms.** `nf`, `compare` and its order laws, soundness and completeness, ported to the separate level syntax (`LevelNormalForm.agda`, `LevelNormalForm/`). - [x] **Decidability.** `_~?_ : Dec (u ~ u')` in `LevelEqualityDecision.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). - [x] **Injectivity of `lsuc`**: `~-lsuc-inj : lsuc l ~ lsuc l' → l ~ l'` via the normaliser (`LevelEqualityDecision.agda`). - [ ] **η for the coercions** (optional, only if an example needs it): `` `lvl (`latom e) `` and `e` are not convertible (only `` `latom (`lvl l) ↪ l `` holds). This matters when level-typed terms are compared as terms, e.g. `F (lvl (latom x ⊔ lzero))` vs `F x` for `F : Level → Set`, or in `≡`. - As a reduction rule `` `lvl (`latom e) ↪ e ``: left-linear, its only overlap with `β-latom` is trivial, and subject reduction needs only `T ≈ Level` from inverting `⊢-lvl` (plus `Level≉Setn`). - Cost: `~` hides η-redexes (`` `lvl (`latom e `⊔ `latom e) ~ `lvl (`latom e) ↪ e ``), so `~-⁺` fails. `⁺` would have to contract `` `lvl l `` whenever `nf l ≡ `latom e`, making `ConfluenceModulo` depend on the normaliser's soundness and completeness. - As an equation in `~` instead: breaks `~→≋` (different heads become `~`-equal), so not recommended. ## Universe hierarchy (typing) - [x] Cumulativity: lifting rules `⊢-Set≤Setω` and `⊢-Setω≤`. - [x] `⊢-∀` split into `⊢-∀`, `⊢-∀ω` and `⊢-∀-dep` (result level determined by the premises; level-dependent codomains only in `Set`, so `∀ (l : Level) → Setω l` is rejected). Checked with example derivations, e.g. `∀ (l : Level) → Set l : Setω lzero`. - [x] `⊢-Setn` and `⊢-Setω` require the level to be well formed (`Γ ⊢ₗ l`). - [x] `⊢-λ` requires the domain to be a type: `Γ ⊢ t₁ ⦂ Setω l` (small domains reach `Setω lzero` via `⊢-Set≤Setω`). - [x] `⊢-∃` mirrors `⊢-∀`: `⊢-∃`, `⊢-∃ω`, `⊢-∃-dep`. - [x] `⊢-≡` requires `Γ ⊢ t ⦂ Set l` and lives in `Set l`; the motive of `⊢-subst` is in `Set (ren wk l)`. - [x] 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. - [x] Proofs for the new rules: `≈-Γ-⊢`, `⊢ren` / `⊢sub` (weakened levels realigned with `wk-extᵣ-fusion` / `wk-extₛ-fusion`), inversion through the lifting rules (universes are never convertible to `∀`, `∃` or `≡`), subject reduction. ## Values - [x] `val-Setω` requires `Value l`, as `val-Setn` does. - [x] `val-l` renamed to `val-lzero`. - [x] `val-⊔`: `_⊔_` of values is a value (`⊔` does not reduce; level equality is handled by conversion). - [x] `val-lvl`, `val-latom` (`` `latom e `` is a value if `e` is neutral). - [x] `Value` describes normal forms (values under binders), matching the full reduction relation; `Neutral` the stuck terms. - [x] **Progress** for open terms: `progress : Γ ⊢ e ⦂ t → Value e ⊎ ∃[ e' ] e ↪ e'` (with `progressₗ` for levels), and `value-normal : Value e → ¬ (e ↪ e')` (`Progress.agda`). ## Decidability of conversion Statements in `Decidability/Statement.agda`. - [ ] **Normalisation**: every well-typed term reduces to a normal form (`Value`). Needs a logical relation (reducibility candidates), with the universe hierarchy and level-dependent ∀ in `Setω`. - [ ] **Normal forms**: convertible normal forms are `~`-equal (from `confluence-modulo` and `value-normal`). - [ ] **`Decidable-≈` / `Decidable-≈ₗ`**: normalise both sides and compare the normal forms with `_~?_` (`LevelEqualityDecision`).