File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -520,6 +520,12 @@ Other minor additions
520
520
index-∈-lookup : (i : Fin n) (xs : Vec A n) → Any.index (∈-lookup i xs) ≡ i
521
521
```
522
522
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
+
523
529
Refactorings
524
530
------------
525
531
Original file line number Diff line number Diff line change 8
8
9
9
module Data.Tree.Binary.Properties where
10
10
11
+ open import Function using (_∘_)
12
+ open import Function.Nary.NonDependent using (congₙ)
11
13
open import Level using (Level)
12
14
open import Data.Nat.Base using (suc; _+_)
13
15
open import Data.Tree.Binary
@@ -16,12 +18,14 @@ open import Relation.Binary.PropositionalEquality
16
18
17
19
private
18
20
variable
19
- a n n₁ l l₁ : Level
21
+ a n n₁ n₂ l l₁ l₂ : Level
20
22
A : Set a
21
23
N : Set n
22
24
N₁ : Set n₁
25
+ N₂ : Set n₂
23
26
L : Set l
24
27
L₁ : Set l₁
28
+ L₂ : Set l₂
25
29
26
30
#nodes-map : ∀ (f : N → N₁) (g : L → L₁) t → #nodes (map f g t) ≡ #nodes t
27
31
#nodes-map f g (leaf x) = refl
@@ -48,3 +52,12 @@ private
48
52
map-id : ∀ (t : Tree N L) → map id id t ≡ t
49
53
map-id (leaf x) = refl
50
54
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)
You can’t perform that action at this time.
0 commit comments