Skip to content

Commit 08fb122

Browse files
committed
fix: symmetry of Bijection; deprecate sym-≡
1 parent 576610f commit 08fb122

File tree

1 file changed

+41
-24
lines changed

1 file changed

+41
-24
lines changed

src/Function/Properties/Bijection.agda

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ open import Relation.Binary.Definitions using (Reflexive; Trans)
1717
open import Relation.Binary.PropositionalEquality.Properties using (setoid)
1818
open import Data.Product.Base using (_,_; proj₁; proj₂)
1919
open import Function.Base using (_∘_)
20-
open import Function.Properties.Surjection using (injective⇒to⁻-cong)
21-
open import Function.Properties.Inverse using (Inverse⇒Equivalence)
20+
open import Function.Properties.Surjection using (injective⇒section-cong)
21+
open import Function.Properties.Inverse
22+
using (Inverse⇒Bijection; Inverse⇒Equivalence)
2223

2324
import Function.Construct.Identity as Identity
2425
import Function.Construct.Symmetry as Symmetry
@@ -30,16 +31,33 @@ private
3031
A B : Set a
3132
T S : Setoid a ℓ
3233

34+
------------------------------------------------------------------------
35+
-- Conversion functions
36+
37+
Bijection⇒Inverse : Bijection S T Inverse S T
38+
Bijection⇒Inverse bij = record
39+
{ to = to
40+
; from = section
41+
; to-cong = cong
42+
; from-cong = injective⇒section-cong surjection injective
43+
; inverse = section-inverseˡ
44+
, λ y≈to[x] injective (Eq₂.trans (section-strictInverseˡ _) y≈to[x])
45+
}
46+
where open Bijection bij
47+
48+
Bijection⇒Equivalence : Bijection T S Equivalence T S
49+
Bijection⇒Equivalence = Inverse⇒Equivalence ∘ Bijection⇒Inverse
50+
3351
------------------------------------------------------------------------
3452
-- Setoid properties
3553

3654
refl : Reflexive (Bijection {a} {ℓ})
3755
refl = Identity.bijection _
3856

39-
-- Can't prove full symmetry as we have no proof that the witness
40-
-- produced by the surjection proof preserves equality
41-
sym-≡ : Bijection S (setoid B) Bijection (setoid B) S
42-
sym-≡ = Symmetry.bijection-≡
57+
-- Now we *can* prove full symmetry as we now have a proof that
58+
-- the witness produced by the surjection proof preserves equality
59+
sym : Bijection S T Bijection T S
60+
sym = Inverse⇒Bijection ∘ Symmetry.inverse ∘ Bijection⇒Inverse
4361

4462
trans : Trans (Bijection {a} {ℓ₁} {b} {ℓ₂}) (Bijection {b} {ℓ₂} {c} {ℓ₃}) Bijection
4563
trans = Composition.bijection
@@ -50,29 +68,28 @@ trans = Composition.bijection
5068
⤖-isEquivalence : IsEquivalence {ℓ = ℓ} _⤖_
5169
⤖-isEquivalence = record
5270
{ refl = refl
53-
; sym = sym-≡
71+
; sym = sym
5472
; trans = trans
5573
}
5674

57-
------------------------------------------------------------------------
58-
-- Conversion functions
59-
60-
Bijection⇒Inverse : Bijection S T Inverse S T
61-
Bijection⇒Inverse bij = record
62-
{ to = to
63-
; from = section
64-
; to-cong = cong
65-
; from-cong = injective⇒to⁻-cong surjection injective
66-
; inverse = (λ y≈to⁻[x] Eq₂.trans (cong y≈to⁻[x]) (to∘to⁻ _)) ,
67-
(λ y≈to[x] injective (Eq₂.trans (to∘to⁻ _) y≈to[x]))
68-
}
69-
where open Bijection bij
70-
71-
Bijection⇒Equivalence : Bijection T S Equivalence T S
72-
Bijection⇒Equivalence = Inverse⇒Equivalence ∘ Bijection⇒Inverse
73-
7475
⤖⇒↔ : A ⤖ B A ↔ B
7576
⤖⇒↔ = Bijection⇒Inverse
7677

7778
⤖⇒⇔ : A ⤖ B A ⇔ B
7879
⤖⇒⇔ = Bijection⇒Equivalence
80+
81+
82+
------------------------------------------------------------------------
83+
-- DEPRECATED NAMES
84+
------------------------------------------------------------------------
85+
-- Please use the new names as continuing support for the old names is
86+
-- not guaranteed.
87+
88+
-- Version 2.3
89+
90+
sym-≡ : Bijection S (setoid B) Bijection (setoid B) S
91+
sym-≡ = Symmetry.bijection-≡
92+
{-# WARNING_ON_USAGE sym-≡
93+
"Warning: sym-≡ was deprecated in v2.3.
94+
Please use sym instead. "
95+
#-}

0 commit comments

Comments
 (0)