Skip to content

Commit 6803957

Browse files
authored
Add some properties relating to List.concat (#1317)
1 parent 6c575be commit 6803957

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ Other minor additions
4040

4141
* Added `Reflection.TypeChecking.Format.errorPartFmt`.
4242

43+
* Added new properties to `Data.List.Properties`:
44+
```agda
45+
concat-++ : concat xss ++ concat yss ≡ concat (xss ++ yss)
46+
concat-concat : concat ∘ map concat ≗ concat ∘ concat
47+
concat-[-] : concat ∘ map [_] ≗ id
48+
```
49+
4350
* Added new records to `Algebra.Bundles`:
4451
```agda
4552
RawNearSemiring c ℓ : Set (suc (c ⊔ ℓ))

src/Data/List/Properties.agda

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,22 @@ concat-map {f = f} xss = begin
496496
foldr (λ ys map f ys ++_) [] xss ≡⟨ sym (foldr-fusion (map f) [] (map-++-commute f) xss) ⟩
497497
map f (concat xss) ∎
498498

499+
concat-++ : (xss yss : List (List A)) concat xss ++ concat yss ≡ concat (xss ++ yss)
500+
concat-++ [] yss = refl
501+
concat-++ ([] ∷ xss) yss = concat-++ xss yss
502+
concat-++ ((x ∷ xs) ∷ xss) yss = cong (x ∷_) (concat-++ (xs ∷ xss) yss)
503+
504+
concat-concat : concat {A = A} ∘ map concat ≗ concat ∘ concat
505+
concat-concat [] = refl
506+
concat-concat (xss ∷ xsss) = begin
507+
concat (map concat (xss ∷ xsss)) ≡⟨ cong (concat xss ++_) (concat-concat xsss) ⟩
508+
concat xss ++ concat (concat xsss) ≡⟨ concat-++ xss (concat xsss) ⟩
509+
concat (concat (xss ∷ xsss)) ∎
510+
511+
concat-[-] : concat {A = A} ∘ map [_] ≗ id
512+
concat-[-] [] = refl
513+
concat-[-] (x ∷ xs) = cong (x ∷_) (concat-[-] xs)
514+
499515
------------------------------------------------------------------------
500516
-- sum
501517

0 commit comments

Comments
 (0)