Files
univTypes/Decidability/Statement.agda
Julius FischerandClaude Opus 5.5 e708f2d425
Typecheck / agda (push) Successful in 1m54s
Restructure folders: Specification, Metatheory, Decidability
Specification/ (moved up from SubjectReduction/) holds only definitions.
Metatheory/ holds the proofs about it: Substitution (was Composition),
Levels/ (Equality, NormalForm, Decision), Confluence/ (Parallel, Modulo,
Conversion) and Typing/ (Inversion, Substitution, SubjectReduction,
Progress). Decidability/ groups SN/ (Inductive, Properties, Strong) and
LogRel/ (Core, Lift, LevelValue, Universes). Theorems.agda re-exports the
main results. Examples/ keeps the hand-written examples apart from the
generated Tests/ (NatExample renamed to Tests/Nat). Module names, docs and
the CI postulate check follow the new paths; no proof changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q7dfaHQ3dYSfqcxR7V5UrJ
2026-11-21 14:50:06 +01:00

103 lines
3.3 KiB
Agda
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
module univTypes.Decidability.Statement where
open import Data.Nat using (ℕ)
open import Data.Product using (∃-syntax; _×_)
open import Relation.Nullary using (Dec)
open import univTypes.Specification
-- Decidability of conversion, stated as types (to be inhabited).
--
-- On arbitrary terms conversion is undecidable (by Scott–Curry, already
-- `e ≈ λx. x` is undecidable for untyped e), so the statements are
-- restricted to well-typed terms in well-formed contexts. The two terms may
-- have different types: the type checker compares types that live in
-- different universes.
-- Well-formed contexts --------------------------------------------------------
-- Every entry is a type. Each type reaches some Setω m (small types via
-- ⊢-Set<Setω), so one premise covers small and large types. The typing
-- rules themselves do not check contexts; this judgement is only a premise
-- of the statements below.
infix 4 ⊢_
data ⊢_ : ∀ {n} → Context n → Set where
⊢∅ : ⊢ ∅
⊢, : ∀ {n} {Γ : Context n} {A : Term n} {m : ℕ}
→ ⊢ Γ
→ Γ ⊢ A ⦂ `Setω m
→ ⊢ Γ , A
-- Strong normalisation ----------------------------------------------------------
-- Every reduction sequence from e is finite.
data SN {s n} (e : Tm s n) : Set where
sn : (∀ {e'} → e ↪ e' → SN e') → SN e
StrongNormalisation : Set
StrongNormalisation = ∀ {n} {Γ : Context n} {e t : Term n}
→ ⊢ Γ
→ Γ ⊢ e ⦂ t
→ SN e
StrongNormalisationₗ : Set
StrongNormalisationₗ = ∀ {n} {Γ : Context n} {l : Lvl n}
→ ⊢ Γ
→ Γ ⊢ₗ l
→ SN l
-- Normalisation ------------------------------------------------------------------
-- Every well-typed term reduces to a normal form (Value).
Normalisation : Set
Normalisation = ∀ {n} {Γ : Context n} {e t : Term n}
→ ⊢ Γ
→ Γ ⊢ e ⦂ t
→ ∃[ v ] e ↪* v × Value v
Normalisationₗ : Set
Normalisationₗ = ∀ {n} {Γ : Context n} {l : Lvl n}
→ ⊢ Γ
→ Γ ⊢ₗ l
→ ∃[ v ] l ↪* v × Value v
-- Normalisation up to level equality: reduction may be interleaved with ~
-- steps. Weaker than Normalisation, and enough for decidability.
Normalisation~ : Set
Normalisation~ = ∀ {n} {Γ : Context n} {e t : Term n}
→ ⊢ Γ
→ Γ ⊢ e ⦂ t
→ ∃[ v ] e ↪~* v × Value v
Normalisation~ₗ : Set
Normalisation~ₗ = ∀ {n} {Γ : Context n} {l : Lvl n}
→ ⊢ Γ
→ Γ ⊢ₗ l
→ ∃[ v ] l ↪~* v × Value v
-- Decidability of conversion -----------------------------------------------------
Decidable-≈ : Set
Decidable-≈ = ∀ {n} {Γ : Context n} {e₁ e₂ t₁ t₂ : Term n}
→ ⊢ Γ
→ Γ ⊢ e₁ ⦂ t₁
→ Γ ⊢ e₂ ⦂ t₂
→ Dec (e₁ ≈ e₂)
-- The same for level expressions (well-formed levels may contain atoms,
-- i.e. arbitrary terms of type Level).
Decidable-≈ₗ : Set
Decidable-≈ₗ = ∀ {n} {Γ : Context n} {l₁ l₂ : Lvl n}
→ ⊢ Γ
→ Γ ⊢ₗ l₁
→ Γ ⊢ₗ l₂
→ Dec (l₁ ≈ l₂)
-- Route (Decidability/Decision): normalisation up to ~ gives decidability,
-- since convertible normal forms are ~-equal (Decidability/NormalForms),
-- which the level normaliser decides. Normalisation up to ~ follows from the
-- inductive characterisation of SN (Decidability/SN); accessibility (SN
-- above) also gives it, with progress and subject reduction.