Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ Deprecated names
nonPos*nonPos⇒nonPos ↦ nonPos*nonPos⇒nonNeg
```

* In `Data.Tree.AVL.Indexed.Relation.Unary.Any.Properties`:
```agda
Any-insertWith-nothing ↦ insertWith-nothing
Any-insertWith-just ↦ insertWith-just
Any-insert-nothing ↦ insert-nothing
Any-insert-just ↦ insert-just
```

* In `Data.Vec.Properties`:
```agda
truncate-irrelevant ↦ Relation.Binary.PropositionalEquality.Core.refl
Expand Down Expand Up @@ -397,6 +405,20 @@ Additions to existing modules
showAtPrecision : ℕ → ℚᵘ → String
```

* In `Data.Tree.AVL.Height`:
```agda
0∼⊔ : 0 ∼ j ⊔ m → j ≡ m
∼0⊔ : i ∼ 0 ⊔ m → i ≡ m
```

* In `Data.Tree.AVL.Indexed`:
```agda
Tree⁺ Tree⁻ : (V : Value v) (l u : Key⁺) (h : ℕ) → Set _
pattern leaf⁻ l<u = _ , leaf l<u
pattern node⁰ʳ k₁ t₁ k₂ t₂ t₃ = node k₁ t₁ (node k₂ t₂ t₃ ∼0) ∼0
pattern node⁰ˡ k₁ k₂ t₁ t₂ t₃ = node k₁ (node k₂ t₁ t₂ ∼0) t₃ ∼0
```

* In `Data.Vec.Properties`:
```agda
map-removeAt : ∀ (f : A → B) (xs : Vec A (suc n)) (i : Fin (suc n)) →
Expand Down
24 changes: 19 additions & 5 deletions src/Data/Tree/AVL/Height.agda
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ module Data.Tree.AVL.Height where

open import Data.Nat.Base
open import Data.Fin.Base using (Fin; zero; suc)
open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl)

private
variable
i j m n : ℕ


ℕ₂ = Fin 2
pattern 0# = zero
Expand Down Expand Up @@ -39,18 +45,26 @@ infix 4 _∼_⊔_
-- absolute value of the balance factor is never more than 1.

data _∼_⊔_ : ℕ → ℕ → ℕ → Set where
∼+ : ∀ {n} → n ∼ 1 + n ⊔ 1 + n
∼0 : ∀ {n} → n ∼ n ⊔ n
∼- : ∀ {n} → 1 + n ∼ n ⊔ 1 + n
∼+ : n ∼ 1 + n ⊔ 1 + n
∼0 : n ∼ n ⊔ n
∼- : 1 + n ∼ n ⊔ 1 + n

-- Some lemmas.

max∼ : ∀ {i j m} → i ∼ j ⊔ m → m ∼ i ⊔ m
max∼ : i ∼ j ⊔ m → m ∼ i ⊔ m
max∼ ∼+ = ∼-
max∼ ∼0 = ∼0
max∼ ∼- = ∼0

∼max : ∀ {i j m} → i ∼ j ⊔ m → j ∼ m ⊔ m
∼max : i ∼ j ⊔ m → j ∼ m ⊔ m
∼max ∼+ = ∼0
∼max ∼0 = ∼0
∼max ∼- = ∼+

0∼⊔ : 0 ∼ j ⊔ m → j ≡ m
0∼⊔ ∼+ = refl
0∼⊔ ∼0 = refl

∼0⊔ : i ∼ 0 ⊔ m → i ≡ m
∼0⊔ ∼- = refl
∼0⊔ ∼0 = refl
Loading
Loading