Skip to content

Commit 4070b9c

Browse files
authored
Add more properties to Data.Tree.Binary.Properties (#1273)
1 parent b52e3e5 commit 4070b9c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,12 @@ Other minor additions
520520
index-∈-lookup : (i : Fin n) (xs : Vec A n) → Any.index (∈-lookup i xs) ≡ i
521521
```
522522

523+
* Added new proofs to `Data.Tree.Binary.Properties`:
524+
```agda
525+
map-compose : map (f₁ ∘ f₂) (g₁ ∘ g₂) ≗ map f₁ g₁ ∘ map f₂ g₂
526+
map-cong : f₁ ≗ f₂ → g₁ ≗ g₂ → map f₁ g₁ ≗ map f₂ g₂
527+
```
528+
523529
Refactorings
524530
------------
525531

src/Data/Tree/Binary/Properties.agda

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
module Data.Tree.Binary.Properties where
1010

11+
open import Function using (_∘_)
12+
open import Function.Nary.NonDependent using (congₙ)
1113
open import Level using (Level)
1214
open import Data.Nat.Base using (suc; _+_)
1315
open import Data.Tree.Binary
@@ -16,12 +18,14 @@ open import Relation.Binary.PropositionalEquality
1618

1719
private
1820
variable
19-
a n n₁ l l₁ : Level
21+
a n n₁ n₂ l l₁ l₂ : Level
2022
A : Set a
2123
N : Set n
2224
N₁ : Set n₁
25+
N₂ : Set n₂
2326
L : Set l
2427
L₁ : Set l₁
28+
L₂ : Set l₂
2529

2630
#nodes-map : (f : N N₁) (g : L L₁) t #nodes (map f g t) ≡ #nodes t
2731
#nodes-map f g (leaf x) = refl
@@ -48,3 +52,12 @@ private
4852
map-id : (t : Tree N L) map id id t ≡ t
4953
map-id (leaf x) = refl
5054
map-id (node l v r) = cong₂ (flip node v) (map-id l) (map-id r)
55+
56+
map-compose : {f₁ : N₁ N₂} {f₂ : N N₁} {g₁ : L₁ L₂} {g₂ : L L₁}
57+
map (f₁ ∘ f₂) (g₁ ∘ g₂) ≗ map f₁ g₁ ∘ map f₂ g₂
58+
map-compose (leaf x) = refl
59+
map-compose (node l v r) = cong₂ (λ l r node l _ r) (map-compose l) (map-compose r)
60+
61+
map-cong : {f₁ f₂ : N N₁} {g₁ g₂ : L L₁} f₁ ≗ f₂ g₁ ≗ g₂ map f₁ g₁ ≗ map f₂ g₂
62+
map-cong p q (leaf x) = cong leaf (q x)
63+
map-cong p q (node l v r) = congₙ 3 node (map-cong p q l) (p v) (map-cong p q r)

0 commit comments

Comments
 (0)