{-# OPTIONS --erased-cubical --safe #-}
import Equality.Path as P
module Structure-identity-principle.Erased
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
open P.Derived-definitions-and-properties eq
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Bijection equality-with-J as B using (_↔_)
open import Equality.Decidable-UIP equality-with-J
open import Equality.Path.Isomorphisms eq
open import Equality.Path.Isomorphisms.Univalence eq
open import Equivalence equality-with-J as Eq
using (_≃_; Is-equivalence)
open import Equivalence.Erased.Cubical eq as EEq
using (_≃ᴱ_; Is-equivalenceᴱ)
open import Equivalence.Erased.Contractible-preimages.Cubical eq as ECP
using (Contractibleᴱ)
open import Equivalence-relation equality-with-J
open import Erased.Cubical eq as Er hiding (map; map-id)
open import Function-universe equality-with-J as F hiding (id; _∘_)
open import H-level equality-with-J as H-level
open import H-level.Closure equality-with-J
open import H-level.Truncation.Propositional.Erased eq as T
using (∥_∥ᴱ; ∣_∣)
import List equality-with-J as L
import Maybe equality-with-J as Maybe
import Monad equality-with-J as Monad
import Nat equality-with-J as Nat
open import Quotient.Erased eq as Q using (_/ᴱ_; [_])
open import Univalence-axiom equality-with-J
open import
Nat.Binary equality-with-J instance-of-[]-cong-axiomatisation
as Bin using (Bin)
private
variable
a b c d e r : Level
C : Type c
A A₁ A₂ B B₁ B₂ Ax F f G g M m N P R R₁ R₂ S
x x′ x₁ x₂ y y′ ys z z₁ z₂ : C
Structure : (a b : Level) → Type (lsuc (a ⊔ b))
Structure a b = Type a → Type b
Type-with : Structure a b → Type (lsuc a ⊔ b)
Type-with {a} F = ∃ λ (A : Type a) → F A
Axioms : Structure a b → (c : Level) → Type (lsuc a ⊔ b ⊔ lsuc c)
Axioms F c = Type-with F → Type c
_With-the-axioms_ :
(F : Structure a b) → Axioms F c → Structure a (b ⊔ c)
(F With-the-axioms Ax) A = ∃ λ (x : F A) → Erased (Ax (A , x))
Structure-preserving-equivalence-predicate :
Structure a b → (c : Level) → Type (lsuc a ⊔ b ⊔ lsuc c)
Structure-preserving-equivalence-predicate F c =
(A B : Type-with F) → proj₁ A ≃ᴱ proj₁ B → Type c
Lift-With-the-axioms :
Structure-preserving-equivalence-predicate F c →
Structure-preserving-equivalence-predicate (F With-the-axioms Ax) c
Lift-With-the-axioms P (A , x , _) (B , y , _) = P (A , x) (B , y)
infix 4 _≃[_]ᴱ_
_≃[_]ᴱ_ :
{F : Structure a b} →
Type-with F → @0 Structure-preserving-equivalence-predicate F c →
Type-with F →
Type (a ⊔ c)
A ≃[ P ]ᴱ B = ∃ λ (eq : proj₁ A ≃ᴱ proj₁ B) → Erased (P A B eq)
record Univalent
(@0 F : Structure a b)
(@0 P : Structure-preserving-equivalence-predicate F c) :
Type (lsuc a ⊔ b ⊔ c) where
no-eta-equality
field
@0 univalent :
{A B : Type-with F}
(eq : proj₁ A ≃ᴱ proj₁ B) →
P A B eq ≃
(subst F (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) (proj₂ A) ≡ proj₂ B)
Univalent-With-the-axioms :
{@0 P : Structure-preserving-equivalence-predicate F c} →
@0 (∀ A → Is-proposition (Ax A)) →
Univalent F P →
Univalent (F With-the-axioms Ax) (Lift-With-the-axioms P)
Univalent-With-the-axioms
{F} {Ax} {P} prop u .Univalent.univalent
{A = A₁ , x₁ , ax₁} {B = A₂ , x₂ , ax₂} eq =
P (A₁ , x₁) (A₂ , x₂) eq ↝⟨ u .Univalent.univalent eq ⟩
subst F (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x₁ ≡ x₂ ↔⟨ ignore-propositional-component (H-level-Erased 1 (prop _)) ⟩
(subst F (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x₁ , _) ≡ (x₂ , ax₂) ↝⟨ ≡⇒≃ $ cong (_≡ _) $ sym $ push-subst-pair _ _ ⟩□
subst (F With-the-axioms Ax) (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) (x₁ , ax₁) ≡
(x₂ , ax₂) □
@0 sip :
Univalent F P →
(A ≃[ P ]ᴱ B) ≃ (A ≡ B)
sip {F} {P} {A} {B} u =
(A ≃[ P ]ᴱ B) ↔⟨⟩
(∃ λ (eq : proj₁ A ≃ᴱ proj₁ B) → Erased (P A B eq)) ↔⟨ (∃-cong λ _ → erased Erased↔) ⟩
(∃ λ (eq : proj₁ A ≃ᴱ proj₁ B) → P A B eq) ↝⟨ Σ-cong
(inverse $ EEq.≃≃≃ᴱ F.∘ ≡≃≃ univ)
(u .Univalent.univalent) ⟩
(∃ λ (eq : proj₁ A ≡ proj₁ B) → subst F eq (proj₂ A) ≡ proj₂ B) ↔⟨ B.Σ-≡,≡↔≡ ⟩□
(A ≡ B) □
induced-structures :
{@0 P : Structure-preserving-equivalence-predicate F c} →
@0 Univalent F P →
(X@(A , x , _) : Type-with (F With-the-axioms Ax)) →
((B , y) : Type-with F) →
(A , x) ≃[ P ]ᴱ (B , y) →
∃ λ (ax : Erased (Ax (B , y))) →
X ≃[ Lift-With-the-axioms P ]ᴱ (B , y , ax)
induced-structures {Ax} u (A , x , ax) (B , y) eq =
Er.map (subst Ax (_≃_.to (sip u) eq)) ax
, eq
infix 10 _⁻¹
_⁻¹ : (A → B → Type c) → (B → A → Type c)
(R ⁻¹) x y = R y x
infixr 9 _;ᴱ_
_;ᴱ_ :
{B : Type b} →
(A → B → Type d) → (B → C → Type e) → A → C → Type (b ⊔ d ⊔ e)
(R ;ᴱ S) x z = ∥ (∃ λ y → R x y × S y z) ∥ᴱ
infix 10 _⟵ _⟶
_⟵ : {B : Type b} → (A → B → Type c) → A → A → Type (b ⊔ c)
R ⟵ = R ;ᴱ R ⁻¹
_⟶ : {A : Type a} → (A → B → Type c) → B → B → Type (a ⊔ c)
R ⟶ = R ⁻¹ ;ᴱ R
⟵≃ᴱ :
{A : Type a}
{R : A → A → Type a} →
@0 (∀ x y → Is-proposition (R x y)) →
Is-equivalence-relation R →
∀ {x y} → (R ⟵) x y ≃ᴱ R x y
⟵≃ᴱ prop equiv =
EEq.⇔→≃ᴱ
T.truncation-is-proposition
(prop _ _)
(T.rec λ where
.T.truncation-is-propositionʳ → prop _ _
.T.∣∣ʳ (_ , Rxy , Rzy) →
E.transitive Rxy (E.symmetric Rzy))
(λ Rxz → ∣ _ , Rxz , E.reflexive ∣)
where
module E = Is-equivalence-relation equiv
⟶≃ᴱ :
{A : Type a}
{R : A → A → Type a} →
@0 (∀ x y → Is-proposition (R x y)) →
Is-equivalence-relation R →
∀ {x y} → (R ⟶) x y ≃ᴱ R x y
⟶≃ᴱ prop equiv =
EEq.⇔→≃ᴱ
T.truncation-is-proposition
(prop _ _)
(T.rec λ where
.T.truncation-is-propositionʳ → prop _ _
.T.∣∣ʳ (_ , Ryx , Ryz) →
E.transitive (E.symmetric Ryx) Ryz)
(λ Rzx →
∣ _ , E.symmetric Rzx , E.reflexive ∣)
where
module E = Is-equivalence-relation equiv
@0 ⟵≡ :
{A : Type a}
{R : A → A → Type a} →
(∀ x y → Is-proposition (R x y)) →
Is-equivalence-relation R →
R ⟵ ≡ R
⟵≡ prop equiv =
⟨ext⟩ λ _ → ⟨ext⟩ λ _ →
≃⇒≡ univ $
EEq.≃ᴱ→≃ $
⟵≃ᴱ prop equiv
@0 ⟶≡ :
{A : Type a}
{R : A → A → Type a} →
(∀ x y → Is-proposition (R x y)) →
Is-equivalence-relation R →
R ⟶ ≡ R
⟶≡ prop equiv =
⟨ext⟩ λ _ → ⟨ext⟩ λ _ →
≃⇒≡ univ $
EEq.≃ᴱ→≃ $
⟶≃ᴱ prop equiv
Graph : {A : Type a} {B : Type b} → (A → B) → A → B → Type b
Graph f x y = f x ≡ y
@0 Graph-[]-⟵≡ :
{A : Type a}
{R : A → A → Type a} →
(∀ x y → Is-proposition (R x y)) →
Is-equivalence-relation R →
Graph (Q.[_] {R = R}) ⟵ ≡ R
Graph-[]-⟵≡ {R} prop equiv =
⟨ext⟩ λ x → ⟨ext⟩ λ y →
let
lemma =
Eq.⇔→≃
T.truncation-is-proposition
Q./ᴱ-is-set
(T.rec λ @0 where
.T.truncation-is-propositionʳ → Q./ᴱ-is-set
.T.∣∣ʳ (_ , [x]≡z , [y]≡z) → trans [x]≡z (sym [y]≡z))
(λ [x]≡[y] → ∣ _ , [x]≡[y] , refl _ ∣)
in
≃⇒≡ univ
((Graph [_] ⟵) x y ↝⟨ lemma ⟩
[ x ] ≡ [ y ] ↔⟨ inverse $ Q.related≃[equal] equiv (prop _ _) ⟩□
R x y □)
@0 ;ᴱ-Graph-[]≡Graph-[] :
{A : Type a}
{R : A → A → Type r} →
(∀ x y → Is-proposition (R x y)) →
Is-equivalence-relation R →
R ;ᴱ Graph ([_] {R = R}) ≡ Graph ([_] {R = R})
;ᴱ-Graph-[]≡Graph-[] {R} prop equiv =
⟨ext⟩ λ x → ⟨ext⟩ λ y →
≃⇒≡ univ $
flip
(Q.elim-prop
{P = λ y → (R ;ᴱ Graph ([_] {R = R})) x y ≃
Graph ([_] {R = R}) x y})
y
λ @0 where
.Q.is-propositionʳ _ →
Eq.left-closure ext 0 $
T.truncation-is-proposition
.Q.[]ʳ y →
Eq.⇔→≃
T.truncation-is-proposition
Q./ᴱ-is-set
(T.rec λ @0 where
.T.Rec.truncation-is-propositionʳ →
Q./ᴱ-is-set
.T.Rec.∣∣ʳ (z , Rxz , [z]≡[y]) →
[ x ] ≡⟨ Q.[]-respects-relation Rxz ⟩
[ z ] ≡⟨ [z]≡[y] ⟩∎
[ y ] ∎)
([ x ] ≡ [ y ] ↔⟨ inverse $ Q.related≃[equal] equiv (prop _ _) ⟩
R x y ↝⟨ (λ Rxy → ∣ _ , Rxy , refl _ ∣) ⟩
(R ;ᴱ Graph [_]) x [ y ] □)
Is-QPER :
{A : Type a} {B : Type b} →
(A → B → Type c) → Type (a ⊔ b ⊔ c)
Is-QPER R =
∀ {x x′ y y′} →
R x y → R x′ y → R x′ y′ → R x y′
Is-QER :
{A : Type a} {B : Type b} →
(A → B → Type c) → Type (a ⊔ b ⊔ c)
Is-QER R =
Is-QPER R ×
(∀ x → ∥ ∃ (λ y → R x y) ∥ᴱ) ×
(∀ y → ∥ ∃ (λ x → R x y) ∥ᴱ)
Is-QERᴱ :
{A : Type a} {B : Type b} →
@0 (A → B → Type c) → Type (a ⊔ b ⊔ c)
Is-QERᴱ R =
Erased (Is-QPER R) ×
(∀ x → ∥ ∃ (λ y → Erased (R x y)) ∥ᴱ) ×
(∀ y → ∥ ∃ (λ x → Erased (R x y)) ∥ᴱ)
Is-QERᴱ≃Is-QER-Erased :
{@0 R : A → B → Type r} →
Is-QERᴱ R ≃ Is-QER (λ x y → Erased (R x y))
Is-QERᴱ≃Is-QER-Erased {A} {B} {R} = ×-cong₁ λ _ →
Erased (∀ {x x′ y y′} → R x y → R x′ y → R x′ y′ → R x y′) ↝⟨ Erased-cong lemma ⟩
Erased (∀ x x′ y y′ → R x y → R x′ y → R x′ y′ → R x y′) ↝⟨ (∀-cong ext λ _ →
(∀-cong ext λ _ →
(∀-cong ext λ _ →
Erased-Π↔Π ext) F.∘
Erased-Π↔Π ext) F.∘
Erased-Π↔Π ext) F.∘
Erased-Π↔Π ext ⟩
(∀ x x′ y y′ → Erased (R x y → R x′ y → R x′ y′ → R x y′)) ↝⟨ (∀-cong ext λ _ →
∀-cong ext λ _ →
∀-cong ext λ _ →
∀-cong ext λ _ →
(∀-cong ext λ _ →
(∀-cong ext λ _ →
Erased-Π↔Π-Erased ext) F.∘
Erased-Π↔Π-Erased ext) F.∘
Erased-Π↔Π-Erased ext) ⟩
(∀ x x′ y y′ →
Erased (R x y) → Erased (R x′ y) →
Erased (R x′ y′) → Erased (R x y′)) ↝⟨ inverse lemma ⟩□
(∀ {x x′ y y′} →
Erased (R x y) → Erased (R x′ y) →
Erased (R x′ y′) → Erased (R x y′)) □
where
lemma :
{P : A → A → B → B → Type r} →
(∀ {x x′ y y′} → P x x′ y y′) ≃
(∀ x x′ y y′ → P x x′ y y′)
lemma = Eq.↔⇒≃ $
(∀-cong ext λ _ →
(∀-cong ext λ _ →
(∀-cong ext λ _ →
B.implicit-Π↔Π) F.∘
B.implicit-Π↔Π) F.∘
B.implicit-Π↔Π) F.∘
B.implicit-Π↔Π
Is-QER→Is-QERᴱ : Is-QER R → Is-QERᴱ R
Is-QER→Is-QERᴱ =
[_]→
×-cong
(∀-cong _ λ x →
T.∥∥ᴱ-map $ ∃-cong λ _ → [_]→)
×-cong
(∀-cong _ λ x →
T.∥∥ᴱ-map $ ∃-cong λ _ → [_]→)
@0 Is-QER≃Is-QERᴱ : Is-QER R ≃ Is-QERᴱ R
Is-QER≃Is-QERᴱ = Eq.↔⇒≃ $ inverse $
Erased↔ .erased
×-cong
(∀-cong ext λ x →
T.∥∥ᴱ-cong $ ∃-cong λ _ → Erased↔ .erased)
×-cong
(∀-cong ext λ x →
T.∥∥ᴱ-cong $ ∃-cong λ _ → Erased↔ .erased)
_ : _≃_.to (Is-QER≃Is-QERᴱ {R = R}) ≡ Is-QER→Is-QERᴱ
_ = refl _
Is-QER→Is-equivalence-relation-⟵ :
Is-QER R →
Is-equivalence-relation (R ⟵)
Is-QER→Is-equivalence-relation-⟵ (qper , lr , rl) = λ where
.Is-equivalence-relation.reflexive {x} →
T.∥∥ᴱ-map (λ (y , Rxy) → y , Rxy , Rxy) (lr x)
.Is-equivalence-relation.symmetric →
T.∥∥ᴱ-map (Σ-map id swap)
.Is-equivalence-relation.transitive →
T.rec λ where
.T.truncation-is-propositionʳ →
Π-closure ext 1 λ _ →
T.truncation-is-proposition
.T.∣∣ʳ (_ , Rx₁y₁ , Rx₂y₁) → T.∥∥ᴱ-map
λ (_ , Rx₂y₂ , Rx₃y₂) →
_ , qper Rx₁y₁ Rx₂y₁ Rx₂y₂ , Rx₃y₂
@0 Is-QERᴱ→Is-equivalence-relation-⟵ :
Is-QERᴱ R →
Is-equivalence-relation (R ⟵)
Is-QERᴱ→Is-equivalence-relation-⟵ {R} =
Is-QERᴱ R ↔⟨ inverse Is-QER≃Is-QERᴱ ⟩
Is-QER R ↝⟨ Is-QER→Is-equivalence-relation-⟵ ⟩□
Is-equivalence-relation (R ⟵) □
Is-QER→Is-equivalence-relation-⟶ :
Is-QER R →
Is-equivalence-relation (R ⟶)
Is-QER→Is-equivalence-relation-⟶ (qper , lr , rl) = λ where
.Is-equivalence-relation.reflexive {x = y} →
T.∥∥ᴱ-map (λ (x , Rxy) → x , Rxy , Rxy) (rl y)
.Is-equivalence-relation.symmetric →
T.∥∥ᴱ-map (Σ-map id swap)
.Is-equivalence-relation.transitive →
T.rec λ where
.T.truncation-is-propositionʳ →
Π-closure ext 1 λ _ →
T.truncation-is-proposition
.T.∣∣ʳ (_ , Rx₁y₁ , Rx₁y₂) → T.∥∥ᴱ-map
λ (_ , Rx₂y₂ , Rx₂y₃) →
_ , qper Rx₂y₂ Rx₁y₂ Rx₁y₁ , Rx₂y₃
@0 Is-QERᴱ→Is-equivalence-relation-⟶ :
Is-QERᴱ R →
Is-equivalence-relation (R ⟶)
Is-QERᴱ→Is-equivalence-relation-⟶ {R} =
Is-QERᴱ R ↔⟨ inverse Is-QER≃Is-QERᴱ ⟩
Is-QER R ↝⟨ Is-QER→Is-equivalence-relation-⟶ ⟩□
Is-equivalence-relation (R ⟶) □
/ᴱ⟵≃ᴱ/ᴱ⟶ :
Is-QER R →
@0 (∀ x y → Is-proposition (R x y)) →
∃ λ (eq : A /ᴱ R ⟵ ≃ᴱ B /ᴱ R ⟶) →
∀ x y →
∃ λ (f : _≃ᴱ_.to eq [ x ] ≡ [ y ] → R x y) →
Erased (Is-equivalence f)
/ᴱ⟵≃ᴱ/ᴱ⟶ {A} {B} {R} qer@(qper , lr , rl) prop =
EEq.↔→≃ᴱ to from to-from from-to
, (λ _ _ →
to″
, [ _≃_.is-equivalence $
Eq.⇔→≃ Q./ᴱ-is-set (prop _ _) to″ from″
])
where
to′ : ∥ ∃ (R x) ∥ᴱ → B /ᴱ R ⟶
to′ =
_≃_.to (Q.Σ→Erased-Constant≃∥∥ᴱ→ Q./ᴱ-is-set)
( [_] ∘ proj₁
, [ (λ (_ , r₁) (_ , r₂) →
Q.[]-respects-relation ∣ _ , r₁ , r₂ ∣)
]
)
@0 to′-lemma :
R x y → R x′ y →
(p : ∥ ∃ (R x) ∥ᴱ)
(p′ : ∥ ∃ (R x′) ∥ᴱ) →
to′ p ≡ to′ p′
to′-lemma Rxy Rx′y = T.elim λ @0 where
.T.truncation-is-propositionʳ _ →
Π-closure ext 1 λ _ →
Q./ᴱ-is-set
.T.∣∣ʳ (y₁ , Rxy₁) → T.elim λ @0 where
.T.truncation-is-propositionʳ _ → Q./ᴱ-is-set
.T.∣∣ʳ (y₂ , Rx′y₂) →
[ y₁ ] ≡⟨ Q.[]-respects-relation ∣ _ , Rxy₁ , qper Rxy Rx′y Rx′y₂ ∣ ⟩∎
[ y₂ ] ∎
to : A /ᴱ R ⟵ → B /ᴱ R ⟶
to = Q.rec λ where
.Q.is-setʳ → Q./ᴱ-is-set
.Q.[]ʳ → to′ ∘ lr
.Q.[]-respects-relationʳ {x} {y = x′} → T.elim λ @0 where
.T.truncation-is-propositionʳ _ → Q./ᴱ-is-set
.T.∣∣ʳ (_ , Rxy , Rx′y) →
to′ (lr x) ≡⟨ to′-lemma Rxy Rx′y (lr x) (lr x′) ⟩∎
to′ (lr x′) ∎
from′ : ∥ ∃ ((R ⁻¹) y) ∥ᴱ → A /ᴱ R ⟵
from′ =
_≃_.to (Q.Σ→Erased-Constant≃∥∥ᴱ→ Q./ᴱ-is-set)
( [_] ∘ proj₁
, [ (λ (_ , r₁) (_ , r₂) →
Q.[]-respects-relation ∣ _ , r₁ , r₂ ∣)
]
)
@0 from′-lemma :
R x y → R x y′ →
(p : ∥ ∃ ((R ⁻¹) y) ∥ᴱ)
(p′ : ∥ ∃ ((R ⁻¹) y′) ∥ᴱ) →
from′ p ≡ from′ p′
from′-lemma Rxy Rxy′ = T.elim λ @0 where
.T.truncation-is-propositionʳ _ →
Π-closure ext 1 λ _ →
Q./ᴱ-is-set
.T.∣∣ʳ (x₁ , Rx₁y) → T.elim λ @0 where
.T.truncation-is-propositionʳ _ → Q./ᴱ-is-set
.T.∣∣ʳ (x₂ , Rx₂y′) →
[ x₁ ] ≡⟨ Q.[]-respects-relation ∣ _ , Rx₁y , qper Rx₂y′ Rxy′ Rxy ∣ ⟩∎
[ x₂ ] ∎
from : B /ᴱ R ⟶ → A /ᴱ R ⟵
from = Q.rec λ where
.Q.is-setʳ → Q./ᴱ-is-set
.Q.[]ʳ → from′ ∘ rl
.Q.[]-respects-relationʳ {x = y} {y = y′} → T.elim λ @0 where
.T.truncation-is-propositionʳ _ → Q./ᴱ-is-set
.T.∣∣ʳ (_ , Rxy , Rxy′) →
from′ (rl y) ≡⟨ from′-lemma Rxy Rxy′ (rl y) (rl y′) ⟩∎
from′ (rl y′) ∎
@0 to′≡[] :
R x y → (p : ∥ ∃ (R x) ∥ᴱ) →
to′ p ≡ [ y ]
to′≡[] {x} {y} Rxy = T.elim λ @0 where
.T.truncation-is-propositionʳ _ → Q./ᴱ-is-set
.T.∣∣ʳ (y′ , Rxy′) →
[ y′ ] ≡⟨ Q.[]-respects-relation ∣ _ , Rxy′ , Rxy ∣ ⟩∎
[ y ] ∎
@0 to-from′ :
∀ y (p : ∥ ∃ ((R ⁻¹) y) ∥ᴱ) →
to (from′ p) ≡ [ y ]
to-from′ y = T.elim λ @0 where
.T.truncation-is-propositionʳ _ → Q./ᴱ-is-set
.T.∣∣ʳ (x , Rxy) →
to′ (lr x) ≡⟨ to′≡[] Rxy (lr x) ⟩∎
[ y ] ∎
@0 to-from : ∀ y → to (from y) ≡ y
to-from = Q.elim-prop λ @0 where
.Q.is-propositionʳ _ → Q./ᴱ-is-set
.Q.[]ʳ y →
to (from′ (rl y)) ≡⟨ to-from′ y (rl y) ⟩∎
[ y ] ∎
@0 from′≡[] :
R x y → (p : ∥ ∃ ((R ⁻¹) y) ∥ᴱ) →
from′ p ≡ [ x ]
from′≡[] {x} {y} Rxy = T.elim λ @0 where
.T.truncation-is-propositionʳ _ → Q./ᴱ-is-set
.T.∣∣ʳ (x′ , Rx′y) →
[ x′ ] ≡⟨ Q.[]-respects-relation ∣ _ , Rx′y , Rxy ∣ ⟩∎
[ x ] ∎
@0 from-to′ :
∀ x (p : ∥ ∃ (R x) ∥ᴱ) →
from (to′ p) ≡ [ x ]
from-to′ x = T.elim λ @0 where
.T.truncation-is-propositionʳ _ → Q./ᴱ-is-set
.T.∣∣ʳ (y , Rxy) →
from′ (rl y) ≡⟨ from′≡[] Rxy (rl y) ⟩∎
[ x ] ∎
@0 from-to : ∀ x → from (to x) ≡ x
from-to = Q.elim-prop λ @0 where
.Q.is-propositionʳ _ → Q./ᴱ-is-set
.Q.[]ʳ x →
from (to′ (lr x)) ≡⟨ from-to′ x (lr x) ⟩∎
[ x ] ∎
to″ : to [ x ] ≡ [ y ] → R x y
to″ {x} {y} =
to′ (lr x) ≡ [ y ] ↝⟨ flip (T.elim {P = λ p → to′ p ≡ [ y ] → R x y}) (lr x) (λ where
.T.truncation-is-propositionʳ _ →
Π-closure ext 1 λ _ →
prop _ _
.T.∣∣ʳ (y′ , Rxy′) →
[ y′ ] ≡ [ y ] ↝⟨ Q.effective
(Is-QER→Is-equivalence-relation-⟶ qer)
T.truncation-is-proposition
∣ _ , Rxy′ , Rxy′ ∣ ⟩
(R ⟶) y′ y ↝⟨ T.rec (λ where
.T.truncation-is-propositionʳ → prop _ _
.T.∣∣ʳ (_ , Rx′y′ , Rx′y) →
qper Rxy′ Rx′y′ Rx′y) ⟩□
R x y □) ⟩□
R x y □
@0 from″ : R x y → to [ x ] ≡ [ y ]
from″ {x} {y} Rxy =
to′ (lr x) ≡⟨ to′≡[] Rxy (lr x) ⟩∎
[ y ] ∎
/ᴱ⟵≃ᴱ/ᴱ⟶ᴱ :
{@0 R : A → B → Type c} →
Is-QERᴱ R →
@0 (∀ x y → Is-proposition (R x y)) →
∃ λ (eq : A /ᴱ R ⟵ ≃ᴱ B /ᴱ R ⟶) →
Erased (∀ x y → (_≃ᴱ_.to eq [ x ] ≡ [ y ]) ≃ R x y)
/ᴱ⟵≃ᴱ/ᴱ⟶ᴱ {A} {B} {R} qer prop = $⟨ [ prop ] ⟩
Erased (∀ x y → Is-proposition (R x y)) ↝⟨ (λ ([ hyp ]) x y → H-level-Erased 1 (hyp x y)) ⦂ (_ → _) ⟩
(∀ x y → Is-proposition (Rᴱ x y)) ↝⟨ (λ prop → /ᴱ⟵≃ᴱ/ᴱ⟶ (_≃_.to Is-QERᴱ≃Is-QER-Erased qer) prop) ⟩
(∃ λ (eq : A /ᴱ Rᴱ ⟵ ≃ᴱ B /ᴱ Rᴱ ⟶) →
∀ x y →
∃ λ (f : _≃ᴱ_.to eq [ x ] ≡ [ y ] → Rᴱ x y) →
Erased (Is-equivalence f)) ↝⟨ (λ (eq , ok) → drop-ᴱ eq , [ drop-ᴱ-ok eq ok ]) ⟩□
(∃ λ (eq : A /ᴱ R ⟵ ≃ᴱ B /ᴱ R ⟶) →
Erased (∀ x y → (_≃ᴱ_.to eq [ x ] ≡ [ y ]) ≃ R x y)) □
where
Rᴱ = λ x y → Erased (R x y)
@0 lemma :
∀ x y →
((λ x y → Erased (R₁ x y)) ;ᴱ (λ x y → Erased (R₂ x y))) x y ⇔
(R₁ ;ᴱ R₂) x y
lemma {R₁} {R₂} x z =
∥ (∃ λ y → Erased (R₁ x y) × Erased (R₂ y z)) ∥ᴱ ↔⟨ (T.∥∥ᴱ-cong $ ∃-cong λ _ →
Erased↔ .erased
×-cong
Erased↔ .erased) ⟩□
∥ (∃ λ y → R₁ x y × R₂ y z) ∥ᴱ □
drop-ᴱ :
A /ᴱ Rᴱ ⟵ ≃ᴱ B /ᴱ Rᴱ ⟶ →
A /ᴱ R ⟵ ≃ᴱ B /ᴱ R ⟶
drop-ᴱ eq =
A /ᴱ R ⟵ ↔⟨ Eq.id Q./ᴱ-cong (λ x y → inverse (lemma {R₁ = R} {R₂ = R ⁻¹} x y)) ⟩
A /ᴱ Rᴱ ⟵ ↝⟨ eq ⟩
B /ᴱ Rᴱ ⟶ ↔⟨ Eq.id Q./ᴱ-cong lemma ⟩□
B /ᴱ R ⟶ □
@0 drop-ᴱ-ok :
(eq : A /ᴱ Rᴱ ⟵ ≃ᴱ B /ᴱ Rᴱ ⟶) →
(∀ x y →
∃ λ (f : _≃ᴱ_.to eq [ x ] ≡ [ y ] → Rᴱ x y) →
Erased (Is-equivalence f)) →
∀ x y → (_≃ᴱ_.to (drop-ᴱ eq) [ x ] ≡ [ y ]) ≃ R x y
drop-ᴱ-ok eq ok x y =
_≃ᴱ_.to (drop-ᴱ eq) [ x ] ≡ [ y ] ↔⟨⟩
_≃_.to (Eq.id Q./ᴱ-cong lemma) (_≃ᴱ_.to eq [ x ]) ≡ [ y ] ↝⟨ Eq.≃-≡ (Eq.id Q./ᴱ-cong lemma) ⟩
_≃ᴱ_.to eq [ x ] ≡ [ y ] ↝⟨ (let f , [ eq ] = ok x y in Eq.⟨ f , eq ⟩) ⟩
Rᴱ x y ↔⟨ Erased↔ .erased ⟩□
R x y □
Relation-transformer-for :
Structure a b → Type (lsuc (a ⊔ b))
Relation-transformer-for {a} {b} F =
∀ {A B} → (A → B → Type a) → F A → F B → Type b
record Suitable
{F : Structure a b}
(@0 G : Relation-transformer-for F) :
Type (lsuc a ⊔ b) where
no-eta-equality
field
@0 preserves-is-set :
Is-set A → Is-set (F A)
@0 preserves-is-proposition :
(∀ x y → Is-proposition (R x y)) →
∀ x y → Is-proposition (G R x y)
@0 symmetric :
(∀ x y → Is-proposition (R x y)) →
G R x y → G (R ⁻¹) y x
@0 transitive :
(∀ x y → Is-proposition (R x y)) →
(∀ x y → Is-proposition (S x y)) →
G R x y → G S y z → G (R ;ᴱ S) x z
descent :
{@0 R : A → A → Type a} →
@0 (∀ x y → Is-proposition (R x y)) →
@0 Is-equivalence-relation R →
@0 G R x x →
Contractibleᴱ (∃ λ (y : F (A /ᴱ R)) → Erased (G (Graph [_]) x y))
@0 transitive-;ᴱ :
(∀ x y → Is-proposition (R x y)) →
(∀ x y → Is-proposition (S x y)) →
∀ x z → (G R ;ᴱ G S) x z → G (R ;ᴱ S) x z
transitive-;ᴱ R-prop S-prop _ _ = T.rec λ @0 where
.T.truncation-is-propositionʳ →
preserves-is-proposition
(λ _ _ → T.truncation-is-proposition) _ _
.T.∣∣ʳ (_ , GRxy , GSyz) →
transitive R-prop S-prop GRxy GSyz
Univalentᴿ :
{F : Structure a b} →
@0 Relation-transformer-for F → Type (lsuc a ⊔ b)
Univalentᴿ {F} G =
Suitable G ×
Univalent F (λ (A , x) (B , y) eq → G (Graph (_≃ᴱ_.to eq)) x y)
record Acts-on-functions
{F : Structure a b}
(@0 G : Relation-transformer-for F) :
Type (lsuc a ⊔ b) where
no-eta-equality
field
map : (A → B) → F A → F B
@0 map-id : map {A = A} id ≡ id
@0 map-map :
{R₁ : A₁ → B₁ → Type a} {R₂ : A₂ → B₂ → Type a} →
(∀ {x y} → R₁ x y → R₂ (f x) (g y)) →
G R₁ x y → G R₂ (map f x) (map g y)
Suitable-map :
{@0 G H : Relation-transformer-for F} →
@0 (∀ {A B} {R : A → B → _} {x y} → G R x y ≃ H R x y) →
Suitable G → Suitable H
Suitable-map {G} {H} G≃H s-G = λ where
.Suitable.preserves-is-set → S.preserves-is-set
.Suitable.preserves-is-proposition {R} →
(∀ x y → Is-proposition (R x y)) ↝⟨ S.preserves-is-proposition ⟩
(∀ x y → Is-proposition (G R x y)) ↝⟨ (∀-cong _ λ _ → ∀-cong _ λ _ → H-level-cong _ 1 G≃H) ⟩□
(∀ x y → Is-proposition (H R x y)) □
.Suitable.symmetric {R} {x} {y} →
(∀ x y → Is-proposition (R x y)) ↝⟨ S.symmetric ⟩
(G R x y → G (R ⁻¹) y x) ↝⟨ →-cong-→ (_≃_.from G≃H) (_≃_.to G≃H) ⟩□
(H R x y → H (R ⁻¹) y x) □
.Suitable.transitive {R} {S} {x} {y} {z} → curry
((∀ x y → Is-proposition (R x y)) ×
(∀ x y → Is-proposition (S x y)) ↝⟨ uncurry S.transitive ⟩
(G R x y → G S y z → G (R ;ᴱ S) x z) ↝⟨ →-cong-→ (_≃_.from G≃H) (→-cong-→ (_≃_.from G≃H) (_≃_.to G≃H)) ⟩□
(H R x y → H S y z → H (R ;ᴱ S) x z) □)
.Suitable.descent {x} {R} prop equiv HRxx → $⟨ [ HRxx ] ⟩
Erased (H R x x) ↔⟨ Erased-cong (inverse G≃H) ⟩
Erased (G R x x) ↝⟨ (λ ([ hyp ]) → S.descent prop equiv hyp) ⦂ (_ → _) ⟩
Contractibleᴱ (∃ λ y → Erased (G (Graph [_]) x y)) ↝⟨ ECP.Contractibleᴱ-cong _ (∃-cong λ _ → Erased-cong G≃H) ⟩□
Contractibleᴱ (∃ λ y → Erased (H (Graph [_]) x y)) □
where
module S = Suitable s-G
Suitable→/ᴱ⟵×/ᴱ⟶ :
{F : Structure a b}
((A , x) (B , y) : Type-with F) →
{@0 R : A → B → Type a}
{@0 G : Relation-transformer-for F} →
Suitable G →
(qer : Is-QERᴱ R)
(@0 prop : ∀ x y → Is-proposition (R x y)) →
@0 G R x y →
∃ λ (x′ : F (A /ᴱ R ⟵)) → ∃ λ (y′ : F (B /ᴱ R ⟶)) →
Erased
(G (Graph [_]) x x′ × G (Graph [_]) y y′ ×
G (Graph (_≃ᴱ_.to (/ᴱ⟵≃ᴱ/ᴱ⟶ᴱ qer prop .proj₁))) x′ y′)
Suitable→/ᴱ⟵×/ᴱ⟶ {F} (A , x) (B , y) {R} {G}
s qer@([ qper ] , _) prop g =
x″ , y″ , [ (Gxx″ , Gyy″ , g″) ]
where
module S = Suitable s
@0 x∼x : G (R ⟵) x x
x∼x = S.transitive prop (flip prop) g (S.symmetric prop g)
@0 y∼y : G (R ⟶) y y
y∼y = S.transitive (flip prop) prop (S.symmetric prop g) g
x-lemma :
Contractibleᴱ
(∃ λ (x′ : F (A /ᴱ R ⟵)) → Erased (G (Graph [_]) x x′))
x-lemma =
S.descent
(λ _ _ → T.truncation-is-proposition)
(Is-QERᴱ→Is-equivalence-relation-⟵ qer)
x∼x
y-lemma :
Contractibleᴱ
(∃ λ (y′ : F (B /ᴱ R ⟶)) → Erased (G (Graph [_]) y y′))
y-lemma =
S.descent
(λ _ _ → T.truncation-is-proposition)
(Is-QERᴱ→Is-equivalence-relation-⟶ qer)
y∼y
x″ = x-lemma .proj₁ .proj₁
y″ = y-lemma .proj₁ .proj₁
@0 Gxx″ : G (Graph [_]) x x″
Gxx″ = x-lemma .proj₁ .proj₂ .erased
@0 Gyy″ : G (Graph [_]) y y″
Gyy″ = y-lemma .proj₁ .proj₂ .erased
@0 g′ : G (Graph [_] ⁻¹ ;ᴱ R ;ᴱ Graph [_]) x″ y″
g′ =
S.transitive
(λ _ _ → Q./ᴱ-is-set)
(λ _ _ → T.truncation-is-proposition)
(S.symmetric (λ _ _ → Q./ᴱ-is-set) Gxx″)
(S.transitive prop (λ _ _ → Q./ᴱ-is-set) g Gyy″)
equiv = /ᴱ⟵≃ᴱ/ᴱ⟶ᴱ qer prop .proj₁
@0 to :
∀ {x y} →
(Graph [_] ⁻¹ ;ᴱ R ;ᴱ Graph [_]) [ x ] [ y ] → R x y
to {x} {y} =
T.rec λ @0 where
.T.truncation-is-propositionʳ →
prop _ _
.T.∣∣ʳ → uncurry λ x′ → uncurry λ [x′]≡[x] →
T.rec λ @0 where
.T.truncation-is-propositionʳ →
prop _ _
.T.∣∣ʳ (y′ , Rx′y′ , [y′]≡[y]) →
let R⟵x′x : (R ⟵) x′ x
R⟵x′x =
_≃_.from
(Q.related≃[equal]
(Is-QERᴱ→Is-equivalence-relation-⟵ qer)
T.truncation-is-proposition)
[x′]≡[x]
R⟶y′y : (R ⟶) y′ y
R⟶y′y =
_≃_.from
(Q.related≃[equal]
(Is-QERᴱ→Is-equivalence-relation-⟶ qer)
T.truncation-is-proposition)
[y′]≡[y]
in
flip T.rec R⟵x′x λ @0 where
.T.truncation-is-propositionʳ →
prop _ _
.T.∣∣ʳ (_ , Rx′x″ , Rxx″) →
flip T.rec R⟶y′y λ @0 where
.T.truncation-is-propositionʳ →
prop _ _
.T.∣∣ʳ (_ , Ry″y′ , Ry″y) →
qper Rxx″ Rx′x″ (qper Rx′y′ Ry″y′ Ry″y)
@0 from :
∀ {x y} →
R x y → (Graph [_] ⁻¹ ;ᴱ R ;ᴱ Graph [_]) [ x ] [ y ]
from Rxy = ∣ _ , refl _ , ∣ _ , Rxy , refl _ ∣ ∣
@0 lemma :
∀ x y →
(Graph [_] ⁻¹ ;ᴱ R ;ᴱ Graph [_]) x y ≃
Graph (_≃ᴱ_.to equiv) x y
lemma = Q.elim-prop λ @0 where
.Q.is-propositionʳ _ →
Π-closure ext 1 λ _ →
Eq.left-closure ext 0 T.truncation-is-proposition
.Q.[]ʳ x → Q.elim-prop λ @0 where
.Q.is-propositionʳ _ →
Eq.left-closure ext 0 T.truncation-is-proposition
.Q.[]ʳ y →
(Graph [_] ⁻¹ ;ᴱ R ;ᴱ Graph [_]) [ x ] [ y ] ↝⟨ Eq.⇔→≃ T.truncation-is-proposition (prop _ _) to from ⟩
R x y ↝⟨ inverse (/ᴱ⟵≃ᴱ/ᴱ⟶ᴱ qer prop .proj₂ .erased _ _) ⟩□
Graph (_≃ᴱ_.to equiv) [ x ] [ y ] □
@0 g″ : G (Graph (_≃ᴱ_.to equiv)) x″ y″
g″ =
subst (λ R → G R x″ y″)
(⟨ext⟩ λ x → ⟨ext⟩ λ y →
≃⇒≡ univ (lemma x y))
g′
Univalentᴿ→/ᴱ⟵×/ᴱ⟶ :
{F : Structure a b}
((A , x) (B , y) : Type-with F) →
{@0 R : A → B → Type a}
{@0 G : Relation-transformer-for F} →
Univalentᴿ G →
(qer : Is-QERᴱ R)
(@0 prop : ∀ x y → Is-proposition (R x y)) →
@0 G R x y →
∃ λ (x′ : F (A /ᴱ R ⟵)) → ∃ λ (y′ : F (B /ᴱ R ⟶)) →
Erased (G (Graph [_]) x x′ × G (Graph [_]) y y′ ×
_≡_ {A = Type-with F}
(A /ᴱ R ⟵ , x′) (B /ᴱ R ⟶ , y′))
Univalentᴿ→/ᴱ⟵×/ᴱ⟶ (A , x) (B , y) {R} {G} (s , u) qer prop g =
let (x′ , y′ , [ x∼x′ , y∼y′ , x′∼y′ ]) =
Suitable→/ᴱ⟵×/ᴱ⟶ (A , x) (B , y) s qer prop g
in
x′
, y′
, [ ( x∼x′
, y∼y′
, ( $⟨ /ᴱ⟵≃ᴱ/ᴱ⟶ᴱ qer prop .proj₁ , [ x′∼y′ ] ⟩
(A /ᴱ R ⟵ , x′)
≃[ (λ (A , x) (B , y) eq → G (Graph (_≃ᴱ_.to eq)) x y) ]ᴱ
(B /ᴱ R ⟶ , y′) ↝⟨ sip u ⟩□
(A /ᴱ R ⟵ , x′) ≡ (B /ᴱ R ⟶ , y′) □)
)
]
/ᴱ→/ᴱ :
{A : Type a}
{@0 R : A → A → Type a}
(@0 G : Relation-transformer-for F) →
Suitable G →
Acts-on-functions G →
@0 (∀ x y → Is-proposition (R x y)) →
@0 Is-equivalence-relation R →
F A /ᴱ G R → F (A /ᴱ R)
/ᴱ→/ᴱ {F} {R} G s acts prop equiv =
Q.rec λ where
.Q.[]ʳ → map [_]
.Q.is-setʳ → S.preserves-is-set Q./ᴱ-is-set
.Q.[]-respects-relationʳ {x} {y} GRxy →
let GRxx = $⟨ GRxy ⟩
G R x y ↝⟨ (λ GRxy → S.transitive prop (flip prop) GRxy (S.symmetric prop GRxy)) ⟩
G (R ⟵) x x ↝⟨ subst (λ R → G R _ _) (⟵≡ prop equiv) ⟩□
G R x x □
((z , _) , [ unique ]) = $⟨ GRxx ⟩
G R x x ↝⟨ (λ GRxx → S.descent prop equiv GRxx) ⦂ (_ → _) ⟩□
Contractibleᴱ (∃ λ z → Erased (G (Graph [_]) x z)) □
lemma₁ = $⟨ map-map Q.[]-respects-relation GRxx ⟩
G (Graph [_]) (map id x) (map [_] x) ↝⟨ subst (λ x′ → G (Graph [_]) x′ (map [_] x)) (cong (_$ x) map-id) ⟩□
G (Graph [_]) x (map [_] x) □
lemma₂ = $⟨ map-map Q.[]-respects-relation GRxy ⟩
G (Graph [_]) (map id x) (map [_] y) ↝⟨ subst (λ x → G (Graph [_]) x (map [_] y)) (cong (_$ x) map-id) ⟩□
G (Graph [_]) x (map [_] y) □
in
map [_] x ≡⟨ sym $ cong proj₁ (unique (_ , [ lemma₁ ])) ⟩
z ≡⟨ cong proj₁ (unique (_ , [ lemma₂ ])) ⟩∎
map [_] y ∎
where
module S = Suitable s
open Acts-on-functions acts
record Positive
{F : Structure a b}
(@0 G : Relation-transformer-for F) :
Type (lsuc a ⊔ b) where
no-eta-equality
field
suitable : Suitable G
acts-on-functions : Acts-on-functions G
@0 reflexive-∥≡∥ᴱ : G (λ x y → ∥ x ≡ y ∥ᴱ) x x
@0 transitive-;ᴱ⁻¹ :
{R : A → B → Type a} {S : B → C → Type a}
(R-prop : ∀ x y → Is-proposition (R x y))
(S-prop : ∀ x y → Is-proposition (S x y))
(x : F A) (z : F C) →
Is-equivalence
(Suitable.transitive-;ᴱ suitable R-prop S-prop x z)
commutes-with-/ᴱ :
{@0 R : A → A → Type a}
(@0 prop : ∀ x y → Is-proposition (R x y))
(@0 equiv : Is-equivalence-relation R) →
Is-equivalenceᴱ (/ᴱ→/ᴱ G suitable acts-on-functions prop equiv)
@0 reflexive :
(∀ x y → Is-proposition (R x y)) →
Is-equivalence-relation R →
∀ x → G R x x
reflexive {R} prop equiv x = $⟨ reflexive-∥≡∥ᴱ ⟩
G (λ x y → ∥ x ≡ y ∥ᴱ) x x ↝⟨ A.map-map
(T.rec λ @0 where
.T.truncation-is-propositionʳ →
prop _ _
.T.∣∣ʳ x≡y →
subst (R _) x≡y E.reflexive) ⟩
G R (A.map id x) (A.map id x) ↝⟨ subst (uncurry (G R)) (cong (λ f → f x , f x) A.map-id) ⟩□
G R x x □
where
module A = Acts-on-functions acts-on-functions
module E = Is-equivalence-relation equiv
Const : Type b → Structure a b
Const B = λ _ → B
Constᴿ : (B : Type b) → Relation-transformer-for (Const {a = a} B)
Constᴿ _ _ = _≡_
Is-Const-equivalence :
{B : Type b} →
Structure-preserving-equivalence-predicate (Const {a = a} B) b
Is-Const-equivalence (_ , x) (_ , y) _ = x ≡ y
Const-univalent : Univalent (Const {a = a} B) Is-Const-equivalence
Const-univalent {B} .Univalent.univalent {A = _ , x} {B = _ , y} eq =
x ≡ y ↝⟨ ≡⇒≃ $ cong (_≡ _) $ sym $ subst-const _ ⟩□
subst (Const B) (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x ≡ y □
Constᴿ-suitable : @0 Is-set B → Suitable (Constᴿ {a = a} B)
Constᴿ-suitable set = λ where
.Suitable.preserves-is-set _ → set
.Suitable.preserves-is-proposition _ _ _ → set
.Suitable.symmetric _ → sym
.Suitable.transitive _ _ → trans
.Suitable.descent _ _ _ → Contractibleᴱ-Erased-other-singleton
Constᴿ-univalent : @0 Is-set B → Univalentᴿ (Constᴿ {a = a} B)
Constᴿ-univalent set = Constᴿ-suitable set , Const-univalent
Constᴿ-acts-on-functions : Acts-on-functions (Constᴿ {a = a} B)
Constᴿ-acts-on-functions = λ where
.Acts-on-functions.map _ → id
.Acts-on-functions.map-id → refl _
.Acts-on-functions.map-map _ → id
Constᴿ-positive : @0 Is-set B → Positive (Constᴿ {a = a} B)
Constᴿ-positive {B} set = λ where
.Positive.suitable → Constᴿ-suitable set
.Positive.acts-on-functions → Constᴿ-acts-on-functions
.Positive.reflexive-∥≡∥ᴱ → refl _
.Positive.transitive-;ᴱ⁻¹ {R} {S} _ _ x z →
_≃_.is-equivalence
((Constᴿ B R ;ᴱ Constᴿ B S) x z ↔⟨⟩
∥ (∃ λ y → x ≡ y × y ≡ z) ∥ᴱ ↝⟨ Eq.⇔→≃ T.truncation-is-proposition set _
(λ x≡z → ∣ _ , x≡z , refl _ ∣) ⟩
x ≡ z ↔⟨⟩
Constᴿ B (R ;ᴱ S) x z □)
.Positive.commutes-with-/ᴱ {A = C} {R} prop equiv →
_≃ᴱ_.is-equivalence $
EEq.with-other-function
(Const B C /ᴱ Constᴿ B R ↔⟨⟩
B /ᴱ _≡_ ↔⟨ Q./ᴱ≡↔ set ⟩
B ↔⟨⟩
Const B (C /ᴱ R) □)
(/ᴱ→/ᴱ (Constᴿ B) (Constᴿ-suitable set) Constᴿ-acts-on-functions
prop equiv)
(Q.elim-prop λ @0 where
.Q.is-propositionʳ _ → set
.Q.[]ʳ _ → refl _)
Id : Structure a a
Id A = A
Idᴿ : Relation-transformer-for (Id {a = a})
Idᴿ R = R
Is-Id-equivalence : Structure-preserving-equivalence-predicate Id a
Is-Id-equivalence (_ , x) (_ , y) eq = _≃ᴱ_.to eq x ≡ y
Id-univalent : Univalent (Id {a = a}) Is-Id-equivalence
Id-univalent .Univalent.univalent {A = _ , x} {B = _ , y} eq =
_≃ᴱ_.to eq x ≡ y ↝⟨ ≡⇒≃ $ cong (_≡ _) $ cong (λ eq → _≃_.to eq x) $ sym $
_≃_.right-inverse-of (≡≃≃ univ) _ ⟩
≡⇒→ (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x ≡ y ↝⟨ ≡⇒≃ $ cong (_≡ _) $ sym $
subst-id-in-terms-of-≡⇒↝ equivalence ⟩□
subst Id (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x ≡ y □
Idᴿ-suitable : Suitable (Idᴿ {a = a})
Idᴿ-suitable = λ where
.Suitable.preserves-is-set → id
.Suitable.preserves-is-proposition → id
.Suitable.symmetric _ → id
.Suitable.transitive _ _ Rxy Syz → ∣ _ , Rxy , Syz ∣
.Suitable.descent _ _ _ →
Contractibleᴱ-Erased-other-singleton
Idᴿ-univalent : Univalentᴿ (Idᴿ {a = a})
Idᴿ-univalent = Idᴿ-suitable , Id-univalent
Idᴿ-acts-on-functions : Acts-on-functions (Idᴿ {a = a})
Idᴿ-acts-on-functions = λ where
.Acts-on-functions.map → id
.Acts-on-functions.map-id → refl _
.Acts-on-functions.map-map f → f
Idᴿ-positive : Positive (Idᴿ {a = a})
Idᴿ-positive = λ where
.Positive.suitable → Idᴿ-suitable
.Positive.acts-on-functions → Idᴿ-acts-on-functions
.Positive.reflexive-∥≡∥ᴱ → ∣ refl _ ∣
.Positive.transitive-;ᴱ⁻¹ {R} {S} R-prop S-prop x z →
_≃_.is-equivalence $
Eq.with-other-function
((Idᴿ R ;ᴱ Idᴿ S) x z ↔⟨⟩
(R ;ᴱ S) x z ↔⟨⟩
Idᴿ (R ;ᴱ S) x z □)
(Suitable.transitive-;ᴱ Idᴿ-suitable R-prop S-prop x z)
(T.elim λ @0 where
.T.truncation-is-propositionʳ _ →
H-level.⇒≡ 1 T.truncation-is-proposition
.T.∣∣ʳ _ →
refl _)
.Positive.commutes-with-/ᴱ {A} {R} prop equiv →
_≃ᴱ_.is-equivalence $
EEq.with-other-function
(Id A /ᴱ Idᴿ R ↔⟨⟩
A /ᴱ R ↔⟨⟩
Id (A /ᴱ R) □)
(/ᴱ→/ᴱ Idᴿ Idᴿ-suitable Idᴿ-acts-on-functions prop equiv)
(Q.elim-prop λ @0 where
.Q.is-propositionʳ _ → Q./ᴱ-is-set
.Q.[]ʳ _ → refl _)
Product : Structure a b → Structure a c → Structure a (b ⊔ c)
Product F G A = F A × G A
Productᴿ :
Relation-transformer-for F →
Relation-transformer-for G →
Relation-transformer-for (Product F G)
Productᴿ S T R = S R ×ᴾ T R
Is-Product-equivalence :
Structure-preserving-equivalence-predicate F a →
Structure-preserving-equivalence-predicate G b →
Structure-preserving-equivalence-predicate (Product F G) (a ⊔ b)
Is-Product-equivalence Is-F-eq Is-G-eq (A , x₁ , x₂) (B , y₁ , y₂) eq =
Is-F-eq (A , x₁) (B , y₁) eq ×
Is-G-eq (A , x₂) (B , y₂) eq
Product-univalent :
{@0 F : Structure a b}
{@0 G : Structure a c}
{@0 Is-F-eq : Structure-preserving-equivalence-predicate F d}
{@0 Is-G-eq : Structure-preserving-equivalence-predicate G e} →
@0 Univalent F Is-F-eq →
@0 Univalent G Is-G-eq →
Univalent (Product F G) (Is-Product-equivalence Is-F-eq Is-G-eq)
Product-univalent
{F} {G} {Is-F-eq} {Is-G-eq}
u-F u-G .Univalent.univalent {A = A , x₁ , x₂} {B = B , y₁ , y₂} eq =
Is-F-eq (A , x₁) (B , y₁) eq × Is-G-eq (A , x₂) (B , y₂) eq ↝⟨ u-F .Univalent.univalent eq
×-cong
u-G .Univalent.univalent eq ⟩
subst F (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x₁ ≡ y₁ ×
subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x₂ ≡ y₂ ↔⟨ ≡×≡↔≡ ⟩
( subst F (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x₁
, subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x₂
) ≡ (y₁ , y₂) ↝⟨ ≡⇒≃ $ cong (_≡ _) $ sym $
push-subst-, _ _ ⟩□
subst (Product F G) (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) (x₁ , x₂) ≡ (y₁ , y₂) □
Productᴿ-suitable :
{@0 S : Relation-transformer-for F}
{@0 T : Relation-transformer-for G} →
Suitable S →
Suitable T →
Suitable (Productᴿ S T)
Productᴿ-suitable {S} {T} s-S s-T = λ where
.Suitable.preserves-is-set set →
×-closure 2
(s-S .Suitable.preserves-is-set set)
(s-T .Suitable.preserves-is-set set)
.Suitable.preserves-is-proposition prop _ _ →
×-closure 1
(s-S .Suitable.preserves-is-proposition prop _ _)
(s-T .Suitable.preserves-is-proposition prop _ _)
.Suitable.symmetric prop →
Σ-map
(s-S .Suitable.symmetric prop)
(s-T .Suitable.symmetric prop)
.Suitable.transitive prop₁ prop₂ →
Σ-zip
(s-S .Suitable.transitive prop₁ prop₂)
(s-T .Suitable.transitive prop₁ prop₂)
.Suitable.descent {x = x , y} {R} prop equiv (SRxx , Tryy) → $⟨ [ SRxx ] , [ Tryy ] ⟩
Erased (S R x x) × Erased (T R y y) ↝⟨ Σ-map (λ ([ SRxx ]) → s-S .Suitable.descent prop equiv SRxx)
(λ ([ TRyy ]) → s-T .Suitable.descent prop equiv TRyy) ⟩
Contractibleᴱ (∃ λ x′ → Erased (S (Graph [_]) x x′)) ×
Contractibleᴱ (∃ λ y′ → Erased (T (Graph [_]) y y′)) ↝⟨ uncurry ECP.Contractibleᴱ-× ⟩
Contractibleᴱ
((∃ λ x′ → Erased (S (Graph [_]) x x′)) ×
(∃ λ y′ → Erased (T (Graph [_]) y y′))) ↝⟨ ECP.Contractibleᴱ-cong _ $
Σ-assoc F.∘
(∃-cong λ _ → ∃-cong λ _ → inverse Erased-Σ↔Σ) F.∘
(∃-cong λ _ → ∃-comm) F.∘
inverse Σ-assoc ⟩□
Contractibleᴱ (∃ λ p → Erased (Productᴿ S T (Graph [_]) (x , y) p)) □
Productᴿ-univalent :
{@0 S : Relation-transformer-for F}
{@0 T : Relation-transformer-for G} →
Univalentᴿ S →
Univalentᴿ T →
Univalentᴿ (Productᴿ S T)
Productᴿ-univalent (s-S , u-S) (s-T , u-T) =
Productᴿ-suitable s-S s-T
, Product-univalent u-S u-T
Productᴿ-acts-on-functions :
{@0 S : Relation-transformer-for F}
{@0 T : Relation-transformer-for G} →
Acts-on-functions S →
Acts-on-functions T →
Acts-on-functions (Productᴿ S T)
Productᴿ-acts-on-functions {S} {T} a-S a-T = λ where
.Acts-on-functions.map f →
Σ-map (a-S .Acts-on-functions.map f)
(a-T .Acts-on-functions.map f)
.Acts-on-functions.map-id →
Σ-map (a-S .Acts-on-functions.map id)
(a-T .Acts-on-functions.map id) ≡⟨ cong₂ (λ f g → Σ-map f g)
(a-S .Acts-on-functions.map-id)
(a-T .Acts-on-functions.map-id) ⟩
Σ-map id id ≡⟨⟩
id ∎
.Acts-on-functions.map-map
{f} {g} {x = x₁ , x₂} {y = y₁ , y₂} {R₁} {R₂} R₁→R₂ →
S R₁ x₁ y₁ × T R₁ x₂ y₂ ↝⟨ a-S .Acts-on-functions.map-map R₁→R₂
×-cong
a-T .Acts-on-functions.map-map R₁→R₂ ⟩□
S R₂ (a-S .Acts-on-functions.map f x₁)
(a-S .Acts-on-functions.map g y₁) ×
T R₂ (a-T .Acts-on-functions.map f x₂)
(a-T .Acts-on-functions.map g y₂) □
Productᴿ-positive :
{@0 S : Relation-transformer-for F}
{@0 T : Relation-transformer-for G} →
Positive S →
Positive T →
Positive (Productᴿ S T)
Productᴿ-positive {F} {G} {S} {T} p-S p-T = λ where
.Positive.suitable → suitable
.Positive.acts-on-functions → acts-on-functions
.Positive.reflexive-∥≡∥ᴱ → SP.reflexive-∥≡∥ᴱ , TP.reflexive-∥≡∥ᴱ
.Positive.transitive-;ᴱ⁻¹
{R = R₁} {S = R₂} R₁-prop R₂-prop x@(x₁ , x₂) z@(z₁ , z₂) →
_≃_.is-equivalence $
Eq.with-other-function
((Productᴿ S T R₁ ;ᴱ Productᴿ S T R₂) x z ↝⟨ lemma ⟩
(S R₁ ;ᴱ S R₂) x₁ z₁ × (T R₁ ;ᴱ T R₂) x₂ z₂ ↝⟨ Eq.⟨ _ , SP.transitive-;ᴱ⁻¹ R₁-prop R₂-prop _ _ ⟩
×-cong
Eq.⟨ _ , TP.transitive-;ᴱ⁻¹ R₁-prop R₂-prop _ _ ⟩ ⟩
S (R₁ ;ᴱ R₂) x₁ z₁ × T (R₁ ;ᴱ R₂) x₂ z₂ ↔⟨⟩
Productᴿ S T (R₁ ;ᴱ R₂) x z □)
_
(T.elim λ @0 where
.T.truncation-is-propositionʳ _ →
H-level.mono₁ 1 $
×-closure 1
(SS.preserves-is-proposition
(λ _ _ → T.truncation-is-proposition) _ _)
(TS.preserves-is-proposition
(λ _ _ → T.truncation-is-proposition) _ _)
.T.∣∣ʳ _ →
refl _)
.Positive.commutes-with-/ᴱ {A} {R} prop equiv →
_≃ᴱ_.is-equivalence $
EEq.with-other-function
(Product F G A /ᴱ Productᴿ S T R ↔⟨⟩
(F A × G A) /ᴱ Productᴿ S T R ↔⟨ Q.×/ᴱ (SP.reflexive prop equiv _) (TP.reflexive prop equiv _) ⟩
F A /ᴱ S R × G A /ᴱ T R ↝⟨ EEq.⟨ _ , SP.commutes-with-/ᴱ prop equiv ⟩
×-cong
EEq.⟨ _ , TP.commutes-with-/ᴱ prop equiv ⟩ ⟩
F (A /ᴱ R) × G (A /ᴱ R) ↔⟨⟩
Product F G (A /ᴱ R) □)
_
(Q.elim-prop λ @0 where
.Q.is-propositionʳ _ →
×-closure 2
(SS.preserves-is-set Q./ᴱ-is-set)
(TS.preserves-is-set Q./ᴱ-is-set)
.Q.[]ʳ _ → refl _)
where
module SP = Positive p-S
module SS = Suitable SP.suitable
module TP = Positive p-T
module TS = Suitable TP.suitable
suitable =
Productᴿ-suitable
SP.suitable
TP.suitable
acts-on-functions =
Productᴿ-acts-on-functions
SP.acts-on-functions
TP.acts-on-functions
@0 lemma :
(Productᴿ S T R₁ ;ᴱ Productᴿ S T R₂) (x₁ , x₂) (z₁ , z₂) ≃
((S R₁ ;ᴱ S R₂) x₁ z₁ × (T R₁ ;ᴱ T R₂) x₂ z₂)
lemma = Eq.⇔→≃
T.truncation-is-proposition
(×-closure 1
T.truncation-is-proposition
T.truncation-is-proposition)
(T.rec λ @0 where
.T.truncation-is-propositionʳ →
×-closure 1
T.truncation-is-proposition
T.truncation-is-proposition
.T.∣∣ʳ (_ , (SR₁x₁y₁ , TR₁x₂y₂) , (SR₂y₁z₁ , TR₂y₂z₂)) →
∣ _ , SR₁x₁y₁ , SR₂y₁z₁ ∣
, ∣ _ , TR₁x₂y₂ , TR₂y₂z₂ ∣)
(uncurry $ T.rec λ @0 where
.T.truncation-is-propositionʳ →
Π-closure ext 1 λ _ →
T.truncation-is-proposition
.T.∣∣ʳ (_ , SR₁x₁y₁ , SR₂y₁z₁) →
T.∥∥ᴱ-map
λ (_ , TR₁x₂y₂ , TR₂y₂z₂) →
_ , (SR₁x₁y₁ , TR₁x₂y₂) , (SR₂y₁z₁ , TR₂y₂z₂))
Maybeᴿ :
Relation-transformer-for F →
Relation-transformer-for (Maybe ∘ F)
Maybeᴿ = Maybeᴾ ∘_
Is-Maybe-equivalence :
Structure-preserving-equivalence-predicate F a →
Structure-preserving-equivalence-predicate (Maybe ∘ F) a
Is-Maybe-equivalence Is-F-eq = λ where
(A , nothing) (B , nothing) eq → ↑ _ ⊤
(A , just x) (B , just y) eq → Is-F-eq (A , x) (B , y) eq
(A , _) (B , _) eq → ⊥
Maybe-univalent :
{@0 F : Structure a b}
{@0 Is-F-eq : Structure-preserving-equivalence-predicate F c} →
@0 Univalent F Is-F-eq →
Univalent (Maybe ∘ F) (Is-Maybe-equivalence Is-F-eq)
Maybe-univalent
{F} {Is-F-eq} u-F .Univalent.univalent {A = A , x} {B = B , y} =
lemma x y
where
lemma :
(x : Maybe (F A)) (y : Maybe (F B)) →
(eq : A ≃ᴱ B) →
Is-Maybe-equivalence Is-F-eq (A , x) (B , y) eq ≃
(subst (Maybe ∘ F) (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x ≡ y)
lemma nothing nothing eq =
↑ _ ⊤ ↔⟨ B.↑↔ ⟩
⊤ ↔⟨ inverse tt≡tt↔⊤ ⟩
tt ≡ tt ↔⟨ B.≡↔inj₁≡inj₁ ⟩
nothing ≡ nothing ↝⟨ ≡⇒≃ $ cong (_≡ _) $ sym $ push-subst-inj₁ _ _ ⟩□
subst (Maybe ∘ F) (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) nothing ≡ nothing □
lemma nothing (just y) eq =
⊥ ↔⟨ ⊥↔⊥ ⟩
⊥ ↔⟨ inverse B.≡↔⊎ ⟩
nothing ≡ just y ↝⟨ ≡⇒≃ $ cong (_≡ _) $ sym $ push-subst-inj₁ _ _ ⟩□
subst (Maybe ∘ F) (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) nothing ≡ just y □
lemma (just x) nothing eq =
⊥ ↔⟨ ⊥↔⊥ ⟩
⊥ ↔⟨ inverse B.≡↔⊎ ⟩
just _ ≡ nothing ↝⟨ ≡⇒≃ $ cong (_≡ _) $ sym $ push-subst-inj₂ _ _ ⟩□
subst (Maybe ∘ F) (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) (just x) ≡ nothing □
lemma (just x) (just y) eq =
Is-F-eq (A , x) (B , y) eq ↝⟨ u-F .Univalent.univalent eq ⟩
subst F (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x ≡ y ↔⟨ B.≡↔inj₂≡inj₂ ⟩
just (subst F (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x) ≡ just y ↝⟨ ≡⇒≃ $ cong (_≡ _) $ sym $ push-subst-inj₂ _ _ ⟩□
subst (Maybe ∘ F) (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) (just x) ≡ just y □
Maybeᴿ-suitable :
{@0 G : Relation-transformer-for F} →
Suitable G →
Suitable (Maybeᴿ G)
Maybeᴿ-suitable {G} s-G = λ where
.Suitable.preserves-is-set set →
Maybe-closure 0 (S.preserves-is-set set)
.Suitable.preserves-is-proposition prop → λ @0 where
nothing nothing →
H-level.mono₁ 0 $
↑-closure 0 ⊤-contractible
nothing (just _) →
⊥-propositional
(just _) nothing →
⊥-propositional
(just x) (just y) →
S.preserves-is-proposition prop x y
.Suitable.symmetric {x = nothing} {y = nothing} → _
.Suitable.symmetric {x = just x} {y = just y} → S.symmetric
.Suitable.transitive {x = nothing} {y = nothing} {z = nothing} → _
.Suitable.transitive {x = just _} {y = just _} {z = just _} →
S.transitive
.Suitable.descent {x = nothing} {R} prop equiv _ →
(nothing , [ _ ])
, [ (λ @0 where
(nothing , [ _ ]) → refl _)
]
.Suitable.descent {x = just x} {R} prop equiv SRxx →
$⟨ [ SRxx ] ⟩
Erased (G R x x) ↝⟨ (λ ([ SRxx ]) → S.descent prop equiv SRxx) ⟩
Contractibleᴱ (∃ λ y → Erased (G (Graph [_]) x y)) ↝⟨ ECP.Contractibleᴱ-cong _
(Eq.↔→≃
(Σ-map just id)
(λ where
(nothing , [ () ])
(just y , s) → y , s)
(λ where
(nothing , [ () ])
(just _ , _) → refl _)
refl)
⦂ (_ → _) ⟩□
Contractibleᴱ (∃ λ y → Erased (Maybeᴿ G (Graph [_]) (just x) y)) □
where
module S = Suitable s-G
Maybeᴿ-univalent :
{@0 G : Relation-transformer-for F} →
Univalentᴿ G →
Univalentᴿ (Maybeᴿ G)
Maybeᴿ-univalent {F} {G} (s-G , u-G) =
Maybeᴿ-suitable s-G
, ( $⟨ Maybe-univalent u-G ⟩
Univalent (Maybe ∘ F)
(Is-Maybe-equivalence λ (A , x) (B , y) eq →
G (Graph (_≃ᴱ_.to eq)) x y) ↝⟨ substᴱ (Univalent _)
(⟨ext⟩ λ p → ⟨ext⟩ λ q → lemma (p .proj₂) (q .proj₂)) ⟩□
Univalent (Maybe ∘ F)
(λ (A , x) (B , y) eq → Maybeᴿ G (Graph (_≃ᴱ_.to eq)) x y) □)
where
@0 lemma :
∀ x y →
Is-Maybe-equivalence
(λ (A , x) (B , y) eq → G (Graph (_≃ᴱ_.to eq)) x y)
(A , x) (B , y) ≡
(λ eq → Maybeᴿ G (Graph (_≃ᴱ_.to eq)) x y)
lemma nothing nothing = refl _
lemma nothing (just _) = refl _
lemma (just _) nothing = refl _
lemma (just _) (just _) = refl _
Maybeᴿ-acts-on-functions :
{@0 G : Relation-transformer-for F} →
Acts-on-functions G →
Acts-on-functions (Maybeᴿ G)
Maybeᴿ-acts-on-functions {G} a-G = λ where
.Acts-on-functions.map f →
Monad.map (A.map f)
.Acts-on-functions.map-id →
Monad.map (A.map id) ≡⟨ cong Monad.map A.map-id ⟩
Monad.map id ≡⟨ ⟨ext⟩ Monad.map-id ⟩∎
id ∎
.Acts-on-functions.map-map {x = nothing} {y = nothing} → _
.Acts-on-functions.map-map {x = nothing} {y = just _} _ ()
.Acts-on-functions.map-map {x = just _} {y = nothing} _ ()
.Acts-on-functions.map-map {x = just _} {y = just _} →
A.map-map
where
module A = Acts-on-functions a-G
Maybeᴿ-positive :
{@0 G : Relation-transformer-for F} →
Positive G →
Positive (Maybeᴿ G)
Maybeᴿ-positive {F} {G} p-G = λ where
.Positive.suitable → suitable
.Positive.acts-on-functions → acts-on-functions
.Positive.reflexive-∥≡∥ᴱ {x = nothing} → _
.Positive.reflexive-∥≡∥ᴱ {x = just _} → SP.reflexive-∥≡∥ᴱ
.Positive.transitive-;ᴱ⁻¹ R₁-prop R₂-prop x z →
_≃_.is-equivalence $
Eq.with-other-function
(lemma R₁-prop R₂-prop x z .proj₁)
_
(lemma R₁-prop R₂-prop x z .proj₂)
.Positive.commutes-with-/ᴱ {A} {R} prop equiv →
_≃ᴱ_.is-equivalence $
EEq.with-other-function
(Maybe (F A) /ᴱ Maybeᴿ G R ↔⟨ Q.Maybe/ᴱ ⟩
Maybe (F A /ᴱ G R) ↝⟨ F.id ⊎-cong EEq.⟨ _ , SP.commutes-with-/ᴱ prop equiv ⟩ ⟩□
Maybe (F (A /ᴱ R)) □)
(/ᴱ→/ᴱ (Maybeᴿ G) suitable acts-on-functions prop equiv)
(Q.elim-prop λ @0 where
.Q.is-propositionʳ _ →
Maybe-closure 0 (SS.preserves-is-set Q./ᴱ-is-set)
.Q.[]ʳ nothing → refl _
.Q.[]ʳ (just _) → refl _)
where
module SP = Positive p-G
module SS = Suitable SP.suitable
suitable = Maybeᴿ-suitable SP.suitable
acts-on-functions = Maybeᴿ-acts-on-functions SP.acts-on-functions
@0 lemma :
(R₁-prop : ∀ x y → Is-proposition (R₁ x y)) →
(R₂-prop : ∀ x y → Is-proposition (R₂ x y)) →
∀ x z →
∃ λ (eq : (Maybeᴿ G R₁ ;ᴱ Maybeᴿ G R₂) x z ≃
Maybeᴿ G (R₁ ;ᴱ R₂) x z) →
∀ p →
_≃_.to eq p ≡
Suitable.transitive-;ᴱ suitable R₁-prop R₂-prop x z p
lemma {R₁} {R₂} R₁-prop R₂-prop = λ @0 where
nothing nothing →
((Maybeᴿ G R₁ ;ᴱ Maybeᴿ G R₂) nothing nothing ↝⟨ Eq.⇔→≃
T.truncation-is-proposition
(H-level.mono₁ 0 $ ↑-closure 0 ⊤-contractible)
_
(λ _ → ∣ nothing , _ ∣) ⟩□
↑ _ ⊤ □)
, (λ _ → refl _)
nothing (just z) →
((Maybeᴿ G R₁ ;ᴱ Maybeᴿ G R₂) nothing (just z) ↝⟨ Eq.⇔→≃
T.truncation-is-proposition
⊥-propositional
(T.rec λ @0 where
.T.truncation-is-propositionʳ →
⊥-propositional
.T.∣∣ʳ (nothing , _ , ())
.T.∣∣ʳ (just _ , () , _))
⊥-elim ⟩□
⊥ □)
, (T.elim λ @0 where
.T.truncation-is-propositionʳ _ →
H-level.⇒≡ 1 $
⊥-propositional
.T.∣∣ʳ (nothing , _ , ())
.T.∣∣ʳ (just _ , () , _))
(just x) nothing →
((Maybeᴿ G R₁ ;ᴱ Maybeᴿ G R₂) (just x) nothing ↝⟨ Eq.⇔→≃
T.truncation-is-proposition
⊥-propositional
(T.rec λ @0 where
.T.truncation-is-propositionʳ →
⊥-propositional
.T.∣∣ʳ (nothing , () , _)
.T.∣∣ʳ (just _ , _ , ()))
⊥-elim ⟩□
⊥ □)
, (T.elim λ @0 where
.T.truncation-is-propositionʳ _ →
H-level.⇒≡ 1 $
⊥-propositional
.T.∣∣ʳ (nothing , () , _)
.T.∣∣ʳ (just _ , _ , ()))
(just x) (just z) →
((Maybeᴿ G R₁ ;ᴱ Maybeᴿ G R₂) (just x) (just z) ↝⟨ Eq.⇔→≃
T.truncation-is-proposition
T.truncation-is-proposition
(T.∥∥ᴱ-map λ where
(nothing , () , ())
(just _ , p) → _ , p)
(T.∥∥ᴱ-map (Σ-map just id)) ⟩
(G R₁ ;ᴱ G R₂) x z ↝⟨ Eq.⟨ _ , SP.transitive-;ᴱ⁻¹ R₁-prop R₂-prop _ _ ⟩ ⟩□
G (R₁ ;ᴱ R₂) x z □)
, (T.elim λ @0 where
.T.truncation-is-propositionʳ _ →
H-level.⇒≡ 1 $
SS.preserves-is-proposition
(λ _ _ → T.truncation-is-proposition) _ _
.T.∣∣ʳ (nothing , () , ())
.T.∣∣ʳ (just _ , _) → refl _)
Function : Structure a b → Structure a c → Structure a (b ⊔ c)
Function F G A = F A → G A
Functionᴿ :
{F : Structure a b}
{G : Structure a c} →
Relation-transformer-for F →
Relation-transformer-for G →
Relation-transformer-for (Function F G)
Functionᴿ S T R f g = ∀ {x y} → S R x y → T R (f x) (g y)
Function-Constᴿ :
{F : Structure b c}
(A : Type a) →
Relation-transformer-for F →
Relation-transformer-for (Function (Const A) F)
Function-Constᴿ A G R f g = (x : A) → G R (f x) (g x)
Function-Constᴿ≃Functionᴿ∘Constᴿ :
{f : A → F B} {g : A → F C}
(G : Relation-transformer-for F) →
Function-Constᴿ A G R f g ≃
(Functionᴿ ∘ Constᴿ) A G R f g
Function-Constᴿ≃Functionᴿ∘Constᴿ {R} {f} {g} G =
(∀ x → G R (f x) (g x)) ↝⟨ (∀-cong ext λ _ → ∀-intro _ ext) ⟩
(∀ x y → x ≡ y → G R (f x) (g y)) ↔⟨ inverse (∀-cong ext (λ _ → B.implicit-Π↔Π) F.∘ B.implicit-Π↔Π) ⟩□
(∀ {x y} → x ≡ y → G R (f x) (g y)) □
Is-Function-equivalence :
{F : Structure a b} →
Structure-preserving-equivalence-predicate F c →
Structure-preserving-equivalence-predicate G d →
Structure-preserving-equivalence-predicate (Function F G) (b ⊔ c ⊔ d)
Is-Function-equivalence Is-F-eq Is-G-eq (A , f) (B , g) eq =
∀ {x y} → Is-F-eq (A , x) (B , y) eq → Is-G-eq (A , f x) (B , g y) eq
Is-Function-equivalence′ :
{F : Structure a b} →
(∀ {A B} → A ≃ᴱ B → F A ≃ᴱ F B) →
Structure-preserving-equivalence-predicate G c →
Structure-preserving-equivalence-predicate (Function F G) (b ⊔ c)
Is-Function-equivalence′ F-cong Is-G-eq (A , f) (B , g) eq =
∀ x → Is-G-eq (A , f x) (B , g (_≃ᴱ_.to (F-cong eq) x)) eq
Function-univalent :
{@0 F : Structure a b}
{@0 G : Structure a c}
{@0 Is-F-eq : Structure-preserving-equivalence-predicate F d}
{@0 Is-G-eq : Structure-preserving-equivalence-predicate G e} →
@0 Univalent F Is-F-eq →
@0 Univalent G Is-G-eq →
Univalent (Function F G) (Is-Function-equivalence Is-F-eq Is-G-eq)
Function-univalent
{F} {G} {Is-F-eq} {Is-G-eq}
u-F u-G .Univalent.univalent
{A = A , f} {B = B , g} eq =
(∀ {x y} → Is-F-eq (A , x) (B , y) eq →
Is-G-eq (A , f x) (B , g y) eq) ↔⟨ B.implicit-Π↔Π F.∘
implicit-∀-cong ext B.implicit-Π↔Π ⟩
(∀ x y → Is-F-eq (A , x) (B , y) eq →
Is-G-eq (A , f x) (B , g y) eq) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ →
→-cong ext (u-F .Univalent.univalent eq) (u-G .Univalent.univalent eq)) ⟩
(∀ x y → subst F (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x ≡ y →
subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) (f x) ≡ g y) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ → →-cong₁ ext $
≡⇒≃ (cong (_ ≡_) $ _≃_.left-inverse-of (Eq.subst-as-equivalence _ _) _) F.∘
inverse (Eq.≃-≡ $ inverse $ Eq.subst-as-equivalence _ _) F.∘
from-bijection ≡-comm) ⟩
(∀ x y → subst F (sym (≃⇒≡ univ (EEq.≃ᴱ→≃ eq))) y ≡ x →
subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) (f x) ≡ g y) ↔⟨ Π-comm ⟩
(∀ y x → subst F (sym (≃⇒≡ univ (EEq.≃ᴱ→≃ eq))) y ≡ x →
subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) (f x) ≡ g y) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ → ∀-cong ext λ eq →
≡⇒≃ $ cong (_≡ _) $ cong (subst G _) $ cong f $ sym eq) ⟩
(∀ y x → subst F (sym (≃⇒≡ univ (EEq.≃ᴱ→≃ eq))) y ≡ x →
subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq))
(f (subst F (sym (≃⇒≡ univ (EEq.≃ᴱ→≃ eq))) y)) ≡
g y) ↝⟨ (∀-cong ext λ _ → inverse $
∀-intro _ ext) ⟩
(∀ y →
subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq))
(f (subst F (sym (≃⇒≡ univ (EEq.≃ᴱ→≃ eq))) y)) ≡
g y) ↝⟨ (∀-cong ext λ _ → ≡⇒≃ $ cong (_≡ _) $ sym $
subst-→) ⟩
(∀ y → subst (Function F G) (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) f y ≡ g y) ↝⟨ Eq.extensionality-isomorphism ext ⟩□
subst (Function F G) (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) f ≡ g □
Function-univalent′ :
{@0 G : Structure a c}
{@0 Is-G-eq : Structure-preserving-equivalence-predicate G e}
(@0 F-cong : ∀ {A B} → A ≃ᴱ B → F A ≃ᴱ F B) →
@0 (∀ {A} (x : F A) → _≃ᴱ_.to (F-cong F.id) x ≡ x) →
@0 Univalent G Is-G-eq →
Univalent (Function F G) (Is-Function-equivalence′ F-cong Is-G-eq)
Function-univalent′
{F} {G} {Is-G-eq}
F-cong F-cong-id u-G .Univalent.univalent
{A = A , f} {B = B , g} eq =
(∀ x → Is-G-eq (A , f x) (B , g (_≃ᴱ_.to (F-cong eq) x)) eq) ↝⟨ (∀-cong ext λ _ → u-G .Univalent.univalent eq) ⟩
(∀ x →
subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) (f x) ≡ g (_≃ᴱ_.to (F-cong eq) x)) ↝⟨ Eq.extensionality-isomorphism ext ⟩
subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) ∘ f ≡ g ∘ _≃ᴱ_.to (F-cong eq) ↝⟨ ≡⇒≃ $ cong (subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) ∘ f ≡_) $
cong (g ∘_) $ cong _≃ᴱ_.to $ cong F-cong $ sym $
_≃_.right-inverse-of EEq.≃≃≃ᴱ _ ⟩
subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) ∘ f ≡
g ∘ _≃ᴱ_.to (F-cong $ EEq.≃→≃ᴱ $ EEq.≃ᴱ→≃ eq) ↝⟨ ≡⇒≃ $ cong (subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) ∘ f ≡_) $
cong (g ∘_) $ ⟨ext⟩ $
transport-theorem
F (_≃ᴱ_.to ∘ F-cong ∘ EEq.≃→≃ᴱ) F-cong-id univ (EEq.≃ᴱ→≃ eq) ⟩
subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) ∘ f ≡
g ∘ subst F (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) ↝⟨ inverse $ Eq.≃-≡ $ →-cong₁ ext $ Eq.subst-as-equivalence _ _ ⟩
subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) ∘ f ∘
subst F (sym (≃⇒≡ univ (EEq.≃ᴱ→≃ eq))) ≡
g ∘ subst F (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) ∘
subst F (sym (≃⇒≡ univ (EEq.≃ᴱ→≃ eq))) ↝⟨ ≡⇒≃ $ cong (subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) ∘ f ∘
subst F (sym (≃⇒≡ univ (EEq.≃ᴱ→≃ eq))) ≡_) $
cong (g ∘_) $ ⟨ext⟩ $
_≃_.right-inverse-of (Eq.subst-as-equivalence _ _) ⟩
subst G (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) ∘ f ∘
subst F (sym (≃⇒≡ univ (EEq.≃ᴱ→≃ eq))) ≡
g ↝⟨ (≡⇒≃ $ cong (_≡ _) $ sym $ ⟨ext⟩ λ _ →
subst-→) ⟩□
subst (Function F G) (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) f ≡ g □
Functionᴿ-suitable :
{@0 S : Relation-transformer-for F} →
{@0 T : Relation-transformer-for G} →
Positive S →
Suitable T →
Suitable (Functionᴿ S T)
Functionᴿ-suitable {F} {G} {S} {T} p-S s-T = λ where
.Suitable.preserves-is-set set →
Π-closure ext 2 λ _ →
TS.preserves-is-set set
.Suitable.preserves-is-proposition prop _ _ →
implicit-Π-closure ext 1 λ _ →
implicit-Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
TS.preserves-is-proposition prop _ _
.Suitable.symmetric {R} {x = f} {y = g} prop S→T {x} {y} →
S (R ⁻¹) x y ↝⟨ SS.symmetric (flip prop) ⟩
S R y x ↝⟨ S→T ⟩
T R (f y) (g x) ↝⟨ TS.symmetric prop ⟩□
T (R ⁻¹) (g x) (f y) □
.Suitable.transitive
{R = R₁} {S = R₂} {x = f} {y = g} {z = h}
R₁-prop R₂-prop S→T₁ S→T₂ {x} {y} →
S (R₁ ;ᴱ R₂) x y ↔⟨ inverse Eq.⟨ _ , SP.transitive-;ᴱ⁻¹ R₁-prop R₂-prop _ _ ⟩ ⟩
(S R₁ ;ᴱ S R₂) x y ↝⟨ T.∥∥ᴱ-map (Σ-map _ (Σ-map S→T₁ S→T₂)) ⟩
(T R₁ ;ᴱ T R₂) (f x) (h y) ↝⟨ TS.transitive-;ᴱ R₁-prop R₂-prop _ _ ⟩□
T (R₁ ;ᴱ R₂) (f x) (h y) □
.Suitable.descent {A} {x = f} {R} prop equiv S→T →
let
d :
(x : F A) →
Contractibleᴱ (∃ λ y → Erased (T (Graph [_]) (f x) y))
d x = TS.descent prop equiv (S→T (SP.reflexive prop equiv x))
g-[] : F A → G (A /ᴱ R)
g-[] x = d x .proj₁ .proj₁
S→T′ : Erased (S R x y → T (Graph [_]) (f x) (g-[] y))
S→T′ = λ {x = x} {y = y} →
[ S R x y ↝⟨ S→T ⟩
T R (f x) (f y) ↝⟨ flip (TS.transitive prop (λ _ _ → Q./ᴱ-is-set)) (d y .proj₁ .proj₂ .erased) ⟩
T (R ;ᴱ Graph [_]) (f x) (g-[] y) ↝⟨ subst (λ R → T R (f x) (g-[] y)) (;ᴱ-Graph-[]≡Graph-[] prop equiv) ⟩□
T (Graph [_]) (f x) (g-[] y) □
]
S-[]-map-[] : ∀ {x} → Erased (S (Graph [_]) x (SA.map [_] x))
S-[]-map-[] = λ {x = x} →
[ $⟨ SA.map-map Q.[]-respects-relation (SP.reflexive prop equiv x) ⟩
S (Graph [_]) (SA.map id x) (SA.map [_] x) ↝⟨ subst (λ f → S (Graph (Q.[_] {R = R})) (f x) (SA.map Q.[_] x)) SA.map-id ⟩□
S (Graph [_]) x (SA.map [_] x) □
]
g : F A /ᴱ S R → G (A /ᴱ R)
g = Q.rec λ where
.Q.is-setʳ → TS.preserves-is-set Q./ᴱ-is-set
.Q.[]ʳ → g-[]
.Q.[]-respects-relationʳ {x} {y} SRxy →
g-[] x ≡⟨ cong proj₁ $
d x .proj₂ .erased
(g-[] y , Er.map (_$ SRxy) S→T′) ⟩∎
g-[] y ∎
h : F A /ᴱ S R ≃ᴱ F (A /ᴱ R)
h = EEq.⟨ _ , SP.commutes-with-/ᴱ prop equiv ⟩
in
( (F (A /ᴱ R) ↝⟨ _≃ᴱ_.from h ⟩
F A /ᴱ S R ↝⟨ g ⟩□
G (A /ᴱ R) □)
, [ (λ {x = x} {y = y} →
let
lemma :
∀ y →
S (Graph [_]) x (_≃ᴱ_.to h y) →
T (Graph [_]) (f x) (g y)
lemma = Q.elim-prop λ @0 where
.Q.is-propositionʳ _ →
Π-closure ext 1 λ _ →
TS.preserves-is-proposition
(λ _ _ → Q./ᴱ-is-set) _ _
.Q.[]ʳ y →
let
s = $⟨ S-[]-map-[] .erased ⟩
S (Graph [_]) y (SA.map [_] y) ↝⟨ SS.symmetric (λ _ _ → Q./ᴱ-is-set) ⟩□
S (Graph [_] ⁻¹) (SA.map [_] y) y □
in
S (Graph [_]) x (SA.map [_] y) ↝⟨ flip (SS.transitive (λ _ _ → Q./ᴱ-is-set) λ _ _ → Q./ᴱ-is-set) s ⟩
S (Graph [_] ⟵) x y ↝⟨ subst (λ R → S R x y) (Graph-[]-⟵≡ prop equiv) ⟩
S R x y ↝⟨ S→T′ .erased ⟩□
T (Graph [_]) (f x) (g-[] y) □
in
S (Graph [_]) x y ↝⟨ subst (S (Graph [_]) x) (sym $ _≃ᴱ_.right-inverse-of h _) ⟩
S (Graph [_]) x (_≃ᴱ_.to h (_≃ᴱ_.from h y)) ↝⟨ lemma (_≃ᴱ_.from h y) ⟩□
T (Graph [_]) (f x) (g (_≃ᴱ_.from h y)) □)
]
)
, [ (λ (g′ , [ g′-hyp ]) →
let
lemma : ∀ y → g y ≡ g′ (_≃ᴱ_.to h y)
lemma = Q.elim-prop λ @0 where
.Q.is-propositionʳ _ →
TS.preserves-is-set Q./ᴱ-is-set
.Q.[]ʳ y →
g-[] y ≡⟨ cong proj₁ $
d y .proj₂ .erased
( g′ (SA.map [_] y)
, [
$⟨ S-[]-map-[] .erased ⟩
S (Graph [_]) y (SA.map [_] y) ↝⟨ g′-hyp ⟩□
T (Graph [_]) (f y) (g′ (SA.map [_] y)) □
]
) ⟩∎
g′ (SA.map [_] y) ∎
in
Σ-≡,≡→≡
(⟨ext⟩ λ x →
g (_≃ᴱ_.from h x) ≡⟨ lemma (_≃ᴱ_.from h x) ⟩
g′ (_≃ᴱ_.to h (_≃ᴱ_.from h x)) ≡⟨ cong g′ $ _≃ᴱ_.right-inverse-of h _ ⟩∎
g′ x ∎)
(H-level-Erased 1
(implicit-Π-closure ext 1 λ _ →
implicit-Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
TS.preserves-is-proposition (λ _ _ → Q./ᴱ-is-set) _ _)
_ _))
]
where
module SP = Positive p-S
module SA = Acts-on-functions SP.acts-on-functions
module SS = Suitable SP.suitable
module TS = Suitable s-T
Function-Constᴿ-suitable :
{@0 G : Relation-transformer-for F} →
@0 Is-set A →
Suitable G →
Suitable (Function-Constᴿ A G)
Function-Constᴿ-suitable {F} {A} {G} set =
Suitable G ↝⟨ Functionᴿ-suitable (Constᴿ-positive set) ⟩
Suitable (Functionᴿ (Constᴿ A) G) ↝⟨ Suitable-map (inverse $ Function-Constᴿ≃Functionᴿ∘Constᴿ G) ⟩□
Suitable (Function-Constᴿ A G) □
Functionᴿ-univalent :
{@0 S : Relation-transformer-for F}
{@0 T : Relation-transformer-for G} →
Positive S →
Univalentᴿ S →
Univalentᴿ T →
Univalentᴿ (Functionᴿ S T)
Functionᴿ-univalent p-S (_ , u-S) (s-T , u-T) =
Functionᴿ-suitable p-S s-T
, Function-univalent u-S u-T
Function-Constᴿ-univalent :
{@0 G : Relation-transformer-for F} →
@0 Is-set A →
Univalentᴿ G →
Univalentᴿ (Function-Constᴿ A G)
Function-Constᴿ-univalent set (s-G , u-G) =
Function-Constᴿ-suitable set s-G
, Function-univalent′ (λ _ → F.id) refl u-G
Erasedᴿ :
{@0 F : Structure a b} →
@0 Relation-transformer-for F →
Relation-transformer-for (λ A → Erased (F A))
Erasedᴿ G R = Erasedᴾ (G R)
Is-Erased-equivalence :
@0 Structure-preserving-equivalence-predicate F a →
Structure-preserving-equivalence-predicate (λ A → Erased (F A)) a
Is-Erased-equivalence Is-F-eq (_ , x) (_ , y) eq =
Erased (Is-F-eq (_ , erased x) (_ , erased y) eq)
Erased-univalent :
{@0 F : Structure a b}
{@0 Is-F-eq : Structure-preserving-equivalence-predicate F c} →
@0 Univalent F Is-F-eq →
Univalent (λ A → Erased (F A)) (Is-Erased-equivalence Is-F-eq)
Erased-univalent
{F} {Is-F-eq} u-F .Univalent.univalent
{A = A , [ x ]} {B = B , [ y ]} eq =
Erased (Is-F-eq (A , x) (B , y) eq) ↝⟨ Erased-cong (u-F .Univalent.univalent eq) ⟩
Erased (subst F (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x ≡ y) ↔⟨ Erased-≡↔[]≡[] ⟩
[ subst F (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) x ] ≡ [ y ] ↝⟨ ≡⇒≃ $ cong (_≡ _) $ sym push-subst-[] ⟩□
subst (λ A → Erased (F A)) (≃⇒≡ univ (EEq.≃ᴱ→≃ eq)) [ x ] ≡ [ y ] □
Erasedᴿ-suitable :
{@0 G : Relation-transformer-for F} →
@0 Suitable G →
Suitable (Erasedᴿ G)
Erasedᴿ-suitable {G} s-G = λ where
.Suitable.preserves-is-set set →
H-level-Erased 2 (s-G .Suitable.preserves-is-set set)
.Suitable.preserves-is-proposition prop _ _ →
H-level-Erased 1 (s-G .Suitable.preserves-is-proposition prop _ _)
.Suitable.symmetric prop →
Er.map (s-G .Suitable.symmetric prop)
.Suitable.transitive R-prop S-prop [ GRxy ] [ GSyz ] →
[ s-G .Suitable.transitive R-prop S-prop GRxy GSyz ]
.Suitable.descent {x = [ x ]} {R} prop equiv [GRxx] → $⟨ [ [GRxx] .erased ] ⟩
Erased (G R x x) ↝⟨ Er.map (λ GRxx → s-G .Suitable.descent prop equiv GRxx) ⟩
Erased (Contractibleᴱ (∃ λ y → Erased (G (Graph [_]) x y))) ↝⟨ ECP.Erased-Contractibleᴱ↔Contractibleᴱ-Erased _ ⟩
Contractibleᴱ (Erased (∃ λ y → Erased (G (Graph [_]) x y))) ↝⟨ ECP.Contractibleᴱ-cong _ Erased-Σ↔Σ ⟩
Contractibleᴱ (∃ λ ([ y ]) → Erased (Erased (G (Graph [_]) x y))) ↔⟨⟩
Contractibleᴱ (∃ λ y → Erased (Erasedᴿ G (Graph [_]) [ x ] y)) □
Erasedᴿ-univalent :
{@0 G : Relation-transformer-for F} →
@0 Univalentᴿ G →
Univalentᴿ (Erasedᴿ G)
Erasedᴿ-univalent (s-G , u-G) =
Erasedᴿ-suitable s-G
, Erased-univalent u-G
Erasedᴿ-acts-on-functions :
{@0 G : Relation-transformer-for F} →
@0 Acts-on-functions G →
Acts-on-functions (Erasedᴿ G)
Erasedᴿ-acts-on-functions {G} a-G = λ where
.Acts-on-functions.map f →
Er.map (a-G .Acts-on-functions.map f)
.Acts-on-functions.map-id →
Er.map (a-G .Acts-on-functions.map id) ≡⟨ cong (λ f → Er.map f) (a-G .Acts-on-functions.map-id) ⟩
Er.map id ≡⟨ (⟨ext⟩ λ _ → Er.map-id) ⟩
id ∎
.Acts-on-functions.map-map
{f} {g} {x = [ x ]} {y = [ y ]} {R₁} {R₂} R₁→R₂ →
Erased (G R₁ x y) ↝⟨ Er.map (a-G .Acts-on-functions.map-map R₁→R₂) ⟩□
Erased (G R₂ (a-G .Acts-on-functions.map f x)
(a-G .Acts-on-functions.map g y)) □
module Example₁ where
Raw-monoid-structure : Structure a a
Raw-monoid-structure A = A × (A → A → A)
_ :
Raw-monoid-structure {a = a} ≡
Product Id (Function Id (Function Id Id))
_ = refl _
Raw-monoid : (a : Level) → Type (lsuc a)
Raw-monoid _ = Type-with Raw-monoid-structure
Is-raw-monoid-equivalence :
Structure-preserving-equivalence-predicate Raw-monoid-structure a
Is-raw-monoid-equivalence (_ , id₁ , _∘₁_) (_ , id₂ , _∘₂_) eq =
_≃ᴱ_.to eq id₁ ≡ id₂ ×
(∀ x y → _≃ᴱ_.to eq (x ∘₁ y) ≡ _≃ᴱ_.to eq x ∘₂ _≃ᴱ_.to eq y)
_ :
Is-raw-monoid-equivalence {a = a} ≡
Is-Product-equivalence
Is-Id-equivalence
(Is-Function-equivalence′ id
(Is-Function-equivalence′ id
Is-Id-equivalence))
_ = refl _
infix 4 _≃ᴿᴹᴱ_
_≃ᴿᴹᴱ_ : Raw-monoid a → Raw-monoid a → Type a
_≃ᴿᴹᴱ_ = _≃[ Is-raw-monoid-equivalence ]ᴱ_
Is-raw-monoid-equivalence-univalent :
Univalent (Raw-monoid-structure {a = a}) Is-raw-monoid-equivalence
Is-raw-monoid-equivalence-univalent =
Product-univalent
Id-univalent
(Function-univalent′ id refl
(Function-univalent′ id refl
Id-univalent))
Monoid-laws : Axioms Raw-monoid-structure a
Monoid-laws (A , id , _∘_) =
Is-set A ×
(∀ x → id ∘ x ≡ x) ×
(∀ x → x ∘ id ≡ x) ×
(∀ x y z → x ∘ (y ∘ z) ≡ (x ∘ y) ∘ z)
Monoid-laws-propositional :
(M : Raw-monoid a) → Is-proposition (Monoid-laws M)
Monoid-laws-propositional (A , id , _∘_) =
Σ-closure 1 (H-level-propositional ext 2) λ A-set →
×-closure 1 (Π-closure ext 1 λ _ → A-set) $
×-closure 1 (Π-closure ext 1 λ _ → A-set) $
Π-closure ext 1 λ _ → Π-closure ext 1 λ _ → Π-closure ext 1 λ _ →
A-set
Monoid-structure : Structure a a
Monoid-structure =
Raw-monoid-structure With-the-axioms Monoid-laws
Monoid : (a : Level) → Type (lsuc a)
Monoid _ = Type-with Monoid-structure
Is-monoid-equivalence :
Structure-preserving-equivalence-predicate Monoid-structure a
Is-monoid-equivalence = Lift-With-the-axioms Is-raw-monoid-equivalence
infix 4 _≃ᴹᴱ_
_≃ᴹᴱ_ : Monoid a → Monoid a → Type a
_≃ᴹᴱ_ = _≃[ Is-monoid-equivalence ]ᴱ_
Is-monoid-equivalence-univalent :
Univalent (Monoid-structure {a = a}) Is-monoid-equivalence
Is-monoid-equivalence-univalent =
Univalent-With-the-axioms
Monoid-laws-propositional
Is-raw-monoid-equivalence-univalent
@0 sip-for-monoids : (M ≃ᴹᴱ N) ≃ (M ≡ N)
sip-for-monoids = sip Is-monoid-equivalence-univalent
induced-monoid :
(M₁@(A₁ , ops₁ , _) : Monoid a)
(M₂@(A₂ , ops₂) : Raw-monoid a) →
(A₁ , ops₁) ≃ᴿᴹᴱ M₂ →
∃ λ (l₂ : Erased (Monoid-laws M₂)) → M₁ ≃ᴹᴱ (A₂ , ops₂ , l₂)
induced-monoid =
induced-structures Is-raw-monoid-equivalence-univalent
ℕ-monoid : Monoid lzero
ℕ-monoid =
ℕ
, (0 , _+_)
, [ ( ℕ-set
, refl
, (λ _ → Nat.+-right-identity)
, (λ m _ _ → Nat.+-assoc m)
)
]
Bin-raw-monoid : Raw-monoid lzero
Bin-raw-monoid =
Bin
, Bin.Operations-for-Bin.zero
, Bin.Operations-for-Bin._+_
ℕ≃ᴿᴹᴱBin : (ℕ , (0 , _+_)) ≃ᴿᴹᴱ Bin-raw-monoid
ℕ≃ᴿᴹᴱBin =
(ℕ ↔⟨ inverse Bin.Bin↔ℕ ⟩□
Bin □)
, [ ( (_↔_.from Bin.Bin↔ℕ 0 ≡⟨ _↔_.to Bin.≡-for-indices↔≡ [ refl _ ] ⟩∎
Bin.Operations-for-Bin.zero ∎)
, (λ m n →
_↔_.from Bin.Bin↔ℕ (m + n) ≡⟨ _↔_.to Bin.≡-for-indices↔≡ [ refl _ ] ⟩∎
_↔_.from Bin.Bin↔ℕ m Bin.Operations-for-Bin.+
_↔_.from Bin.Bin↔ℕ n ∎)
)
]
@0 Bin-monoid-laws : Monoid-laws Bin-raw-monoid
Bin-monoid-laws =
induced-monoid ℕ-monoid Bin-raw-monoid ℕ≃ᴿᴹᴱBin .proj₁ .erased
Bin-monoid : Monoid lzero
Bin-monoid =
Bin-raw-monoid .proj₁ , Bin-raw-monoid .proj₂ , [ Bin-monoid-laws ]
ℕ≃ᴹᴱBin : ℕ-monoid ≃ᴹᴱ Bin-monoid
ℕ≃ᴹᴱBin =
induced-monoid ℕ-monoid Bin-raw-monoid ℕ≃ᴿᴹᴱBin .proj₂
@0 ℕ≡Bin : ℕ-monoid ≡ Bin-monoid
ℕ≡Bin = _≃_.to sip-for-monoids ℕ≃ᴹᴱBin
module Example₂ {A : Type a} (_≟_ : Decidable-equality A) where
private
set : Is-set A
set = decidable⇒set _≟_
Raw-bag-structure : Structure a a
Raw-bag-structure Bag =
Bag ×
(A → Bag → Bag) ×
(Bag → Bag → Bag) ×
(A → Bag → ℕ)
_ :
Raw-bag-structure ≡
Product Id
(Product (Function (Const A) (Function Id Id))
(Product (Function Id (Function Id Id))
(Function (Const A) (Function Id (Const ℕ)))))
_ = refl _
Raw-bag-type : Type (lsuc a)
Raw-bag-type = Type-with Raw-bag-structure
Is-raw-bag-equivalence :
Structure-preserving-equivalence-predicate Raw-bag-structure a
Is-raw-bag-equivalence
(_ , empty₁ , insert₁ , union₁ , count₁)
(_ , empty₂ , insert₂ , union₂ , count₂)
eq =
_≃ᴱ_.to eq empty₁ ≡ empty₂ ×
(∀ x xs → _≃ᴱ_.to eq (insert₁ x xs) ≡ insert₂ x (_≃ᴱ_.to eq xs)) ×
(∀ xs ys →
_≃ᴱ_.to eq (union₁ xs ys) ≡
union₂ (_≃ᴱ_.to eq xs) (_≃ᴱ_.to eq ys)) ×
(∀ x xs → count₁ x xs ≡ count₂ x (_≃ᴱ_.to eq xs))
_ :
Is-raw-bag-equivalence ≡
Is-Product-equivalence
Is-Id-equivalence
(Is-Product-equivalence
(Is-Function-equivalence′ (λ _ → EEq.id)
(Is-Function-equivalence′ id
Is-Id-equivalence))
(Is-Product-equivalence
(Is-Function-equivalence′ id
(Is-Function-equivalence′ id
Is-Id-equivalence))
(Is-Function-equivalence′ (λ _ → EEq.id)
(Is-Function-equivalence′ id
Is-Const-equivalence))))
_ = refl _
infix 4 _≃ᴮᴱ_
_≃ᴮᴱ_ : Raw-bag-type → Raw-bag-type → Type a
_≃ᴮᴱ_ = _≃[ Is-raw-bag-equivalence ]ᴱ_
Raw-bag-typeᴿ : Relation-transformer-for Raw-bag-structure
Raw-bag-typeᴿ =
Productᴿ Idᴿ
(Productᴿ (Function-Constᴿ A (Functionᴿ Idᴿ Idᴿ))
(Productᴿ (Functionᴿ Idᴿ (Functionᴿ Idᴿ Idᴿ))
(Function-Constᴿ A (Functionᴿ Idᴿ (Constᴿ ℕ)))))
Raw-bag-typeᴿ-univalent : Univalentᴿ Raw-bag-typeᴿ
Raw-bag-typeᴿ-univalent =
Productᴿ-univalent Idᴿ-univalent
(Productᴿ-univalent
(Function-Constᴿ-univalent set
(Functionᴿ-univalent Idᴿ-positive Idᴿ-univalent
Idᴿ-univalent))
(Productᴿ-univalent
(Functionᴿ-univalent Idᴿ-positive Idᴿ-univalent
(Functionᴿ-univalent Idᴿ-positive Idᴿ-univalent
Idᴿ-univalent))
(Function-Constᴿ-univalent set
(Functionᴿ-univalent Idᴿ-positive Idᴿ-univalent
(Constᴿ-univalent ℕ-set)))))
List-bag : Type a
List-bag = List A
count₁′ : A → A → ℕ
count₁′ x y = if x ≟ y then 1 else 0
count₁ : A → List-bag → ℕ
count₁ x = L.foldr (λ y → count₁′ x y +_) 0
Raw-bag-structure-List-bag : Raw-bag-structure List-bag
Raw-bag-structure-List-bag =
[]
, _∷_
, L._++_
, count₁
Raw-bag-type-List-bag : Raw-bag-type
Raw-bag-type-List-bag = List-bag , Raw-bag-structure-List-bag
Assoc-list-bag : Type a
Assoc-list-bag = List (ℕ × A)
insert : ℕ → A → Assoc-list-bag → Assoc-list-bag
insert m x [] = (m , x) ∷ []
insert m x ((n , y) ∷ ys) =
if x ≟ y
then (m + n , y) ∷ ys
else (n , y) ∷ insert m x ys
union : Assoc-list-bag → Assoc-list-bag → Assoc-list-bag
union = flip (L.foldr (uncurry insert))
count₂′ : A → ℕ × A → ℕ
count₂′ x (n , y) = if x ≟ y then n else 0
count₂ : A → Assoc-list-bag → ℕ
count₂ x = L.foldr (λ y → count₂′ x y +_) 0
Raw-bag-structure-Assoc-list-bag : Raw-bag-structure Assoc-list-bag
Raw-bag-structure-Assoc-list-bag =
[]
, insert 1
, union
, count₂
Raw-bag-type-Assoc-list-bag : Raw-bag-type
Raw-bag-type-Assoc-list-bag =
Assoc-list-bag , Raw-bag-structure-Assoc-list-bag
count₁-++ :
∀ xs → count₁ z (xs L.++ ys) ≡ count₁ z xs + count₁ z ys
count₁-++ [] = refl _
count₁-++ {z} {ys} (x ∷ xs) =
count₁′ z x + (count₁ z (xs L.++ ys)) ≡⟨ cong (count₁′ z x +_) $ count₁-++ xs ⟩
count₁′ z x + (count₁ z xs + count₁ z ys) ≡⟨ Nat.+-assoc (count₁′ z x) ⟩∎
(count₁′ z x + count₁ z xs) + count₁ z ys ∎
count₁-replicate :
∀ n → count₁ z (L.replicate n y) ≡ count₂′ z (n , y)
count₁-replicate {z} {y} zero with z ≟ y
… | yes _ = refl _
… | no _ = refl _
count₁-replicate {z} {y} (suc n) =
count₁′ z y + count₁ z (L.replicate n y) ≡⟨ cong (count₁′ z y +_) $ count₁-replicate n ⟩
count₁′ z y + count₂′ z (n , y) ≡⟨ lemma ⟩∎
count₂′ z (suc n , y) ∎
where
lemma : count₁′ z y + count₂′ z (n , y) ≡ count₂′ z (suc n , y)
lemma with z ≟ y
… | yes _ = refl _
… | no _ = refl _
count₂-insert-≡ :
z ≡ x → ∀ ys → count₂ z (insert m x ys) ≡ m + count₂ z ys
count₂-insert-≡ {z} {x} {m} z≡x = helper
where
helper : ∀ ys → count₂ z (insert m x ys) ≡ m + count₂ z ys
helper [] with z ≟ x
… | yes _ = m + 0 ∎
… | no z≢x = ⊥-elim $ z≢x z≡x
helper ((n , y) ∷ ys) with x ≟ y
helper ((n , y) ∷ ys) | no x≢y =
count₂′ z (n , y) + count₂ z (insert m x ys) ≡⟨ cong (count₂′ z (n , y) +_) $ helper ys ⟩
count₂′ z (n , y) + (m + count₂ z ys) ≡⟨ Nat.+-assoc (count₂′ z (n , y)) ⟩
(count₂′ z (n , y) + m) + count₂ z ys ≡⟨ cong (_+ count₂ z ys) $ sym $ Nat.+-comm m ⟩
(m + count₂′ z (n , y)) + count₂ z ys ≡⟨ sym $ Nat.+-assoc m ⟩∎
m + (count₂′ z (n , y) + count₂ z ys) ∎
helper ((n , y) ∷ ys) | yes x≡y =
count₂′ z (m + n , y) + count₂ z ys ≡⟨ cong (_+ _) lemma ⟩
(m + count₂′ z (n , y)) + count₂ z ys ≡⟨ sym $ Nat.+-assoc m ⟩∎
m + (count₂′ z (n , y) + count₂ z ys) ∎
where
lemma : count₂′ z (m + n , y) ≡ m + count₂′ z (n , y)
lemma with z ≟ y
… | yes _ = m + n ∎
… | no z≢y = ⊥-elim $ z≢y (trans z≡x x≡y)
count₂-insert-≢ :
z ≢ x → ∀ ys → count₂ z (insert m x ys) ≡ count₂ z ys
count₂-insert-≢ {z} {x} {m} z≢x = helper
where
helper : ∀ ys → count₂ z (insert m x ys) ≡ count₂ z ys
helper [] with z ≟ x
… | no _ = 0 ∎
… | yes z≡x = ⊥-elim $ z≢x z≡x
helper ((n , y) ∷ ys) with x ≟ y
… | no _ =
count₂′ z (n , y) + count₂ z (insert m x ys) ≡⟨ cong (count₂′ z (n , y) +_) $ helper ys ⟩∎
count₂′ z (n , y) + count₂ z ys ∎
… | yes x≡y =
count₂′ z (m + n , y) + count₂ z ys ≡⟨ cong (_+ _) lemma ⟩∎
count₂′ z ( n , y) + count₂ z ys ∎
where
lemma : count₂′ z (m + n , y) ≡ count₂′ z (n , y)
lemma with z ≟ y
… | no _ = 0 ∎
… | yes z≡y = ⊥-elim $ z≢x (trans z≡y (sym x≡y))
count₂-insert :
∀ ys → count₂ z (insert m x ys) ≡ count₂′ z (m , x) + count₂ z ys
count₂-insert {z} {m} {x} ys with z ≟ x
… | yes z≡x =
count₂ z (insert m x ys) ≡⟨ count₂-insert-≡ z≡x ys ⟩∎
m + count₂ z ys ∎
… | no z≢x =
count₂ z (insert m x ys) ≡⟨ count₂-insert-≢ z≢x ys ⟩∎
count₂ z ys ∎
count₂-union :
∀ xs → count₂ z (union xs ys) ≡ count₂ z xs + count₂ z ys
count₂-union {z} {ys} [] =
count₂ z ys ∎
count₂-union {z} {ys} ((m , x) ∷ xs) =
count₂ z (insert m x (union xs ys)) ≡⟨ count₂-insert (union xs ys) ⟩
count₂′ z (m , x) + count₂ z (union xs ys) ≡⟨ cong (count₂′ z (m , x) +_) $ count₂-union xs ⟩
count₂′ z (m , x) + (count₂ z xs + count₂ z ys) ≡⟨ Nat.+-assoc (count₂′ z (m , x)) ⟩∎
(count₂′ z (m , x) + count₂ z xs) + count₂ z ys ∎
infix 4 _∼_
_∼_ : List-bag → Assoc-list-bag → Type a
xs ∼ ys = ∀ z → count₁ z xs ≡ count₂ z ys
∼-propositional : ∀ xs ys → Is-proposition (xs ∼ ys)
∼-propositional _ _ =
Π-closure ext 1 λ _ →
ℕ-set
∼-QER : Is-QER _∼_
∼-QER =
(λ {xs₁ xs₂ ys₁ ys₂} xs₁∼ys₁ xs₂∼ys₁ xs₂∼ys₂ z →
count₁ z xs₁ ≡⟨ xs₁∼ys₁ z ⟩
count₂ z ys₁ ≡⟨ sym $ xs₂∼ys₁ z ⟩
count₁ z xs₂ ≡⟨ xs₂∼ys₂ z ⟩∎
count₂ z ys₂ ∎)
, (λ xs → ∣ to xs , ∼to xs ∣)
, (λ ys → ∣ from ys , from∼ ys ∣)
where
to : List-bag → Assoc-list-bag
to = L.foldr (insert 1) []
from : Assoc-list-bag → List-bag
from = L.foldr (λ (n , x) → L.replicate n x L.++_) []
∼to : ∀ xs → xs ∼ to xs
∼to [] _ = refl _
∼to (x ∷ xs) z =
count₁′ z x + count₁ z xs ≡⟨ cong (count₁′ z x +_) $ ∼to xs z ⟩
count₁′ z x + count₂ z (to xs) ≡⟨⟩
count₂′ z (1 , x) + count₂ z (to xs) ≡⟨ sym $ count₂-insert (to xs) ⟩∎
count₂ z (insert 1 x (to xs)) ∎
from∼ : ∀ ys → from ys ∼ ys
from∼ [] _ = refl _
from∼ ((n , y) ∷ ys) z =
count₁ z (L.replicate n y L.++ from ys) ≡⟨ count₁-++ (L.replicate n y) ⟩
count₁ z (L.replicate n y) + count₁ z (from ys) ≡⟨ cong (count₁ z (L.replicate n y) +_) $ from∼ ys z ⟩
count₁ z (L.replicate n y) + count₂ z ys ≡⟨ cong (_+ count₂ z ys) $ count₁-replicate n ⟩
count₂′ z (n , y) + count₂ z ys ≡⟨⟩
count₂ z ((n , y) ∷ ys) ∎
List-bag∼Assoc-list-bag :
Raw-bag-typeᴿ _∼_
Raw-bag-structure-List-bag Raw-bag-structure-Assoc-list-bag
List-bag∼Assoc-list-bag =
(λ z →
count₁ z [] ≡⟨⟩
count₂ z [] ∎)
, (λ x {x = xs} {y = ys} xs∼ys z →
count₁ z (x ∷ xs) ≡⟨⟩
count₁′ z x + count₁ z xs ≡⟨ cong (count₁′ z x +_) (xs∼ys z) ⟩
count₁′ z x + count₂ z ys ≡⟨⟩
count₂′ z (1 , x) + count₂ z ys ≡⟨ sym $ count₂-insert ys ⟩∎
count₂ z (insert 1 x ys) ∎)
, (λ {x = xs₁} {y = ys₁} xs₁∼ys₁ {x = xs₂} {y = ys₂} xs₂∼ys₂ z →
count₁ z (xs₁ L.++ xs₂) ≡⟨ count₁-++ xs₁ ⟩
count₁ z xs₁ + count₁ z xs₂ ≡⟨ cong₂ _+_ (xs₁∼ys₁ z) (xs₂∼ys₂ z) ⟩
count₂ z ys₁ + count₂ z ys₂ ≡⟨ sym $ count₂-union ys₁ ⟩∎
count₂ z (union ys₁ ys₂) ∎)
, (λ x {x = xs} {y = ys} xs∼ys →
count₁ x xs ≡⟨ xs∼ys x ⟩∎
count₂ x ys ∎)
List-bag≃ᴱAssoc-list-bag :
List-bag /ᴱ _∼_ ⟵ ≃ᴱ Assoc-list-bag /ᴱ _∼_ ⟶
List-bag≃ᴱAssoc-list-bag =
/ᴱ⟵≃ᴱ/ᴱ⟶ᴱ (Is-QER→Is-QERᴱ ∼-QER) ∼-propositional .proj₁
→∼ :
∀ xs ys →
_≃ᴱ_.to List-bag≃ᴱAssoc-list-bag [ xs ] ≡ [ ys ] →
xs ∼ ys
→∼ xs ys = /ᴱ⟵≃ᴱ/ᴱ⟶ ∼-QER ∼-propositional .proj₂ xs ys .proj₁
@0 →∼-equivalence : ∀ xs ys → Is-equivalence (→∼ xs ys)
→∼-equivalence xs ys =
/ᴱ⟵≃ᴱ/ᴱ⟶ ∼-QER ∼-propositional .proj₂ xs ys .proj₂ .erased
@0 ≃∼ :
∀ xs ys →
(_≃ᴱ_.to List-bag≃ᴱAssoc-list-bag [ xs ] ≡ [ ys ]) ≃ (xs ∼ ys)
≃∼ = /ᴱ⟵≃ᴱ/ᴱ⟶ᴱ (Is-QER→Is-QERᴱ ∼-QER) ∼-propositional .proj₂ .erased
private
instance-of-Suitable→/ᴱ⟵×/ᴱ⟶ =
Suitable→/ᴱ⟵×/ᴱ⟶
Raw-bag-type-List-bag
Raw-bag-type-Assoc-list-bag
(Raw-bag-typeᴿ-univalent .proj₁)
(Is-QER→Is-QERᴱ ∼-QER)
∼-propositional
List-bag∼Assoc-list-bag
Raw-bag-structure-List-bag-/ᴱ :
Raw-bag-structure (List-bag /ᴱ _∼_ ⟵)
Raw-bag-structure-List-bag-/ᴱ = instance-of-Suitable→/ᴱ⟵×/ᴱ⟶ .proj₁
Raw-bag-type-List-bag-/ᴱ : Raw-bag-type
Raw-bag-type-List-bag-/ᴱ =
List-bag /ᴱ _∼_ ⟵ , Raw-bag-structure-List-bag-/ᴱ
Raw-bag-structure-Assoc-list-bag-/ᴱ :
Raw-bag-structure (Assoc-list-bag /ᴱ _∼_ ⟶)
Raw-bag-structure-Assoc-list-bag-/ᴱ =
instance-of-Suitable→/ᴱ⟵×/ᴱ⟶ .proj₂ .proj₁
Raw-bag-type-Assoc-list-bag-/ᴱ : Raw-bag-type
Raw-bag-type-Assoc-list-bag-/ᴱ =
Assoc-list-bag /ᴱ _∼_ ⟶ , Raw-bag-structure-Assoc-list-bag-/ᴱ
@0 List∼List-/ᴱ :
Raw-bag-typeᴿ (Graph [_])
Raw-bag-structure-List-bag Raw-bag-structure-List-bag-/ᴱ
List∼List-/ᴱ = instance-of-Suitable→/ᴱ⟵×/ᴱ⟶ .proj₂ .proj₂ .erased .proj₁
@0 Assoc-list∼Assoc-list-/ᴱ :
Raw-bag-typeᴿ (Graph [_])
Raw-bag-structure-Assoc-list-bag
Raw-bag-structure-Assoc-list-bag-/ᴱ
Assoc-list∼Assoc-list-/ᴱ =
instance-of-Suitable→/ᴱ⟵×/ᴱ⟶ .proj₂ .proj₂ .erased .proj₂ .proj₁
@0 List-/ᴱ∼Assoc-list-/ᴱ :
Raw-bag-typeᴿ (Graph (_≃ᴱ_.to List-bag≃ᴱAssoc-list-bag))
Raw-bag-structure-List-bag-/ᴱ
Raw-bag-structure-Assoc-list-bag-/ᴱ
List-/ᴱ∼Assoc-list-/ᴱ =
instance-of-Suitable→/ᴱ⟵×/ᴱ⟶ .proj₂ .proj₂ .erased .proj₂ .proj₂
@0 List-/ᴱ≡Assoc-list-/ᴱ :
Raw-bag-type-List-bag-/ᴱ ≡ Raw-bag-type-Assoc-list-bag-/ᴱ
List-/ᴱ≡Assoc-list-/ᴱ =
Univalentᴿ→/ᴱ⟵×/ᴱ⟶
Raw-bag-type-List-bag
Raw-bag-type-Assoc-list-bag
Raw-bag-typeᴿ-univalent
(Is-QER→Is-QERᴱ ∼-QER)
∼-propositional
List-bag∼Assoc-list-bag
.proj₂ .proj₂ .erased .proj₂ .proj₂
@0 List-≡≃ :
let count = Raw-bag-structure-List-bag-/ᴱ .proj₂ .proj₂ .proj₂ in
(xs ys : List-bag /ᴱ _∼_ ⟵) →
(xs ≡ ys) ≃ (∀ z → count z xs ≡ count z ys)
List-≡≃ = Q.elim-prop λ @0 where
.Q.is-propositionʳ _ →
Π-closure ext 1 λ _ →
Eq.left-closure ext 0 $
Q./ᴱ-is-set
.Q.[]ʳ xs → Q.elim-prop λ @0 where
.Q.is-propositionʳ _ →
Eq.left-closure ext 0 $
Q./ᴱ-is-set
.Q.[]ʳ ys →
([ xs ] ≡ [ ys ]) ↝⟨ inverse $
Q.related≃[equal]
(Is-QER→Is-equivalence-relation-⟵ ∼-QER)
T.truncation-is-proposition ⟩
(_∼_ ⟵) xs ys ↝⟨ Eq.⇔→≃
T.truncation-is-proposition
(Π-closure ext 1 λ _ → ℕ-set)
(T.rec λ @0 where
.T.truncation-is-propositionʳ →
Π-closure ext 1 λ _ → ℕ-set
.T.∣∣ʳ (zs , xs∼zs , ys∼zs) z →
count₁ z xs ≡⟨ xs∼zs z ⟩
count₂ z zs ≡⟨ sym $ ys∼zs z ⟩∎
count₁ z ys ∎)
(λ xs∼ys →
T.∥∥ᴱ-map
(λ (zs , xs∼zs) →
zs
, xs∼zs
, λ z →
count₁ z ys ≡⟨ sym $ xs∼ys z ⟩
count₁ z xs ≡⟨ xs∼zs z ⟩∎
count₂ z zs ∎)
(∼-QER .proj₂ .proj₁ xs)) ⟩□
(∀ z → count₁ z xs ≡ count₁ z ys) □
@0 Assoc-list-≡≃ :
let count = Raw-bag-structure-Assoc-list-bag-/ᴱ
.proj₂ .proj₂ .proj₂ in
(xs ys : Assoc-list-bag /ᴱ _∼_ ⟶) →
(xs ≡ ys) ≃ (∀ z → count z xs ≡ count z ys)
Assoc-list-≡≃ =
subst
(λ B → let count = B .proj₂ .proj₂ .proj₂ .proj₂ in
(xs ys : B .proj₁) →
(xs ≡ ys) ≃ (∀ z → count z xs ≡ count z ys))
List-/ᴱ≡Assoc-list-/ᴱ
List-≡≃