395
425
from-cong : P._≡_ ⇒ (P._≡_ ⊎-Rel P._≡_)
396
426
from-cong P.refl = P.refl ⊎-refl P.refl
399
429
∀ {s₁ s₂ s₃ s₄ s₅ s₆ s₇ s₈}
400
430
{A : Setoid s₁ s₂} {B : Setoid s₃ s₄}
401
431
{C : Setoid s₅ s₆} {D : Setoid s₇ s₈} →
402
Equivalent A B → Equivalent C D →
403
Equivalent (A ⊎-setoid C) (B ⊎-setoid D)
404
_⊎-equivalent_ {A = A} {B} {C} {D} A⇔B C⇔D = record
405
{ to = record { _⟨$⟩_ = to; cong = to-cong }
406
; from = record { _⟨$⟩_ = from; cong = from-cong }
432
A ⟶ B → C ⟶ D → (A ⊎-setoid C) ⟶ (B ⊎-setoid D)
433
_⊎-⟶_ {A = A} {B} {C} {D} f g = record
409
438
open Setoid (A ⊎-setoid C) using () renaming (_≈_ to _≈AC_)
410
439
open Setoid (B ⊎-setoid D) using () renaming (_≈_ to _≈BD_)
412
to = Sum.map (_⟨$⟩_ (Equivalent.to A⇔B))
413
(_⟨$⟩_ (Equivalent.to C⇔D))
415
to-cong : _≈AC_ =[ to ]⇒ _≈BD_
417
to-cong (₁∼₁ x∼₁y) = ₁∼₁ $ F.cong (Equivalent.to A⇔B) x∼₁y
418
to-cong (₂∼₂ x∼₂y) = ₂∼₂ $ F.cong (Equivalent.to C⇔D) x∼₂y
420
from = Sum.map (_⟨$⟩_ (Equivalent.from A⇔B))
421
(_⟨$⟩_ (Equivalent.from C⇔D))
423
from-cong : _≈BD_ =[ from ]⇒ _≈AC_
425
from-cong (₁∼₁ x∼₁y) = ₁∼₁ $ F.cong (Equivalent.from A⇔B) x∼₁y
426
from-cong (₂∼₂ x∼₂y) = ₂∼₂ $ F.cong (Equivalent.from C⇔D) x∼₂y
441
fg = Sum.map (_⟨$⟩_ f) (_⟨$⟩_ g)
443
fg-cong : _≈AC_ =[ fg ]⇒ _≈BD_
445
fg-cong (₁∼₁ x∼₁y) = ₁∼₁ $ F.cong f x∼₁y
446
fg-cong (₂∼₂ x∼₂y) = ₂∼₂ $ F.cong g x∼₂y
449
∀ {s₁ s₂ s₃ s₄ s₅ s₆ s₇ s₈}
450
{A : Setoid s₁ s₂} {B : Setoid s₃ s₄}
451
{C : Setoid s₅ s₆} {D : Setoid s₇ s₈} →
452
Equivalence A B → Equivalence C D →
453
Equivalence (A ⊎-setoid C) (B ⊎-setoid D)
454
A⇔B ⊎-equivalence C⇔D = record
455
{ to = to A⇔B ⊎-⟶ to C⇔D
456
; from = from A⇔B ⊎-⟶ from C⇔D
457
} where open Equivalence
428
459
_⊎-⇔_ : ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} →
429
460
A ⇔ B → C ⇔ D → (A ⊎ C) ⇔ (B ⊎ D)
430
461
_⊎-⇔_ {A = A} {B} {C} {D} A⇔B C⇔D =
431
Inverse.equivalent (⊎-Rel⇿≡ B D) ⟨∘⟩
432
A⇔B ⊎-equivalent C⇔D ⟨∘⟩
433
Eq.sym (Inverse.equivalent (⊎-Rel⇿≡ A C))
462
Inverse.equivalence (⊎-Rel↔≡ B D) ⟨∘⟩
463
A⇔B ⊎-equivalence C⇔D ⟨∘⟩
464
Eq.sym (Inverse.equivalence (⊎-Rel↔≡ A C))
465
where open Eq using () renaming (_∘_ to _⟨∘⟩_)
468
∀ {s₁ s₂ s₃ s₄ s₅ s₆ s₇ s₈}
469
{A : Setoid s₁ s₂} {B : Setoid s₃ s₄}
470
{C : Setoid s₅ s₆} {D : Setoid s₇ s₈} →
471
Injection A B → Injection C D →
472
Injection (A ⊎-setoid C) (B ⊎-setoid D)
473
_⊎-injection_ {A = A} {B} {C} {D} A↣B C↣D = record
474
{ to = to A↣B ⊎-⟶ to C↣D
475
; injective = inj _ _
479
open Setoid (A ⊎-setoid C) using () renaming (_≈_ to _≈AC_)
480
open Setoid (B ⊎-setoid D) using () renaming (_≈_ to _≈BD_)
483
(to A↣B ⊎-⟶ to C↣D) ⟨$⟩ x ≈BD (to A↣B ⊎-⟶ to C↣D) ⟨$⟩ y →
485
inj (inj₁ x) (inj₁ y) (₁∼₁ x∼₁y) = ₁∼₁ (injective A↣B x∼₁y)
486
inj (inj₂ x) (inj₂ y) (₂∼₂ x∼₂y) = ₂∼₂ (injective C↣D x∼₂y)
487
inj (inj₁ x) (inj₂ y) (₁∼₂ ())
488
inj (inj₂ x) (inj₁ y) ()
490
_⊎-↣_ : ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} →
491
A ↣ B → C ↣ D → (A ⊎ C) ↣ (B ⊎ D)
492
_⊎-↣_ {A = A} {B} {C} {D} A↣B C↣D =
493
Inverse.injection (⊎-Rel↔≡ B D) ⟨∘⟩
494
A↣B ⊎-injection C↣D ⟨∘⟩
495
Inverse.injection (Inv.sym (⊎-Rel↔≡ A C))
496
where open Inj using () renaming (_∘_ to _⟨∘⟩_)
499
∀ {s₁ s₂ s₃ s₄ s₅ s₆ s₇ s₈}
500
{A : Setoid s₁ s₂} {B : Setoid s₃ s₄}
501
{C : Setoid s₅ s₆} {D : Setoid s₇ s₈} →
502
LeftInverse A B → LeftInverse C D →
503
LeftInverse (A ⊎-setoid C) (B ⊎-setoid D)
504
A↞B ⊎-left-inverse C↞D = record
505
{ to = Equivalence.to eq
506
; from = Equivalence.from eq
507
; left-inverse-of = [ ₁∼₁ ∘ left-inverse-of A↞B
508
, ₂∼₂ ∘ left-inverse-of C↞D
513
eq = LeftInverse.equivalence A↞B ⊎-equivalence
514
LeftInverse.equivalence C↞D
516
_⊎-↞_ : ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} →
517
A ↞ B → C ↞ D → (A ⊎ C) ↞ (B ⊎ D)
518
_⊎-↞_ {A = A} {B} {C} {D} A↞B C↞D =
519
Inverse.left-inverse (⊎-Rel↔≡ B D) ⟨∘⟩
520
A↞B ⊎-left-inverse C↞D ⟨∘⟩
521
Inverse.left-inverse (Inv.sym (⊎-Rel↔≡ A C))
522
where open LeftInv using () renaming (_∘_ to _⟨∘⟩_)
525
∀ {s₁ s₂ s₃ s₄ s₅ s₆ s₇ s₈}
526
{A : Setoid s₁ s₂} {B : Setoid s₃ s₄}
527
{C : Setoid s₅ s₆} {D : Setoid s₇ s₈} →
528
Surjection A B → Surjection C D →
529
Surjection (A ⊎-setoid C) (B ⊎-setoid D)
530
A↠B ⊎-surjection C↠D = record
531
{ to = LeftInverse.from inv
532
; surjective = record
533
{ from = LeftInverse.to inv
534
; right-inverse-of = LeftInverse.left-inverse-of inv
539
inv = right-inverse A↠B ⊎-left-inverse right-inverse C↠D
541
_⊎-↠_ : ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} →
542
A ↠ B → C ↠ D → (A ⊎ C) ↠ (B ⊎ D)
543
_⊎-↠_ {A = A} {B} {C} {D} A↠B C↠D =
544
Inverse.surjection (⊎-Rel↔≡ B D) ⟨∘⟩
545
A↠B ⊎-surjection C↠D ⟨∘⟩
546
Inverse.surjection (Inv.sym (⊎-Rel↔≡ A C))
547
where open Surj using () renaming (_∘_ to _⟨∘⟩_)
436
550
∀ {s₁ s₂ s₃ s₄ s₅ s₆ s₇ s₈}
437
551
{A : Setoid s₁ s₂} {B : Setoid s₃ s₄}
438
552
{C : Setoid s₅ s₆} {D : Setoid s₇ s₈} →
439
553
Inverse A B → Inverse C D → Inverse (A ⊎-setoid C) (B ⊎-setoid D)
440
A⇿B ⊎-inverse C⇿D = record
441
{ to = Equivalent.to eq
442
; from = Equivalent.from eq
554
A↔B ⊎-inverse C↔D = record
555
{ to = Surjection.to surj
556
; from = Surjection.from surj
443
557
; inverse-of = record
444
{ left-inverse-of = [ ₁∼₁ ∘ left-inverse-of A⇿B
445
, ₂∼₂ ∘ left-inverse-of C⇿D
447
; right-inverse-of = [ ₁∼₁ ∘ right-inverse-of A⇿B
448
, ₂∼₂ ∘ right-inverse-of C⇿D
558
{ left-inverse-of = LeftInverse.left-inverse-of inv
559
; right-inverse-of = Surjection.right-inverse-of surj
454
eq = equivalent A⇿B ⊎-equivalent equivalent C⇿D
456
_⊎-⇿_ : ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} →
457
A ⇿ B → C ⇿ D → (A ⊎ C) ⇿ (B ⊎ D)
458
_⊎-⇿_ {A = A} {B} {C} {D} A⇿B C⇿D =
459
⊎-Rel⇿≡ B D ⟪∘⟫ A⇿B ⊎-inverse C⇿D ⟪∘⟫ Inv.sym (⊎-Rel⇿≡ A C)
564
surj = Inverse.surjection A↔B ⊎-surjection
565
Inverse.surjection C↔D
566
inv = Inverse.left-inverse A↔B ⊎-left-inverse
567
Inverse.left-inverse C↔D
569
_⊎-↔_ : ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} →
570
A ↔ B → C ↔ D → (A ⊎ C) ↔ (B ⊎ D)
571
_⊎-↔_ {A = A} {B} {C} {D} A↔B C↔D =
572
⊎-Rel↔≡ B D ⟨∘⟩ A↔B ⊎-inverse C↔D ⟨∘⟩ Inv.sym (⊎-Rel↔≡ A C)
573
where open Inv using () renaming (_∘_ to _⟨∘⟩_)
575
_⊎-cong_ : ∀ {k a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} →
576
A ∼[ k ] B → C ∼[ k ] D → (A ⊎ C) ∼[ k ] (B ⊎ D)
577
_⊎-cong_ {implication} = Sum.map
578
_⊎-cong_ {reverse-implication} = λ f g → lam (Sum.map (app-← f) (app-← g))
579
_⊎-cong_ {equivalence} = _⊎-⇔_
580
_⊎-cong_ {injection} = _⊎-↣_
581
_⊎-cong_ {reverse-injection} = λ f g → lam (app-↢ f ⊎-↣ app-↢ g)
582
_⊎-cong_ {left-inverse} = _⊎-↞_
583
_⊎-cong_ {surjection} = _⊎-↠_
584
_⊎-cong_ {bijection} = _⊎-↔_