Typecheck / agda (push) Successful in 1m54s
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
92 lines
4.2 KiB
Agda
92 lines
4.2 KiB
Agda
module univTypes.Decidability.LogRel.Lift where
|
||
|
||
open import Data.Product using (Σ; _×_) renaming (_,_ to ⟨_,_⟩)
|
||
|
||
open import univTypes.Specification
|
||
open import univTypes.Metatheory.Confluence.Conversion using (≈-sym; ≈-trans)
|
||
open import univTypes.Decidability.SN.Properties using (idᵣ)
|
||
open import univTypes.Decidability.LogRel.Core
|
||
|
||
-- Cumulativity of the relation: an embedding of the universes of one kit
|
||
-- into another (with the same members) lifts every reducible type, with the
|
||
-- same members. Used to move reducible types up the strata.
|
||
|
||
record KitEmb (K₁ K₂ : Kit) : Set where
|
||
private
|
||
module K₁ = Kit K₁
|
||
module K₂ = Kit K₂
|
||
field
|
||
emb : ∀ {n} {U : Term n} → K₁.Univ U → K₂.Univ U
|
||
to : ∀ {n} {U e : Term n} (u : K₁.Univ U) → K₁._∋ᵁ_ u e → K₂._∋ᵁ_ (emb u) e
|
||
from : ∀ {n} {U e : Term n} (u : K₁.Univ U) → K₂._∋ᵁ_ (emb u) e → K₁._∋ᵁ_ u e
|
||
|
||
-- Embeddings compose.
|
||
_∘ᴱ_ : ∀ {K₁ K₂ K₃} → KitEmb K₂ K₃ → KitEmb K₁ K₂ → KitEmb K₁ K₃
|
||
E₂ ∘ᴱ E₁ = record
|
||
{ emb = λ u → KitEmb.emb E₂ (KitEmb.emb E₁ u)
|
||
; to = λ u x → KitEmb.to E₂ (KitEmb.emb E₁ u) (KitEmb.to E₁ u x)
|
||
; from = λ u x → KitEmb.from E₁ u (KitEmb.from E₂ (KitEmb.emb E₁ u) x)
|
||
}
|
||
|
||
idᴱ : ∀ {K} → KitEmb K K
|
||
idᴱ = record { emb = λ u → u ; to = λ u x → x ; from = λ u x → x }
|
||
|
||
module Lift {K₁ K₂ : Kit} (E : KitEmb K₁ K₂) (L₁ : KitLaws K₁) where
|
||
open KitEmb E
|
||
private
|
||
module R₁ = LogRel K₁
|
||
module R₂ = LogRel K₂
|
||
open R₁.Properties L₁ using (conv)
|
||
open R₁ using (⊩ne; ⊩Level; ⊩Unit; ⊩ℕ; ⊩≡; ⊩U; ⊩∀; ⊩∃)
|
||
|
||
lift : ∀ {n} {A : Term n} → R₁.⊩ A → R₂.⊩ A
|
||
lift-∋ : ∀ {n} {A e : Term n} (p : R₁.⊩ A) → p R₁.∋ e → lift p R₂.∋ e
|
||
lower-∋ : ∀ {n} {A e : Term n} (p : R₁.⊩ A) → lift p R₂.∋ e → p R₁.∋ e
|
||
|
||
lift (⊩ne r s) = R₂.⊩ne r s
|
||
lift (⊩Level r) = R₂.⊩Level r
|
||
lift (⊩Unit r) = R₂.⊩Unit r
|
||
lift (⊩ℕ r) = R₂.⊩ℕ r
|
||
lift (⊩≡ r) = R₂.⊩≡ r
|
||
lift (⊩U r u) = R₂.⊩U r (emb u)
|
||
lift (⊩∀ r XB XB≈ ⊩B XC XC≈ ⊩C) =
|
||
R₂.⊩∀ r XB XB≈ (λ ρ → lift (⊩B ρ))
|
||
(λ ρ u∈ → XC ρ (lower-∋ (⊩B ρ) u∈))
|
||
(λ ρ u∈ → XC≈ ρ (lower-∋ (⊩B ρ) u∈))
|
||
(λ ρ u∈ → lift (⊩C ρ (lower-∋ (⊩B ρ) u∈)))
|
||
lift (⊩∃ r XB XB≈ ⊩B XC XC≈ ⊩C) =
|
||
R₂.⊩∃ r XB XB≈ (λ ρ → lift (⊩B ρ))
|
||
(λ ρ u∈ → XC ρ (lower-∋ (⊩B ρ) u∈))
|
||
(λ ρ u∈ → XC≈ ρ (lower-∋ (⊩B ρ) u∈))
|
||
(λ ρ u∈ → lift (⊩C ρ (lower-∋ (⊩B ρ) u∈)))
|
||
|
||
lift-∋ (⊩ne _ _) x = x
|
||
lift-∋ (⊩Level _) x = x
|
||
lift-∋ (⊩Unit _) x = x
|
||
lift-∋ (⊩ℕ _) x = x
|
||
lift-∋ (⊩≡ _) x = x
|
||
lift-∋ (⊩U _ u) x = to u x
|
||
lift-∋ (⊩∀ _ _ _ ⊩B _ _ ⊩C) ⟨ s , app ⟩ =
|
||
⟨ s , (λ ρ u∈ → lift-∋ (⊩C ρ (lower-∋ (⊩B ρ) u∈)) (app ρ (lower-∋ (⊩B ρ) u∈))) ⟩
|
||
lift-∋ (⊩∃ _ _ _ ⊩B _ XC≈ ⊩C) ⟨ s , ⟨ q₁ , q₂ ⟩ ⟩ =
|
||
let q₁' = lift-∋ (⊩B idᵣ) q₁
|
||
q₁'' = lower-∋ (⊩B idᵣ) q₁'
|
||
in ⟨ s , ⟨ q₁' , lift-∋ (⊩C idᵣ q₁'')
|
||
(conv (⊩C idᵣ q₁) (⊩C idᵣ q₁'')
|
||
(≈-trans (XC≈ idᵣ q₁) (≈-sym (XC≈ idᵣ q₁''))) q₂) ⟩ ⟩
|
||
|
||
lower-∋ (⊩ne _ _) x = x
|
||
lower-∋ (⊩Level _) x = x
|
||
lower-∋ (⊩Unit _) x = x
|
||
lower-∋ (⊩ℕ _) x = x
|
||
lower-∋ (⊩≡ _) x = x
|
||
lower-∋ (⊩U _ u) x = from u x
|
||
lower-∋ (⊩∀ _ _ _ ⊩B _ XC≈ ⊩C) ⟨ s , app' ⟩ =
|
||
⟨ s , (λ ρ u∈ →
|
||
let u∈' = lift-∋ (⊩B ρ) u∈
|
||
u∈'' = lower-∋ (⊩B ρ) u∈'
|
||
in conv (⊩C ρ u∈'') (⊩C ρ u∈) (≈-trans (XC≈ ρ u∈'') (≈-sym (XC≈ ρ u∈)))
|
||
(lower-∋ (⊩C ρ u∈'') (app' ρ u∈'))) ⟩
|
||
lower-∋ (⊩∃ _ _ _ ⊩B _ _ ⊩C) ⟨ s , ⟨ q₁' , q₂' ⟩ ⟩ =
|
||
⟨ s , ⟨ lower-∋ (⊩B idᵣ) q₁' , lower-∋ (⊩C idᵣ (lower-∋ (⊩B idᵣ) q₁')) q₂' ⟩ ⟩
|