\begin{code}
{-# OPTIONS --without-K #-}
module CwF.Sets.IdentityType where
open import Preliminaries.SetsAndFunctions
open import CwF.Sets.Base
open import CwF.Sets.TypesAndTerms
open import CwF.Sets.ContextComprehension
\end{code}
\begin{code}
Id : {Γ : Cxt} → (A : Type Γ) → Type (Γ ₊ A ₊ A [ ⓟ ]ʸ)
Id A ((γ , a) , b) = a ≡ b
Ⓡ : {Γ : Cxt} {A : Type Γ} → Sub (Γ ₊ A) (Γ ₊ A ₊ A [ ⓟ ]ʸ ₊ Id A)
Ⓡ (γ , a) = ((γ , a) , a) , refl
Ⓙ : {Γ : Cxt} {A : Type Γ} {B : Type (Γ ₊ A ₊ A [ ⓟ ]ʸ ₊ Id A)}
→ Term (Γ ₊ A) (B [ Ⓡ ]ʸ) → Term (Γ ₊ A ₊ A [ ⓟ ]ʸ ₊ Id A) B
Ⓙ {B = B} u (((γ , a) , b) , p) = J (λ x y q → B (((γ , x) , y) , q)) (λ x → u(γ , x)) a b p
\end{code}
\begin{code}
⟪_⟫Ⓡ : {Γ : Cxt} (A : Type Γ) → Sub (Γ ₊ A) (Γ ₊ A ₊ A [ ⓟ ]ʸ ₊ Id A)
⟪ A ⟫Ⓡ = Ⓡ
⟪_⟫Ⓙ : {Γ : Cxt} {A : Type Γ}
→ (B : Type (Γ ₊ A ₊ A [ ⓟ ]ʸ ₊ Id A))
→ Term (Γ ₊ A) (B [ Ⓡ ]ʸ) → Term (Γ ₊ A ₊ A [ ⓟ ]ʸ ₊ Id A) B
⟪ B ⟫Ⓙ = Ⓙ
\end{code}
\begin{code}
EqIT₁ : {Γ : Cxt} {A : Type Γ}
→ ⓟ ∘ ⟪ A ⟫Ⓡ ≡ ⟨ Ι , ⓠ ⟩
EqIT₁ = refl
EqIT₂ : {Γ : Cxt} {A : Type Γ} {B : Type (Γ ₊ A ₊ A [ ⓟ ]ʸ ₊ Id A)}
{u : Term (Γ ₊ A) (B [ Ⓡ ]ʸ)}
→ (⟪ B ⟫Ⓙ u) [ Ⓡ ]ᵐ ≡ u
EqIT₂ = refl
EqIT₃ : {Γ : Cxt} {A : Type Γ} {Δ : Cxt} {σ : Sub Δ Γ}
→ (Id A) [ ⟨ ⟨ σ ∘ ⓟ , ⓠ ⟩ ∘ ⓟ , ⓠ ⟩ ]ʸ ≡ Id (A [ σ ]ʸ)
EqIT₃ = refl
⟨_∘p,q⟩ : {Γ : Cxt} {A : Type Γ} {Δ : Cxt}
→ (σ : Sub Δ Γ) → Sub (Δ ₊ A [ σ ]ʸ) (Γ ₊ A)
⟨ σ ∘p,q⟩ = ⟨ σ ∘ ⓟ , ⓠ ⟩
EqIT₄ : {Γ : Cxt} {A : Type Γ} {B : Type (Γ ₊ A ₊ A [ ⓟ ]ʸ ₊ Id A)}
{u : Term (Γ ₊ A) (B [ Ⓡ ]ʸ)} {Δ : Cxt} {σ : Sub Δ Γ}
→ (⟪ B ⟫Ⓙ u) [ ⟨ ⟨ ⟨ σ ∘ ⓟ , ⓠ ⟩ ∘ ⓟ , ⓠ ⟩ ∘ ⓟ , ⓠ ⟩ ]ᵐ
≡ Ⓙ (u [ ⟨ σ ∘ ⓟ , ⓠ ⟩ ]ᵐ)
EqIT₄ = refl
\end{code}