annotate hoareBinaryTree.agda @ 589:37f5826ca7d2

minor fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 06 Dec 2019 13:01:53 +0900
parents 8627d35d4bff
children 7c424dd0945d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
1 module hoareBinaryTree where
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
2
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
3 open import Level renaming (zero to Z ; suc to succ)
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
4
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
5 open import Data.Nat hiding (compare)
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
6 open import Data.Nat.Properties as NatProp
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
7 open import Data.Maybe
588
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
8 -- open import Data.Maybe.Properties
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
9 open import Data.Empty
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
10 open import Data.List
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
11 open import Data.Product
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
12
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
13 open import Function as F hiding (const)
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
14
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
15 open import Relation.Binary
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
16 open import Relation.Binary.PropositionalEquality
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
17 open import Relation.Nullary
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
18 open import logic
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
19
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
20
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
21 SingleLinkedStack = List
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
22
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
23 emptySingleLinkedStack : {n : Level } {Data : Set n} -> SingleLinkedStack Data
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
24 emptySingleLinkedStack = []
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
25
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
26 clearSingleLinkedStack : {n m : Level } {Data : Set n} {t : Set m} -> SingleLinkedStack Data → ( SingleLinkedStack Data → t) → t
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
27 clearSingleLinkedStack [] cg = cg []
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
28 clearSingleLinkedStack (x ∷ as) cg = cg []
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
29
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
30 pushSingleLinkedStack : {n m : Level } {t : Set m } {Data : Set n} -> List Data -> Data -> (Code : SingleLinkedStack Data -> t) -> t
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
31 pushSingleLinkedStack stack datum next = next ( datum ∷ stack )
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
32
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
33
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
34 popSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} -> SingleLinkedStack a -> (Code : SingleLinkedStack a -> (Maybe a) -> t) -> t
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
35 popSingleLinkedStack [] cs = cs [] nothing
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
36 popSingleLinkedStack (data1 ∷ s) cs = cs s (just data1)
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
37
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
38
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
39
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
40 emptySigmaStack : {n : Level } { Data : Set n} → List Data
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
41 emptySigmaStack = []
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
42
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
43 pushSigmaStack : {n m : Level} {d d2 : Set n} {t : Set m} → d2 → List d → (List (d × d2) → t) → t
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
44 pushSigmaStack {n} {m} {d} d2 st next = next (Data.List.zip (st) (d2 ∷ []) )
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
45
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
46 tt = pushSigmaStack 3 (true ∷ []) (λ st → st)
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
47
588
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
48 _iso_ : {n : Level} {a : Set n} → ℕ → ℕ → Set
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
49 d iso d' = (¬ (suc d ≤ d')) ∧ (¬ (suc d' ≤ d))
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
50
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
51 iso-intro : {n : Level} {a : Set n} {x y : ℕ} → ¬ (suc x ≤ y) → ¬ (suc y ≤ x) → _iso_ {n} {a} x y
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
52 iso-intro = λ z z₁ → record { proj1 = z ; proj2 = z₁ }
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
53
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
54
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
55 {--
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
56 data A B : C → D → Set where の A B と C → D の差は?
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
57
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
58 --}
588
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
59
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
60 data bt {n : Level} {a : Set n} : Set n where -- (a : Setn)
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
61 bt-leaf : ⦃ l u : ℕ ⦄ → l ≤ u → bt
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
62 bt-node : ⦃ l l' u u' : ℕ ⦄ → (d : ℕ) →
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
63 bt {n} {a} → bt {n} {a} → l ≤ l' → u' ≤ u → bt
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
64
588
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
65 data bt' {n : Level} (A : Set n) : (key : ℕ) → Set n where -- (a : Setn)
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
66 bt'-leaf : (key : ℕ) → bt' A key
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
67 bt'-node : { l r : ℕ } → (key : ℕ) → (value : A) →
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
68 bt' {n} A l → bt' {n} A r → l < key → key < r → bt' A key
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
69
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
70 data bt'-path {n : Level} (A : Set n) : Set n where -- (a : Setn)
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
71 bt'-left : (key : ℕ) → {left-key : ℕ} → (bt' A left-key ) → (key < left-key) → bt'-path A
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
72 bt'-right : (key : ℕ) → {right-key : ℕ} → (bt' A right-key ) → (right-key < key) → bt'-path A
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
73 bt'-null : bt'-path A
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
74
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
75
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
76 test = bt'-left {Z} {ℕ} 3 {5} (bt'-leaf 5) (s≤s (s≤s (s≤s (s≤s z≤n))))
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
77
589
37f5826ca7d2 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 588
diff changeset
78 bt-find' : {n m : Level} {A : Set n} {t : Set m} {tn : ℕ} → (key : ℕ) → (tree : bt' A tn ) → List (bt'-path A )
37f5826ca7d2 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 588
diff changeset
79 → ( {key1 : ℕ } → bt' A key1 → List (bt'-path A ) → t ) → t
37f5826ca7d2 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 588
diff changeset
80 bt-find' key tr@(bt'-leaf key₁) stack next = next tr stack -- no key found
588
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
81 bt-find' key (bt'-node key₁ value tree tree₁ x x₁) stack next with <-cmp key key₁
589
37f5826ca7d2 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 588
diff changeset
82 bt-find' key tr@(bt'-node {l} {r} key₁ value tree tree₁ x x₁) stack next | tri< a ¬b ¬c =
37f5826ca7d2 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 588
diff changeset
83 bt-find' key tree ( (bt'-left key {key₁} tr a ) ∷ stack) next
37f5826ca7d2 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 588
diff changeset
84 bt-find' key found@(bt'-node key₁ value tree tree₁ x x₁) stack next | tri≈ ¬a b ¬c = next found stack
37f5826ca7d2 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 588
diff changeset
85 bt-find' key tr@(bt'-node key₁ value tree tree₁ x x₁) stack next | tri> ¬a ¬b c =
37f5826ca7d2 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 588
diff changeset
86 bt-find' key tree ( (bt'-right key {key₁} tr c ) ∷ stack) next
588
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
87
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
88
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
89 bt-replace' : {n m : Level} {A : Set n} {t : Set m} {tn : ℕ} → (key : ℕ) → (tree : bt' ℕ tn ) → List (bt'-path A ) → ( {key1 : ℕ } → bt' A key1 → List (bt'-path A ) → t ) → t
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
90 bt-replace' = {!!}
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
91
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
92 bt-find'-assert1 : {n m : Level} {A : Set n} {t : Set m} → Set n
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
93 bt-find'-assert1 {n} {m} {A} {t} = (key : ℕ) → (val : A) → bt-find' key {!!} {!!} (λ tree stack → {!!})
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
94
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
95
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
96 -- find'-support : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → (d : ℕ) → (tree : bt' {n} {a} ) → SingleLinkedStack (bt' {n} {a} ) → ( (bt' {n} {a} ) → SingleLinkedStack (bt' {n} {a} ) → Maybe (Σ ℕ (λ d' → _iso_ {n} {a} d d')) → t ) → t
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
97
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
98 -- find'-support {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key leaf@(bt'-leaf x) st cg = cg leaf st nothing
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
99 -- find'-support {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key (bt'-node d tree₁ tree₂ x x₁) st cg with <-cmp key d
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
100 -- find'-support {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key node@(bt'-node d tree₁ tree₂ x x₁) st cg | tri≈ ¬a b ¬c = cg node st (just (d , iso-intro {n} {a} ¬a ¬c))
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
101
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
102 -- find'-support {n} {m} {a} {t} key node@(bt'-node ⦃ nl ⦄ ⦃ l' ⦄ ⦃ nu ⦄ ⦃ u' ⦄ d L R x x₁) st cg | tri< a₁ ¬b ¬c =
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
103 -- pushSingleLinkedStack st node
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
104 -- (λ st2 → find'-support {n} {m} {a} {t} {{l'}} {{d}} key L st2 cg)
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
105
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
106 -- find'-support {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key node@(bt'-node ⦃ ll ⦄ ⦃ ll' ⦄ ⦃ lr ⦄ ⦃ lr' ⦄ d L R x x₁) st cg | tri> ¬a ¬b c = pushSingleLinkedStack st node
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
107 -- (λ st2 → find'-support {n} {m} {a} {t} {{d}} {{lr'}} key R st2 cg)
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
108
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
109
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
110
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
111 lleaf : {n : Level} {a : Set n} → bt {n} {a}
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
112 lleaf = (bt-leaf ⦃ 0 ⦄ ⦃ 3 ⦄ z≤n)
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
113
588
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
114 lleaf1 : {n : Level} {A : Set n} → (0 < 3) → (a : A) → (d : ℕ ) → bt' {n} A d
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
115 lleaf1 0<3 a d = bt'-leaf d
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
116
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
117 test-node1 : bt' ℕ 3
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
118 test-node1 = bt'-node (3) 3 (bt'-leaf 2) (bt'-leaf 4) (s≤s (s≤s (s≤s z≤n))) (s≤s (s≤s (s≤s (s≤s z≤n))))
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
119
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
120
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
121 rleaf : {n : Level} {a : Set n} → bt {n} {a}
588
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
122 rleaf = (bt-leaf ⦃ 3 ⦄ ⦃ 3 ⦄ (s≤s (s≤s (s≤s z≤n))))
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
123
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
124 test-node : {n : Level} {a : Set n} → bt {n} {a}
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
125 test-node {n} {a} = (bt-node ⦃ 0 ⦄ ⦃ 0 ⦄ ⦃ 4 ⦄ ⦃ 4 ⦄ 3 lleaf rleaf z≤n ≤-refl )
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
126
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
127 -- stt : {n m : Level} {a : Set n} {t : Set m} → {!!}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
128 -- stt {n} {m} {a} {t} = pushSingleLinkedStack [] (test-node ) (λ st → pushSingleLinkedStack st lleaf (λ st2 → st2) )
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
129
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
130
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
131
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
132 -- search の {{ l }} {{ u }} はその時みている node の 大小。 l が小さく u が大きい
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
133 -- ここでは d が現在の node のkey値なので比較後のsearch では値が変わる
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
134 bt-search : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → (d : ℕ) → bt {n} {a} → (Maybe (Σ ℕ (λ d' → _iso_ {n} {a} d d')) → t ) → t
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
135 bt-search {n} {m} {a} {t} key (bt-leaf x) cg = cg nothing
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
136 bt-search {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key (bt-node ⦃ ll ⦄ ⦃ l' ⦄ ⦃ uu ⦄ ⦃ u' ⦄ d L R x x₁) cg with <-cmp key d
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
137 bt-search {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key (bt-node ⦃ ll ⦄ ⦃ l' ⦄ ⦃ uu ⦄ ⦃ u' ⦄ d L R x x₁) cg | tri< a₁ ¬b ¬c = bt-search ⦃ l' ⦄ ⦃ d ⦄ key L cg
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
138 bt-search {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key (bt-node ⦃ ll ⦄ ⦃ l' ⦄ ⦃ uu ⦄ ⦃ u' ⦄ d L R x x₁) cg | tri≈ ¬a b ¬c = cg (just (d , iso-intro {n} {a} ¬a ¬c))
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
139 bt-search {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key (bt-node ⦃ ll ⦄ ⦃ l' ⦄ ⦃ uu ⦄ ⦃ u' ⦄ d L R x x₁) cg | tri> ¬a ¬b c = bt-search ⦃ d ⦄ ⦃ u' ⦄ key R cg
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
140
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
141 -- bt-search {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key (bt-node ⦃ l ⦄ ⦃ l' ⦄ ⦃ u ⦄ ⦃ u' ⦄ d L R x x₁) cg | tri< a₁ ¬b ¬c = ? -- bt-search ⦃ l' ⦄ ⦃ d ⦄ key L cg
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
142 -- bt-search {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key (bt-node d L R x x₁) cg | tri≈ ¬a b ¬c = cg (just (d , iso-intro {n} {a} ¬a ¬c))
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
143 -- bt-search {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key (bt-node ⦃ l ⦄ ⦃ l' ⦄ ⦃ u ⦄ ⦃ u' ⦄ d L R x x₁) cg | tri> ¬a ¬b c = bt-search ⦃ d ⦄ ⦃ u' ⦄ key R cg
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
144
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
145
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
146 -- この辺の test を書くときは型を考えるのがやや面倒なので先に動作を書いてから型を ? から補間するとよさそう
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
147 bt-search-test : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → (x : (x₁ : Maybe (Σ ℕ (λ z → ((x₂ : 4 ≤ z) → ⊥) ∧ ((x₂ : suc z ≤ 3) → ⊥)))) → t) → t
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
148 bt-search-test {n} {m} {a} {t} = bt-search {n} {m} {a} {t} ⦃ zero ⦄ ⦃ 4 ⦄ 3 test-node
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
149
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
150 bt-search-test-bad : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → (x : (x₁ : Maybe (Σ ℕ (λ z → ((x₂ : 8 ≤ z) → ⊥) ∧ ((x₂ : suc z ≤ 7) → ⊥)))) → t) → t
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
151 bt-search-test-bad {n} {m} {a} {t} = bt-search {n} {m} {a} {t} ⦃ zero ⦄ ⦃ 4 ⦄ 7 test-node
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
152
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
153
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
154 -- up-some : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ {d : ℕ} → (Maybe (Σ ℕ (λ d' → _iso_ {n} {a} d d'))) → (Maybe ℕ)
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
155 -- up-some (just (fst , snd)) = just fst
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
156 -- up-some nothing = nothing
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
157
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
158 search-lem : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → (key : ℕ) → (tree : bt {n} {a} ) → bt-search ⦃ l ⦄ ⦃ u ⦄ key tree (λ gdata → gdata ≡ gdata)
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
159 search-lem {n} {m} {a} {t} key (bt-leaf x) = refl
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
160 search-lem {n} {m} {a} {t} key (bt-node d tree₁ tree₂ x x₁) with <-cmp key d
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
161 search-lem {n} {m} {a} {t} key (bt-node ⦃ ll ⦄ ⦃ ll' ⦄ ⦃ lr ⦄ ⦃ lr' ⦄ d tree₁ tree₂ x x₁) | tri< lt ¬eq ¬gt = search-lem {n} {m} {a} {t} ⦃ ll' ⦄ ⦃ d ⦄ key tree₁
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
162 search-lem {n} {m} {a} {t} key (bt-node d tree₁ tree₂ x x₁) | tri≈ ¬lt eq ¬gt = refl
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
163 search-lem {n} {m} {a} {t} key (bt-node ⦃ ll ⦄ ⦃ ll' ⦄ ⦃ lr ⦄ ⦃ lr' ⦄ d tree₁ tree₂ x x₁) | tri> ¬lt ¬eq gt = search-lem {n} {m} {a} {t} ⦃ d ⦄ ⦃ lr' ⦄ key tree₂
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
164
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
165
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
166 -- bt-find
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
167 find-support : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → (d : ℕ) → (tree : bt {n} {a} ) → SingleLinkedStack (bt {n} {a} ) → ( (bt {n} {a} ) → SingleLinkedStack (bt {n} {a} ) → Maybe (Σ ℕ (λ d' → _iso_ {n} {a} d d')) → t ) → t
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
168
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
169 find-support {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key leaf@(bt-leaf x) st cg = cg leaf st nothing
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
170 find-support {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key (bt-node d tree₁ tree₂ x x₁) st cg with <-cmp key d
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
171 find-support {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key node@(bt-node d tree₁ tree₂ x x₁) st cg | tri≈ ¬a b ¬c = cg node st (just (d , iso-intro {n} {a} ¬a ¬c))
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
172
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
173 find-support {n} {m} {a} {t} key node@(bt-node ⦃ nl ⦄ ⦃ l' ⦄ ⦃ nu ⦄ ⦃ u' ⦄ d L R x x₁) st cg | tri< a₁ ¬b ¬c =
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
174 pushSingleLinkedStack st node
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
175 (λ st2 → find-support {n} {m} {a} {t} {{l'}} {{d}} key L st2 cg)
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
176
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
177 find-support {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key node@(bt-node ⦃ ll ⦄ ⦃ ll' ⦄ ⦃ lr ⦄ ⦃ lr' ⦄ d L R x x₁) st cg | tri> ¬a ¬b c = pushSingleLinkedStack st node
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
178 (λ st2 → find-support {n} {m} {a} {t} {{d}} {{lr'}} key R st2 cg)
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
179
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
180 bt-find : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → (d : ℕ) → (tree : bt {n} {a} ) → SingleLinkedStack (bt {n} {a} ) → ( (bt {n} {a} ) → SingleLinkedStack (bt {n} {a} ) → Maybe (Σ ℕ (λ d' → _iso_ {n} {a} d d')) → t ) → t
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
181 bt-find {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key tr st cg = clearSingleLinkedStack st
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
182 (λ cst → find-support ⦃ l ⦄ ⦃ u ⦄ key tr cst cg)
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
183
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
184 find-test : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → List bt -- ?
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
185 find-test {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ = bt-find {n} {_} {a} ⦃ l ⦄ ⦃ u ⦄ 3 test-node [] (λ tt st ad → st)
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
186 {-- result
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
187 λ {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ →
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
188 bt-node 3 (bt-leaf z≤n) (bt-leaf (s≤s (s≤s (s≤s z≤n)))) z≤n (s≤s (s≤s (s≤s (s≤s z≤n)))) ∷ []
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
189 --}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
190
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
191 find-lem : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → (d : ℕ) → (tree : bt {n} {a}) → (st : List (bt {n} {a})) → find-support {{l}} {{u}} d tree st (λ ta st ad → ta ≡ ta)
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
192 find-lem d (bt-leaf x) st = refl
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
193 find-lem d (bt-node d₁ tree tree₁ x x₁) st with <-cmp d d₁
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
194 find-lem d (bt-node d₁ tree tree₁ x x₁) st | tri≈ ¬a b ¬c = refl
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
195
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
196
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
197 find-lem d (bt-node d₁ tree tree₁ x x₁) st | tri< a ¬b ¬c with tri< a ¬b ¬c
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
198 find-lem {n} {m} {a} {t} {{l}} {{u}} d (bt-node d₁ tree tree₁ x x₁) st | tri< lt ¬b ¬c | tri< a₁ ¬b₁ ¬c₁ = find-lem {n} {m} {a} {t} {{l}} {{u}} d tree {!!}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
199 find-lem d (bt-node d₁ tree tree₁ x x₁) st | tri< a ¬b ¬c | tri≈ ¬a b ¬c₁ = {!!}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
200 find-lem d (bt-node d₁ tree tree₁ x x₁) st | tri< a ¬b ¬c | tri> ¬a ¬b₁ c = {!!}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
201
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
202 find-lem d (bt-node d₁ tree tree₁ x x₁) st | tri> ¬a ¬b c = {!!}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
203
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
204 bt-singleton :{n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → (d : ℕ) → ( (bt {n} {a} ) → t ) → t
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
205 bt-singleton {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ d cg = cg (bt-node ⦃ 0 ⦄ ⦃ 0 ⦄ ⦃ d ⦄ ⦃ d ⦄ d (bt-leaf ⦃ 0 ⦄ ⦃ d ⦄ z≤n ) (bt-leaf ⦃ d ⦄ ⦃ d ⦄ ≤-refl) z≤n ≤-refl)
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
206
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
207
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
208 singleton-test : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → bt -- ?
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
209 singleton-test {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ = bt-singleton {n} {_} {a} ⦃ l ⦄ ⦃ u ⦄ 10 λ x → x
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
210
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
211
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
212 replace-helper : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → (tree : bt {n} {a} ) → SingleLinkedStack (bt {n} {a} ) → ( (bt {n} {a} ) → t ) → t
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
213 replace-helper {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ tree [] cg = cg tree
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
214 replace-helper {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ tree@(bt-node d L R x₁ x₂) (bt-leaf x ∷ st) cg = replace-helper ⦃ l ⦄ ⦃ u ⦄ tree st cg -- Unknown Case
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
215 replace-helper {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ (bt-node d tree tree₁ x₁ x₂) (bt-node d₁ x x₃ x₄ x₅ ∷ st) cg with <-cmp d d₁
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
216 replace-helper {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ subt@(bt-node d tree tree₁ x₁ x₂) (bt-node d₁ x x₃ x₄ x₅ ∷ st) cg | tri< a₁ ¬b ¬c = replace-helper ⦃ l ⦄ ⦃ u ⦄ (bt-node d₁ subt x₃ x₄ x₅) st cg
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
217 replace-helper {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ subt@(bt-node d tree tree₁ x₁ x₂) (bt-node d₁ x x₃ x₄ x₅ ∷ st) cg | tri≈ ¬a b ¬c = replace-helper ⦃ l ⦄ ⦃ u ⦄ (bt-node d₁ subt x₃ x₄ x₅) st cg
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
218 replace-helper {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ subt@(bt-node d tree tree₁ x₁ x₂) (bt-node d₁ x x₃ x₄ x₅ ∷ st) cg | tri> ¬a ¬b c = replace-helper ⦃ l ⦄ ⦃ u ⦄ (bt-node d₁ x₃ subt x₄ x₅) st cg
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
219 replace-helper {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ tree (x ∷ st) cg = replace-helper ⦃ l ⦄ ⦃ u ⦄ tree st cg -- Unknown Case
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
220
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
221
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
222
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
223 bt-replace : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
224 → (d : ℕ) → (bt {n} {a} ) → SingleLinkedStack (bt {n} {a} )
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
225 → Maybe (Σ ℕ (λ d' → _iso_ {n} {a} d d')) → ( (bt {n} {a} ) → t ) → t
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
226 bt-replace {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ d tree st eqP cg = replace-helper {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ ((bt-node ⦃ 0 ⦄ ⦃ 0 ⦄ ⦃ d ⦄ ⦃ d ⦄ d (bt-leaf ⦃ 0 ⦄ ⦃ d ⦄ z≤n ) (bt-leaf ⦃ d ⦄ ⦃ d ⦄ ≤-refl) z≤n ≤-refl)) st cg
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
227
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
228
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
229
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
230 -- 証明に insert がはいっててほしい
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
231 bt-insert : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → (d : ℕ) → (tree : bt {n} {a})
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
232 → ((bt {n} {a}) → t) → t
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
233
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
234 bt-insert {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ d tree cg = bt-find {n} {_} {a} ⦃ l ⦄ ⦃ u ⦄ d tree [] (λ tt st ad → bt-replace ⦃ l ⦄ ⦃ u ⦄ d tt st ad cg )
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
235
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
236 pickKey : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → (tree : bt {n} {a}) → Maybe ℕ
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
237 pickKey (bt-leaf x) = nothing
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
238 pickKey (bt-node d tree tree₁ x x₁) = just d
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
239
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
240 insert-test : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → bt -- ?
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
241 insert-test {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ = bt-insert {n} {_} {a} ⦃ l ⦄ ⦃ u ⦄ 1 test-node λ x → x
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
242
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
243 insert-test-l : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → bt -- ?
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
244 insert-test-l {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ = bt-insert {n} {_} {a} ⦃ l ⦄ ⦃ u ⦄ 1 (lleaf) λ x → x
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
245
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
246
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
247 insert-lem : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → (d : ℕ) → (tree : bt {n} {a})
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
248 → bt-insert {n} {_} {a} ⦃ l ⦄ ⦃ u ⦄ d tree (λ tree1 → bt-find ⦃ l ⦄ ⦃ u ⦄ d tree1 []
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
249 (λ tt st ad → (pickKey {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ tt) ≡ just d ) )
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
250
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
251
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
252 insert-lem d (bt-leaf x) with <-cmp d d -- bt-insert d (bt-leaf x) (λ tree1 → {!!})
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
253 insert-lem d (bt-leaf x) | tri< a ¬b ¬c = ⊥-elim (¬b refl)
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
254 insert-lem d (bt-leaf x) | tri≈ ¬a b ¬c = refl
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
255 insert-lem d (bt-leaf x) | tri> ¬a ¬b c = ⊥-elim (¬b refl)
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
256 insert-lem d (bt-node d₁ tree tree₁ x x₁) with <-cmp d d₁
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
257 -- bt-insert d (bt-node d₁ tree tree₁ x x₁) (λ tree1 → {!!})
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
258 insert-lem d (bt-node d₁ tree tree₁ x x₁) | tri≈ ¬a b ¬c with <-cmp d d
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
259 insert-lem d (bt-node d₁ tree tree₁ x x₁) | tri≈ ¬a b ¬c | tri< a ¬b ¬c₁ = ⊥-elim (¬b refl)
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
260 insert-lem d (bt-node d₁ tree tree₁ x x₁) | tri≈ ¬a b ¬c | tri≈ ¬a₁ b₁ ¬c₁ = refl
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
261 insert-lem d (bt-node d₁ tree tree₁ x x₁) | tri≈ ¬a b ¬c | tri> ¬a₁ ¬b c = ⊥-elim (¬b refl)
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
262
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
263 insert-lem d (bt-node d₁ tree tree₁ x x₁) | tri< a ¬b ¬c = {!!}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
264 where
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
265 lem-helper : find-support ⦃ {!!} ⦄ ⦃ {!!} ⦄ d tree (bt-node d₁ tree tree₁ x x₁ ∷ []) (λ tt₁ st ad → replace-helper ⦃ {!!} ⦄ ⦃ {!!} ⦄ (bt-node ⦃ {!!} ⦄ ⦃ {!!} ⦄ ⦃ {!!} ⦄ ⦃ {!!} ⦄ d (bt-leaf ⦃ 0 ⦄ ⦃ d ⦄ z≤n) (bt-leaf ⦃ {!!} ⦄ ⦃ {!!} ⦄ (≤-reflexive refl)) z≤n (≤-reflexive refl)) st (λ tree1 → find-support ⦃ {!!} ⦄ ⦃ {!!} ⦄ d tree1 [] (λ tt₂ st₁ ad₁ → pickKey {{!!}} {{!!}} {{!!}} {{!!}} ⦃ {!!} ⦄ ⦃ {!!} ⦄ tt₂ ≡ just d)))
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
266 lem-helper = {!!}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
267
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
268 insert-lem d (bt-node d₁ tree tree₁ x x₁) | tri> ¬a ¬b c = {!!}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
269