annotate RBTree1.agda @ 954:08281092430b

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 06 Oct 2024 17:59:51 +0900
parents
children 415915a840fe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
954
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 -- {-# OPTIONS --cubical-compatible --safe #-}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 {-# OPTIONS --allow-unsolved-metas --cubical-compatible #-}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 module RBTree1 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Level hiding (suc ; zero ; _⊔_ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 open import Data.Nat hiding (compare)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 open import Data.Nat.Properties as NatProp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 open import Data.Maybe
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 open import Data.Maybe.Properties
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 open import Data.Empty
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 open import Data.Unit
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 open import Data.List
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 open import Data.List.Properties
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 open import Data.Product
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 open import Function as F hiding (const)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 open import Relation.Binary
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 open import Relation.Binary.PropositionalEquality
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 open import Relation.Nullary
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 open import logic
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 open import nat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 open import BTree
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 open import RBTreeBase
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 open _∧_
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 RB-repl→ti-lem03 : {n : Level} {A : Set n} {key k : ℕ} {value v1 : A} {ca : Color} {t t1 t2 : bt (Color ∧ A)} (x : color t1 ≡ color t) (x₁ : key < k)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 (rbt : replacedRBTree key value t1 t) → (treeInvariant t1 → treeInvariant t) → treeInvariant (node k ⟪ ca , v1 ⟫ t1 t2) → treeInvariant (node k ⟪ ca , v1 ⟫ t t2)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 RB-repl→ti-lem03 {n} {A} {key} {k} {value} {v1} {ca} {t} {t1} {t2} ceq x₁ rbt prev ti = lem21 (node k ⟪ ca , v1 ⟫ t1 t2) ti refl rbt where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 lem22 : treeInvariant t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 lem22 = prev (treeLeftDown _ _ ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 lem21 : (tree : bt (Color ∧ A)) → treeInvariant tree → tree ≡ node k ⟪ ca , v1 ⟫ t1 t2 → replacedRBTree key value t1 t → treeInvariant (node k ⟪ ca , v1 ⟫ t t2)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 lem21 .leaf t-leaf () rbt
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 lem21 .(node k₃ value₁ leaf leaf) (t-single k₃ value₁) eq rbr-leaf = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-left key k₃ (subst (λ k → key < k) (sym lem23) x₁) tt tt lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 lem23 : k₃ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 lem21 .(node key value leaf leaf) (t-single key value) () rbr-node
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 lem21 .(node key value leaf leaf) (t-single key value) () (rbr-right x x₁ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 lem21 .(node key value leaf leaf) (t-single key value) () (rbr-left x x₁ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 lem21 .(node key value leaf leaf) (t-single key value) () (rbr-black-right x x₁ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 lem21 .(node key value leaf leaf) (t-single key value) () (rbr-black-left x x₁ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 lem21 .(node key value leaf leaf) (t-single key value) () (rbr-flip-ll x x₁ x₂ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 lem21 .(node key value leaf leaf) (t-single key value) () (rbr-flip-lr x x₁ x₂ x₃ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 lem21 .(node key value leaf leaf) (t-single key value) () (rbr-flip-rl x x₁ x₂ x₃ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 lem21 .(node key value leaf leaf) (t-single key value) () (rbr-flip-rr x x₁ x₂ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 lem21 .(node key value leaf leaf) (t-single key value) () (rbr-rotate-ll x x₁ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 lem21 .(node key value leaf leaf) (t-single key value) () (rbr-rotate-rr x x₁ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 lem21 .(node key value leaf leaf) (t-single key value) () (rbr-rotate-lr t₂ t₃ kg kp kn x x₁ x₂ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 lem21 .(node key value leaf leaf) (t-single key value) () (rbr-rotate-rl t₂ t₃ kg kp kn x x₁ x₂ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 lem21 .(node k₄ _ leaf (node k₃ _ _ _)) (t-right k₄ k₃ x x₁₀ x₂ ti₁) eq rbr-leaf = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-node _ _ k₃ (subst (λ j → key < j) (sym lem23) x₁) x tt tt x₁₀ x₂ (t-single _ _) ti₁ ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 lem23 = just-injective (cong node-key eq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 lem21 .(node k₄ _ leaf (node key₁ _ _ _)) (t-right k₄ key₁ x x₁₀ x₂ ti₁) () rbr-node
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 lem21 .(node k₄ _ leaf (node key₁ _ _ _)) (t-right k₄ key₁ x x₁₀ x₂ ti₁) () (rbr-right x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 lem21 .(node k₄ _ leaf (node key₁ _ _ _)) (t-right k₄ key₁ x x₁₀ x₂ ti₁) () (rbr-left x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 lem21 .(node k₄ _ leaf (node key₁ _ _ _)) (t-right k₄ key₁ x x₁₀ x₂ ti₁) () (rbr-black-right x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 lem21 .(node k₄ _ leaf (node key₁ _ _ _)) (t-right k₄ key₁ x x₁₀ x₂ ti₁) () (rbr-black-left x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 lem21 .(node k₄ _ leaf (node key₁ _ _ _)) (t-right k₄ key₁ x x₁₀ x₂ ti₁) () (rbr-flip-ll x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 lem21 .(node k₄ _ leaf (node key₁ _ _ _)) (t-right k₄ key₁ x x₁₀ x₂ ti₁) () (rbr-flip-lr x₃ x₄ x₅ x₆ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 lem21 .(node k₄ _ leaf (node key₁ _ _ _)) (t-right k₄ key₁ x x₁₀ x₂ ti₁) () (rbr-flip-rl x₃ x₄ x₅ x₆ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 lem21 .(node k₄ _ leaf (node key₁ _ _ _)) (t-right k₄ key₁ x x₁₀ x₂ ti₁) () (rbr-flip-rr x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 lem21 .(node k₄ _ leaf (node key₁ _ _ _)) (t-right k₄ key₁ x x₁₀ x₂ ti₁) () (rbr-rotate-ll x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 lem21 .(node k₄ _ leaf (node key₁ _ _ _)) (t-right k₄ key₁ x x₁₀ x₂ ti₁) () (rbr-rotate-rr x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 lem21 .(node k₄ _ leaf (node key₁ _ _ _)) (t-right k₄ key₁ x x₁₀ x₂ ti₁) () (rbr-rotate-lr t₂ t₃ kg kp kn x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 lem21 .(node k₄ _ leaf (node key₁ _ _ _)) (t-right k₄ key₁ x x₁₀ x₂ ti₁) () (rbr-rotate-rl t₂ t₃ kg kp kn x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 lem21 (node k₄ _ (node k₃ _ t₁ t₂) leaf) (t-left k₃ k₄ x x₁₀ x₂ ti₁) eq (rbr-node {_} {_} {t₃} {t₄} ) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-left key k₄ (proj1 rr04) (proj1 (proj2 rr04)) (proj2 (proj2 rr04)) lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 lem23 = just-injective (cong node-key eq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 rr04 : (key < k₄) ∧ tr< k₄ t₃ ∧ tr< k₄ t₄
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 lem21 (node k₄ _ (node k₃ _ t₁ t₂) leaf) (t-left k₃ k₄ x x₁₀ x₂ ti₁) eq (rbr-right {k₁} {_} {_} {t₃} {t₄} {t₅} x₁₁ x₃ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-left _ k₄ (proj1 rr04) (proj1 (proj2 rr04)) rr02 lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 lem23 = just-injective (cong node-key eq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 rr04 : (k₁ < k₄) ∧ tr< k₄ t₄ ∧ tr< k₄ t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 rr02 : tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 lem21 (node k₄ _ (node k₃ _ t₁ t₂) leaf) (t-left k₃ k₄ x x₁₀ x₂ ti₁) eq (rbr-left {k₁} {_} {_} {t₃} {t₄} {t₅} x₁₁ x₃ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-left _ k₄ (proj1 rr04) rr02 (proj2 (proj2 rr04)) lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 lem23 = just-injective (cong node-key eq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 rr04 : (k₁ < k₄) ∧ tr< k₄ t₄ ∧ tr< k₄ t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 rr02 : tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj1 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 lem21 .(node k₄ _ (node k₃ _ _ _) leaf) (t-left k₃ k₄ x x₁₀ x₂ ti₁) eq (rbr-black-right {t₁} {t₂} {t₃} {_} {k₂} x₁₁ x₃ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-left _ k₄ (proj1 rr04) (proj1 (proj2 rr04)) rr02 lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 lem23 = just-injective (cong node-key eq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 rr04 : (k₂ < k₄) ∧ tr< k₄ t₁ ∧ tr< k₄ t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 rr02 : tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 lem21 .(node k₄ _ (node k₃ _ _ _) leaf) (t-left k₃ k₄ x x₁₀ x₂ ti₁) eq (rbr-black-left {t₁} {t₂} {t₃} {_} {k₂} x₁₁ x₃ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-left _ k₄ (proj1 rr04) rr02 (proj2 (proj2 rr04)) lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 lem23 = just-injective (cong node-key eq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 rr04 : (k₂ < k₄) ∧ tr< k₄ t₂ ∧ tr< k₄ t₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 rr02 : tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj1 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 lem21 .(node k₄ _ (node k₃ _ _ _) leaf) (t-left k₃ k₄ x x₁₀ x₂ ti₁) eq (rbr-flip-ll x₁₁ x₃ x₄ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 lem21 .(node k₄ _ (node k₃ _ _ _) leaf) (t-left k₃ k₄ x x₁₀ x₂ ti₁) eq (rbr-flip-lr x₁₁ x₃ x₄ x₅ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 lem21 .(node k₄ _ (node k₃ _ _ _) leaf) (t-left k₃ k₄ x x₁₀ x₂ ti₁) eq (rbr-flip-rl x₁₁ x₃ x₄ x₅ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 lem21 .(node k₄ _ (node k₃ _ _ _) leaf) (t-left k₃ k₄ x x₁₀ x₂ ti₁) eq (rbr-flip-rr x₁₁ x₃ x₄ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 lem21 .(node k₄ _ (node k₃ _ _ _) leaf) (t-left k₃ k₄ x x₁₀ x₂ ti₁) eq (rbr-rotate-ll {t₁} {t₂} {t₃} {uncle} {kg} {kp} x₁₁ x₃ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-left _ k₄ (proj1 (proj1 (proj2 rr04))) rr02
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 ⟪ proj1 rr04 , ⟪ proj2 (proj2 (proj1 (proj2 rr04))) , proj2 (proj2 rr04) ⟫ ⟫ lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 lem23 = just-injective (cong node-key eq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 rr04 : (kg < k₄) ∧ ((kp < k₄) ∧ tr< k₄ t₂ ∧ tr< k₄ t₁ ) ∧ tr< k₄ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 rr02 : tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj1 (proj2 (proj1 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 lem21 .(node k₄ _ (node k₃ _ _ _) leaf) (t-left k₃ k₄ x x₁₀ x₂ ti₁) eq (rbr-rotate-rr {t₁} {t₂} {t₃} {uncle} {kg} {kp} x₁₁ x₃ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-left _ k₄ (proj1 (proj2 (proj2 rr04)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 ⟪ proj1 rr04 , ⟪ proj1 (proj2 rr04) , proj1 (proj2 (proj2 (proj2 rr04))) ⟫ ⟫ rr02 lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 lem23 = just-injective (cong node-key eq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 rr04 : (kg < k₄) ∧ tr< k₄ uncle ∧ ((kp < k₄) ∧ tr< k₄ t₁ ∧ tr< k₄ t₂)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 rr02 : tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj2 (proj2 (proj2 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 lem21 .(node k₄ _ (node k₃ _ _ _) leaf) (t-left k₃ k₄ x x₁₀ x₂ ti₁) eq (rbr-rotate-lr {t} {t₁} {uncle} t₂ t₃ kg kp kn x₁₁ x₃ x₄ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-left _ k₄ (proj1 rr02)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 ⟪ proj1 (proj1 (proj2 rr04)) , ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , proj1 (proj2 rr02) ⟫ ⟫ ⟪ proj1 rr04 , ⟪ proj2 (proj2 rr02) , proj2 (proj2 rr04) ⟫ ⟫ lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 lem23 = just-injective (cong node-key eq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 rr04 : (kg < k₄) ∧ ((kp < k₄) ∧ tr< k₄ t ∧ tr< k₄ t₁) ∧ tr< k₄ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 rr02 : (kn < k₄) ∧ tr< k₄ t₂ ∧ tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj2 (proj2 (proj1 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 lem21 .(node k₄ _ (node k₃ _ _ _) leaf) (t-left k₃ k₄ x x₁₀ x₂ ti₁) eq (rbr-rotate-rl {t} {t₁} {uncle} t₂ t₃ kg kp kn x₁₁ x₃ x₄ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-left _ k₄ (proj1 rr02)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 ⟪ proj1 rr04 , ⟪ proj1 (proj2 rr04) , proj1 (proj2 rr02) ⟫ ⟫ ⟪ proj1 (proj2 (proj2 rr04)) , ⟪ proj2 (proj2 rr02) , proj2 (proj2 (proj2 (proj2 rr04))) ⟫ ⟫ lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 lem23 = just-injective (cong node-key eq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 rr04 : (kg < k₄) ∧ tr< k₄ uncle ∧ ((kp < k₄) ∧ tr< k₄ t₁ ∧ tr< k₄ t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 rr02 : (kn < k₄) ∧ tr< k₄ t₂ ∧ tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj1 (proj2 (proj2 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 lem21 .(node k₄ _ (node k₃ _ _ _) (node key₂ _ _ _)) (t-node k₃ k₄ key₂ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-node {_} {_} {t₃} {t₄}) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 rr04) x₁₀ (proj1 (proj2 rr04)) (proj2 (proj2 rr04)) x₄ x₅ lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 rr04 : (key < k₄) ∧ tr< k₄ t₃ ∧ tr< k₄ t₄
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 lem21 .(node k₄ _ (node k₃ _ _ _) (node key₂ _ _ _)) (t-node k₃ k₄ key₂ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-right {k₁} {_} {_} {t₃} {t₄} {t₅} x₁₁ x₆ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 rr04) x₁₀ (proj1 (proj2 rr04)) rr02 x₄ x₅ lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 rr04 : (k₁ < k₄) ∧ tr< k₄ t₄ ∧ tr< k₄ t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 rr02 : tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 lem21 .(node k₄ _ (node k₃ _ _ _) (node key₂ _ _ _)) (t-node k₃ k₄ key₂ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-left {k₁} {_} {_} {t₃} {t₄} {t₅} x₁₁ x₆ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 rr04) x₁₀ rr02 (proj2 (proj2 rr04)) x₄ x₅ lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 rr04 : (k₁ < k₄) ∧ tr< k₄ t₄ ∧ tr< k₄ t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 rr02 : tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj1 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 lem21 .(node k₄ _ (node k₃ _ _ _) (node key₂ _ _ _)) (t-node k₃ k₄ key₂ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-black-right {t₁} {t₂} {t₃} {_} {k₂} x₁₁ x₆ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 rr04) x₁₀ (proj1 (proj2 rr04)) rr02 x₄ x₅ lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 rr04 : (k₂ < k₄) ∧ tr< k₄ t₁ ∧ tr< k₄ t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 rr02 : tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 lem21 .(node k₄ _ (node k₃ _ _ _) (node key₂ _ _ _)) (t-node k₃ k₄ key₂ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-black-left {t₁} {t₂} {t₃} {_} {k₂} x₁₁ x₆ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 rr04) x₁₀ rr02 (proj2 (proj2 rr04)) x₄ x₅ lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 rr04 : (k₂ < k₄) ∧ tr< k₄ t₂ ∧ tr< k₄ t₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 rr02 : tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj1 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 lem21 .(node k₄ _ (node k₃ _ _ _) (node key₂ _ _ _)) (t-node k₃ k₄ key₂ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-ll x₁ x₆ x₇ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 lem21 .(node k₄ _ (node k₃ _ _ _) (node key₂ _ _ _)) (t-node k₃ k₄ key₂ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-rr x₁ x₆ x₇ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 lem21 .(node k₄ _ (node k₃ _ _ _) (node key₂ _ _ _)) (t-node k₃ k₄ key₂ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-rl x₁ x₆ x₇ x₈ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 lem21 .(node k₄ _ (node k₃ _ _ _) (node key₂ _ _ _)) (t-node k₃ k₄ key₂ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-lr x₁ x₆ x₇ x₈ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 lem21 .(node k₄ _ (node k₃ _ _ _) (node key₂ _ _ _)) (t-node k₃ k₄ key₂ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-ll {t₁} {t₂} {t₃} {uncle} {kg} {kp} x₁₁ x₆ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 (proj1 (proj2 rr04))) x₁₀ rr02
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 ⟪ proj1 rr04 , ⟪ proj2 (proj2 (proj1 (proj2 rr04))) , proj2 (proj2 rr04) ⟫ ⟫ x₄ x₅ lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 rr04 : (kg < k₄) ∧ ((kp < k₄) ∧ tr< k₄ t₂ ∧ tr< k₄ t₁) ∧ tr< k₄ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 rr02 : tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj1 (proj2 (proj1 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 lem21 .(node k₄ _ (node k₃ _ _ _) (node key₂ _ _ _)) (t-node k₃ k₄ key₂ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-rr {t₁} {t₂} {t₃} {uncle} {kg} {kp} x₁₁ x₆ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 (proj2 (proj2 rr04))) x₁₀
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 ⟪ proj1 rr04 , ⟪ proj1 (proj2 rr04) , proj1 (proj2 (proj2 (proj2 rr04))) ⟫ ⟫ rr02 x₄ x₅ lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 rr04 : (kg < k₄) ∧ tr< k₄ uncle ∧ ((kp < k₄) ∧ tr< k₄ t₁ ∧ tr< k₄ t₂)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 rr02 : tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj2 (proj2 (proj2 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 lem21 .(node k₄ _ (node k₃ _ _ _) (node key₂ _ _ _)) (t-node k₃ k₄ key₂ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-lr {t} {t₁} {uncle} t₂ t₃ kg kp kn x₁₁ x₆ x₇ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 rr02) x₁₀
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 ⟪ proj1 (proj1 (proj2 rr04)) , ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , proj1 (proj2 rr02) ⟫ ⟫ ⟪ proj1 rr04 , ⟪ proj2 (proj2 rr02) , proj2 (proj2 rr04) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 x₄ x₅ lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
216 rr04 : (kg < k₄) ∧ ((kp < k₄) ∧ tr< k₄ t ∧ tr< k₄ t₁) ∧ tr< k₄ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 rr02 : (kn < k₄) ∧ tr< k₄ t₂ ∧ tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj2 (proj2 (proj1 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 lem21 .(node k₄ _ (node k₃ _ _ _) (node key₂ _ _ _)) (t-node k₃ k₄ key₂ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-rl {t} {t₁} {uncle} t₂ t₃ kg kp kn x₁₁ x₆ x₇ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 (node-cong lem23 refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 rr02) x₁₀
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 ⟪ proj1 rr04 , ⟪ proj1 (proj2 rr04) , proj1 (proj2 rr02) ⟫ ⟫ ⟪ proj1 (proj2 (proj2 rr04)) , ⟪ proj2 (proj2 rr02) , proj2 (proj2 (proj2 (proj2 rr04))) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 x₄ x₅ lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 lem23 : k₄ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 rr04 : (kg < k₄) ∧ tr< k₄ uncle ∧ ((kp < k₄) ∧ tr< k₄ t₁ ∧ tr< k₄ t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 rr02 : (kn < k₄) ∧ tr< k₄ t₂ ∧ tr< k₄ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 rr02 = RB-repl→ti< _ _ _ _ _ rbt (subst (λ j → key < j) (sym lem23) x₁) (proj1 (proj2 (proj2 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
230
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 RB-repl→ti-lem04 : {n : Level} {A : Set n} {key : ℕ} {value : A} {t t₁ t₂ : bt (Color ∧ A)} {value₁ : A} {key₁ : ℕ} (x : color t₂ ≡ Red) (x₁ : key₁ < key)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 (rbt : replacedRBTree key value t₁ t₂) → (treeInvariant t₁ → treeInvariant t₂) → treeInvariant (node key₁ ⟪ Black , value₁ ⟫ t t₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 → treeInvariant (node key₁ ⟪ Black , value₁ ⟫ t t₂)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 RB-repl→ti-lem04 {n} {A} {key} {value} {t} {t1} {t2} {v1} {k} ceq x₁ rbt prev ti = lem21 (node k ⟪ Black , v1 ⟫ t t1) ti refl rbt where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 lem22 : treeInvariant t2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 lem22 = prev (treeRightDown _ _ ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 lem21 : (tree : bt (Color ∧ A)) → treeInvariant tree → tree ≡ node k ⟪ Black , v1 ⟫ t t1 → replacedRBTree key value t1 t2 → treeInvariant (node k ⟪ Black , v1 ⟫ t t2)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 lem21 _ t-leaf () rbt
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 lem21 _ (t-single key value) eq rbr-leaf = subst treeInvariant (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-right _ _ x₁ _ _ lem22)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 lem21 _ (t-single key value) () (rbr-node {_} {_} {t₃} {t₄})
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 lem21 _ (t-single key value) () (rbr-right {k₁} {_} {_} {t₃} {t₄} {t₅} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 lem21 _ (t-single key value) () (rbr-left {k₁} {_} {_} {t₃} {t₄} {t₅} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 lem21 _ (t-single key value) () (rbr-black-right {t₁} {t₂} {t₃} {_} {k₂}x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 lem21 _ (t-single key value) () (rbr-black-left {t₁} {t₂} {t₃} {_} {k₂}x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 lem21 _ (t-single key value) () (rbr-flip-ll {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 lem21 _ (t-single key value) () (rbr-flip-lr {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ x₆ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 lem21 _ (t-single key value) () (rbr-flip-rl {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ x₆ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 lem21 _ (t-single key value) () (rbr-flip-rr {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 lem21 _ (t-single key value) () (rbr-rotate-ll {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 lem21 _ (t-single key value) () (rbr-rotate-rr {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 lem21 _ (t-single key value) () (rbr-rotate-rl {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 lem21 _ (t-single key value) () (rbr-rotate-lr {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) () rbr-leaf
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) eq (rbr-node {_} {_} {t₃} {t₄}) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-right _ _ x₁ (proj1 (proj2 rr04)) (proj2 (proj2 rr04)) lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 rr04 : (k < _ ) ∧ tr> k t₃ ∧ tr> k t₄
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) eq (rbr-right {k₁} {_} {_} {t₃} {t₄} {t₅} x₃ x₄ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-right _ _ (proj1 rr04) (proj1 (proj2 rr04)) rr02 lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 rr04 : (k < k₁ ) ∧ tr> k t₄ ∧ tr> k t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 rr02 : tr> k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 rr02 = RB-repl→ti> _ _ _ _ _ rbt x₁ (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) eq (rbr-left {k₁} {_} {_} {t₃} {t₄} {t₅} x₃ x₄ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-right _ _ (proj1 rr04) rr02 (proj2 (proj2 rr04)) lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 rr04 : (k < k₁) ∧ tr> k t₄ ∧ tr> k t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 rr02 : tr> k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 rr02 = RB-repl→ti> _ _ _ _ _ rbt x₁ (proj1 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) eq (rbr-black-right {t₁} {t₂} {t₃} {_} {k₂}x₃ x₄ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-right _ _ (proj1 rr04) (proj1 (proj2 rr04)) rr02 lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 rr04 : (k < k₂) ∧ tr> k t₁ ∧ tr> k t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 rr02 : tr> k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 rr02 = RB-repl→ti> _ _ _ _ _ rbt x₁ (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) eq (rbr-black-left {t₁} {t₂} {t₃} {_} {k₂}x₃ x₄ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-right _ _ (proj1 rr04) rr02 (proj2 (proj2 rr04)) lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 rr04 : (k < k₂) ∧ tr> k t₂ ∧ tr> k t₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 rr02 : tr> k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 rr02 = RB-repl→ti> _ _ _ _ _ rbt x₁ (proj1 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) eq (rbr-flip-ll {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-right _ _ (proj1 rr04)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 ⟪ proj1 (proj1 (proj2 rr04)) , ⟪ rr02 , proj2 (proj2 (proj1 (proj2 rr04))) ⟫ ⟫ (tr>-to-black (proj2 (proj2 rr04))) lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 rr04 : (k < kg) ∧ ((k < kp) ∧ tr> k t₂ ∧ tr> k t₁) ∧ tr> k uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 rr02 : tr> k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 rr02 = RB-repl→ti> _ _ _ _ _ rbt x₁ (proj1 (proj2 (proj1 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) eq (rbr-flip-lr {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ x₆ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-right _ _ (proj1 rr04)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 ⟪ proj1 (proj1 (proj2 rr04)) , ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , rr02 ⟫ ⟫ (tr>-to-black (proj2 (proj2 rr04))) lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 rr04 : (k < kg) ∧ ((k < kp) ∧ tr> k t₁ ∧ tr> k t₂) ∧ tr> k uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 rr02 : tr> k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 rr02 = RB-repl→ti> _ _ _ _ _ rbt x₁ (proj2 (proj2 (proj1 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) eq (rbr-flip-rl {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ x₆ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-right _ _ (proj1 rr04)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 (tr>-to-black (proj1 (proj2 rr04))) ⟪ proj1 (proj2 (proj2 rr04)) , ⟪ rr02 , proj2 (proj2 (proj2 (proj2 rr04))) ⟫ ⟫ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 rr04 : (k < kg) ∧ tr> k uncle ∧ ((k < kp) ∧ tr> k t₂ ∧ tr> k t₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 rr02 : tr> k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 rr02 = RB-repl→ti> _ _ _ _ _ rbt x₁ (proj1 (proj2 (proj2 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) eq (rbr-flip-rr {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-right _ _ (proj1 rr04)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 (tr>-to-black (proj1 (proj2 rr04))) ⟪ proj1 (proj2 (proj2 rr04)) , ⟪ proj1 (proj2 (proj2 (proj2 rr04))) , rr02 ⟫ ⟫ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 rr04 : (k < kg) ∧ tr> k uncle ∧ ((k < kp) ∧ tr> k t₁ ∧ tr> k t₂)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 rr02 : tr> k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 rr02 = RB-repl→ti> _ _ _ _ _ rbt x₁ (proj2 (proj2 (proj2 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) eq (rbr-rotate-ll {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) eq (rbr-rotate-rr {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) eq (rbr-rotate-rl {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) eq (rbr-rotate-lr {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 lem21 _ (t-left key₂ key₁ {_} {_} {t} {t₁} x x₁₀ x₂ ti₁) eq rbr-leaf = subst treeInvariant (node-cong refl refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 (t-node _ _ _ (subst (λ j → key₂ < j ) lem23 x) x₁ (subst (λ k → tr< k t) lem23 x₁₀) (subst (λ k → tr< k t₁) lem23 x₂) tt tt ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 lem21 _ (t-left key₂ key₁ {_} {_} {t₁} {t₂} x x₁₀ x₂ ti₁) eq (rbr-node {_} {_} {t₃} {t₄}) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-node _ _ _ (subst (λ j → key₂ < j ) lem23 x) x₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 (subst (λ k → tr< k t₁) lem23 x₁₀) (subst (λ k → tr< k t₂) lem23 x₂) (proj1 (proj2 rr04)) (proj2 (proj2 rr04)) ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
321 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 rr04 : (k < key) ∧ tr> k t₃ ∧ tr> k t₄
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 lem21 _ (t-left key₂ key₁ {_} {_} {t₁} {t₂} x x₁₀ x₂ ti₁) () (rbr-right {k₁} {_} {_} {t₃} {t₄} {t₅} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 lem21 _ (t-left key₂ key₁ {_} {_} {t₁} {t₂} x x₁₀ x₂ ti₁) () (rbr-left {k₁} {_} {_} {t₃} {t₄} {t₅} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) () (rbr-black-right {t₁} {t₂} {t₃} {_} {k₂} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) () (rbr-black-left {t₁} {t₂} {t₃} {_} {k₂} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) () (rbr-flip-ll {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) () (rbr-flip-lr {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ x₆ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
331 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) () (rbr-flip-rl {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ x₆ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) () (rbr-flip-rr {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-rotate-ll {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-rotate-rr {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-rotate-rl {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-rotate-lr {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) () rbr-leaf
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-node {_} {_} {t₃} {t₄}) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-node _ _ _ (subst (λ j → key₃ < j) lem23 x) x₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 (subst (λ k → tr< k t₇) lem23 x₂) (subst (λ k → tr< k t₈) lem23 x₃) (proj1 (proj2 rr04)) (proj2 (proj2 rr04)) ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 rr04 : (k < key ) ∧ tr> k t₃ ∧ tr> k t₄
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
345 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-right {k₃} {_} {_} {t₃} {t₄} {t₅} x₆ x₇ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
346 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-node _ _ _ (subst (λ j → key₃ < j) lem23 x) (proj1 rr04)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 (subst (λ k → tr< k t₇) lem23 x₂) (subst (λ k → tr< k t₈) lem23 x₃) (proj1 (proj2 rr04)) rr02 ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
348 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
350 rr04 : (k < k₃) ∧ tr> k t₄ ∧ tr> k t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 rr02 : tr> k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 rr02 = RB-repl→ti> _ _ _ _ _ rbt x₁ (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-left {k₃} {_} {_} {t₃} {t₄} {t₅} x₆ x₇ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-node _ _ _ (subst (λ j → key₃ < j) lem23 x) (proj1 rr04)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
356 (subst (λ k → tr< k t₇) lem23 x₂) (subst (λ k → tr< k t₈) lem23 x₃) rr02 (proj2 (proj2 rr04)) ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 rr04 : (k < k₃) ∧ tr> k t₄ ∧ tr> k t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
360 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
361 rr02 : tr> k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 rr02 = RB-repl→ti> _ _ _ _ _ rbt x₁ (proj1 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-black-right {t₃} {t₄} {t₅} x₆ x₇ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-black-left {t₃} {t₄} {t₅} x₆ x₇ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-ll {t} {t₁} {t₂} {uncle} {kg} {kp} {vg} {vp} x₆ x₇ x₈ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-node _ _ _ (subst (λ j → key₃ < j) lem23 x) (proj1 rr04)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
368 (subst (λ k → tr< k t₇) lem23 x₂) (subst (λ k → tr< k t₈) lem23 x₃)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
369 ⟪ proj1 (proj1 (proj2 rr04)) , ⟪ rr02 , proj2 (proj2 (proj1 (proj2 rr04))) ⟫ ⟫ ( tr>-to-black (proj2 (proj2 rr04))) ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
370 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
372 rr04 : (k < kg) ∧ ((k < kp) ∧ tr> k t₁ ∧ tr> k t) ∧ tr> k uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 rr02 : tr> k t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
375 rr02 = RB-repl→ti> _ _ _ _ _ rbt x₁ (proj1 (proj2 (proj1 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
376 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-lr {t} {t₁} {t₂} {uncle} {kg} {kp} {vg} {vp} x₆ x₇ x₈ x₉ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-node _ _ _ (subst (λ j → key₃ < j) lem23 x) (proj1 rr04)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 (subst (λ k → tr< k t₇) lem23 x₂) (subst (λ k → tr< k t₈) lem23 x₃)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 ⟪ proj1 (proj1 (proj2 rr04)) , ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , rr02 ⟫ ⟫ ( tr>-to-black (proj2 (proj2 rr04))) ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 rr04 : (k < kg) ∧ ((k < kp) ∧ tr> k t ∧ tr> k t₁) ∧ tr> k uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 rr02 : tr> k t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 rr02 = RB-repl→ti> _ _ _ _ _ rbt x₁ (proj2 (proj2 (proj1 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-rl {t} {t₁} {t₂} {uncle} {kg} {kp} {vg} {vp} x₆ x₇ x₈ x₉ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-node _ _ _ (subst (λ j → key₃ < j) lem23 x) (proj1 rr04)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 (subst (λ k → tr< k t₇) lem23 x₂) (subst (λ k → tr< k t₈) lem23 x₃)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 (tr>-to-black (proj1 (proj2 rr04))) ⟪ proj1 (proj2 (proj2 rr04)) , ⟪ rr02 , proj2 (proj2 (proj2 (proj2 rr04))) ⟫ ⟫ ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 rr04 : (k < kg) ∧ tr> k uncle ∧ ((k < kp) ∧ tr> k t₁ ∧ tr> k t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
395 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 rr02 : tr> k t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
397 rr02 = RB-repl→ti> _ _ _ _ _ rbt x₁ (proj1 (proj2 (proj2 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
398 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-rr {t} {t₁} {t₂} {uncle} {kg} {kp} {vg} {vp} x₆ x₇ x₈ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
399 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
400 (node-cong refl refl (just-injective (cong node-left eq)) refl) (t-node _ _ _ (subst (λ j → key₃ < j) lem23 x) (proj1 rr04)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
401 (subst (λ k → tr< k t₇) lem23 x₂) (subst (λ k → tr< k t₈) lem23 x₃)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 (tr>-to-black (proj1 (proj2 rr04))) ⟪ proj1 (proj2 (proj2 rr04)) , ⟪ proj1 (proj2 (proj2 (proj2 rr04))) , rr02 ⟫ ⟫ ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 rr04 : (k < kg) ∧ tr> k uncle ∧ ((k < kp) ∧ tr> k t ∧ tr> k t₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 rr02 : tr> k t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 rr02 = RB-repl→ti> _ _ _ _ _ rbt x₁ (proj2 (proj2 (proj2 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-rr x₆ x₇ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-ll x₆ x₇ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-rl {t} {t₁} {uncle} t₂ t₃ kg kp kn x₆ x₇ x₈ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-lr {t} {t₁} {uncle} t₂ t₃ kg kp kn x₆ x₇ x₈ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
413
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 RB-repl→ti-lem05 : {n : Level} {A : Set n} {key : ℕ} {value : A} {t t₁ t₂ : bt (Color ∧ A)} {value₁ : A} {key₁ : ℕ} (x : color t₂ ≡ Red) (x₁ : key < key₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 (rbt : replacedRBTree key value t₁ t₂) → (treeInvariant t₁ → treeInvariant t₂) → treeInvariant (node key₁ ⟪ Black , value₁ ⟫ t₁ t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
416 → treeInvariant (node key₁ ⟪ Black , value₁ ⟫ t₂ t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 RB-repl→ti-lem05 {n} {A} {key} {value} {t} {t1} {t2} {v1} {k} ceq x₁ rbt prev ti = lem21 (node k ⟪ Black , v1 ⟫ t1 t) ti refl rbt where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 lem22 : treeInvariant t2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
419 lem22 = prev (treeLeftDown _ _ ti )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
420 lem21 : (tree : bt (Color ∧ A)) → treeInvariant tree → tree ≡ node k ⟪ Black , v1 ⟫ t1 t → replacedRBTree key value t1 t2 → treeInvariant (node k ⟪ Black , v1 ⟫ t2 t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 lem21 _ t-leaf () rbt
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 lem21 _ (t-single key value) eq rbr-leaf = subst treeInvariant (node-cong refl refl refl (just-injective (cong node-right eq)) ) (t-left _ _ x₁ _ _ lem22)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
423 lem21 _ (t-single key value) () (rbr-node {_} {_} {t₃} {t₄})
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 lem21 _ (t-single key value) () (rbr-right {k₁} {_} {_} {t₃} {t₄} {t₅} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 lem21 _ (t-single key value) () (rbr-left {k₁} {_} {_} {t₃} {t₄} {t₅} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
426 lem21 _ (t-single key value) () (rbr-black-right {t₁} {t₂} {t₃} {_} {k₂}x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
427 lem21 _ (t-single key value) () (rbr-black-left {t₁} {t₂} {t₃} {_} {k₂}x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
428 lem21 _ (t-single key value) () (rbr-flip-ll {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 lem21 _ (t-single key value) () (rbr-flip-lr {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ x₆ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 lem21 _ (t-single key value) () (rbr-flip-rl {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ x₆ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 lem21 _ (t-single key value) () (rbr-flip-rr {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 lem21 _ (t-single key value) () (rbr-rotate-ll {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 lem21 _ (t-single key value) () (rbr-rotate-rr {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 lem21 _ (t-single key value) () (rbr-rotate-rl {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 lem21 _ (t-single key value) () (rbr-rotate-lr {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 lem21 _ (t-right key₂ key₁ {v1} {v2} {t} {t₁} x x₁₀ x₂ ti₁) eq rbr-leaf = subst treeInvariant (node-cong refl refl refl (just-injective (cong node-right eq)) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 (t-node _ _ _ x₁ (subst (λ j → j < key₁) lem23 x) tt tt (subst (λ k → tr> k t) lem23 x₁₀ ) (subst (λ k → tr> k t₁) lem23 x₂ ) (t-single _ _) ti₁) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
438 lem23 : key₂ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
439 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
440 lem21 _ (t-right key₂ key₁ {v1} {v2} {t} {t₁} x x₁₀ x₂ ti₁) () (rbr-node {_} {_} {t₃} {t₄})
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 lem21 _ (t-right key₂ key₁ x x₁₀ x₂ ti₁) () (rbr-right {k₁} {_} {_} {t₃} {t₄} {t₅} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
442 lem21 _ (t-right key₂ key₁ x x₁₀ x₂ ti₁) () (rbr-left {k₁} {_} {_} {t₃} {t₄} {t₅} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
443 lem21 _ (t-right key₂ key₁ x x₁₀ x₂ ti₁) () (rbr-black-right {t₁} {t₂} {t₃} {_} {k₂}x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
444 lem21 _ (t-right key₂ key₁ x x₁₀ x₂ ti₁) () (rbr-black-left {t₁} {t₂} {t₃} {_} {k₂}x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
445 lem21 _ (t-right key₂ key₁ x x₁₀ x₂ ti₁) () (rbr-flip-ll {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
446 lem21 _ (t-right key₂ key₁ x x₁₀ x₂ ti₁) () (rbr-flip-lr {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ x₆ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
447 lem21 _ (t-right key₂ key₁ x x₁₀ x₂ ti₁) () (rbr-flip-rl {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ x₆ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
448 lem21 _ (t-right key₂ key₁ x x₁₀ x₂ ti₁) () (rbr-flip-rr {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
449 lem21 _ (t-right key₂ key₁ x x₁₀ x₂ ti₁) eq (rbr-rotate-ll {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
450 lem21 _ (t-right key₂ key₁ x x₁₀ x₂ ti₁) eq (rbr-rotate-rr {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
451 lem21 _ (t-right key₂ key₁ x x₁₀ x₂ ti₁) eq (rbr-rotate-rl {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 lem21 _ (t-right key₂ key₁ x x₁₀ x₂ ti₁) eq (rbr-rotate-lr {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
453 lem21 _ (t-left key₂ key₁ {_} {_} {t} {t₁} x x₁₀ x₂ ti₁) () rbr-leaf
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
454 lem21 _ (t-left key₂ key₁ {_} {_} {t₁} {t₂} x x₁₀ x₂ ti₁) eq (rbr-node {_} {_} {t₃} {t₄}) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
455 (node-cong refl refl refl (just-injective (cong node-right eq))) (t-left _ _ (proj1 rr04) (proj1 (proj2 rr04)) (proj2 (proj2 rr04)) lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 rr04 : (key < k) ∧ tr< k t₃ ∧ tr< k t₄
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
457 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
458 lem21 _ (t-left key₂ key₁ {_} {_} {t₁} {t₂} x x₁₀ x₂ ti₁) eq (rbr-right {k₁} {_} {_} {t₃} {t₄} {t₅} x₃ x₄ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
459 (node-cong refl refl refl (just-injective (cong node-right eq))) (t-left _ _ (proj1 rr04) (proj1 (proj2 rr04)) rr02 lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
460 rr04 : (k₁ < k) ∧ tr< k t₄ ∧ tr< k t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
461 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 rr02 : tr< k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
463 rr02 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 lem21 _ (t-left key₂ key₁ {_} {_} {t₁} {t₂} x x₁₀ x₂ ti₁) eq (rbr-left {k₁} {_} {_} {t₃} {t₄} {t₅} x₃ x₄ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
465 (node-cong refl refl refl (just-injective (cong node-right eq))) (t-left _ _ (proj1 rr04) rr02 (proj2 (proj2 rr04)) lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 rr04 : (k₁ < k) ∧ tr< k t₄ ∧ tr< k t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
467 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
468 rr02 : tr< k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 rr02 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj1 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-black-right {t₁} {t₂} {t₃} {_} {k₂} x₃ x₄ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
471 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-black-left {t₁} {t₂} {t₃} {_} {k₂} x₃ x₄ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
472 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-flip-ll {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
473 (node-cong refl refl refl (just-injective (cong node-right eq))) (t-left _ _ (proj1 rr04) ⟪ proj1 (proj1 (proj2 rr04)) ,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
474 ⟪ rr02 , proj2 (proj2 (proj1 (proj2 rr04))) ⟫ ⟫ (tr<-to-black (proj2 (proj2 rr04))) lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
475 rr04 : (kg < k) ∧ ((kp < k) ∧ tr< k t₂ ∧ tr< k t₁) ∧ tr< k uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
476 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
477 rr02 : tr< k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
478 rr02 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj1 (proj2 (proj1 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
479 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-flip-lr {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ x₆ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
480 (node-cong refl refl refl (just-injective (cong node-right eq))) (t-left _ _ (proj1 rr04) ⟪ proj1 (proj1 (proj2 rr04)) ,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
481 ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , rr02 ⟫ ⟫ (tr<-to-black (proj2 (proj2 rr04))) lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 rr04 : (kg < k) ∧ ((kp < k) ∧ tr< k t₁ ∧ tr< k t₂) ∧ tr< k uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 rr02 : tr< k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
485 rr02 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj2 (proj2 (proj1 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-flip-rl {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ x₆ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 (node-cong refl refl refl (just-injective (cong node-right eq))) (t-left _ _ (proj1 rr04) (tr<-to-black (proj1 (proj2 rr04)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 ⟪ proj1 (proj2 (proj2 rr04)) , ⟪ rr02 , proj2 (proj2 (proj2 (proj2 rr04))) ⟫ ⟫ lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 rr04 : (kg < k) ∧ tr< k uncle ∧ ((kp < k) ∧ tr< k t₂ ∧ tr< k t₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
490 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
491 rr02 : tr< k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
492 rr02 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj1 (proj2 (proj2 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
493 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-flip-rr {t₁} {t₂} {t₃} {uncle} {kg} {kp} {vg} {vp} x₃ x₄ x₅ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
494 (node-cong refl refl refl (just-injective (cong node-right eq))) (t-left _ _ (proj1 rr04) (tr<-to-black (proj1 (proj2 rr04)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
495 ⟪ proj1 (proj2 (proj2 rr04)) , ⟪ proj1 (proj2 (proj2 (proj2 rr04))) , rr02 ⟫ ⟫ lem22 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
496 rr04 : (kg < k) ∧ tr< k uncle ∧ ((kp < k) ∧ tr< k t₁ ∧ tr< k t₂)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
497 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
498 rr02 : tr< k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
499 rr02 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj2 (proj2 (proj2 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
500 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-rotate-ll {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-rotate-rr {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-rotate-rl {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-rotate-lr {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
504 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) () rbr-leaf
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
505 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} {t₁₁} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-node {_} {_} {t₃} {t₄}) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 (node-cong refl refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 rr04) (subst (λ j → j < key₂) lem23 x₁₀)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
507 (proj1 (proj2 rr04)) (proj2 (proj2 rr04)) (subst (λ j → tr> j t₁₀) lem23 x₄) (subst (λ j → tr> j t₁₁) lem23 x₅) lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
509 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 rr04 : (key < k) ∧ tr< k t₃ ∧ tr< k t₄
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
511 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₉} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-right {k₃} {_} {_} {t₃} {t₄} {t₅} x₆ x₇ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 (node-cong refl refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 rr04) (subst (λ j → j < key₂) lem23 x₁₀)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
514 (proj1 (proj2 rr04)) rr02 (subst (λ k → tr> k t₉) lem23 x₄) (subst (λ k → tr> k t₁₀) lem23 x₅) lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
516 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 rr04 : (k₃ < k) ∧ tr< k t₄ ∧ tr< k t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 rr02 : tr< k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
520 rr02 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₉} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-left {k₃} {_} {_} {t₃} {t₄} {t₅} x₆ x₇ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
522 (node-cong refl refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 rr04) (subst (λ j → j < key₂) lem23 x₁₀)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
523 rr02 (proj2 (proj2 rr04)) (subst (λ k → tr> k t₉) lem23 x₄) (subst (λ k → tr> k t₁₀) lem23 x₅) lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
524 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
525 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
526 rr04 : (k₃ < k) ∧ tr< k t₄ ∧ tr< k t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
527 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
528 rr02 : tr< k t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
529 rr02 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj1 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₉} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-black-right {t₃} {t₄} {t₅} x₆ x₇ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₉} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-black-left {t₃} {t₄} {t₅} x₆ x₇ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₉} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-ll {t} {t₁} {t₂} {uncle} {kg} {kp} {vg} {vp} x₆ x₇ x₈ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 (node-cong refl refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 rr04) (subst (λ j → j < key₂) lem23 x₁₀)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 ⟪ proj1 (proj1 (proj2 rr04)) , ⟪ rr02 , proj2 (proj2 (proj1 (proj2 rr04))) ⟫ ⟫ (tr<-to-black (proj2 (proj2 rr04))) (subst (λ k → tr> k t₉) lem23 x₄) (subst (λ k → tr> k t₁₀) lem23 x₅) lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
536 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
538 rr04 : (kg < k) ∧ ((kp < k) ∧ tr< k t₁ ∧ tr< k t) ∧ tr< k uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
539 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 rr02 : tr< k t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
541 rr02 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj1 (proj2 (proj1 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
542 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₉} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-lr {t} {t₁} {t₂} {uncle} {kg} {kp} {vg} {vp} x₆ x₇ x₈ x₉ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
543 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 (node-cong refl refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 rr04) (subst (λ j → j < key₂) lem23 x₁₀)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 ⟪ proj1 (proj1 (proj2 rr04)) , ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , rr02 ⟫ ⟫ (tr<-to-black (proj2 (proj2 rr04))) (subst (λ k → tr> k t₉) lem23 x₄) (subst (λ k → tr> k t₁₀) lem23 x₅) lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
546 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
548 rr04 : (kg < k) ∧ ((kp < k) ∧ tr< k t ∧ tr< k t₁) ∧ tr< k uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
550 rr02 : tr< k t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
551 rr02 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj2 (proj2 (proj1 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
552 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₉} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-rl {t} {t₁} {t₂} {uncle} {kg} {kp} {vg} {vp} x₆ x₇ x₈ x₉ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
553 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
554 (node-cong refl refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 rr04) (subst (λ j → j < key₂) lem23 x₁₀)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
555 (tr<-to-black (proj1 (proj2 rr04))) ⟪ proj1 (proj2 (proj2 rr04)) , ⟪ rr02 , proj2 (proj2 (proj2 (proj2 rr04))) ⟫ ⟫ (subst (λ k → tr> k t₉) lem23 x₄) (subst (λ k → tr> k t₁₀) lem23 x₅) lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
556 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
557 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 rr04 : (kg < k) ∧ tr< k uncle ∧ ((kp < k) ∧ tr< k t₁ ∧ tr< k t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
559 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 rr02 : tr< k t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
561 rr02 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj1 (proj2 (proj2 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
562 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₉} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-rr {t} {t₁} {t₂} {uncle} {kg} {kp} {vg} {vp} x₆ x₇ x₈ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
564 (node-cong refl refl refl (just-injective (cong node-right eq))) (t-node _ _ _ (proj1 rr04) (subst (λ j → j < key₂) lem23 x₁₀)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
565 (tr<-to-black (proj1 (proj2 rr04))) ⟪ proj1 (proj2 (proj2 rr04)) , ⟪ proj1 (proj2 (proj2 (proj2 rr04))) , rr02 ⟫ ⟫ (subst (λ k → tr> k t₉) lem23 x₄) (subst (λ k → tr> k t₁₀) lem23 x₅) lem22 ti₂) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
566 lem23 : key₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
568 rr04 : (kg < k) ∧ tr< k uncle ∧ ((kp < k) ∧ tr< k t ∧ tr< k t₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
569 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
570 rr02 : tr< k t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 rr02 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj2 (proj2 (proj2 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
572 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-rr x₆ x₇ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
573 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-ll x₆ x₇ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
574 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-rl {t} {t₁} {uncle} t₂ t₃ kg kp kn x₆ x₇ x₈ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
575 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-lr {t} {t₁} {uncle} t₂ t₃ kg kp kn x₆ x₇ x₈ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
576
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
577
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
578
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
579 to-black-treeInvariant : {n : Level} {A : Set n} → (t : bt (Color ∧ A) ) → treeInvariant t → treeInvariant (to-black t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
580 to-black-treeInvariant {n} {A} .leaf t-leaf = t-leaf
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
581 to-black-treeInvariant {n} {A} .(node key value leaf leaf) (t-single key value) = t-single key _
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
582 to-black-treeInvariant {n} {A} .(node key _ leaf (node key₁ _ _ _)) (t-right key key₁ x x₁ x₂ ti) = t-right key key₁ x x₁ x₂ ti
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
583 to-black-treeInvariant {n} {A} .(node key₁ _ (node key _ _ _) leaf) (t-left key key₁ x x₁ x₂ ti) = t-left key key₁ x x₁ x₂ ti
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
584 to-black-treeInvariant {n} {A} .(node key₁ _ (node key _ _ _) (node key₂ _ _ _)) (t-node key key₁ key₂ x x₁ x₂ x₃ x₄ x₅ ti ti₁) = t-node key key₁ key₂ x x₁ x₂ x₃ x₄ x₅ ti ti₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
585
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
586 RB→t2notLeaf : {n : Level} {A : Set n} {key : ℕ} {value : A} → (t₁ t₂ : bt (Color ∧ A) ) → (rbt : replacedRBTree key value t₁ t₂) → IsNode t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
587 RB→t2notLeaf {n} {A} {k} {v} .leaf .(node k ⟪ Red , v ⟫ leaf leaf) rbr-leaf = record { key = k ; value = ⟪ Red , v ⟫ ; left = leaf ; right = leaf ; t=node = refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
588 RB→t2notLeaf {n} {A} {k} {v} .(node k ⟪ _ , _ ⟫ _ _) .(node k ⟪ _ , v ⟫ _ _) rbr-node = record { key = k ; value = ⟪ _ , v ⟫ ; left = _ ; right = _ ; t=node = refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
589 RB→t2notLeaf {n} {A} {k} {v} .(node _ ⟪ _ , _ ⟫ _ _) .(node _ ⟪ _ , _ ⟫ _ _) (rbr-right x x₁ rbt) = record { key = _ ; value = _ ; left = _ ; right = _; t=node = refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 RB→t2notLeaf {n} {A} {k} {v} .(node _ ⟪ _ , _ ⟫ _ _) .(node _ ⟪ _ , _ ⟫ _ _) (rbr-left x x₁ rbt) = record { key = _ ; value = _ ; left = _ ; right = _; t=node = refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
591 RB→t2notLeaf {n} {A} {k} {v} .(node _ ⟪ Black , _ ⟫ _ _) .(node _ ⟪ Black , _ ⟫ _ _) (rbr-black-right x x₁ rbt) = record { key = _ ; value = _ ; left = _ ; right = _; t=node = refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 RB→t2notLeaf {n} {A} {k} {v} .(node _ ⟪ Black , _ ⟫ _ _) .(node _ ⟪ Black , _ ⟫ _ _) (rbr-black-left x x₁ rbt) = record { key = _ ; value = _ ; left = _ ; right = _; t=node = refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
593 RB→t2notLeaf {n} {A} {k} {v} .(node _ ⟪ Black , _ ⟫ (node _ ⟪ Red , _ ⟫ _ _) _) .(node _ ⟪ Red , _ ⟫ (node _ ⟪ Black , _ ⟫ _ _) (to-black _)) (rbr-flip-ll x x₁ x₂ rbt) = record { key = _ ; value = _ ; left = _ ; right = _; t=node = refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 RB→t2notLeaf {n} {A} {k} {v} .(node _ ⟪ Black , _ ⟫ (node _ ⟪ Red , _ ⟫ _ _) _) .(node _ ⟪ Red , _ ⟫ (node _ ⟪ Black , _ ⟫ _ _) (to-black _)) (rbr-flip-lr x x₁ x₂ x₃ rbt) = record { key = _ ; value = _ ; left = _ ; right = _; t=node = refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
595 RB→t2notLeaf {n} {A} {k} {v} .(node _ ⟪ Black , _ ⟫ _ (node _ ⟪ Red , _ ⟫ _ _)) .(node _ ⟪ Red , _ ⟫ (to-black _) (node _ ⟪ Black , _ ⟫ _ _)) (rbr-flip-rl x x₁ x₂ x₃ rbt) = record { key = _ ; value = _ ; left = _ ; right = _; t=node = refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 RB→t2notLeaf {n} {A} {k} {v} .(node _ ⟪ Black , _ ⟫ _ (node _ ⟪ Red , _ ⟫ _ _)) .(node _ ⟪ Red , _ ⟫ (to-black _) (node _ ⟪ Black , _ ⟫ _ _)) (rbr-flip-rr x x₁ x₂ rbt) = record { key = _ ; value = _ ; left = _ ; right = _; t=node = refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 RB→t2notLeaf {n} {A} {k} {v} .(node _ ⟪ Black , _ ⟫ (node _ ⟪ Red , _ ⟫ _ _) _) .(node _ ⟪ Black , _ ⟫ _ (node _ ⟪ Red , _ ⟫ _ _)) (rbr-rotate-ll x x₁ rbt) = record { key = _ ; value = _ ; left = _ ; right = _; t=node = refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 RB→t2notLeaf {n} {A} {k} {v} .(node _ ⟪ Black , _ ⟫ _ (node _ ⟪ Red , _ ⟫ _ _)) .(node _ ⟪ Black , _ ⟫ (node _ ⟪ Red , _ ⟫ _ _) _) (rbr-rotate-rr x x₁ rbt) = record { key = _ ; value = _ ; left = _ ; right = _; t=node = refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
599 RB→t2notLeaf {n} {A} {k} {v} .(node kg ⟪ Black , _ ⟫ (node kp ⟪ Red , _ ⟫ _ _) _) .(node kn ⟪ Black , _ ⟫ (node kp ⟪ Red , _ ⟫ _ t₂) (node kg ⟪ Red , _ ⟫ t₃ _)) (rbr-rotate-lr t₂ t₃ kg kp kn x x₁ x₂ rbt) = record { key = kn ; value = ⟪ Black , _ ⟫ ; left = _ ; right = _; t=node = refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 RB→t2notLeaf {n} {A} {k} {v} .(node kg ⟪ Black , _ ⟫ _ (node kp ⟪ Red , _ ⟫ _ _)) .(node kn ⟪ Black , _ ⟫ (node kg ⟪ Red , _ ⟫ _ t₂) (node kp ⟪ Red , _ ⟫ t₃ _)) (rbr-rotate-rl t₂ t₃ kg kp kn x x₁ x₂ rbt) = record { key = kn ; value = ⟪ Black , _ ⟫ ; left = _ ; right = _; t=node = refl }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
601
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
602
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
603 RB-repl→ti-lem06 : {n : Level} {A : Set n} {key : ℕ} {value : A} {t t₁ t₂ uncle : bt (Color ∧ A)} {kg kp : ℕ} {vg vp : A} (x : color t₂ ≡ Red)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
604 (x₁ : color uncle ≡ Red) (x₂ : key < kp) (rbt : replacedRBTree key value t₁ t₂) → (treeInvariant t₁ → treeInvariant t₂)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
605 → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ t₁ t) uncle)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
606 → treeInvariant (node kg ⟪ Red , vg ⟫ (node kp ⟪ Black , vp ⟫ t₂ t) (to-black uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
607 RB-repl→ti-lem06 {n} {A} {key} {value} {t} {t1} {t2} {uncle} {kg} {kp} {vg} {vp} ceq ueq x₁ rbt prev ti
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
608 = lem21 (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ t1 t) uncle) ti refl rbt where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
609 lem22 : treeInvariant t2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
610 lem22 = prev (treeLeftDown _ _ (treeLeftDown _ _ ti ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
611 lem25 : treeInvariant t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
612 lem25 = treeRightDown _ _ (treeLeftDown _ _ ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
613 lem21 : (tree : bt (Color ∧ A)) → treeInvariant tree → tree ≡ (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ t1 t) uncle) → replacedRBTree key value t1 t2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
614 → treeInvariant (node kg ⟪ Red , vg ⟫ (node kp ⟪ Black , vp ⟫ t2 t) (to-black uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
615 lem21 _ t-leaf () rbt
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
616 lem21 _ (t-single key value) () _
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
617 lem21 _ (t-right key key₁ x x₁₀ x₂ ti₁) () _
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
618 lem21 _ (t-left key₂ key₁ {_} {_} {t} {t₁} x x₁₀ x₂ ti₁) eq rbr-leaf = subst treeInvariant (node-cong refl refl refl (subst (λ k → leaf ≡ to-black k ) lem24 refl) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
619 (t-left _ _ (proj1 rr04) ⟪ rr07 , ⟪ tt , tt ⟫ ⟫ (proj2 (proj2 rr04)) (subst (λ k → treeInvariant (node kp ⟪ Black , vp ⟫ (node key ⟪ Red , value ⟫ leaf leaf) k ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
620 (just-injective (cong node-right (just-injective (cong node-left eq)))) (rr05 t₁ refl rr06) )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
621 lem24 : leaf ≡ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
622 lem24 = just-injective (cong node-right eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
623 lem23 : key₁ ≡ kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
624 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
625 rr04 : (kp < kg) ∧ ⊤ ∧ tr< kg _
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
626 rr04 = proj1 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) refl ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
627 rr06 : treeInvariant t₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
628 rr06 = treeRightDown _ _ ti₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
629 rr07 : key < kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
630 rr07 = <-trans x₁ (proj1 rr04)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
631 rr05 : (tree : bt (Color ∧ A)) → tree ≡ t₁ → treeInvariant tree → treeInvariant (node kp ⟪ Black , vp ⟫ (node key ⟪ Red , value ⟫ leaf leaf) tree)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
632 rr05 .leaf eq₁ t-leaf = t-left _ _ x₁ tt tt (t-single _ _)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
633 rr05 .(node key₃ value leaf leaf) eq₁ ti₃@(t-single key₃ value) = t-node _ _ _ x₁ rr09 tt tt tt tt (t-single _ _) (t-single _ _) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
634 rr08 : (key₂ < key₃) ∧ ⊤ ∧ ⊤
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
635 rr08 = proj2 (ti-property1 (subst (λ k → treeInvariant k) (node-cong refl refl refl (sym eq₁)) ti₁))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
636 rr09 : kp < key₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
637 rr09 = subst (λ k → k < key₃) (just-injective (cong node-key (just-injective (cong node-left eq)))) (proj1 rr08)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
638 rr05 .(node key₃ _ leaf (node key₁ _ _ _)) eq₁ ti₃@(t-right key₃ key₁ {_} {_} {t₃} {t₄} x x₁₀ x₂ ti₂) = t-node _ _ _ x₁ (proj1 rr08) tt tt tt
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
639 ⟪ <-trans (proj1 rr08) x , ⟪ proj1 (proj2 (proj2 (proj2 rr08))) , proj2 (proj2 (proj2 (proj2 rr08))) ⟫ ⟫ (t-single _ _) ti₃ where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
640 rr08 : (kp < key₃) ∧ ⊤ ∧ ((kp < key₁) ∧ tr> kp t₃ ∧ tr> kp t₄)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
641 rr08 = proj2 (ti-property1 (subst (λ k → treeInvariant k) (node-cong (just-injective (cong node-key (just-injective (cong node-left eq)))) refl refl (sym eq₁)) ti₁))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
642 rr05 .(node key₁ _ (node key₃ _ _ _) leaf) eq₁ ti₃@(t-left key₃ key₁ {_} {_} {t₃} {t₄} x x₁₀ x₂ ti₂) = t-node _ _ _ x₁ (proj1 rr08) tt tt
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
643 (proj1 (proj2 rr08)) tt (t-single _ _) ti₃ where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
644 rr08 : (kp < key₁) ∧ ((kp < key₃) ∧ tr> kp t₃ ∧ tr> kp t₄) ∧ ⊤
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
645 rr08 = proj2 (ti-property1 (subst (λ k → treeInvariant k) (node-cong (just-injective (cong node-key (just-injective (cong node-left eq)))) refl refl (sym eq₁)) ti₁))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
646 rr05 .(node key₁ _ (node key₃ _ _ _) (node key₂ _ _ _)) eq₁ ti₄@(t-node key₃ key₁ key₂ {_} {_} {_} {t₃} {t₄} {t₅} {t₆} x x₁₀ x₂ x₃ x₄ x₅ ti₂ ti₃)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
647 = t-node _ _ _ x₁ (proj1 rr08) tt tt (proj1 (proj2 rr08)) (proj2 (proj2 rr08)) (t-single _ _) ti₄ where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
648 rr08 : (kp < key₁) ∧ ((kp < key₃) ∧ tr> kp t₃ ∧ tr> kp t₄) ∧ ((kp < key₂) ∧ tr> kp t₅ ∧ tr> kp t₆)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
649 rr08 = proj2 (ti-property1 (subst (λ k → treeInvariant k) (node-cong (just-injective (cong node-key (just-injective (cong node-left eq)))) refl refl (sym eq₁)) ti₁))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
650 lem21 _ (t-left key₂ key₁ {value₁} {_} {t₁} {t₂} x x₁₀ x₂ ti₁) eq (rbr-node {v₁} {ca} {t₃} {t₄}) = rr05 t refl lem25 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
651 lem23 : key₁ ≡ kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
652 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
653 lem24 : leaf ≡ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 lem24 = just-injective (cong node-right eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
655 rr04 : (kp < kg) ∧ ((key < kg) ∧ tr< kg t₃ ∧ tr< kg t₄) ∧ tr< kg t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
656 rr04 = proj1 (ti-property1 ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
657 rr08 : (key < kp) ∧ tr< kp t₃ ∧ tr< kp t₄
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
658 rr08 = proj1 (ti-property1 (treeLeftDown _ _ ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
659 rr05 : (tree : bt (Color ∧ A)) → tree ≡ t → treeInvariant tree
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
660 → treeInvariant (node kg ⟪ Red , vg ⟫ (node kp ⟪ Black , vp ⟫ (node key ⟪ ca , value ⟫ t₃ t₄) t) (to-black uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
661 rr05 _ eq₁ t-leaf = subst treeInvariant (node-cong refl refl (node-cong refl refl refl eq₁) (subst (λ k → leaf ≡ to-black k ) lem24 refl))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
662 ( t-left _ _ (proj1 rr04) (proj1 (proj2 rr04)) tt (t-left _ _ x₁ (proj1 (proj2 rr08)) (proj2 (proj2 rr08)) lem22 ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
663 rr05 _ eq₁ (t-single key₃ value) = subst treeInvariant (node-cong refl refl (node-cong refl refl refl eq₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
664 (subst (λ k → leaf ≡ to-black k ) lem24 refl))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
665 ( t-left _ _ (proj1 rr04) (proj1 (proj2 rr04)) ⟪ proj1 (proj2 (proj2 rr09)) , ⟪ tt , tt ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
666 (t-node _ _ _ (proj1 rr08) rr10 (proj1 (proj2 rr08)) (proj2 (proj2 rr08)) tt tt lem22 (t-single _ _) )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
667 rr09 : (kp < kg) ∧ ((key < kg) ∧ tr< kg t₃ ∧ tr< kg t₄) ∧ ((key₃ < kg) ∧ ⊤ ∧ ⊤ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
668 rr09 = proj1 (ti-property1 (subst (λ k → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ (node key ⟪ ca , v₁ ⟫ t₃ t₄) k) uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
669 (sym eq₁) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
670 rr10 : kp < key₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
671 rr10 = proj1 (subst (λ k → tr> kp k) (sym eq₁) (proj2 (ti-property1 (treeLeftDown _ _ ti))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
672 rr05 _ eq₁ (t-right key₃ key₁ {_} {_} {t₅} {t₆} y y₁ y₂ ti₁) = subst treeInvariant (node-cong refl refl (node-cong refl refl refl eq₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
673 (subst (λ k → leaf ≡ to-black k ) lem24 refl))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
674 ( t-left _ _ (proj1 rr04) (proj1 (proj2 rr04)) ⟪ proj1 (proj2 (proj2 rr09)) , ⟪ tt , proj2 (proj2 (proj2 (proj2 rr09))) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
675 (t-node _ _ _ (proj1 rr08) rr10 (proj1 (proj2 rr08)) (proj2 (proj2 rr08)) tt
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
676 ⟪ <-trans rr10 y , ⟪ <-tr> y₁ rr10 , <-tr> y₂ rr10 ⟫ ⟫ lem22 (t-right _ _ y y₁ y₂ ti₁) )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
677 rr09 : (kp < kg) ∧ ((key < kg) ∧ tr< kg t₃ ∧ tr< kg t₄) ∧ ((key₃ < kg) ∧ ⊤ ∧ ( (key₁ < kg) ∧ tr< kg t₅ ∧ tr< kg t₆ ) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
678 rr09 = proj1 (ti-property1 (subst (λ k → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ (node key ⟪ ca , v₁ ⟫ t₃ t₄) k) uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
679 (sym eq₁) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
680 rr10 : kp < key₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
681 rr10 = proj1 (subst (λ k → tr> kp k) (sym eq₁) (proj2 (ti-property1 (treeLeftDown _ _ ti))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
682 rr05 _ eq₁ (t-left key₃ key₁ {_} {_} {t₅} {t₆} y y₁ y₂ ti₁) = subst treeInvariant (node-cong refl refl (node-cong refl refl refl eq₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
683 (subst (λ k → leaf ≡ to-black k ) lem24 refl))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
684 ( t-left _ _ (proj1 rr04) (proj1 (proj2 rr04)) ⟪ proj1 (proj2 (proj2 rr09)) , ⟪ proj1 (proj2 (proj2 (proj2 rr09))) , tt ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
685 (t-node _ _ _ (proj1 rr08) (proj1 rr10) (proj1 (proj2 rr08)) (proj2 (proj2 rr08))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
686 ⟪ proj1 (proj1 (proj2 rr10)) , ⟪ proj1 (proj2 (proj1 (proj2 rr10))) , proj2 (proj2 (proj1 (proj2 rr10))) ⟫ ⟫ tt lem22 (t-left _ _ y y₁ y₂ ti₁) )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
687 rr09 : (kp < kg) ∧ ((key < kg) ∧ tr< kg t₃ ∧ tr< kg t₄) ∧ ((key₁ < kg) ∧ ( (key₃ < kg) ∧ tr< kg t₅ ∧ tr< kg t₆ ) ∧ ⊤ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
688 rr09 = proj1 (ti-property1 (subst (λ k → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ (node key ⟪ ca , v₁ ⟫ t₃ t₄) k) uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
689 (sym eq₁) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
690 rr10 : (kp < key₁ ) ∧ ((kp < key₃) ∧ tr> kp t₅ ∧ tr> kp t₆) ∧ ⊤
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
691 rr10 = subst (λ k → tr> kp k) (sym eq₁) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
692 rr05 _ eq₁ (t-node key₃ key₁ key₂ {_} {_} {_} {t₅} {t₆} {t₇} {t₈} y y₁ y₂ y₃ y₄ y₅ ti₁ ti₂)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
693 = subst treeInvariant (node-cong refl refl (node-cong refl refl refl eq₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
694 (subst (λ k → leaf ≡ to-black k ) lem24 refl))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
695 ( t-left _ _ (proj1 rr04) (proj1 (proj2 rr04)) ⟪ proj1 (proj2 (proj2 rr09)) , ⟪ proj1 (proj2 (proj2 (proj2 rr09))) , proj2 (proj2 (proj2 (proj2 rr09))) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
696 (t-node _ _ _ (proj1 rr08) (proj1 rr10) (proj1 (proj2 rr08)) (proj2 (proj2 rr08))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
697 ⟪ proj1 (proj1 (proj2 rr10)) , ⟪ proj1 (proj2 (proj1 (proj2 rr10))) , proj2 (proj2 (proj1 (proj2 rr10))) ⟫ ⟫ (proj2 (proj2 rr10)) lem22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
698 (t-node _ _ _ y y₁ y₂ y₃ y₄ y₅ ti₁ ti₂))) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
699 rr09 : (kp < kg) ∧ ((key < kg) ∧ tr< kg t₃ ∧ tr< kg t₄) ∧ ((key₁ < kg) ∧ ( (key₃ < kg) ∧ tr< kg t₅ ∧ tr< kg t₆ ) ∧ ( (key₂ < kg) ∧ tr< kg t₇ ∧ tr< kg t₈ ) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
700 rr09 = proj1 (ti-property1 (subst (λ k → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ (node key ⟪ ca , v₁ ⟫ t₃ t₄) k) uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
701 (sym eq₁) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
702 rr10 : (kp < key₁ ) ∧ ((kp < key₃) ∧ tr> kp t₅ ∧ tr> kp t₆) ∧ ((kp < key₂) ∧ tr> kp t₇ ∧ tr> kp t₈)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 rr10 = subst (λ k → tr> kp k) (sym eq₁) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
704 lem21 _ (t-left key₂ key₁ {_} {_} {t₁} {t₂} x x₁₀ x₂ ti₁) eq (rbr-right {k₁} {v₁} {ca} {t₃} {t₄} {t₅} x₃ x₄ rbt) = rr05 t refl lem25 where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
705 lem23 : key₁ ≡ kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
706 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
707 lem24 : leaf ≡ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
708 lem24 = just-injective (cong node-right eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
709 rr04 : (kp < kg) ∧ ((k₁ < kg) ∧ tr< kg t₄ ∧ tr< kg t₅) ∧ tr< kg t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
710 rr04 = proj1 (ti-property1 ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
711 rr08 : (k₁ < kp) ∧ tr< kp t₄ ∧ tr< kp t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
712 rr08 = proj1 (ti-property1 (treeLeftDown _ _ ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
713 rr03 : tr< kp t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
714 rr03 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj2 (proj2 rr08))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
715 rr05 : (tree : bt (Color ∧ A)) → tree ≡ t → treeInvariant tree
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
716 → treeInvariant (node kg ⟪ Red , vg ⟫ (node kp ⟪ Black , vp ⟫ (node k₁ ⟪ ca , v₁ ⟫ t₄ t₃) t) (to-black uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
717 rr05 _ eq₁ t-leaf = subst treeInvariant (node-cong refl refl (node-cong refl refl refl eq₁) (subst (λ k → leaf ≡ to-black k ) lem24 refl))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
718 ( t-left _ _ (proj1 rr04) ⟪ <-trans (proj1 rr08) (proj1 rr04) , ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , >-tr< rr03 (proj1 rr04) ⟫ ⟫ tt
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
719 (t-left _ _ (proj1 rr08) (proj1 (proj2 rr08)) rr03 lem22 ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
720 rr05 _ eq₁ (t-single key₃ value) = subst treeInvariant (node-cong refl refl (node-cong refl refl refl eq₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
721 (subst (λ k → leaf ≡ to-black k ) lem24 refl))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
722 ( t-left _ _ (proj1 rr04) ⟪ <-trans (proj1 rr08) (proj1 rr04) , ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , >-tr< rr03 (proj1 rr04) ⟫ ⟫ ⟪ proj1 (proj2 (proj2 rr09)) , ⟪ tt , tt ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
723 (t-node _ _ _ (proj1 rr08) rr10 (proj1 (proj2 rr08)) rr03 tt tt lem22 (t-single _ _) )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
724 rr09 : (kp < kg) ∧ ((k₁ < kg) ∧ tr< kg t₄ ∧ tr< kg t₅) ∧ ((key₃ < kg) ∧ ⊤ ∧ ⊤ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
725 rr09 = proj1 (ti-property1 (subst (λ k → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ (node k₁ ⟪ ca , v₁ ⟫ t₄ t₅) k) uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
726 (sym eq₁) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
727 rr10 : kp < key₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
728 rr10 = proj1 (subst (λ k → tr> kp k) (sym eq₁) (proj2 (ti-property1 (treeLeftDown _ _ ti))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
729 rr05 _ eq₁ (t-right key₃ key₁ {_} {_} {t₆} {t₇} y y₁ y₂ ti₁) = subst treeInvariant (node-cong refl refl (node-cong refl refl refl eq₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
730 (subst (λ k → leaf ≡ to-black k ) lem24 refl))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
731 ( t-left _ _ (proj1 rr04) ⟪ <-trans (proj1 rr08) (proj1 rr04) , ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , >-tr< rr03 (proj1 rr04) ⟫ ⟫ ⟪ proj1 (proj2 (proj2 rr09)) , ⟪ tt , proj2 (proj2 (proj2 (proj2 rr09))) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
732 (t-node _ _ _ (proj1 rr08) rr10 (proj1 (proj2 rr08)) rr03 tt
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
733 ⟪ <-trans rr10 y , ⟪ <-tr> y₁ rr10 , <-tr> y₂ rr10 ⟫ ⟫ lem22 (t-right _ _ y y₁ y₂ ti₁) )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
734 rr09 : (kp < kg) ∧ ((k₁ < kg) ∧ tr< kg t₄ ∧ tr< kg t₅) ∧ ((key₃ < kg) ∧ ⊤ ∧ ( (key₁ < kg) ∧ tr< kg t₆ ∧ tr< kg t₇ ) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
735 rr09 = proj1 (ti-property1 (subst (λ k → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ (node k₁ ⟪ ca , v₁ ⟫ t₄ t₅) k) uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
736 (sym eq₁) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
737 rr10 : kp < key₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
738 rr10 = proj1 (subst (λ k → tr> kp k) (sym eq₁) (proj2 (ti-property1 (treeLeftDown _ _ ti))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
739 rr05 _ eq₁ (t-left key₃ key₁ {_} {_} {t₆} {t₇} y y₁ y₂ ti₁) = subst treeInvariant (node-cong refl refl (node-cong refl refl refl eq₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
740 (subst (λ k → leaf ≡ to-black k ) lem24 refl))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
741 ( t-left _ _ (proj1 rr04) ⟪ <-trans (proj1 rr08) (proj1 rr04) , ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , >-tr< rr03 (proj1 rr04) ⟫ ⟫ ⟪ proj1 (proj2 (proj2 rr09)) , ⟪ proj1 (proj2 (proj2 (proj2 rr09))) , tt ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
742 (t-node _ _ _ (proj1 rr08) (proj1 rr10) (proj1 (proj2 rr08)) rr03
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
743 ⟪ proj1 (proj1 (proj2 rr10)) , ⟪ proj1 (proj2 (proj1 (proj2 rr10))) , proj2 (proj2 (proj1 (proj2 rr10))) ⟫ ⟫ tt lem22 (t-left _ _ y y₁ y₂ ti₁) )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
744 rr09 : (kp < kg) ∧ ((k₁ < kg) ∧ tr< kg t₄ ∧ tr< kg t₅) ∧ ((key₁ < kg) ∧ ( (key₃ < kg) ∧ tr< kg t₆ ∧ tr< kg t₇ ) ∧ ⊤ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
745 rr09 = proj1 (ti-property1 (subst (λ k → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ (node k₁ ⟪ ca , v₁ ⟫ t₄ t₅) k) uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
746 (sym eq₁) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
747 rr10 : (kp < key₁ ) ∧ ((kp < key₃) ∧ tr> kp t₆ ∧ tr> kp t₇) ∧ ⊤
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
748 rr10 = subst (λ k → tr> kp k) (sym eq₁) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
749 rr05 _ eq₁ (t-node key₃ key₁ key₂ {_} {_} {_} {t₆} {t₇} {t₈} {t₉} y y₁ y₂ y₃ y₄ y₅ ti₁ ti₂)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
750 = subst treeInvariant (node-cong refl refl (node-cong refl refl refl eq₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
751 (subst (λ k → leaf ≡ to-black k ) lem24 refl))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
752 ( t-left _ _ (proj1 rr04) ⟪ <-trans (proj1 rr08) (proj1 rr04) , ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , >-tr< rr03 (proj1 rr04) ⟫ ⟫ ⟪ proj1 (proj2 (proj2 rr09)) , ⟪ proj1 (proj2 (proj2 (proj2 rr09))) , proj2 (proj2 (proj2 (proj2 rr09))) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
753 (t-node _ _ _ (proj1 rr08) (proj1 rr10) (proj1 (proj2 rr08)) rr03
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
754 ⟪ proj1 (proj1 (proj2 rr10)) , ⟪ proj1 (proj2 (proj1 (proj2 rr10))) , proj2 (proj2 (proj1 (proj2 rr10))) ⟫ ⟫ (proj2 (proj2 rr10)) lem22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
755 (t-node _ _ _ y y₁ y₂ y₃ y₄ y₅ ti₁ ti₂))) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
756 rr09 : (kp < kg) ∧ ((k₁ < kg) ∧ tr< kg t₄ ∧ tr< kg t₅) ∧ ((key₁ < kg) ∧ ( (key₃ < kg) ∧ tr< kg t₆ ∧ tr< kg t₇ ) ∧ ( (key₂ < kg) ∧ tr< kg t₈ ∧ tr< kg t₉ ) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
757 rr09 = proj1 (ti-property1 (subst (λ k → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ (node k₁ ⟪ ca , v₁ ⟫ t₄ t₅) k) uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
758 (sym eq₁) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
759 rr10 : (kp < key₁ ) ∧ ((kp < key₃) ∧ tr> kp t₆ ∧ tr> kp t₇) ∧ ((kp < key₂) ∧ tr> kp t₈ ∧ tr> kp t₉)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
760 rr10 = subst (λ k → tr> kp k) (sym eq₁) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
761 lem21 _ (t-left key₂ key₁ {_} {_} {t₁} {t₂} x x₁₀ x₂ ti₁) eq (rbr-left {k₁} {v₁} {ca} {t₃} {t₄} {t₅} x₃ x₄ rbt) =
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
762 subst treeInvariant (node-cong refl refl refl (subst (λ k → leaf ≡ to-black k ) lem24 refl))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
763 ( t-left _ _ (proj1 rr04) ⟪ <-trans (proj1 rr08) (proj1 rr04) , ⟪ >-tr< rr03 (proj1 rr04) , proj2 (proj2 (proj1 (proj2 rr04))) ⟫ ⟫ (proj2 (proj2 rr04)) rr06) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
764 lem23 : key₁ ≡ kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
765 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
766 lem24 : leaf ≡ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
767 lem24 = just-injective (cong node-right eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
768 rr04 : (kp < kg) ∧ ((k₁ < kg) ∧ tr< kg t₄ ∧ tr< kg t₅) ∧ tr< kg t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
769 rr04 = proj1 (ti-property1 ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
770 rr08 : (k₁ < kp) ∧ tr< kp t₄ ∧ tr< kp t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
771 rr08 = proj1 (ti-property1 (treeLeftDown _ _ ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
772 rr03 : tr< kp t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
773 rr03 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj1 (proj2 rr08))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
774 rr06 : treeInvariant (node kp ⟪ Black , vp ⟫ (node k₁ ⟪ ca , v₁ ⟫ t₃ t₅) t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
775 rr06 with node→leaf∨IsNode t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
776 ... | case1 eq₁ = subst treeInvariant (node-cong refl refl refl (sym eq₁)) (t-left _ _ (proj1 rr08) rr03 (proj2 (proj2 rr08)) lem22 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
777 ... | case2 tn = subst treeInvariant (node-cong refl refl refl (sym (IsNode.t=node tn))) ( t-node _ _ _ (proj1 rr08) (proj1 rr11) rr03 (proj2 (proj2 rr08)) (proj1 (proj2 rr11)) (proj2 (proj2 rr11))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
778 lem22 (subst treeInvariant (IsNode.t=node tn) lem25 )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
779 rr11 : (kp < IsNode.key tn) ∧ tr> kp (IsNode.left tn) ∧ tr> kp (IsNode.right tn)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
780 rr11 = subst (λ k → tr> kp k) (IsNode.t=node tn) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
781 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-black-right {t₁} {t₂} {t₃} {_} {k₂} x₃ x₄ rbt) =
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
782 subst treeInvariant (node-cong refl refl refl (subst (λ k → leaf ≡ to-black k ) lem24 refl))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
783 ( t-left _ _ (proj1 rr04) ⟪ <-trans (proj1 rr08) (proj1 rr04) , ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , >-tr< rr03 (proj1 rr04) ⟫ ⟫ (proj2 (proj2 rr04)) rr06) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
784 lem23 : key₁ ≡ kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
785 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
786 lem24 : leaf ≡ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
787 lem24 = just-injective (cong node-right eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
788 rr04 : (kp < kg) ∧ ((_ < kg) ∧ tr< kg t₁ ∧ tr< kg t₂) ∧ tr< kg t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
789 rr04 = proj1 (ti-property1 ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
790 rr08 : (_ < kp) ∧ tr< kp t₁ ∧ tr< kp t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
791 rr08 = proj1 (ti-property1 (treeLeftDown _ _ ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
792 rr03 : tr< kp t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
793 rr03 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj2 (proj2 rr08))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
794 rr06 : treeInvariant (node kp ⟪ Black , vp ⟫ (node _ ⟪ _ , _ ⟫ t₁ t₃) t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
795 rr06 with node→leaf∨IsNode t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
796 ... | case1 eq₁ = subst treeInvariant (node-cong refl refl refl (sym eq₁)) (t-left _ _ (proj1 rr08) (proj1 (proj2 rr08)) rr03 lem22 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
797 ... | case2 tn = subst treeInvariant (node-cong refl refl refl (sym (IsNode.t=node tn))) ( t-node _ _ _ (proj1 rr08) (proj1 rr11) (proj1 (proj2 rr08))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
798 rr03 (proj1 (proj2 rr11)) (proj2 (proj2 rr11)) lem22 (subst treeInvariant (IsNode.t=node tn) lem25 )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
799 rr11 : (kp < IsNode.key tn) ∧ tr> kp (IsNode.left tn) ∧ tr> kp (IsNode.right tn)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
800 rr11 = subst (λ k → tr> kp k) (IsNode.t=node tn) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
801 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-black-left {t₁} {t₂} {t₃} {_} {k₂} x₃ x₄ rbt) =
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
802 subst treeInvariant (node-cong refl refl refl (subst (λ k → leaf ≡ to-black k ) lem24 refl))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
803 ( t-left _ _ (proj1 rr04) ⟪ <-trans (proj1 rr08) (proj1 rr04) , ⟪ >-tr< rr03 (proj1 rr04) , proj2 (proj2 (proj1 (proj2 rr04))) ⟫ ⟫ (proj2 (proj2 rr04)) rr06 ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
804 lem23 : key₁ ≡ kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
805 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
806 lem24 : leaf ≡ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
807 lem24 = just-injective (cong node-right eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
808 rr04 : (kp < kg) ∧ ((_ < kg) ∧ tr< kg t₂ ∧ tr< kg t₁) ∧ tr< kg t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
809 rr04 = proj1 (ti-property1 ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
810 rr08 : (_ < kp) ∧ tr< kp t₂ ∧ tr< kp t₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
811 rr08 = proj1 (ti-property1 (treeLeftDown _ _ ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
812 rr03 : tr< kp t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
813 rr03 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj1 (proj2 rr08))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
814 rr06 : treeInvariant (node kp ⟪ Black , vp ⟫ (node _ ⟪ _ , _ ⟫ t₃ t₁) t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
815 rr06 with node→leaf∨IsNode t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
816 ... | case1 eq₁ = subst treeInvariant (node-cong refl refl refl (sym eq₁)) (t-left _ _ (proj1 rr08) rr03 (proj2 (proj2 rr08)) lem22 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
817 ... | case2 tn = subst treeInvariant (node-cong refl refl refl (sym (IsNode.t=node tn))) ( t-node _ _ _ (proj1 rr08) (proj1 rr11) rr03
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
818 (proj2 (proj2 rr08)) (proj1 (proj2 rr11)) (proj2 (proj2 rr11)) lem22 (subst treeInvariant (IsNode.t=node tn) lem25 )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
819 rr11 : (kp < IsNode.key tn) ∧ tr> kp (IsNode.left tn) ∧ tr> kp (IsNode.right tn)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
820 rr11 = subst (λ k → tr> kp k) (IsNode.t=node tn) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
821 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-flip-ll {t₁} {t₂} {t₃} {t₆} {kg} {kp} {vg} {vp} x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
822 = ⊥-elim (⊥-color (trans (sym lem26) ueq) ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
823 lem26 : color uncle ≡ Black
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
824 lem26 = subst (λ k → color k ≡ Black) (just-injective (cong node-right eq )) refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
825 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-flip-lr {t₁} {t₂} {t₃} {t₆} {kg} {kp} {vg} {vp} x₃ x₄ x₅ x₆ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
826 = ⊥-elim (⊥-color (trans (sym lem26) ueq) ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
827 lem26 : color uncle ≡ Black
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
828 lem26 = subst (λ k → color k ≡ Black) (just-injective (cong node-right eq )) refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
829 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-flip-rl {t₁} {t₂} {t₃} {t₆} {kg} {kp} {vg} {vp} x₃ x₄ x₅ x₆ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
830 = ⊥-elim (⊥-color (trans (sym lem26) ueq) ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
831 lem26 : color uncle ≡ Black
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
832 lem26 = subst (λ k → color k ≡ Black) (just-injective (cong node-right eq )) refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
833 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-flip-rr {t₁} {t₂} {t₃} {t₆} {kg} {kp} {vg} {vp} x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
834 = ⊥-elim (⊥-color (trans (sym lem26) ueq) ) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
835 lem26 : color uncle ≡ Black
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
836 lem26 = subst (λ k → color k ≡ Black) (just-injective (cong node-right eq )) refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
837 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-rotate-ll {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
838 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-rotate-rr {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
839 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-rotate-rl {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
840 lem21 _ (t-left key₂ key₁ {_} {_} {t₄} {t₅} x x₁₀ x₂ ti₁) eq (rbr-rotate-lr {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
841 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} {t₁₁} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq rbr-leaf =
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
842 subst treeInvariant (node-cong refl refl refl (cong to-black lem24) ) ( t-node _ _ _ (proj1 rr04) (proj1 rr03) ⟪ <-trans x₁ (proj1 rr04) , ⟪ tt , tt ⟫ ⟫ (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
843 (proj1 (proj2 rr03)) (proj2 (proj2 rr03)) rr06 (to-black-treeInvariant _ ti₂)) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
844 lem23 : key₁ ≡ kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
845 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
846 lem24 : node key₂ v2 t₁₀ t₁₁ ≡ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
847 lem24 = just-injective (cong node-right eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
848 rr04 : (kp < kg) ∧ ⊤ ∧ tr< kg t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
849 rr04 = proj1 (ti-property1 ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
850 rr03 : (kg < key₂) ∧ tr> kg t₁₀ ∧ tr> kg t₁₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
851 rr03 = proj2 (ti-property1 (subst (λ k → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ _ t) k)) (sym lem24) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
852 rr06 : treeInvariant (node kp ⟪ Black , vp ⟫ _ t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
853 rr06 with node→leaf∨IsNode t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
854 ... | case1 eq₁ = subst treeInvariant (node-cong refl refl refl (sym eq₁)) (t-left _ _ x₁ tt tt lem22 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
855 ... | case2 tn = subst treeInvariant (node-cong refl refl refl (sym (IsNode.t=node tn))) ( t-node _ _ _ x₁ (proj1 rr11) tt
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
856 tt (proj1 (proj2 rr11)) (proj2 (proj2 rr11)) lem22 (subst treeInvariant (IsNode.t=node tn) lem25 )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
857 rr11 : (kp < IsNode.key tn) ∧ tr> kp (IsNode.left tn) ∧ tr> kp (IsNode.right tn)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
858 rr11 = subst (λ k → tr> kp k) (IsNode.t=node tn) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
859 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} {t₁₁} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-node {_} {_} {t₃} {t₄}) =
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
860 subst treeInvariant (node-cong refl refl refl (cong to-black lem24) ) ( t-node _ _ _ (proj1 rr04) (proj1 rr03) (proj1 (proj2 rr04)) (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
861 (proj1 (proj2 rr03)) (proj2 (proj2 rr03)) rr06 (to-black-treeInvariant _ ti₂)) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
862 lem23 : key₁ ≡ kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
863 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
864 lem24 : node key₂ v2 t₁₀ t₁₁ ≡ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
865 lem24 = just-injective (cong node-right eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
866 rr04 : (kp < kg) ∧ ((key < kg) ∧ tr< kg t₃ ∧ tr< kg t₄) ∧ tr< kg t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
867 rr04 = proj1 (ti-property1 ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
868 rr08 : (key < kp) ∧ tr< kp t₃ ∧ tr< kp t₄
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
869 rr08 = proj1 (ti-property1 (treeLeftDown _ _ ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
870 rr03 : (kg < key₂) ∧ tr> kg t₁₀ ∧ tr> kg t₁₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
871 rr03 = proj2 (ti-property1 (subst (λ k → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ (node key ⟪ _ , _ ⟫ t₃ t₄) t) k)) (sym lem24) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
872 rr06 : treeInvariant (node kp ⟪ Black , vp ⟫ (node _ ⟪ _ , _ ⟫ t₃ t₄) t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
873 rr06 with node→leaf∨IsNode t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
874 ... | case1 eq₁ = subst treeInvariant (node-cong refl refl refl (sym eq₁)) (t-left _ _ (proj1 rr08) (proj1 (proj2 rr08)) (proj2 (proj2 rr08)) lem22 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
875 ... | case2 tn = subst treeInvariant (node-cong refl refl refl (sym (IsNode.t=node tn))) ( t-node _ _ _ (proj1 rr08) (proj1 rr11) (proj1 (proj2 rr08))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
876 (proj2 (proj2 rr08)) (proj1 (proj2 rr11)) (proj2 (proj2 rr11)) lem22 (subst treeInvariant (IsNode.t=node tn) lem25 )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
877 rr11 : (kp < IsNode.key tn) ∧ tr> kp (IsNode.left tn) ∧ tr> kp (IsNode.right tn)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
878 rr11 = subst (λ k → tr> kp k) (IsNode.t=node tn) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
879 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} {t₁₁} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-right {k₃} {_} {_} {t₃} {t₄} {t₅} x₆ x₇ rbt) =
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
880 subst treeInvariant (node-cong refl refl refl (cong to-black lem24) ) ( t-node _ _ _ (proj1 rr04) (proj1 rr03)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
881 ⟪ proj1 (proj1 (proj2 rr04)) , ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , >-tr< rr05 (proj1 rr04) ⟫ ⟫ (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
882 (proj1 (proj2 rr03)) (proj2 (proj2 rr03)) rr06 (to-black-treeInvariant _ ti₂)) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
883 lem23 : key₁ ≡ kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
884 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
885 lem24 : node key₂ v2 t₁₀ t₁₁ ≡ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
886 lem24 = just-injective (cong node-right eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
887 rr04 : (kp < kg) ∧ ((k₃ < kg) ∧ tr< kg t₄ ∧ tr< kg t₅) ∧ tr< kg t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
888 rr04 = proj1 (ti-property1 ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
889 rr08 : (k₃ < kp) ∧ tr< kp t₄ ∧ tr< kp t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
890 rr08 = proj1 (ti-property1 (treeLeftDown _ _ ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
891 rr03 : (kg < key₂) ∧ tr> kg t₁₀ ∧ tr> kg t₁₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
892 rr03 = proj2 (ti-property1 (subst (λ k → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ (node k₃ ⟪ _ , _ ⟫ t₄ t₅) t) k)) (sym lem24) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
893 rr05 : tr< kp t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
894 rr05 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj2 (proj2 rr08))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
895 rr06 : treeInvariant (node kp ⟪ Black , vp ⟫ (node k₃ ⟪ _ , _ ⟫ t₄ t₃) t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
896 rr06 with node→leaf∨IsNode t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
897 ... | case1 eq₁ = subst treeInvariant (node-cong refl refl refl (sym eq₁)) (t-left _ _ (proj1 rr08) (proj1 (proj2 rr08)) rr05 lem22)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
898 ... | case2 tn = subst treeInvariant (node-cong refl refl refl (sym (IsNode.t=node tn))) ( t-node _ _ _ (proj1 rr08) (proj1 rr11) (proj1 (proj2 rr08))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
899 rr05 (proj1 (proj2 rr11)) (proj2 (proj2 rr11)) lem22 (subst treeInvariant (IsNode.t=node tn) lem25 )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
900 rr11 : (kp < IsNode.key tn) ∧ tr> kp (IsNode.left tn) ∧ tr> kp (IsNode.right tn)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
901 rr11 = subst (λ k → tr> kp k) (IsNode.t=node tn) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
902 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} {t₁₁} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-left {k₃} {_} {_} {t₃} {t₄} {t₅} x₆ x₇ rbt) =
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
903 subst treeInvariant (node-cong refl refl refl (cong to-black lem24) ) ( t-node _ _ _ (proj1 rr04) (proj1 rr03)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
904 ⟪ proj1 (proj1 (proj2 rr04)) , ⟪ >-tr< rr05 (proj1 rr04) , proj2 (proj2 (proj1 (proj2 rr04))) ⟫ ⟫ (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
905 (proj1 (proj2 rr03)) (proj2 (proj2 rr03)) rr06 (to-black-treeInvariant _ ti₂)) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
906 lem23 : key₁ ≡ kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
907 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
908 lem24 : node key₂ v2 t₁₀ t₁₁ ≡ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
909 lem24 = just-injective (cong node-right eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
910 rr04 : (kp < kg) ∧ ((k₃ < kg) ∧ tr< kg t₄ ∧ tr< kg t₅) ∧ tr< kg t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
911 rr04 = proj1 (ti-property1 ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
912 rr08 : (k₃ < kp) ∧ tr< kp t₄ ∧ tr< kp t₅
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
913 rr08 = proj1 (ti-property1 (treeLeftDown _ _ ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
914 rr03 : (kg < key₂) ∧ tr> kg t₁₀ ∧ tr> kg t₁₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
915 rr03 = proj2 (ti-property1 (subst (λ k → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ (node k₃ ⟪ _ , _ ⟫ t₄ t₅) t) k)) (sym lem24) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
916 rr05 : tr< kp t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
917 rr05 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj1 (proj2 rr08))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
918 rr06 : treeInvariant (node kp ⟪ Black , vp ⟫ (node k₃ ⟪ _ , _ ⟫ t₃ t₅) t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
919 rr06 with node→leaf∨IsNode t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
920 ... | case1 eq₁ = subst treeInvariant (node-cong refl refl refl (sym eq₁)) (t-left _ _ (proj1 rr08) rr05 (proj2 (proj2 rr08)) lem22)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
921 ... | case2 tn = subst treeInvariant (node-cong refl refl refl (sym (IsNode.t=node tn))) ( t-node _ _ _ (proj1 rr08) (proj1 rr11) rr05
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
922 (proj2 (proj2 rr08)) (proj1 (proj2 rr11)) (proj2 (proj2 rr11)) lem22 (subst treeInvariant (IsNode.t=node tn) lem25 )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
923 rr11 : (kp < IsNode.key tn) ∧ tr> kp (IsNode.left tn) ∧ tr> kp (IsNode.right tn)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
924 rr11 = subst (λ k → tr> kp k) (IsNode.t=node tn) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
925 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} {t₁₁} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-black-right {t₃} {t₄} {t₅} x₆ x₇ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
926 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} {t₁₁} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-black-left {t₃} {t₄} {t₅} x₆ x₇ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
927 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} {t₁₁} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-ll {t₄} {t₁} {t₂} {t₃} {kg₁} {kp₁} {vg₁} {vp₁} x₆ x₇ x₈ rbt) =
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
928 subst treeInvariant (node-cong refl refl refl (cong to-black lem24) ) ( t-node _ _ _ (proj1 rr04) (subst (λ k → k < key₂) lem23 (proj1 rr03))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
929 ⟪ proj1 (proj1 (proj2 rr04)) , ⟪ ⟪ <-trans (proj1 (proj1 (proj2 rr08))) (proj1 rr04) ,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
930 ⟪ >-tr< rr05 (proj1 rr04) , proj2 (proj2 (proj1 (proj2 (proj1 (proj2 rr04))))) ⟫ ⟫ , tr<-to-black (proj2 (proj2 (proj1 (proj2 rr04)))) ⟫ ⟫ (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
931 (subst (λ k → tr> k t₁₀) lem23 (proj1 (proj2 rr03))) (subst (λ k → tr> k t₁₁) lem23 (proj2 (proj2 rr03))) rr06 (to-black-treeInvariant _ ti₂)) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
932 lem23 : key₁ ≡ kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
933 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
934 lem24 : node key₂ v2 t₁₀ t₁₁ ≡ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
935 lem24 = just-injective (cong node-right eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
936 rr04 : (kp < kg) ∧ ((kg₁ < kg) ∧ ((kp₁ < kg) ∧ tr< kg t₁ ∧ tr< kg t₄) ∧ tr< kg t₃ ) ∧ tr< kg t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
937 rr04 = proj1 (ti-property1 ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
938 rr08 : (kg₁ < kp) ∧ ((kp₁ < kp) ∧ tr< kp t₁ ∧ tr< kp t₄) ∧ tr< kp t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
939 rr08 = proj1 (ti-property1 (treeLeftDown _ _ ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
940 rr03 : (key₁ < key₂) ∧ tr> key₁ t₁₀ ∧ tr> key₁ t₁₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
941 rr03 = proj2 (ti-property1 (subst (λ k → treeInvariant k) (sym eq) ti ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
942 rr05 : tr< kp t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
943 rr05 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj1 (proj2 (proj1 (proj2 rr08))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
944 rr06 : treeInvariant (node kp ⟪ Black , vp ⟫ (node kg₁ ⟪ Red , vg₁ ⟫ (node kp₁ ⟪ Black , vp₁ ⟫ t₂ t₄) (to-black t₃)) t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
945 rr06 with node→leaf∨IsNode t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
946 ... | case1 eq₁ = subst treeInvariant (node-cong refl refl refl (sym eq₁)) (t-left _ _ (proj1 rr08) ⟪ proj1 (proj1 (proj2 rr08)) ,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
947 ⟪ rr05 , proj2 (proj2 (proj1 (proj2 rr08))) ⟫ ⟫ (tr<-to-black (proj2 (proj2 rr08))) lem22)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
948 ... | case2 tn = subst treeInvariant (node-cong refl refl refl (sym (IsNode.t=node tn))) ( t-node _ _ _ (proj1 rr08) (proj1 rr11)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
949 ⟪ proj1 (proj1 (proj2 rr08)) , ⟪ rr05 , proj2 (proj2 (proj1 (proj2 rr08))) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
950 (tr<-to-black (proj2 (proj2 rr08))) (proj1 (proj2 rr11)) (proj2 (proj2 rr11)) lem22 (subst treeInvariant (IsNode.t=node tn) lem25 )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
951 rr11 : (kp < IsNode.key tn) ∧ tr> kp (IsNode.left tn) ∧ tr> kp (IsNode.right tn)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
952 rr11 = subst (λ k → tr> kp k) (IsNode.t=node tn) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
953 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} {t₁₁} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-lr {t₀} {t₁} {t₂} {t₃} {kg₁} {kp₁} {vg₁} {vp₁} x₆ x₇ x₈ x₉ rbt) =
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
954 subst treeInvariant (node-cong refl refl refl (cong to-black lem24) ) ( t-node _ _ _ (proj1 rr04) (subst (λ k → k < key₂) lem23 (proj1 rr03))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
955 ⟪ proj1 (proj1 (proj2 rr04)) , ⟪ ⟪ <-trans (proj1 (proj1 (proj2 rr08))) (proj1 rr04) ,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
956 ⟪ proj1 (proj2 (proj1 (proj2 (proj1 (proj2 rr04))))) , >-tr< rr05 (proj1 rr04) ⟫ ⟫ , tr<-to-black (proj2 (proj2 (proj1 (proj2 rr04)))) ⟫ ⟫ (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
957 (subst (λ k → tr> k t₁₀) lem23 (proj1 (proj2 rr03))) (subst (λ k → tr> k t₁₁) lem23 (proj2 (proj2 rr03))) rr06 (to-black-treeInvariant _ ti₂)) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
958 lem23 : key₁ ≡ kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
959 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
960 lem24 : node key₂ v2 t₁₀ t₁₁ ≡ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
961 lem24 = just-injective (cong node-right eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
962 rr04 : (kp < kg) ∧ ((kg₁ < kg) ∧ ((kp₁ < kg) ∧ tr< kg t₀ ∧ tr< kg t₁) ∧ tr< kg t₃ ) ∧ tr< kg t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
963 rr04 = proj1 (ti-property1 ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
964 rr08 : (kg₁ < kp) ∧ ((kp₁ < kp) ∧ tr< kp t₀ ∧ tr< kp t₁) ∧ tr< kp t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
965 rr08 = proj1 (ti-property1 (treeLeftDown _ _ ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
966 rr03 : (key₁ < key₂) ∧ tr> key₁ t₁₀ ∧ tr> key₁ t₁₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
967 rr03 = proj2 (ti-property1 (subst (λ k → treeInvariant k) (sym eq) ti ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
968 rr05 : tr< kp t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
969 rr05 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj2 (proj2 (proj1 (proj2 rr08))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
970 rr06 : treeInvariant (node kp ⟪ Black , vp ⟫ (node kg₁ ⟪ Red , vg₁ ⟫ (node kp₁ ⟪ Black , _ ⟫ t₀ t₂) (to-black t₃)) t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
971 rr06 with node→leaf∨IsNode t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
972 ... | case1 eq₁ = subst treeInvariant (node-cong refl refl refl (sym eq₁)) (t-left _ _ (proj1 rr08) ⟪ proj1 (proj1 (proj2 rr08)) ,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
973 ⟪ proj1 (proj2 (proj1 (proj2 rr08))) , rr05 ⟫ ⟫ (tr<-to-black (proj2 (proj2 rr08))) lem22)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
974 ... | case2 tn = subst treeInvariant (node-cong refl refl refl (sym (IsNode.t=node tn))) ( t-node _ _ _ (proj1 rr08) (proj1 rr11)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
975 ⟪ proj1 (proj1 (proj2 rr08)) , ⟪ proj1 (proj2 (proj1 (proj2 rr08))) , rr05 ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
976 (tr<-to-black (proj2 (proj2 rr08))) (proj1 (proj2 rr11)) (proj2 (proj2 rr11)) lem22 (subst treeInvariant (IsNode.t=node tn) lem25 )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
977 rr11 : (kp < IsNode.key tn) ∧ tr> kp (IsNode.left tn) ∧ tr> kp (IsNode.right tn)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
978 rr11 = subst (λ k → tr> kp k) (IsNode.t=node tn) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
979 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} {t₁₁} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-rl {t₀} {t₁} {t₂} {t₃} {kg₁} {kp₁} {vg₁} {vp₁} x₆ x₇ x₈ x₉ rbt) =
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
980 subst treeInvariant (node-cong refl refl refl (cong to-black lem24) ) ( t-node _ _ _ (proj1 rr04) (subst (λ k → k < key₂) lem23 (proj1 rr03))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
981 ⟪ proj1 (proj1 (proj2 rr04)) , ⟪
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
982 tr<-to-black (proj1 (proj2 (proj1 (proj2 rr04)))) , ⟪ proj1 (proj2 (proj2 (proj1 (proj2 rr04)))) ,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
983 ⟪ >-tr< rr05 (proj1 rr04) , proj2 (proj2 (proj2 (proj2 (proj1 (proj2 rr04))))) ⟫ ⟫ ⟫ ⟫ (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
984 (subst (λ k → tr> k t₁₀) lem23 (proj1 (proj2 rr03))) (subst (λ k → tr> k t₁₁) lem23 (proj2 (proj2 rr03))) rr06 (to-black-treeInvariant _ ti₂)) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
985 lem23 : key₁ ≡ kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
986 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
987 lem24 : node key₂ v2 t₁₀ t₁₁ ≡ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
988 lem24 = just-injective (cong node-right eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
989 rr04 : (kp < kg) ∧ ((kg₁ < kg) ∧ tr< kg t₃ ∧ ((kp₁ < kg) ∧ tr< kg t₁ ∧ tr< kg t₀) ) ∧ tr< kg t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
990 rr04 = proj1 (ti-property1 ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
991 rr08 : (kg₁ < kp) ∧ tr< kp t₃ ∧ ((kp₁ < kp) ∧ tr< kp t₁ ∧ tr< kp t₀)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
992 rr08 = proj1 (ti-property1 (treeLeftDown _ _ ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
993 rr03 : (key₁ < key₂) ∧ tr> key₁ t₁₀ ∧ tr> key₁ t₁₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
994 rr03 = proj2 (ti-property1 (subst (λ k → treeInvariant k) (sym eq) ti ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
995 rr05 : tr< kp t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
996 rr05 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj1 (proj2 (proj2 (proj2 rr08))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
997 rr06 : treeInvariant (node kp ⟪ Black , vp ⟫ (node kg₁ ⟪ Red , vg₁ ⟫ (to-black t₃) (node kp₁ ⟪ Black , vp₁ ⟫ t₂ t₀)) t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
998 rr06 with node→leaf∨IsNode t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
999 ... | case1 eq₁ = subst treeInvariant (node-cong refl refl refl (sym eq₁)) (t-left _ _ (proj1 rr08) (tr<-to-black (proj1 (proj2 rr08)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1000 ⟪ proj1 (proj2 (proj2 rr08)) , ⟪ rr05 , proj2 (proj2 (proj2 (proj2 rr08))) ⟫ ⟫ lem22)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1001 ... | case2 tn = subst treeInvariant (node-cong refl refl refl (sym (IsNode.t=node tn))) ( t-node _ _ _ (proj1 rr08) (proj1 rr11)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1002 (tr<-to-black (proj1 (proj2 rr08))) ⟪ proj1 (proj2 (proj2 rr08)) , ⟪ rr05 , proj2 (proj2 (proj2 (proj2 rr08))) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1003 (proj1 (proj2 rr11)) (proj2 (proj2 rr11)) lem22 (subst treeInvariant (IsNode.t=node tn) lem25 )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1004 rr11 : (kp < IsNode.key tn) ∧ tr> kp (IsNode.left tn) ∧ tr> kp (IsNode.right tn)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1005 rr11 = subst (λ k → tr> kp k) (IsNode.t=node tn) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1006 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} {t₁₁} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-flip-rr {t₀} {t₁} {t₂} {t₃} {kg₁} {kp₁} {vg₁} {vp₁} x₆ x₇ x₈ rbt) =
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1007 subst treeInvariant (node-cong refl refl refl (cong to-black lem24) ) ( t-node _ _ _ (proj1 rr04) (subst (λ k → k < key₂) lem23 (proj1 rr03))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1008 ⟪ proj1 (proj1 (proj2 rr04)) , ⟪
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1009 tr<-to-black (proj1 (proj2 (proj1 (proj2 rr04)))) , ⟪ proj1 (proj2 (proj2 (proj1 (proj2 rr04)))) ,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1010 ⟪ proj1 (proj2 (proj2 (proj2 (proj1 (proj2 rr04))))) , >-tr< rr05 (proj1 rr04) ⟫ ⟫ ⟫ ⟫ (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1011 (subst (λ k → tr> k t₁₀) lem23 (proj1 (proj2 rr03))) (subst (λ k → tr> k t₁₁) lem23 (proj2 (proj2 rr03))) rr06 (to-black-treeInvariant _ ti₂)) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1012 lem23 : key₁ ≡ kg
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1013 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1014 lem24 : node key₂ v2 t₁₀ t₁₁ ≡ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1015 lem24 = just-injective (cong node-right eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1016 rr04 : (kp < kg) ∧ ((kg₁ < kg) ∧ tr< kg t₃ ∧ ((kp₁ < kg) ∧ tr< kg t₀ ∧ tr< kg t₁) ) ∧ tr< kg t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1017 rr04 = proj1 (ti-property1 ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1018 rr08 : (kg₁ < kp) ∧ tr< kp t₃ ∧ ((kp₁ < kp) ∧ tr< kp t₀ ∧ tr< kp t₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1019 rr08 = proj1 (ti-property1 (treeLeftDown _ _ ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1020 rr03 : (key₁ < key₂) ∧ tr> key₁ t₁₀ ∧ tr> key₁ t₁₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1021 rr03 = proj2 (ti-property1 (subst (λ k → treeInvariant k) (sym eq) ti ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1022 rr05 : tr< kp t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1023 rr05 = RB-repl→ti< _ _ _ _ _ rbt x₁ (proj2 (proj2 (proj2 (proj2 rr08))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1024 rr06 : treeInvariant (node kp ⟪ Black , vp ⟫ (node kg₁ ⟪ Red , vg₁ ⟫ (to-black t₃) (node kp₁ ⟪ Black , vp₁ ⟫ t₀ t₂)) t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1025 rr06 with node→leaf∨IsNode t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1026 ... | case1 eq₁ = subst treeInvariant (node-cong refl refl refl (sym eq₁)) (t-left _ _ (proj1 rr08) (tr<-to-black (proj1 (proj2 rr08)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1027 ⟪ proj1 (proj2 (proj2 rr08)) , ⟪ proj1 (proj2 (proj2 (proj2 rr08))) , rr05 ⟫ ⟫ lem22)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1028 ... | case2 tn = subst treeInvariant (node-cong refl refl refl (sym (IsNode.t=node tn))) ( t-node _ _ _ (proj1 rr08) (proj1 rr11)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1029 (tr<-to-black (proj1 (proj2 rr08))) ⟪ proj1 (proj2 (proj2 rr08)) , ⟪ proj1 (proj2 (proj2 (proj2 rr08))) , rr05 ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1030 (proj1 (proj2 rr11)) (proj2 (proj2 rr11)) lem22 (subst treeInvariant (IsNode.t=node tn) lem25 )) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1031 rr11 : (kp < IsNode.key tn) ∧ tr> kp (IsNode.left tn) ∧ tr> kp (IsNode.right tn)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1032 rr11 = subst (λ k → tr> kp k) (IsNode.t=node tn) (proj2 (ti-property1 (treeLeftDown _ _ ti)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1033 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-rr x₆ x₇ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1034 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-ll x₆ x₇ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1035 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-rl {t} {t₁} {uncle} t₂ t₃ kg kp kn x₆ x₇ x₈ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1036 lem21 _ (t-node key₃ key₁ key₂ {v0} {v1} {v2} {t₇} {t₈} {t₁₀} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-lr {t} {t₁} {uncle} t₂ t₃ kg kp kn x₆ x₇ x₈ rbt) = ⊥-elim (⊥-color ceq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1037
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1038
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1039
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1040 RB-repl→ti-lem07 : {n : Level} {A : Set n} {key : ℕ} {value : A} {t t₁ t₂ uncle : bt (Color ∧ A)} {kg kp : ℕ} {vg vp : A}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1041 (x : color t₂ ≡ Red) (x₁ : color uncle ≡ Red) (x₂ : kp < key) (x₃ : key < kg) (rbt : replacedRBTree key value t₁ t₂) → (treeInvariant t₁ → treeInvariant t₂)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1042 → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ t t₁) uncle)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1043 → treeInvariant (node kg ⟪ Red , vg ⟫ (node kp ⟪ Black , vp ⟫ t t₂) (to-black uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1044 RB-repl→ti-lem07 = ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1045
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1046 RB-repl→ti-lem08 : {n : Level} {A : Set n} {key : ℕ} {value : A} → {t t₁ t₂ uncle : bt (Color ∧ A)} {kg kp : ℕ} {vg vp : A}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1047 (x : color t₂ ≡ Red) (x₁ : color uncle ≡ Red) (x₂ : kg < key) (x₃ : key < kp) (rbt : replacedRBTree key value t₁ t₂)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1048 → (treeInvariant t₁ → treeInvariant t₂) → treeInvariant (node kg ⟪ Black , vg ⟫ uncle (node kp ⟪ Red , vp ⟫ t₁ t))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1049 → treeInvariant (node kg ⟪ Red , vg ⟫ (to-black uncle) (node kp ⟪ Black , vp ⟫ t₂ t))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1050 RB-repl→ti-lem08 = ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1051
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1052 RB-repl→ti-lem09 : {n : Level} {A : Set n} {key : ℕ} {value : A} → {t t₁ t₂ uncle : bt (Color ∧ A)} {kg kp : ℕ} {vg vp : A}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1053 (x : color t₂ ≡ Red) (x₁ : color uncle ≡ Red) (x₂ : kp < key) (rbt : replacedRBTree key value t₁ t₂) →
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1054 (treeInvariant t₁ → treeInvariant t₂) → treeInvariant (node kg ⟪ Black , vg ⟫ uncle (node kp ⟪ Red , vp ⟫ t t₁)) →
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1055 treeInvariant (node kg ⟪ Red , vg ⟫ (to-black uncle) (node kp ⟪ Black , vp ⟫ t t₂))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1056 RB-repl→ti-lem09 = ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1057
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1058 RB-repl→ti-lem10 : {n : Level} {A : Set n} {key : ℕ} {value : A} → {t t₁ t₂ uncle : bt (Color ∧ A)} {kg kp : ℕ} {vg vp : A}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1059 (x : color t₂ ≡ Red) (x₁ : key < kp) (rbt : replacedRBTree key value t₁ t₂) →
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1060 (treeInvariant t₁ → treeInvariant t₂) → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ t₁ t) uncle) →
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1061 treeInvariant (node kp ⟪ Black , vp ⟫ t₂ (node kg ⟪ Red , vg ⟫ t uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1062 RB-repl→ti-lem10 = ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1063
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1064 RB-repl→ti-lem11 : {n : Level} {A : Set n} {key : ℕ} {value : A} → {t t₁ t₂ uncle : bt (Color ∧ A)} {kg kp : ℕ} {vg vp : A}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1065 (x : color t₂ ≡ Red) (x₁ : kp < key) (rbt : replacedRBTree key value t₁ t₂) →
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1066 (treeInvariant t₁ → treeInvariant t₂) → treeInvariant (node kg ⟪ Black , vg ⟫ uncle (node kp ⟪ Red , vp ⟫ t t₁)) →
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1067 treeInvariant (node kp ⟪ Black , vp ⟫ (node kg ⟪ Red , vg ⟫ uncle t) t₂)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1068 RB-repl→ti-lem11 = ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1069
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1070 RB-repl→ti-lem12 : {n : Level} {A : Set n} {key : ℕ} {value : A} → {t t₁ uncle : bt (Color ∧ A)} (t₂ t₃ : bt (Color ∧ A)) (kg kp kn : ℕ) {vg vp vn : A} (x : color t₃ ≡ Black)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1071 (x₁ : kp < key) (x₂ : key < kg) (rbt : replacedRBTree key value t₁ (node kn ⟪ Red , vn ⟫ t₂ t₃)) →
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1072 (treeInvariant t₁ → treeInvariant (node kn ⟪ Red , vn ⟫ t₂ t₃)) → treeInvariant (node kg ⟪ Black , vg ⟫ (node kp ⟪ Red , vp ⟫ t t₁) uncle) →
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1073 treeInvariant (node kn ⟪ Black , vn ⟫ (node kp ⟪ Red , vp ⟫ t t₂) (node kg ⟪ Red , vg ⟫ t₃ uncle))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1074 RB-repl→ti-lem12 = ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1075
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1076 RB-repl→ti-lem13 : {n : Level} {A : Set n} {key : ℕ} {value : A} → {t t₁ uncle : bt (Color ∧ A)} (t₂ t₃ : bt (Color ∧ A)) (kg kp kn : ℕ) {vg vp vn : A} (x : color t₃ ≡ Black)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1077 (x₁ : kg < key) (x₂ : key < kp) (rbt : replacedRBTree key value t₁ (node kn ⟪ Red , vn ⟫ t₂ t₃)) →
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1078 (treeInvariant t₁ → treeInvariant (node kn ⟪ Red , vn ⟫ t₂ t₃)) → treeInvariant (node kg ⟪ Black , vg ⟫ uncle (node kp ⟪ Red , vp ⟫ t₁ t)) →
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1079 treeInvariant (node kn ⟪ Black , vn ⟫ (node kg ⟪ Red , vg ⟫ uncle t₂) (node kp ⟪ Red , vp ⟫ t₃ t))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1080 RB-repl→ti-lem13 = ?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1081
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1082
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1083 RB-repl→ti : {n : Level} {A : Set n} → (tree repl : bt (Color ∧ A) ) → (key : ℕ ) → (value : A) → treeInvariant tree
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1084 → replacedRBTree key value tree repl → treeInvariant repl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1085 RB-repl→ti {n} {A} tree repl key value ti rbr = RBTI-induction A tree tree repl key value refl rbr {λ key value b a rbr → treeInvariant b → treeInvariant a }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1086 ⟪ lem00 , ⟪ lem01 , ⟪ lem02 , ⟪ RB-repl→ti-lem03 , ⟪ RB-repl→ti-lem04 , ⟪ RB-repl→ti-lem05 ,
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1087 ⟪ RB-repl→ti-lem06 , ⟪ RB-repl→ti-lem07 , ⟪ RB-repl→ti-lem08 , ⟪ RB-repl→ti-lem09 , ⟪ RB-repl→ti-lem10 , ⟪ RB-repl→ti-lem11
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1088 , ⟪ RB-repl→ti-lem12 , RB-repl→ti-lem13 ⟫ ⟫ ⟫ ⟫ ⟫ ⟫ ⟫ ⟫ ⟫ ⟫ ⟫ ⟫ ⟫ ti where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1089 lem00 : treeInvariant leaf → treeInvariant (node key ⟪ Red , value ⟫ leaf leaf)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1090 lem00 ti = t-single key ⟪ Red , value ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1091 lem01 : (ca : Color) (value₂ : A) (t t₁ : bt (Color ∧ A)) → treeInvariant (node key ⟪ ca , value₂ ⟫ t t₁) → treeInvariant (node key ⟪ ca , value ⟫ t t₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1092 lem01 ca v2 t t₁ ti = lem20 (node key ⟪ ca , v2 ⟫ t t₁) ti refl where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1093 lem20 : (tree : bt (Color ∧ A)) → treeInvariant tree → tree ≡ node key ⟪ ca , v2 ⟫ t t₁ → treeInvariant (node key ⟪ ca , value ⟫ t t₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1094 lem20 .leaf t-leaf ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1095 lem20 (node key v3 leaf leaf) (t-single key v3) eq = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1096 (node-cong (just-injective (cong node-key eq)) refl (just-injective (cong node-left eq)) (just-injective (cong node-right eq))) (t-single key ⟪ ca , value ⟫)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1097 lem20 (node key _ leaf (node key₁ _ _ _)) (t-right key key₁ x x₁ x₂ ti) eq = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1098 (node-cong (just-injective (cong node-key eq)) refl (just-injective (cong node-left eq)) (just-injective (cong node-right eq))) (t-right key key₁ x x₁ x₂ ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1099 lem20 (node key₁ _ (node key _ _ _) leaf) (t-left key key₁ x x₁ x₂ ti) eq = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1100 (node-cong (just-injective (cong node-key eq)) refl (just-injective (cong node-left eq)) (just-injective (cong node-right eq))) (t-left key key₁ x x₁ x₂ ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1101 lem20 (node key₁ _ (node key _ _ _) (node key₂ _ _ _)) (t-node key key₁ key₂ x x₁ x₂ x₃ x₄ x₅ ti ti₁) eq = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1102 (node-cong (just-injective (cong node-key eq)) refl (just-injective (cong node-left eq)) (just-injective (cong node-right eq)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1103 (t-node key key₁ key₂ x x₁ x₂ x₃ x₄ x₅ ti ti₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1104 lem02 : {k : ℕ} {v1 : A} {ca : Color} {t t1 t2 : bt (Color ∧ A)} (x : color t2 ≡ color t) (x₁ : k < key)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1105 (rbt : replacedRBTree key value t2 t) → (treeInvariant t2 → treeInvariant t) → treeInvariant (node k ⟪ ca , v1 ⟫ t1 t2) → treeInvariant (node k ⟪ ca , v1 ⟫ t1 t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1106 lem02 {k} {v1} {ca} {t} {t1} {t2} ceq x₁ rbt prev ti = lem21 (node k ⟪ ca , v1 ⟫ t1 t2) ti refl rbt where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1107 lem22 : treeInvariant t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1108 lem22 = prev (treeRightDown _ _ ti)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1109 lem21 : (tree : bt (Color ∧ A)) → treeInvariant tree → tree ≡ node k ⟪ ca , v1 ⟫ t1 t2 → replacedRBTree key value t2 t → treeInvariant (node k ⟪ ca , v1 ⟫ t1 t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1110 lem21 .leaf t-leaf ()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1111 lem21 (node k₁ v2 leaf leaf) (t-single k₁ v2) eq rbr-leaf = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1112 (node-cong lem23 refl (just-injective (cong node-left eq)) refl) (t-right k₁ _ (subst (λ k → k < key) (sym lem23) x₁) tt tt lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1113 lem23 : k₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1114 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1115 lem21 (node k₁ v2 leaf leaf) (t-single k₁ v2) () rbr-node
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1116 lem21 (node k₁ v2 leaf leaf) (t-single k₁ v2) () (rbr-right x x₁ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1117 lem21 (node k₁ v2 leaf leaf) (t-single k₁ v2) () (rbr-left x x₁ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1118 lem21 (node k₁ v2 leaf leaf) (t-single k₁ v2) () (rbr-black-right x x₁ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1119 lem21 (node k₁ v2 leaf leaf) (t-single k₁ v2) () (rbr-black-left x x₁ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1120 lem21 (node k₁ v2 leaf leaf) (t-single k₁ v2) () (rbr-flip-ll x x₁ x₂ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1121 lem21 (node k₁ v2 leaf leaf) (t-single k₁ v2) () (rbr-flip-lr x x₁ x₂ x₃ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1122 lem21 (node k₁ v2 leaf leaf) (t-single k₁ v2) () (rbr-flip-rl x x₁ x₂ x₃ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1123 lem21 (node k₁ v2 leaf leaf) (t-single k₁ v2) () (rbr-flip-rr x x₁ x₂ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1124 lem21 (node k₁ v2 leaf leaf) (t-single k₁ v2) () (rbr-rotate-ll x x₁ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1125 lem21 (node k₁ v2 leaf leaf) (t-single k₁ v2) () (rbr-rotate-rr x x₁ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1126 lem21 (node k₁ v2 leaf leaf) (t-single k₁ v2) () (rbr-rotate-lr t₂ t₃ kg kp kn x x₁ x₂ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1127 lem21 (node k₁ v2 leaf leaf) (t-single k₁ v2) () (rbr-rotate-rl t₂ t₃ kg kp kn x x₁ x₂ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1128 lem21 (node k₃ _ leaf (node k₁ _ _ _)) (t-right k₃ k₁ x x₄ x₂ ti) eq rbr-leaf = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1129 (node-cong lem23 refl (just-injective (cong node-left eq)) refl) (t-right k₃ _ (subst (λ k → k < key) (sym lem23) x₁) tt tt lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1130 lem23 : k₃ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1131 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1132 lem21 (node k₃ _ leaf (node k₁ _ _ _)) (t-right k₃ k₁ {_} {_} {t₁} {t₂} x x₁₀ x₂ ti) eq (rbr-node {_} {_} {left} {right}) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1133 (node-cong lem23 refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1134 (t-right k₃ _ (subst (λ k → k < key) (sym lem23) x₁) (subst (λ k → tr> k₃ k) lem24 x₁₀) (subst (λ k → tr> k₃ k) lem25 x₂) lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1135 lem23 : k₃ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1136 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1137 lem24 : t₁ ≡ left
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1138 lem24 = just-injective (cong node-left (just-injective (cong node-right eq)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1139 lem25 : t₂ ≡ right
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1140 lem25 = just-injective (cong node-right (just-injective (cong node-right eq)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1141 lem21 (node k₃ _ leaf (node k₁ _ _ _)) (t-right k₃ k₁ {_} {_} {left} {right} x x₁₀ x₂ ti) eq (rbr-right {k₂} {_} {_} {t₁} {t₂} {t₃} x₃ x₄ trb) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1142 (node-cong lem23 refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1143 (t-right k₃ _ (subst (λ k → k₃ < k) lem26 x) (subst (λ k → tr> k₃ k) lem24 x₁₀) rr01 lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1144 lem23 : k₃ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1145 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1146 lem26 : k₁ ≡ k₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1147 lem26 = just-injective (cong node-key (just-injective (cong node-right eq)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1148 lem24 : left ≡ t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1149 lem24 = just-injective (cong node-left (just-injective (cong node-right eq)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1150 rr01 : tr> k₃ t₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1151 rr01 = RB-repl→ti> _ _ _ _ _ trb (<-trans (subst (λ k → k₃ < k ) lem26 x ) x₄ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1152 (subst (λ j → tr> k₃ j) (just-injective (cong node-right (just-injective (cong node-right eq)))) x₂ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1153 lem21 (node k₃ _ leaf (node k₁ _ _ _)) (t-right k₃ k₁ {_} {_} {left} {right} x x₁₀ x₂ ti) eq (rbr-left {k₂} {_} {_} {t₁} {t₂} {t₃} x₃ x₄ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1154 (node-cong lem23 refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1155 (t-right k₃ _ (subst (λ k → k₃ < k) lem26 x) rr02 rr01 lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1156 lem23 : k₃ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1157 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1158 lem26 : k₁ ≡ k₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1159 lem26 = just-injective (cong node-key (just-injective (cong node-right eq)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1160 rr01 : tr> k₃ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1161 rr01 = subst (λ k → tr> k₃ k) (just-injective (cong node-right (just-injective (cong node-right eq)))) x₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1162 rr02 : tr> k₃ t₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1163 rr02 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1164 (subst (λ j → tr> k₃ j) (just-injective (cong node-left (just-injective (cong node-right eq)))) x₁₀ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1165 lem21 (node k₃ _ leaf (node k₁ _ _ _)) (t-right k₃ k₁ {_} {_} {left} {right} x x₁₀ x₂ ti) eq (rbr-black-right {t₁} {t₂} {t₃} {_} {k₂} x₃ x₄ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1166 (node-cong lem23 refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1167 (t-right k₃ _ (subst (λ k → k₃ < k) lem26 x) rr01 rr02 lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1168 lem23 : k₃ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1169 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1170 lem26 : k₁ ≡ k₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1171 lem26 = just-injective (cong node-key (just-injective (cong node-right eq)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1172 rr01 : tr> k₃ t₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1173 rr01 = subst (λ k → tr> k₃ k) (just-injective (cong node-left (just-injective (cong node-right eq)))) x₁₀
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1174 rr02 : tr> k₃ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1175 rr02 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1176 (subst (λ k → tr> k₃ k) (just-injective (cong node-right (just-injective (cong node-right eq)))) x₂ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1177 lem21 (node k₃ _ leaf (node k₁ _ _ _)) (t-right k₃ k₁ {_} {_} {left} {right} x x₁₀ x₂ ti) eq (rbr-black-left {t₁} {t₂} {t₃} {_} {k₂} x₃ x₄ rbt) = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1178 (node-cong lem23 refl (just-injective (cong node-left eq)) refl) (t-right k₃ _ (subst (λ k → k₃ < k) lem26 x) rr02 rr01 lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1179 lem23 : k₃ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1180 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1181 lem26 : k₁ ≡ k₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1182 lem26 = just-injective (cong node-key (just-injective (cong node-right eq)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1183 rr01 : tr> k₃ t₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1184 rr01 = subst (λ k → tr> k₃ k) (just-injective (cong node-right (just-injective (cong node-right eq)))) x₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1185 rr02 : tr> k₃ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1186 rr02 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1187 (subst (λ k → tr> k₃ k) (just-injective (cong node-left (just-injective (cong node-right eq)))) x₁₀ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1188 lem21 (node k₃ _ leaf (node k₁ _ _ _)) (t-right k₃ k₁ x x₁₀ x₂ ti) eq (rbr-flip-ll x₃ x₄ x₅ rbt) = ⊥-elim ( ⊥-color ceq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1189 lem21 (node k₃ _ leaf (node k₁ _ _ _)) (t-right k₃ k₁ x x₁₀ x₂ ti) eq (rbr-flip-lr x₃ x₄ x₅ x₆ rbt) = ⊥-elim ( ⊥-color ceq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1190 lem21 (node k₃ _ leaf (node k₁ _ _ _)) (t-right k₃ k₁ x x₁₀ x₂ ti) eq (rbr-flip-rl x₃ x₄ x₅ x₆ rbt) = ⊥-elim ( ⊥-color ceq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1191 lem21 (node k₃ _ leaf (node k₁ _ _ _)) (t-right k₃ k₁ x x₁₀ x₂ ti) eq (rbr-flip-rr x₃ x₄ x₅ rbt) = ⊥-elim ( ⊥-color ceq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1192 lem21 (node k₃ _ leaf (node k₁ _ _ _)) (t-right k₃ k₁ {_} {_} {left} {right} x x₁₀ x₂ ti₁) eq (rbr-rotate-ll {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1193 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1194 (node-cong lem23 refl (just-injective (cong node-left eq)) refl) (t-right k₃ _ lem27 rr02 rr01 lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1195 lem23 : k₃ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1196 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1197 lem27 : k₃ < kp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1198 lem27 = subst (λ k → k < kp) (sym lem23) (<-trans x₁ x₄)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1199 rr04 : (k₃ < kg) ∧ ((k₃ < kp) ∧ tr> k₃ t₁ ∧ tr> k₃ t) ∧ tr> k₃ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1200 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1201 rr01 : (k₃ < kg) ∧ tr> k₃ t ∧ tr> k₃ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1202 rr01 = ⟪ proj1 rr04 , ⟪ proj2 (proj2 (proj1 (proj2 rr04))) , proj2 (proj2 rr04) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1203 rr02 : tr> k₃ t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1204 rr02 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁) (proj1 (proj2 (proj1 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1205 lem21 (node k₃ _ leaf (node k₁ _ _ _)) (t-right k₃ k₁ x x₁₀ x₂ ti₁) eq (rbr-rotate-rr {t} {t₁} {t₂} {uncle} {kg} {kp} x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1206 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1207 (node-cong lem23 refl (just-injective (cong node-left eq)) refl) (t-right k₃ _ lem27 rr01 rr02 lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1208 lem23 : k₃ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1209 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1210 rr04 : (k₃ < kg) ∧ tr> k₃ uncle ∧ ((k₃ < kp) ∧ tr> k₃ t ∧ tr> k₃ t₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1211 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1212 lem27 : k₃ < kp
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1213 lem27 = proj1 (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1214 rr01 : (k₃ < kg) ∧ tr> k₃ uncle ∧ tr> k₃ t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1215 rr01 = ⟪ proj1 rr04 , ⟪ proj1 (proj2 rr04) , proj1 (proj2 (proj2 (proj2 rr04))) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1216 rr02 : tr> k₃ t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1217 rr02 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁) (proj2 (proj2 (proj2 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1218 lem21 (node k₃ _ leaf (node k₁ _ _ _)) (t-right k₃ k₁ x x₁₀ x₂ ti₁) eq (rbr-rotate-lr {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1219 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1220 (node-cong lem23 refl (just-injective (cong node-left eq)) refl) (t-right k₃ _ lem27 rr05 rr06 lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1221 lem23 : k₃ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1222 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1223 rr04 : (k₃ < kg) ∧ ((k₃ < kp) ∧ tr> k₃ t ∧ tr> k₃ t₁) ∧ tr> k₃ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1224 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1225 rr01 : (k₃ < kn) ∧ tr> k₃ t₂ ∧ tr> k₃ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1226 rr01 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁) (proj2 (proj2 (proj1 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1227 lem27 : k₃ < kn
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1228 lem27 = proj1 rr01
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1229 rr05 : (k₃ < kp) ∧ tr> k₃ t ∧ tr> k₃ t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1230 rr05 = ⟪ proj1 (proj1 (proj2 rr04)) , ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , proj1 (proj2 rr01) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1231 rr06 : (k₃ < kg) ∧ tr> k₃ t₃ ∧ tr> k₃ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1232 rr06 = ⟪ proj1 rr04 , ⟪ proj2 (proj2 rr01) , proj2 (proj2 rr04) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1233 lem21 (node k₃ _ leaf (node k₁ _ _ _)) (t-right k₃ k₁ x x₁₀ x₂ ti₁) eq (rbr-rotate-rl {t} {t₁} {uncle} t₂ t₃ kg kp kn x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1234 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1235 (node-cong lem23 refl (just-injective (cong node-left eq)) refl) (t-right k₃ _ lem27 rr05 rr06 lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1236 lem23 : k₃ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1237 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1238 rr04 : (k₃ < kg) ∧ tr> k₃ uncle ∧ ( (k₃ < kp) ∧ tr> k₃ t₁ ∧ tr> k₃ t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1239 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1240 rr01 : (k₃ < kn) ∧ tr> k₃ t₂ ∧ tr> k₃ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1241 rr01 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁) (proj1 (proj2 (proj2 (proj2 rr04))) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1242 lem27 : k₃ < kn
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1243 lem27 = proj1 rr01
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1244 rr05 : (k₃ < kg) ∧ tr> k₃ uncle ∧ tr> k₃ t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1245 rr05 = ⟪ proj1 rr04 , ⟪ proj1 (proj2 rr04) , proj1 (proj2 rr01) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1246 rr06 : (k₃ < kp) ∧ tr> k₃ t₃ ∧ tr> k₃ t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1247 rr06 = ⟪ proj1 (proj2 (proj2 rr04)) , ⟪ proj2 (proj2 rr01) , proj2 (proj2 (proj2 (proj2 rr04))) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1248 lem21 (node k₃ _ (node k₁ _ _ _) leaf) (t-left .k₁ k₃ x x₁₀ x₂ ti₁) eq rbr-leaf = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1249 (node-cong lem23 refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1250 (t-node _ _ _ x (subst (λ j → j < key) (sym lem23) x₁) x₁₀ x₂ tt tt ti₁ (t-single key ⟪ Red , value ⟫)) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1251 lem23 : k₃ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1252 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1253 lem21 (node k₃ _ (node k₁ _ _ _) leaf) (t-left .k₁ k₃ x x₁₀ x₂ ti) () rbr-node
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1254 lem21 (node k₃ _ (node k₁ _ _ _) leaf) (t-left .k₁ k₃ x x₁₀ x₂ ti) () (rbr-right x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1255 lem21 (node k₃ _ (node k₁ _ _ _) leaf) (t-left .k₁ k₃ x x₁₀ x₂ ti) () (rbr-left x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1256 lem21 (node k₃ _ (node k₁ _ _ _) leaf) (t-left .k₁ k₃ x x₁₀ x₂ ti) () (rbr-black-right x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1257 lem21 (node k₃ _ (node k₁ _ _ _) leaf) (t-left .k₁ k₃ x x₁₀ x₂ ti) () (rbr-black-left x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1258 lem21 (node k₃ _ (node k₁ _ _ _) leaf) (t-left .k₁ k₃ x x₁₀ x₂ ti) () (rbr-flip-ll x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1259 lem21 (node k₃ _ (node k₁ _ _ _) leaf) (t-left .k₁ k₃ x x₁₀ x₂ ti) () (rbr-flip-lr x₃ x₄ x₅ x₆ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1260 lem21 (node k₃ _ (node k₁ _ _ _) leaf) (t-left .k₁ k₃ x x₁₀ x₂ ti) () (rbr-flip-rl x₃ x₄ x₅ x₆ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1261 lem21 (node k₃ _ (node k₁ _ _ _) leaf) (t-left .k₁ k₃ x x₁₀ x₂ ti) () (rbr-flip-rr x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1262 lem21 (node k₃ _ (node k₁ _ _ _) leaf) (t-left .k₁ k₃ x x₁₀ x₂ ti) () (rbr-rotate-ll x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1263 lem21 (node k₃ _ (node k₁ _ _ _) leaf) (t-left .k₁ k₃ x x₁₀ x₂ ti) () (rbr-rotate-rr x₃ x₄ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1264 lem21 (node k₃ _ (node k₁ _ _ _) leaf) (t-left .k₁ k₃ x x₁₀ x₂ ti) () (rbr-rotate-lr t₂ t₃ kg kp kn x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1265 lem21 (node k₃ _ (node k₁ _ _ _) leaf) (t-left .k₁ k₃ x x₁₀ x₂ ti) () (rbr-rotate-rl t₂ t₃ kg kp kn x₃ x₄ x₅ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1266 lem21 (node k₁ _ (node k₂ _ _ _) (node k₄ _ _ _)) (t-node k₂ .k₁ k₄ x x₁₀ x₂ x₃ x₄ x₅ ti ti₁) () rbr-leaf
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1267 lem21 (node k₁ _ (node k₂ _ _ _) (node k₄ _ _ _)) (t-node k₂ .k₁ k₄ {_} {_} {_} {t} {t₁} {t₂} x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-node {_} {_} {t₃} {t₄})
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1268 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1269 (node-cong lem23 refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1270 (t-node _ _ _ x (subst (λ j → j < key) (sym lem23) x₁) x₂ x₃ (proj1 (proj2 rr04)) (proj2 (proj2 rr04)) ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1271 lem23 : k₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1272 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1273 rr04 : (k₁ < key) ∧ tr> k₁ t₃ ∧ tr> k₁ t₄
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1274 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1275 lem21 (node k₁ _ (node k₂ _ _ _) (node k₄ _ _ _)) (t-node k₂ .k₁ k₄ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-right {k₃} {_} {_} {t₁} {t₂} {t₃} x₆ x₇ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1276 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1277 (node-cong lem23 refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1278 (t-node _ _ _ x (proj1 rr04) x₂ x₃ (proj1 (proj2 rr04)) rr05 ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1279 lem23 : k₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1280 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1281 rr04 : (k₁ < k₃) ∧ tr> k₁ t₂ ∧ tr> k₁ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1282 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1283 rr05 : tr> k₁ t₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1284 rr05 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁) (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1285 lem21 (node k₁ _ (node k₂ _ _ _) (node k₄ _ _ _)) (t-node k₂ .k₁ k₄ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-left {k₃} {_} {_} {t₁} {t₂} {t₃} x₆ x₇ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1286 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1287 (node-cong lem23 refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1288 (t-node _ _ _ x (proj1 rr04) x₂ x₃ rr05 (proj2 (proj2 rr04)) ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1289 lem23 : k₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1290 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1291 rr04 : (k₁ < k₃) ∧ tr> k₁ t₂ ∧ tr> k₁ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1292 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1293 rr05 : tr> k₁ t₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1294 rr05 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁) (proj1 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1295 lem21 (node k₁ _ (node k₂ _ _ _) (node k₄ _ _ _)) (t-node k₂ .k₁ k₄ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-black-right {t₁} {t₂} {t₃} {_} {k₃} x₆ x₇ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1296 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1297 (node-cong lem23 refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1298 (t-node _ _ _ x (proj1 rr04) x₂ x₃ (proj1 (proj2 rr04)) rr05 ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1299 lem23 : k₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1300 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1301 rr04 : (k₁ < k₃) ∧ tr> k₁ t₁ ∧ tr> k₁ t₂
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1302 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1303 rr05 : tr> k₁ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1304 rr05 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁) (proj2 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1305 lem21 (node k₁ _ (node k₂ _ _ _) (node k₄ _ _ _)) (t-node k₂ .k₁ k₄ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-black-left {t₁} {t₂} {t₃} {_} {k₃} x₆ x₇ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1306 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1307 (node-cong lem23 refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1308 (t-node _ _ _ x (proj1 rr04) x₂ x₃ rr05 (proj2 (proj2 rr04)) ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1309 lem23 : k₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1310 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1311 rr04 : (k₁ < k₃) ∧ tr> k₁ t₂ ∧ tr> k₁ t₁
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1312 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1313 rr05 : tr> k₁ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1314 rr05 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁) (proj1 (proj2 rr04))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1315 lem21 (node k₁ _ (node k₂ _ _ _) (node k₄ _ _ _)) (t-node k₂ .k₁ k₄ x x₁₀ x₂ x₃ x₄ x₅ ti ti₁) eq (rbr-flip-ll x₆ x₇ x₈ rbt) = ⊥-elim ( ⊥-color ceq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1316 lem21 (node k₁ _ (node k₂ _ _ _) (node k₄ _ _ _)) (t-node k₂ .k₁ k₄ x x₁₀ x₂ x₃ x₄ x₅ ti ti₁) eq (rbr-flip-lr x₆ x₇ x₈ x₉ rbt) = ⊥-elim ( ⊥-color ceq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1317 lem21 (node k₁ _ (node k₂ _ _ _) (node k₄ _ _ _)) (t-node k₂ .k₁ k₄ x x₁₀ x₂ x₃ x₄ x₅ ti ti₁) eq (rbr-flip-rl x₆ x₇ x₈ x₉ rbt) = ⊥-elim ( ⊥-color ceq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1318 lem21 (node k₁ _ (node k₂ _ _ _) (node k₄ _ _ _)) (t-node k₂ .k₁ k₄ x x₁₀ x₂ x₃ x₄ x₅ ti ti₁) eq (rbr-flip-rr x₆ x₇ x₈ rbt) = ⊥-elim ( ⊥-color ceq )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1319 lem21 (node k₁ _ (node k₂ _ _ _) (node k₄ _ _ _)) (t-node k₂ .k₁ k₄ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-ll {t₁} {t₂} {t₃} {uncle} {kg} {kp} x₆ x₇ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1320 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1321 (node-cong lem23 refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1322 (t-node _ _ _ x (proj1 (proj1 (proj2 rr04))) x₂ x₃ rr05 ⟪ proj1 rr04 , ⟪ proj2 (proj2 (proj1 (proj2 rr04))) , proj2 (proj2 rr04) ⟫ ⟫ ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1323 lem23 : k₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1324 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1325 rr04 : (k₁ < kg) ∧ ((k₁ < kp) ∧ tr> k₁ t₂ ∧ tr> k₁ t₁) ∧ tr> k₁ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1326 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1327 rr05 : tr> k₁ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1328 rr05 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁) (proj1 (proj2 (proj1 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1329 lem21 (node k₁ _ (node k₂ _ _ _) (node k₄ _ _ _)) (t-node k₂ .k₁ k₄ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-rr {t₁} {t₂} {t₃} {uncle} {kg} {kp} x₆ x₇ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1330 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1331 (node-cong lem23 refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1332 (t-node _ _ _ x (proj1 (proj2 (proj2 rr04))) x₂ x₃ ⟪ proj1 rr04 , ⟪ proj1 (proj2 rr04) , proj1 (proj2 (proj2 (proj2 rr04))) ⟫ ⟫ rr05 ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1333 lem23 : k₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1334 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1335 rr04 : (k₁ < kg) ∧ tr> k₁ uncle ∧ ((k₁ < kp) ∧ tr> k₁ t₁ ∧ tr> k₁ t₂)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1336 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1337 rr05 : tr> k₁ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1338 rr05 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁) (proj2 (proj2 (proj2 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1339 lem21 (node k₁ _ (node k₂ _ _ _) (node k₄ _ _ _)) (t-node k₂ .k₁ k₄ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-lr {t} {t₁} {uncle} t₂ t₃ kg kp kn x₆ x₇ x₈ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1340 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1341 (node-cong lem23 refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1342 (t-node _ _ _ x (proj1 rr05) x₂ x₃ ⟪ proj1 (proj1 (proj2 rr04)) , ⟪ proj1 (proj2 (proj1 (proj2 rr04))) , proj1 (proj2 rr05) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1343 ⟪ proj1 rr04 , ⟪ proj2 (proj2 rr05) , proj2 (proj2 rr04) ⟫ ⟫ ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1344 lem23 : k₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1345 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1346 rr04 : (k₁ < kg) ∧ ((k₁ < kp) ∧ tr> k₁ t ∧ tr> k₁ t₁) ∧ tr> k₁ uncle
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1347 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1348 rr05 : (k₁ < kn) ∧ tr> k₁ t₂ ∧ tr> k₁ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1349 rr05 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁) (proj2 (proj2 (proj1 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1350 lem21 (node k₁ _ (node k₂ _ _ _) (node k₄ _ _ _)) (t-node k₂ .k₁ k₄ x x₁₀ x₂ x₃ x₄ x₅ ti₁ ti₂) eq (rbr-rotate-rl {t} {t₁} {uncle} t₂ t₃ kg kp kn x₆ x₇ x₈ rbt)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1351 = subst treeInvariant
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1352 (node-cong lem23 refl (just-injective (cong node-left eq)) refl)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1353 (t-node _ _ _ x (proj1 rr05) x₂ x₃ ⟪ proj1 rr04 , ⟪ proj1 (proj2 rr04) , proj1 (proj2 rr05) ⟫ ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1354 ⟪ proj1 (proj2 (proj2 rr04)) , ⟪ proj2 (proj2 rr05) , proj2 (proj2 (proj2 (proj2 rr04))) ⟫ ⟫ ti₁ lem22) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1355 lem23 : k₁ ≡ k
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1356 lem23 = just-injective (cong node-key eq)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1357 rr04 : (k₁ < kg) ∧ tr> k₁ uncle ∧ ((k₁ < kp) ∧ tr> k₁ t₁ ∧ tr> k₁ t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1358 rr04 = proj2 (ti-property1 (subst (λ k → treeInvariant ( node k _ _ _ )) (sym lem23) ti ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1359 rr05 : (k₁ < kn) ∧ tr> k₁ t₂ ∧ tr> k₁ t₃
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1360 rr05 = RB-repl→ti> _ _ _ _ _ rbt (subst (λ j → j < key) (sym lem23) x₁) (proj1 (proj2 (proj2 (proj2 rr04))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1361