Skip to content

Commit 106caef

Browse files
committed
Share Sum and Product type isomorphism proof
1 parent 3628383 commit 106caef

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/Data/Product/Properties.agda

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ map-cong f≗g h≗i (x , y) = cong₂ _,_ (f≗g x) (h≗i y)
6464
swap-involutive : swap {A = A} {B = B} ∘ swap ≗ id
6565
swap-involutive _ = refl
6666

67+
swap-↔ : (A × B) ↔ (B × A)
68+
swap-↔ = mk↔ₛ′ swap swap swap-involutive swap-involutive
69+
6770
------------------------------------------------------------------------
6871
-- Equality between pairs can be expressed as a pair of equalities
6972

src/Function/Related/TypeIsomorphisms.agda

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ open import Data.Empty.Polymorphic using (⊥; ⊥-elim)
2424
open import Data.Product.Base as Product
2525
using (_×_; Σ; curry; uncurry; _,_; -,_; <_,_>; proj₁; proj₂; ∃₂; ∃; ∃-syntax)
2626
open import Data.Product.Function.NonDependent.Propositional
27+
import Data.Product.Properties as Product
2728
open import Data.Sum.Base as Sum
28-
open import Data.Sum.Properties using (swap-involutive)
29+
import Data.Sum.Properties as Sum
2930
open import Data.Sum.Function.Propositional using (_⊎-cong_)
3031
open import Data.Unit.Polymorphic.Base using (⊤)
3132
open import Level using (Level; Lift; 0ℓ; suc)
@@ -63,7 +64,7 @@ open import Relation.Nullary.Decidable public
6364
-- × is commutative
6465

6566
×-comm : (A : Set a) (B : Set b) (A × B) ↔ (B × A)
66-
×-comm _ _ = mk↔ₛ′ Product.swap Product.swap (λ _ refl) λ _ refl
67+
×-comm _ _ = Product.swap-↔
6768

6869
-- × has ⊤ as its identity
6970

@@ -102,7 +103,7 @@ open import Relation.Nullary.Decidable public
102103
-- ⊎ is commutative
103104

104105
⊎-comm : (A : Set a) (B : Set b) (A ⊎ B) ↔ (B ⊎ A)
105-
⊎-comm _ _ = mk↔ₛ′ swap swap swap-involutive swap-involutive
106+
⊎-comm _ _ = Sum.swap-↔
106107

107108
-- ⊎ has ⊥ as its identity
108109

@@ -279,13 +280,7 @@ open import Relation.Nullary.Decidable public
279280

280281
∃∃↔∃∃ : {a b p} {A : Set a} {B : Set b} (P : A B Set p)
281282
(∃₂ λ x y P x y) ↔ (∃₂ λ y x P x y)
282-
∃∃↔∃∃ P = mk↔ₛ′ to from (λ _ refl) (λ _ refl)
283-
where
284-
to : (∃₂ λ x y P x y) (∃₂ λ y x P x y)
285-
to (x , y , Pxy) = (y , x , Pxy)
286-
287-
from : (∃₂ λ y x P x y) (∃₂ λ x y P x y)
288-
from (y , x , Pxy) = (x , y , Pxy)
283+
∃∃↔∃∃ = Product.∃∃↔∃∃
289284

290285
------------------------------------------------------------------------
291286
-- Implicit and explicit function spaces are isomorphic

0 commit comments

Comments
 (0)