Debian Codegraph @

src/Data/Tree/AVL/Indexed/WithK.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Some code related to indexed AVL trees that relies on the K rule
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --with-K --safe #-}
8
9 open import Relation.Binary.Core using (Rel)
10 open import Relation.Binary.Structures using (IsStrictTotalOrder)
11 open import Relation.Binary.Bundles using (StrictTotalOrder)
12 open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; subst)
13
14 module Data.Tree.AVL.Indexed.WithK
15 {k r} (Key : Set k) {_<_ : Rel Key r}
16 (isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_) where
17
18 strictTotalOrder : StrictTotalOrder _ _ _
19 strictTotalOrder = record { isStrictTotalOrder = isStrictTotalOrder }
20
21 open import Data.Tree.AVL.Indexed strictTotalOrder as AVL hiding (Value)
22
23 module _ {v} {V′ : Key → Set v} where
24
25 private
26 V : AVL.Value v
27 V = AVL.MkValue V′ (subst V′)
28
29 node-injectiveˡ : ∀ {hˡ hʳ h l u k}
30 {lk₁ : Tree V l [ k .key ] hˡ} {lk₂ : Tree V l [ k .key ] hˡ}
31 {ku₁ : Tree V [ k .key ] u hʳ} {ku₂ : Tree V [ k .key ] u hʳ}
32 {bal₁ bal₂ : hˡ ∼ hʳ ⊔ h} →
33 node k lk₁ ku₁ bal₁ ≡ node k lk₂ ku₂ bal₂ → lk₁ ≡ lk₂
34 node-injectiveˡ refl = refl
35
36 node-injectiveʳ : ∀ {hˡ hʳ h l u k}
37 {lk₁ : Tree V l [ k .key ] hˡ} {lk₂ : Tree V l [ k .key ] hˡ}
38 {ku₁ : Tree V [ k .key ] u hʳ} {ku₂ : Tree V [ k .key ] u hʳ}
39 {bal₁ bal₂ : hˡ ∼ hʳ ⊔ h} →
40 node k lk₁ ku₁ bal₁ ≡ node k lk₂ ku₂ bal₂ → ku₁ ≡ ku₂
41 node-injectiveʳ refl = refl
42
43 node-injective-bal : ∀ {hˡ hʳ h l u k}
44 {lk₁ : Tree V l [ k .key ] hˡ} {lk₂ : Tree V l [ k .key ] hˡ}
45 {ku₁ : Tree V [ k .key ] u hʳ} {ku₂ : Tree V [ k .key ] u hʳ}
46 {bal₁ bal₂ : hˡ ∼ hʳ ⊔ h} →
47 node k lk₁ ku₁ bal₁ ≡ node k lk₂ ku₂ bal₂ → bal₁ ≡ bal₂
48 node-injective-bal refl = refl