Skip to content

Commit 824cca0

Browse files
MatthewDaggittandreasabel
authored andcommitted
Weakened pre-conditions of grouped map lemmas (#2108)
1 parent 2589f89 commit 824cca0

File tree

3 files changed

+40
-25
lines changed

3 files changed

+40
-25
lines changed

CHANGELOG.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,10 @@ Non-backwards compatible changes
851851
found in `Data.List.NonEmpty.Properties` under the names `groupSeqs-groups`
852852
and `ungroupSeqs` and `groupSeqs`.
853853

854+
* In `Data.List.Relation.Unary.Grouped.Properties` the proofs `map⁺` and `map⁻`
855+
have had their preconditions weakened so the equivalences no longer require congruence
856+
proofs.
857+
854858
* The constructors `+0` and `+[1+_]` from `Data.Integer.Base` are no longer
855859
exported by `Data.Rational.Base`. You will have to open `Data.Integer(.Base)`
856860
directly to use them.
@@ -1349,6 +1353,11 @@ Deprecated names
13491353
map-with-∈↔ ↦ mapWith∈↔
13501354
```
13511355
1356+
* In `Data.List.Relation.Unary.All.Properties`:
1357+
```
1358+
gmap ↦ gmap⁺
1359+
```
1360+
13521361
* In `Data.Nat.Properties`:
13531362
```
13541363
suc[pred[n]]≡n ↦ suc-pred
@@ -3462,6 +3471,11 @@ This is a full list of proofs that have changed form to use irrelevant instance
34623471
#-congˡ : y ≈ z → x # y → x # z
34633472
```
34643473

3474+
* Added new proof to `Data.List.Relation.Unary.All.Properties`:
3475+
```agda
3476+
gmap⁻ : Q ∘ f ⋐ P → All Q ∘ map f ⋐ All P
3477+
```
3478+
34653479
* Added new proofs to `Data.List.Relation.Binary.Sublist.Setoid.Properties`
34663480
and `Data.List.Relation.Unary.Sorted.TotalOrder.Properties`.
34673481
```agda
@@ -3484,4 +3498,4 @@ This is a full list of proofs that have changed form to use irrelevant instance
34843498
b #⟨ b#c ⟩
34853499
c ≈⟨ c≈d ⟩
34863500
d ∎
3487-
```
3501+
```

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

+12-3
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,11 @@ map⁻ {xs = _ ∷ _} (p ∷ ps) = p ∷ map⁻ ps
371371

372372
-- A variant of All.map.
373373

374-
gmap : {f : A B} P ⋐ Q ∘ f All P ⋐ All Q ∘ map f
375-
gmap g = map⁺ ∘ All.map g
374+
gmap⁺ : {f : A B} P ⋐ Q ∘ f All P ⋐ All Q ∘ map f
375+
gmap⁺ g = map⁺ ∘ All.map g
376+
377+
gmap⁻ : {f : A B} Q ∘ f ⋐ P All Q ∘ map f ⋐ All P
378+
gmap⁻ g = All.map g ∘ map⁻
376379

377380
------------------------------------------------------------------------
378381
-- mapMaybe
@@ -679,7 +682,7 @@ replicate⁻ (px ∷ _) = px
679682

680683
inits⁺ : All P xs All (All P) (inits xs)
681684
inits⁺ [] = [] ∷ []
682-
inits⁺ (px ∷ pxs) = [] ∷ gmap (px ∷_) (inits⁺ pxs)
685+
inits⁺ (px ∷ pxs) = [] ∷ gmap (px ∷_) (inits⁺ pxs)
683686

684687
inits⁻ : xs All (All P) (inits xs) All P xs
685688
inits⁻ [] pxs = []
@@ -773,3 +776,9 @@ updateAt-cong-relative = updateAt-cong-local
773776
"Warning: updateAt-cong-relative was deprecated in v2.0.
774777
Please use updateAt-cong-local instead."
775778
#-}
779+
780+
gmap = gmap⁺
781+
{-# WARNING_ON_USAGE gmap
782+
"Warning: gmap was deprecated in v2.0.
783+
Please use gmap⁺ instead."
784+
#-}

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

+13-21
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ open import Data.List.Relation.Unary.All as All using (All; []; _∷_)
1414
import Data.List.Relation.Unary.All.Properties as All
1515
open import Data.List.Relation.Unary.AllPairs as AllPairs using (AllPairs; []; _∷_)
1616
open import Data.List.Relation.Unary.Grouped
17-
open import Function.Base using (__)
18-
open import Function.Bundles using (module Equivalence; _⇔_)
17+
open import Data.Product.Base using (_,_)
18+
open import Function.Base using (_∘_; _on_)
1919
open import Relation.Binary.Definitions as B
20-
open import Relation.Binary.Core using (REL; Rel)
20+
open import Relation.Binary.Core using (_⇔_; REL; Rel)
2121
open import Relation.Unary as U using (Pred)
2222
open import Relation.Nullary using (¬_; does; yes; no)
2323
open import Relation.Nullary.Negation using (contradiction)
@@ -26,31 +26,23 @@ open import Level
2626
private
2727
variable
2828
a b c p q : Level
29-
A : Set a
30-
B : Set b
31-
C : Set c
29+
A B C : Set a
3230

3331
------------------------------------------------------------------------
3432
-- map
3533

3634
module _ (P : Rel A p) (Q : Rel B q) where
3735

38-
map⁺ : {f xs} ( {x y} P x y ⇔ Q (f x) (f y)) Grouped P xs Grouped Q (map f xs)
39-
map⁺ {f} {[]} P⇔Q [] = []
40-
map⁺ {f} {x ∷ xs} P⇔Q (all[¬Px,xs] ∷≉ g) = aux all[¬Px,xs] ∷≉ map⁺ P⇔Q g where
41-
aux : {ys} All (λ y ¬ P x y) ys All (λ y ¬ Q (f x) y) (map f ys)
42-
aux [] = []
43-
aux (py ∷ pys) = py ∘ Equivalence.from P⇔Q ∷ aux pys
44-
map⁺ {f} {x₁ ∷ x₂ ∷ xs} P⇔Q (Px₁x₂ ∷≈ g) = Equivalence.to P⇔Q Px₁x₂ ∷≈ map⁺ P⇔Q g
36+
map⁺ : {f xs} P ⇔ (Q on f) Grouped P xs Grouped Q (map f xs)
37+
map⁺ P⇔Q [] = []
38+
map⁺ P⇔Q@(_ , Q⇒P) (all[¬Px,xs] ∷≉ g[xs]) = All.gmap⁺ (_∘ Q⇒P) all[¬Px,xs] ∷≉ map⁺ P⇔Q g[xs]
39+
map⁺ P⇔Q@(P⇒Q , _) (Px₁x₂ ∷≈ g[xs]) = P⇒Q Px₁x₂ ∷≈ map⁺ P⇔Q g[xs]
4540

46-
map⁻ : {f xs} ( {x y} P x y ⇔ Q (f x) (f y)) Grouped Q (map f xs) Grouped P xs
47-
map⁻ {f} {[]} P⇔Q [] = []
48-
map⁻ {f} {x ∷ []} P⇔Q ([] ∷≉ []) = [] ∷≉ []
49-
map⁻ {f} {x₁ ∷ x₂ ∷ xs} P⇔Q (all[¬Qx,xs] ∷≉ g) = aux all[¬Qx,xs] ∷≉ map⁻ P⇔Q g where
50-
aux : {ys} All (λ y ¬ Q (f x₁) y) (map f ys) All (λ y ¬ P x₁ y) ys
51-
aux {[]} [] = []
52-
aux {y ∷ ys} (py ∷ pys) = py ∘ Equivalence.to P⇔Q ∷ aux pys
53-
map⁻ {f} {x₁ ∷ x₂ ∷ xs} P⇔Q (Qx₁x₂ ∷≈ g) = Equivalence.from P⇔Q Qx₁x₂ ∷≈ map⁻ P⇔Q g
41+
map⁻ : {f xs} P ⇔ (Q on f) Grouped Q (map f xs) Grouped P xs
42+
map⁻ {xs = []} P⇔Q [] = []
43+
map⁻ {xs = _ ∷ []} P⇔Q ([] ∷≉ []) = [] ∷≉ []
44+
map⁻ {xs = _ ∷ _ ∷ _} P⇔Q@(P⇒Q , _) (all[¬Qx,xs] ∷≉ g) = All.gmap⁻ (_∘ P⇒Q) all[¬Qx,xs] ∷≉ map⁻ P⇔Q g
45+
map⁻ {xs = _ ∷ _ ∷ _} P⇔Q@(_ , Q⇒P) (Qx₁x₂ ∷≈ g) = Q⇒P Qx₁x₂ ∷≈ map⁻ P⇔Q g
5446

5547
------------------------------------------------------------------------
5648
-- [_]

0 commit comments

Comments
 (0)