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