Files
univTypes/Examples/Issue.agda
2026-11-06 17:24:59 +01:00

77 lines
2.4 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.Examples.Issue where
-- Example derivations for the typing rules (universe hierarchy, cumulativity,
-- level-dependent ∀/∃, ≡) and for Value. Checked by typechecking this file.
open import Relation.Binary.PropositionalEquality using (refl)
open import Data.Fin using (zero; suc)
open import univTypes.SubjectReduction.Specification
open import Agda.Primitive
open import Agda.Builtin.Unit
-- From the issue
basic : Set₁
basic = (t : ⊤) → Set
obfuscated : Setω
obfuscated = (λ (ℓ : ⊤ → Level) → ∀ t → Set (ℓ t)) (λ _ → lzero)
-- In my language
myBasicTerm : Term 0
myBasicTerm = ∀[x⦂ `Unit ] `Set
-- Under `λ ℓ and ∀ t: t is the innermost variable.
t : Term 2
t = ` zero
ℓ : Term 2
ℓ = ` (suc zero)
myObfuscatedTerm : Term 0
myObfuscatedTerm = (`λ ( ∀[x⦂ `Unit ] `Setn `latom (ℓ · t))) · (`λ `lvl `lzero)
l0 : ∀ {n} → Lvl n
l0 = `lzero
l1 : ∀ {n} → Lvl n
l1 = `lsuc l0
myBasicTyping : ∅ ⊢ myBasicTerm ⦂ `Setn l0 `⊔ l1
myBasicTyping = ⊢-∀ ⊢-Unit (⊢-Setn ⊢-lzero)
myBasicTyping2 : ∅ ⊢ myBasicTerm ⦂ `Setn l1
myBasicTyping2 = ⊢-≈ (mk-≈ (`Setn l1) (↪~*-step (↪~-~ (~-Setn ⊔-lsuc)) ↪~*-refl) ↪~*-refl) myBasicTyping
myBasicTyping3 : ∅ ⊢ myBasicTerm ⦂ `Setω 0
myBasicTyping3 = ⊢-∀-dep (⊢-Set<Setω ⊢-Unit) (⊢-Setn ⊢-lzero)
myBasicTyping4 : ∅ ⊢ myBasicTerm ⦂ `Setω 0
myBasicTyping4 = ⊢-Set<Setω myBasicTyping2
myObfuscatedTyping : ∅ ⊢ myObfuscatedTerm ⦂ `Setω 0
myObfuscatedTyping =
⊢-· -- Lambda applied to lambda
(⊢-λ (⊢-Set<Setω (⊢-∀ ⊢-Unit ⊢-Level)) -- ℓ : ⊤ → Level
(⊢-∀-dep (⊢-Set<Setω ⊢-Unit) -- ∀ t → Set (ℓ t)
(⊢-Setn (⊢-latom (⊢-· (⊢-` (suc zero) refl) (⊢-` zero refl))))))
(⊢-λ -- λ _ → lzero : ⊤ → Level
(⊢-Set<Setω ⊢-Unit) (⊢-lvl ⊢-lzero))
myCoolReduction : myObfuscatedTerm ↪* myBasicTerm
myCoolReduction =
begin
myObfuscatedTerm
↪⟨ β-λ ⟩ -- substitute λ _ → lzero for ℓ
∀[x⦂ `Unit ] `Setn `latom ((`λ `lvl `lzero) · ` zero)
↪⟨ ξ-∀₂ (ξ-Setn (ξ-latom β-λ)) ⟩ -- (λ _ → lzero) t
∀[x⦂ `Unit ] `Setn `latom (`lvl `lzero)
↪⟨ ξ-∀₂ (ξ-Setn β-latom) ⟩ -- latom (lvl lzero) ↪ lzero
myBasicTerm
∎
where open ↪*-Reasoning