Skip to content

Commit 314e6d0

Browse files
Deprivatising Function.Related (#413)
1 parent 0354279 commit 314e6d0

File tree

9 files changed

+123
-100
lines changed

9 files changed

+123
-100
lines changed

CHANGELOG.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,9 @@ anticipated any time soon, they may eventually be removed in some future release
335335
```
336336
* In `Function.Related`
337337
```agda
338-
preorder ↦ ↔-preorder
338+
preorder ↦ R-preorder
339+
setoid ↦ SR-setoid
340+
EquationReasoning.sym ↦ SR-sym
339341
```
340342

341343
* In `Function.Related.TypeIsomorphisms`:
@@ -555,6 +557,17 @@ Other minor additions
555557
leftInverse : (∀ x → from (to x) ≡ x) → From ↞ To
556558
```
557559

560+
* Added new proofs to `Function.Related`:
561+
```agda
562+
K-refl : Reflexive (Related k)
563+
K-reflexive : _≡_ ⇒ Related k
564+
K-trans : Trans (Related k) (Related k) (Related k)
565+
K-isPreorder : IsPreorder _↔_ (Related k)
566+
567+
SK-sym : Sym (Related ⌊ k ⌋) (Related ⌊ k ⌋)
568+
SK-isEquivalence : IsEquivalence (Related ⌊ k ⌋)
569+
```
570+
558571
* Added new proofs to `Function.Related.TypeIsomorphisms`:
559572
```agda
560573
×-≡×≡↔≡,≡ : (x ≡ proj₁ p × y ≡ proj₂ p) ↔ (x , y) ≡ p

src/Data/Container/Any.agda

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ open import Function
1919
open import Function.Equality using (_⟨$⟩_)
2020
open import Function.Equivalence using (equivalence)
2121
open import Function.Inverse as Inv using (_↔_; inverse; module Inverse)
22-
open import Function.Related as Related using (Related)
22+
open import Function.Related as Related using (Related; SK-sym)
2323
open import Function.Related.TypeIsomorphisms
2424
open import Relation.Unary using (Pred ; _∪_ ; _∩_)
2525
open import Relation.Binary using (REL)
@@ -58,7 +58,7 @@ module _ {s p} {C : Container s p} {x} {X : Set x}
5858
cong {k} {xs₁} {xs₂} P₁↔P₂ xs₁≈xs₂ =
5959
◇ P₁ xs₁ ↔⟨ ↔∈ C ⟩
6060
(∃ λ x x ∈ xs₁ × P₁ x) ∼⟨ Σ.cong Inv.id (xs₁≈xs₂ ×-cong P₁↔P₂ _) ⟩
61-
(∃ λ x x ∈ xs₂ × P₂ x) ↔⟨ sym (↔∈ C) ⟩
61+
(∃ λ x x ∈ xs₂ × P₂ x) ↔⟨ SK-sym (↔∈ C) ⟩
6262
◇ P₂ xs₂ ∎
6363

6464
-- Nested occurrences of ◇ can sometimes be swapped.
@@ -76,13 +76,13 @@ module _ {s₁ s₂ p₁ p₂} {C₁ : Container s₁ p₁} {C₂ : Container s
7676
(∃ λ x x ∈ xs × ∃ λ y y ∈ ys × P x y) ↔⟨ Σ.cong Inv.id (λ {x} ∃∃↔∃∃ (λ _ y y ∈ ys × P x y)) ⟩
7777
(∃₂ λ x y x ∈ xs × y ∈ ys × P x y) ↔⟨ ∃∃↔∃∃ (λ x y x ∈ xs × y ∈ ys × P x y) ⟩
7878
(∃₂ λ y x x ∈ xs × y ∈ ys × P x y) ↔⟨ Σ.cong Inv.id (λ {y} Σ.cong Inv.id (λ {x}
79-
(x ∈ xs × y ∈ ys × P x y) ↔⟨ sym Σ-assoc ⟩
79+
(x ∈ xs × y ∈ ys × P x y) ↔⟨ SK-sym Σ-assoc ⟩
8080
((x ∈ xs × y ∈ ys) × P x y) ↔⟨ Σ.cong (×-comm _ _) Inv.id ⟩
8181
((y ∈ ys × x ∈ xs) × P x y) ↔⟨ Σ-assoc ⟩
8282
(y ∈ ys × x ∈ xs × P x y) ∎)) ⟩
8383
(∃₂ λ y x y ∈ ys × x ∈ xs × P x y) ↔⟨ Σ.cong Inv.id (λ {y} ∃∃↔∃∃ {B = y ∈ ys} (λ x _ x ∈ xs × P x y)) ⟩
84-
(∃ λ y y ∈ ys × ∃ λ x x ∈ xs × P x y) ↔⟨ Σ.cong Inv.id (Σ.cong Inv.id (sym (↔∈ C₁))) ⟩
85-
(∃ λ y y ∈ ys × ◇ (flip P y) xs) ↔⟨ sym (↔∈ C₂) ⟩
84+
(∃ λ y y ∈ ys × ∃ λ x x ∈ xs × P x y) ↔⟨ Σ.cong Inv.id (Σ.cong Inv.id (SK-sym (↔∈ C₁))) ⟩
85+
(∃ λ y y ∈ ys × ◇ (flip P y) xs) ↔⟨ SK-sym (↔∈ C₂) ⟩
8686
◇ (λ y ◇ (flip P y) xs) ys ∎
8787

8888
-- Nested occurrences of ◇ can sometimes be flattened.
@@ -172,7 +172,7 @@ module _ {s p} (C : Container s p) {x y} {X : Set x} {Y : Set y}
172172
map-cong {f₁ = f₁} {f₂} {xs₁} {xs₂} f₁≗f₂ xs₁≈xs₂ {x} =
173173
x ∈ C.map f₁ xs₁ ↔⟨ map↔∘ C (_≡_ x) f₁ ⟩
174174
◇ (λ y x ≡ f₁ y) xs₁ ∼⟨ cong {xs₁ = xs₁} {xs₂ = xs₂} (Related.↔⇒ ∘ helper) xs₁≈xs₂ ⟩
175-
◇ (λ y x ≡ f₂ y) xs₂ ↔⟨ sym (map↔∘ C (_≡_ x) f₂) ⟩
175+
◇ (λ y x ≡ f₂ y) xs₂ ↔⟨ SK-sym (map↔∘ C (_≡_ x) f₂) ⟩
176176
x ∈ C.map f₂ xs₂ ∎
177177
where
178178
helper : y (x ≡ f₁ y) ↔ (x ≡ f₂ y)
@@ -244,6 +244,6 @@ module _ {s₁ s₂ s₃ p₁ p₂ p₃}
244244
◇ P (join xss) ↔ ◇ (◇ P) xss
245245
join↔◇ join xss =
246246
◇ P (⟪ join ⟫⊸ xss′) ↔⟨ remove-linear P join ⟩
247-
◇ P xss′ ↔⟨ sym $ flatten P xss ⟩
247+
◇ P xss′ ↔⟨ SK-sym $ flatten P xss ⟩
248248
◇ (◇ P) xss ∎
249249
where xss′ = Inverse.from (Composition.correct C₁ C₂) ⟨$⟩ xss

src/Data/List/Any/Properties.agda

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ open import Function
3636
open import Function.Equality using (_⟨$⟩_)
3737
open import Function.Equivalence using (_⇔_; equivalence; Equivalence)
3838
open import Function.Inverse as Inv using (_↔_; inverse; Inverse)
39-
open import Function.Related as Related using (Related)
39+
open import Function.Related as Related using (Related; SK-sym)
4040
open import Relation.Binary
4141
open import Relation.Binary.PropositionalEquality as P
4242
using (_≡_; refl; inspect)
@@ -87,7 +87,7 @@ module _ {a k p q} {A : Set a} {P : Pred A p} {Q : Pred A q} where
8787
Preorder._∼_ (Related.InducedPreorder₂ k {A = A} _∈_) xs ys
8888
Related k (Any P xs) (Any Q ys)
8989
Any-cong {xs} {ys} P↔Q xs≈ys =
90-
Any P xs ↔⟨ sym Any↔ ⟩
90+
Any P xs ↔⟨ SK-sym Any↔ ⟩
9191
(∃ λ x x ∈ xs × P x) ∼⟨ Σ.cong Inv.id (xs≈ys ×-cong P↔Q _) ⟩
9292
(∃ λ x x ∈ ys × Q x) ↔⟨ Any↔ ⟩
9393
Any Q ys ∎

src/Data/List/Relation/BagAndSetEquality.agda

+9-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ open import Function
2424
open import Function.Equality using (_⟨$⟩_)
2525
import Function.Equivalence as FE
2626
open import Function.Inverse as Inv using (_↔_; Inverse; inverse)
27-
open import Function.Related as Related using (↔⇒; ⌊_⌋; ⌊_⌋→; ⇒→)
27+
open import Function.Related as Related using (↔⇒; ⌊_⌋; ⌊_⌋→; ⇒→; SK-sym)
2828
open import Function.Related.TypeIsomorphisms
2929
open import Relation.Binary
3030
import Relation.Binary.EqReasoning as EqR
@@ -98,7 +98,7 @@ module _ {a k} {A : Set a} {x y : A} {xs ys} where
9898

9999
∷-cong : x ≡ y xs ∼[ k ] ys x ∷ xs ∼[ k ] y ∷ ys
100100
∷-cong refl xs≈ys {y} =
101-
y ∈ x ∷ xs ↔⟨ sym $ ∷↔ (y ≡_) ⟩
101+
y ∈ x ∷ xs ↔⟨ SK-sym $ ∷↔ (y ≡_) ⟩
102102
(y ≡ x ⊎ y ∈ xs) ∼⟨ (y ≡ x ∎) ⊎-cong xs≈ys ⟩
103103
(y ≡ x ⊎ y ∈ ys) ↔⟨ ∷↔ (y ≡_) ⟩
104104
y ∈ x ∷ ys ∎
@@ -111,7 +111,7 @@ module _ {ℓ k} {A B : Set ℓ} {f g : A → B} {xs ys} where
111111

112112
map-cong : f ≗ g xs ∼[ k ] ys map f xs ∼[ k ] map g ys
113113
map-cong f≗g xs≈ys {x} =
114-
x ∈ map f xs ↔⟨ sym $ map↔ ⟩
114+
x ∈ map f xs ↔⟨ SK-sym $ map↔ ⟩
115115
Any (λ y x ≡ f y) xs ∼⟨ Any-cong (↔⇒ ∘ helper) xs≈ys ⟩
116116
Any (λ y x ≡ g y) ys ↔⟨ map↔ ⟩
117117
x ∈ map g ys ∎
@@ -136,7 +136,7 @@ module _ {a k} {A : Set a} {xs₁ xs₂ ys₁ ys₂ : List A} where
136136
++-cong : xs₁ ∼[ k ] xs₂ ys₁ ∼[ k ] ys₂
137137
xs₁ ++ ys₁ ∼[ k ] xs₂ ++ ys₂
138138
++-cong xs₁≈xs₂ ys₁≈ys₂ {x} =
139-
x ∈ xs₁ ++ ys₁ ↔⟨ sym $ ++↔ ⟩
139+
x ∈ xs₁ ++ ys₁ ↔⟨ SK-sym $ ++↔ ⟩
140140
(x ∈ xs₁ ⊎ x ∈ ys₁) ∼⟨ xs₁≈xs₂ ⊎-cong ys₁≈ys₂ ⟩
141141
(x ∈ xs₂ ⊎ x ∈ ys₂) ↔⟨ ++↔ ⟩
142142
x ∈ xs₂ ++ ys₂ ∎
@@ -149,7 +149,7 @@ module _ {a k} {A : Set a} {xss yss : List (List A)} where
149149

150150
concat-cong : xss ∼[ k ] yss concat xss ∼[ k ] concat yss
151151
concat-cong xss≈yss {x} =
152-
x ∈ concat xss ↔⟨ sym concat↔ ⟩
152+
x ∈ concat xss ↔⟨ SK-sym concat↔ ⟩
153153
Any (Any (x ≡_)) xss ∼⟨ Any-cong (λ _ _ ∎) xss≈yss ⟩
154154
Any (Any (x ≡_)) yss ↔⟨ concat↔ ⟩
155155
x ∈ concat yss ∎
@@ -163,7 +163,7 @@ module _ {ℓ k} {A B : Set ℓ} {xs ys} {f g : A → List B} where
163163
>>=-cong : xs ∼[ k ] ys ( x f x ∼[ k ] g x)
164164
(xs >>= f) ∼[ k ] (ys >>= g)
165165
>>=-cong xs≈ys f≈g {x} =
166-
x ∈ (xs >>= f) ↔⟨ sym >>=↔ ⟩
166+
x ∈ (xs >>= f) ↔⟨ SK-sym >>=↔ ⟩
167167
Any (λ y x ∈ f y) xs ∼⟨ Any-cong (λ x f≈g x) xs≈ys ⟩
168168
Any (λ y x ∈ g y) ys ↔⟨ >>=↔ ⟩
169169
x ∈ (ys >>= g) ∎
@@ -243,9 +243,9 @@ empty-unique {xs = _ ∷ _} ∷∼[] with ⇒→ ∷∼[] (here refl)
243243
{ℓ} {A B : Set ℓ} (xs : List A) {f g : A List B}
244244
(xs >>= λ x f x ++ g x) ∼[ bag ] (xs >>= f) ++ (xs >>= g)
245245
>>=-left-distributive {ℓ} xs {f} {g} {y} =
246-
y ∈ (xs >>= λ x f x ++ g x) ↔⟨ sym $ >>=↔ ⟩
247-
Any (λ x y ∈ f x ++ g x) xs ↔⟨ sym (Any-cong (λ _ ++↔) (_ ∎)) ⟩
248-
Any (λ x y ∈ f x ⊎ y ∈ g x) xs ↔⟨ sym $ ⊎↔ ⟩
246+
y ∈ (xs >>= λ x f x ++ g x) ↔⟨ SK-sym $ >>=↔ ⟩
247+
Any (λ x y ∈ f x ++ g x) xs ↔⟨ SK-sym (Any-cong (λ _ ++↔) (_ ∎)) ⟩
248+
Any (λ x y ∈ f x ⊎ y ∈ g x) xs ↔⟨ SK-sym $ ⊎↔ ⟩
249249
(Any (λ x y ∈ f x) xs ⊎ Any (λ x y ∈ g x) xs) ↔⟨ >>=↔ ⟨ _⊎-cong_ ⟩ >>=↔ ⟩
250250
(y ∈ (xs >>= f) ⊎ y ∈ (xs >>= g)) ↔⟨ ++↔ ⟩
251251
y ∈ (xs >>= f) ++ (xs >>= g) ∎

src/Data/Product/Relation/Pointwise/Dependent.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ private
398398
B₁ (Inverse.from A₁↔A₂ ⟨$⟩ x)
399399
∼⟨ eq ⟩
400400
B₂ (Inverse.to A₁↔A₂ ⟨$⟩ (Inverse.from A₁↔A₂ ⟨$⟩ x))
401-
↔⟨ B.Setoid.reflexive (Related.setoid Related.bijection _)
401+
↔⟨ Related.K-reflexive
402402
(P.cong B₂ $ Inverse.right-inverse-of A₁↔A₂ x) ⟩
403403
B₂ x
404404

src/Data/Product/Relation/Pointwise/NonDependent.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ open import Function.Inverse as Inv
2020
using (Inverse; _↔_; module Inverse)
2121
open import Function.LeftInverse as LeftInv
2222
using (LeftInverse; _↞_; _LeftInverseOf_; module LeftInverse)
23-
open import Function.Related hiding (isEquivalence)
23+
open import Function.Related
2424
open import Function.Surjection as Surj
2525
using (Surjection; _↠_; module Surjection)
2626
import Relation.Nullary.Decidable as Dec

src/Data/Sum/Relation/Pointwise.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ open import Function.Inverse as Inv
2020
using (Inverse; _↔_; module Inverse)
2121
open import Function.LeftInverse as LeftInv
2222
using (LeftInverse; _↞_; module LeftInverse)
23-
open import Function.Related hiding (isEquivalence)
23+
open import Function.Related
2424
open import Function.Surjection as Surj
2525
using (Surjection; _↠_; module Surjection)
2626
open import Relation.Nullary

0 commit comments

Comments
 (0)