annotate hoareBinaryTree.agda @ 588:8627d35d4bff

add data bt', and some function
author ryokka
date Thu, 05 Dec 2019 20:38:54 +0900
parents f103f07c0552
children 37f5826ca7d2
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
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
78 bt-find' : {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
79 bt-find' key (bt'-leaf key₁) stack next = {!!}
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
80 bt-find' key (bt'-node key₁ value tree tree₁ x x₁) stack next with <-cmp key key₁
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
81 bt-find' {n} {m} {A} {t} key tr@(bt'-node {l} {r} key₁ value tree tree₁ x x₁) stack next | tri< a ¬b ¬c =
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
82 bt-find' {n} {m} {A} {t} key tree ( (bt'-left {n} {A} key {key₁} {!!} {!!} ) ∷ stack) next
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
83 bt-find' key found@(bt'-node key₁ value tree tree₁ x x₁) stack next | tri≈ ¬a b ¬c = next {!!} stack
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
84 bt-find' key (bt'-node key₁ value tree tree₁ x x₁) stack next | tri> ¬a ¬b c = {!!}
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
85
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
86
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
87 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
88 bt-replace' = {!!}
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
89
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
90 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
91 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
92
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
93
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
94 -- 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
95
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
96 -- 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
97 -- 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
98 -- 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
99
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
100 -- 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
101 -- pushSingleLinkedStack st node
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
102 -- (λ 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
103
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
104 -- 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
105 -- (λ 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
106
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
107
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
108
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
109 lleaf : {n : Level} {a : Set n} → bt {n} {a}
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
110 lleaf = (bt-leaf ⦃ 0 ⦄ ⦃ 3 ⦄ z≤n)
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
111
588
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
112 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
113 lleaf1 0<3 a d = bt'-leaf d
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
114
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
115 test-node1 : bt' ℕ 3
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
116 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
117
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
118
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
119 rleaf : {n : Level} {a : Set n} → bt {n} {a}
588
8627d35d4bff add data bt', and some function
ryokka
parents: 587
diff changeset
120 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
121
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
122 test-node : {n : Level} {a : Set n} → bt {n} {a}
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
123 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
124
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
125 -- stt : {n m : Level} {a : Set n} {t : Set m} → {!!}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
126 -- stt {n} {m} {a} {t} = pushSingleLinkedStack [] (test-node ) (λ st → pushSingleLinkedStack st lleaf (λ st2 → st2) )
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
127
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
128
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
129
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
130 -- search の {{ l }} {{ u }} はその時みている node の 大小。 l が小さく u が大きい
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
131 -- ここでは d が現在の node のkey値なので比較後のsearch では値が変わる
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
132 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
133 bt-search {n} {m} {a} {t} key (bt-leaf x) cg = cg nothing
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
134 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
135 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
136 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
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 ⦃ d ⦄ ⦃ u' ⦄ key R cg
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
138
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
139 -- 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
140 -- 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
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 ⦃ d ⦄ ⦃ u' ⦄ key R cg
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
142
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
143
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
144 -- この辺の test を書くときは型を考えるのがやや面倒なので先に動作を書いてから型を ? から補間するとよさそう
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
145 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
146 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
147
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
148 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
149 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
150
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
151
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
152 -- 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
153 -- up-some (just (fst , snd)) = just fst
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
154 -- up-some nothing = nothing
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
155
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
156 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
157 search-lem {n} {m} {a} {t} key (bt-leaf x) = refl
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
158 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
159 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
160 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
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} ⦃ d ⦄ ⦃ lr' ⦄ key tree₂
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
162
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
163
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
164 -- bt-find
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
165 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
166
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
167 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
168 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
169 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
170
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
171 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
172 pushSingleLinkedStack st node
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
173 (λ st2 → find-support {n} {m} {a} {t} {{l'}} {{d}} key L st2 cg)
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
174
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
175 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
176 (λ st2 → find-support {n} {m} {a} {t} {{d}} {{lr'}} key R st2 cg)
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
177
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
178 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
179 bt-find {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ key tr st cg = clearSingleLinkedStack st
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
180 (λ cst → find-support ⦃ l ⦄ ⦃ u ⦄ key tr cst cg)
586
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
181
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
182 find-test : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → List bt -- ?
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
183 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
184 {-- result
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
185 λ {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ →
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
186 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
187 --}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
188
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
189 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
190 find-lem d (bt-leaf x) st = refl
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
191 find-lem d (bt-node d₁ tree tree₁ x x₁) st with <-cmp d d₁
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
192 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
193
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
194
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
195 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
196 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
197 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
198 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
199
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 = {!!}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
201
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
202 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
203 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
204
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
205
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
206 singleton-test : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → bt -- ?
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
207 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
208
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
209
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
210 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
211 replace-helper {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ tree [] cg = cg tree
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
212 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
213 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
214 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
215 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
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₁ x₃ subt x₄ x₅) st cg
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
217 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
218
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
219
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
220
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
221 bt-replace : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
222 → (d : ℕ) → (bt {n} {a} ) → SingleLinkedStack (bt {n} {a} )
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
223 → Maybe (Σ ℕ (λ d' → _iso_ {n} {a} d d')) → ( (bt {n} {a} ) → t ) → t
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
224 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
225
0ddfa505d612 isolate search function problem, and add hoareBinaryTree.agda.
ryokka
parents:
diff changeset
226
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 -- 証明に insert がはいっててほしい
587
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
229 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
230 → ((bt {n} {a}) → t) → t
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
231
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
232 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
233
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
234 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
235 pickKey (bt-leaf x) = nothing
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
236 pickKey (bt-node d tree tree₁ x x₁) = just d
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
237
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
238 insert-test : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → bt -- ?
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
239 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
240
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
241 insert-test-l : {n m : Level} {a : Set n} {t : Set m} ⦃ l u : ℕ ⦄ → bt -- ?
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
242 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
243
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
244
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
245 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
246 → bt-insert {n} {_} {a} ⦃ l ⦄ ⦃ u ⦄ d tree (λ tree1 → bt-find ⦃ l ⦄ ⦃ u ⦄ d tree1 []
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
247 (λ tt st ad → (pickKey {n} {m} {a} {t} ⦃ l ⦄ ⦃ u ⦄ tt) ≡ just d ) )
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
248
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
249
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
250 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
251 insert-lem d (bt-leaf x) | tri< a ¬b ¬c = ⊥-elim (¬b refl)
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
252 insert-lem d (bt-leaf x) | tri≈ ¬a b ¬c = refl
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-node d₁ tree tree₁ x x₁) with <-cmp d d₁
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
255 -- bt-insert d (bt-node d₁ tree tree₁ x x₁) (λ tree1 → {!!})
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
256 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
257 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
258 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
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
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
261 insert-lem d (bt-node d₁ tree tree₁ x x₁) | tri< a ¬b ¬c = {!!}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
262 where
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
263 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
264 lem-helper = {!!}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
265
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
266 insert-lem d (bt-node d₁ tree tree₁ x x₁) | tri> ¬a ¬b c = {!!}
f103f07c0552 add insert code
ryokka
parents: 586
diff changeset
267