Skip to content

Commit ca27adf

Browse files
javierdiaz72jamesmckinnagallais
authored
Add map⁻ to Unique (#2742)
* Add `map⁻` to `Unique` * Update src/Data/List/Relation/Unary/AllPairs/Properties.agda Co-authored-by: jamesmckinna <[email protected]> * Update `CHANGELOG.md` * Fix bug by bringing `_on_` into scope * backport use of `_on_` * fix: whitespace * [ fix ] functions are always congruent wrt propeq * fix: removed redundant `import` --------- Co-authored-by: jamesmckinna <[email protected]> Co-authored-by: jamesmckinna <[email protected]> Co-authored-by: Guillaume Allais <[email protected]>
1 parent 4b3bb54 commit ca27adf

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,4 +327,18 @@ Additions to existing modules
327327
```agda
328328
⊤-reflects : Reflects (⊤ {a}) true
329329
⊥-reflects : Reflects (⊥ {a}) false
330+
331+
* In `Data.List.Relation.Unary.AllPairs.Properties`:
332+
```agda
333+
map⁻ : AllPairs R (map f xs) → AllPairs (R on f) xs
334+
```
335+
336+
* In `Data.List.Relation.Unary.Unique.Setoid.Properties`:
337+
```agda
338+
map⁻ : Congruent _≈₁_ _≈₂_ f → Unique R (map f xs) → Unique S xs
339+
```
340+
341+
* In `Data.List.Relation.Unary.Unique.Propositional.Properties`:
342+
```agda
343+
map⁻ : Unique (map f xs) → Unique xs
330344
```

src/Data/List/Relation/Unary/AllPairs/Properties.agda

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ open import Data.Fin.Base as F using (Fin)
2020
open import Data.Fin.Properties using (suc-injective; <⇒≢)
2121
open import Data.Nat.Base using (zero; suc; _<_; z≤n; s≤s; z<s; s<s)
2222
open import Data.Nat.Properties using (≤-refl; m<n⇒m<1+n)
23-
open import Function.Base using (_∘_; flip)
23+
open import Function.Base using (_∘_; flip; _on_)
2424
open import Level using (Level)
2525
open import Relation.Binary.Core using (Rel)
2626
open import Relation.Binary.Bundles using (DecSetoid)
@@ -42,11 +42,14 @@ private
4242

4343
module _ {R : Rel A ℓ} {f : B A} where
4444

45-
map⁺ : {xs} AllPairs (λ x y R (f x) (f y)) xs
46-
AllPairs R (map f xs)
45+
map⁺ : {xs} AllPairs (R on f) xs AllPairs R (map f xs)
4746
map⁺ [] = []
4847
map⁺ (x∉xs ∷ xs!) = All.map⁺ x∉xs ∷ map⁺ xs!
4948

49+
map⁻ : {xs} AllPairs R (map f xs) AllPairs (R on f) xs
50+
map⁻ {[]} _ = []
51+
map⁻ {_ ∷ _} (fx∉fxs ∷ fxs!) = All.map⁻ fx∉fxs ∷ map⁻ fxs!
52+
5053
------------------------------------------------------------------------
5154
-- ++
5255

src/Data/List/Relation/Unary/Unique/Propositional/Properties.agda

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ open import Level using (Level)
3030
open import Relation.Binary.Core using (Rel)
3131
open import Relation.Binary.Bundles using (Setoid)
3232
open import Relation.Binary.PropositionalEquality.Core
33-
using (refl; _≡_; _≢_; sym)
33+
using (refl; _≡_; _≢_; sym; cong)
3434
open import Relation.Binary.PropositionalEquality.Properties using (setoid)
3535
open import Relation.Unary using (Pred; Decidable)
3636
open import Relation.Nullary.Negation using (¬_)
@@ -53,6 +53,9 @@ module _ {A : Set a} {B : Set b} where
5353
{xs} Unique xs Unique (map f xs)
5454
map⁺ = Setoid.map⁺ (setoid A) (setoid B)
5555

56+
map⁻ : {f xs} Unique (map f xs) Unique xs
57+
map⁻ = Setoid.map⁻ (setoid A) (setoid B) (cong _)
58+
5659
------------------------------------------------------------------------
5760
-- ++
5861

src/Data/List/Relation/Unary/Unique/Setoid/Properties.agda

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Data.List.Relation.Unary.AllPairs.Properties as AllPairs
2424
open import Data.Fin.Base using (Fin)
2525
open import Data.Nat.Base using (_<_)
2626
open import Function.Base using (_∘_; id)
27+
open import Function.Definitions using (Congruent)
2728
open import Level using (Level)
2829
open import Relation.Binary.Core using (Rel)
2930
open import Relation.Binary.Bundles using (Setoid)
@@ -50,6 +51,10 @@ module _ (S : Setoid a ℓ₁) (R : Setoid b ℓ₂) where
5051
{xs} Unique S xs Unique R (map f xs)
5152
map⁺ inj xs! = AllPairs.map⁺ (AllPairs.map (contraposition inj) xs!)
5253

54+
map⁻ : {f} Congruent _≈₁_ _≈₂_ f
55+
{xs} Unique R (map f xs) Unique S xs
56+
map⁻ cong fxs! = AllPairs.map (contraposition cong) (AllPairs.map⁻ fxs!)
57+
5358
------------------------------------------------------------------------
5459
-- ++
5560

0 commit comments

Comments
 (0)