Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ add ] concat [ xs ] ≡ xs #2530

Merged
merged 5 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ Deprecated names
normalise-correct ↦ Algebra.Solver.Monoid.Normal.correct
```

* In `Data.Vec.Properties`:
```agda
concat-[_] ↦ concat-map-[_]
```

* In `Data.List.Relation.Binary.Permutation.Setoid.Properties`:
```agda
split ↦ ↭-split
Expand Down Expand Up @@ -318,6 +323,7 @@ Additions to existing modules
```agda
product≢0 : All NonZero ns → NonZero (product ns)
∈⇒≤product : All NonZero ns → n ∈ ns → n ≤ product ns
concat-[_] : concat ∘ [_] ≗ id
concatMap-++ : concatMap f (xs ++ ys) ≡ concatMap f xs ++ concatMap f ys
filter-≐ : P ≐ Q → filter P? ≗ filter Q?

Expand Down
19 changes: 15 additions & 4 deletions src/Data/List/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,12 @@ concat-concat (xss ∷ xsss) = begin
concat xss ++ concat (concat xsss) ≡⟨ concat-++ xss (concat xsss) ⟩
concat (concat (xss ∷ xsss)) ∎

concat-[-] : concat {A = A} ∘ map [_] ≗ id
concat-[-] [] = refl
concat-[-] (x ∷ xs) = cong (x ∷_) (concat-[-] xs)
concat-map-[_] : concat {A = A} ∘ map [_] ≗ id
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved
concat-map-[ [] ] = refl
concat-map-[ x ∷ xs ] = cong (x ∷_) (concat-map-[ xs ])

concat-[_] : concat {A = A} ∘ [_] ≗ id
jamesmckinna marked this conversation as resolved.
Show resolved Hide resolved
concat-[ xs ] = ++-identityʳ xs

------------------------------------------------------------------------
-- concatMap
Expand All @@ -688,7 +691,7 @@ concatMap-cong : ∀ {f g : A → List B} → f ≗ g → concatMap f ≗ concat
concatMap-cong eq xs = cong concat (map-cong eq xs)

concatMap-pure : concatMap {A = A} [_] ≗ id
concatMap-pure = concat-[-]
concatMap-pure = concat-map-[_]

concatMap-map : (g : B → List C) → (f : A → B) → (xs : List A) →
concatMap g (map f xs) ≡ concatMap (g ∘′ f) xs
Expand Down Expand Up @@ -1654,3 +1657,11 @@ scanl-defn f e (x ∷ xs) = cong (e ∷_) (begin
"Warning: scanl-defn was deprecated in v2.1.
Please use Data.List.Scans.Properties.scanl-defn instead."
#-}

-- Version 2.2

concat-[-] = concat-map-[_]
{-# WARNING_ON_USAGE concat-[-]
"Warning: concat-[-] was deprecated in v2.2.
Please use concat-map-[_] instead."
#-}
4 changes: 2 additions & 2 deletions src/Data/List/Sort/MergeSort.agda
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Data.List.Sort.MergeSort
open import Data.Bool.Base using (true; false)
open import Data.List.Base
using (List; []; _∷_; merge; length; map; [_]; concat; _++_)
open import Data.List.Properties using (length-partition; ++-assoc; concat-[-])
open import Data.List.Properties using (length-partition; ++-assoc; concat-map-[_])
open import Data.List.Relation.Unary.Linked using ([]; [-])
import Data.List.Relation.Unary.Sorted.TotalOrder.Properties as Sorted
open import Data.List.Relation.Unary.All as All using (All; []; _∷_)
Expand Down Expand Up @@ -86,7 +86,7 @@ mergeAll-↭ (xs ∷ ys ∷ xss) (acc rec) = begin
sort-↭ : ∀ xs → sort xs ↭ xs
sort-↭ xs = begin
mergeAll (map [_] xs) _ ↭⟨ mergeAll-↭ (map [_] xs) _ ⟩
concat (map [_] xs) ≡⟨ concat-[-] xs ⟩
concat (map [_] xs) ≡⟨ concat-map-[ xs ]
xs ∎

------------------------------------------------------------------------
Expand Down
Loading