diff --git a/CHANGELOG.md b/CHANGELOG.md index 99dea4e749..62062b45f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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) open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl) -private - variable - l v : Level - A : Set l - -open StrictTotalOrder strictTotalOrder renaming (Carrier to Key) +open StrictTotalOrder strictTotalOrder + using (module Eq; compare) renaming (Carrier to Key) ------------------------------------------------------------------------ -- Re-export core definitions publicly @@ -37,33 +33,76 @@ open import Data.Tree.AVL.Value Eq.setoid public open import Data.Tree.AVL.Height public ------------------------------------------------------------------------ --- Definitions of the tree +-- Now we have vocabulary in which to state things more cleanly + +private + variable + ℓ v w : Level + A : Set ℓ + l m u : Key⁺ + hˡ hʳ h : ℕ + + +------------------------------------------------------------------------ +-- Definitions of the tree types -- The trees have three parameters/indices: a lower bound on the -- keys, an upper bound, and a height. -- -- (The bal argument is the balance factor.) -data Tree {v} (V : Value v) (l u : Key⁺) : ℕ → Set (a ⊔ v ⊔ ℓ₂) where +data Tree (V : Value v) (l u : Key⁺) : ℕ → Set (a ⊔ v ⊔ ℓ₂) where leaf : (l _ _ k′ _ _ k′ _ _ k′>k = joinˡ⁻ _ p (delete k lp (lk ]ᴿ)) pu bal - ... | tri≈ _ k′≡k _ = join lp pu bal + delete : ∀ k → Tree V l u h → l < k < u → Tree⁻ V l u h + delete k (leaf l _ _ k′>k = joinˡ⁻ _ kv (delete k lk (lk ]ᴿ)) ku bal + ... | tri≈ _ k′≡k _ = join lk ku bal -- Looks up a key. Logarithmic in the size of the tree (assuming -- constant-time comparisons). - lookup : ∀ {l u h} → Tree V l u h → (k : Key) → l < k < u → Maybe (Val k) - lookup (leaf _) k l _ _ k′>k = lookup lk′ k (lk ]ᴿ) - ... | tri≈ _ k′≡k _ = just (V≈ k′≡k v) + lookup : Tree V l u h → ∀ k → l < k < u → Maybe (Val k) + lookup (leaf _) k l _ _ k′>k = lookup lk k (lk ]ᴿ) + ... | tri≈ _ k′≡k _ = just (respects k′≡k v) -- Converts the tree to an ordered list. Linear in the size of the -- tree. - foldr : ∀ {l u h} → (∀ {k} → Val k → A → A) → A → Tree V l u h → A + foldr : (∀ {k} → Val k → A → A) → A → Tree V l u h → A foldr cons nil (leaf l _ _ k>k′ = let seg′ = [ k>k′ ]ᴿ , k _ _ k>k′ = let seg′ = [ k>k′ ]ᴿ , k _ _ k _ _ k