annotate prepaper/src/redBlackTreeTest.agda.replaced @ 14:a63df15c9afc default tip

DONE
author soto <soto@cr.ie.u-ryukyu.ac.jp>
date Mon, 15 Feb 2021 23:36:39 +0900
parents 3dba680da508
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3dba680da508 init-test
soto
parents:
diff changeset
1 module redBlackTreeTest where
3dba680da508 init-test
soto
parents:
diff changeset
2
3dba680da508 init-test
soto
parents:
diff changeset
3 open import RedBlackTree
3dba680da508 init-test
soto
parents:
diff changeset
4 open import stack
3dba680da508 init-test
soto
parents:
diff changeset
5 open import Level hiding (zero)
3dba680da508 init-test
soto
parents:
diff changeset
6
3dba680da508 init-test
soto
parents:
diff changeset
7 open import Data.Nat
3dba680da508 init-test
soto
parents:
diff changeset
8
3dba680da508 init-test
soto
parents:
diff changeset
9 open Tree
3dba680da508 init-test
soto
parents:
diff changeset
10 open Node
3dba680da508 init-test
soto
parents:
diff changeset
11 open RedBlackTree.RedBlackTree
3dba680da508 init-test
soto
parents:
diff changeset
12 open Stack
3dba680da508 init-test
soto
parents:
diff changeset
13
3dba680da508 init-test
soto
parents:
diff changeset
14 -- tests
3dba680da508 init-test
soto
parents:
diff changeset
15
3dba680da508 init-test
soto
parents:
diff changeset
16 putTree1 : {n m : Level } {a k : Set n} {t : Set m} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ k @$\rightarrow$@ a @$\rightarrow$@ (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ t) @$\rightarrow$@ t
3dba680da508 init-test
soto
parents:
diff changeset
17 putTree1 {n} {m} {a} {k} {t} tree k1 value next with (root tree)
3dba680da508 init-test
soto
parents:
diff changeset
18 ... | Nothing = next (record tree {root = Just (leafNode k1 value) })
3dba680da508 init-test
soto
parents:
diff changeset
19 ... | Just n2 = clearSingleLinkedStack (nodeStack tree) (\ s @$\rightarrow$@ findNode tree s (leafNode k1 value) n2 (\ tree1 s n1 @$\rightarrow$@ replaceNode tree1 s n1 next))
3dba680da508 init-test
soto
parents:
diff changeset
20
3dba680da508 init-test
soto
parents:
diff changeset
21 open import Relation.Binary.PropositionalEquality
3dba680da508 init-test
soto
parents:
diff changeset
22 open import Relation.Binary.Core
3dba680da508 init-test
soto
parents:
diff changeset
23 open import Function
3dba680da508 init-test
soto
parents:
diff changeset
24
3dba680da508 init-test
soto
parents:
diff changeset
25
3dba680da508 init-test
soto
parents:
diff changeset
26 check1 : {m : Level } (n : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)) @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ Bool {m}
3dba680da508 init-test
soto
parents:
diff changeset
27 check1 Nothing _ = False
3dba680da508 init-test
soto
parents:
diff changeset
28 check1 (Just n) x with Data.Nat.compare (value n) x
3dba680da508 init-test
soto
parents:
diff changeset
29 ... | equal _ = True
3dba680da508 init-test
soto
parents:
diff changeset
30 ... | _ = False
3dba680da508 init-test
soto
parents:
diff changeset
31
3dba680da508 init-test
soto
parents:
diff changeset
32 check2 : {m : Level } (n : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)) @$\rightarrow$@ @$\mathbb{N}$@ @$\rightarrow$@ Bool {m}
3dba680da508 init-test
soto
parents:
diff changeset
33 check2 Nothing _ = False
3dba680da508 init-test
soto
parents:
diff changeset
34 check2 (Just n) x with compare2 (value n) x
3dba680da508 init-test
soto
parents:
diff changeset
35 ... | EQ = True
3dba680da508 init-test
soto
parents:
diff changeset
36 ... | _ = False
3dba680da508 init-test
soto
parents:
diff changeset
37
3dba680da508 init-test
soto
parents:
diff changeset
38 test1 : putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ {Set Level.zero} ) 1 1 ( \t @$\rightarrow$@ getRedBlackTree t 1 ( \t x @$\rightarrow$@ check2 x 1 @$\equiv$@ True ))
3dba680da508 init-test
soto
parents:
diff changeset
39 test1 = refl
3dba680da508 init-test
soto
parents:
diff changeset
40
3dba680da508 init-test
soto
parents:
diff changeset
41 test2 : putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ {Set Level.zero} ) 1 1 (
3dba680da508 init-test
soto
parents:
diff changeset
42 \t @$\rightarrow$@ putTree1 t 2 2 (
3dba680da508 init-test
soto
parents:
diff changeset
43 \t @$\rightarrow$@ getRedBlackTree t 1 (
3dba680da508 init-test
soto
parents:
diff changeset
44 \t x @$\rightarrow$@ check2 x 1 @$\equiv$@ True )))
3dba680da508 init-test
soto
parents:
diff changeset
45 test2 = refl
3dba680da508 init-test
soto
parents:
diff changeset
46
3dba680da508 init-test
soto
parents:
diff changeset
47 open @$\equiv$@-Reasoning
3dba680da508 init-test
soto
parents:
diff changeset
48 test3 : putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ {Set Level.zero}) 1 1
3dba680da508 init-test
soto
parents:
diff changeset
49 $ \t @$\rightarrow$@ putTree1 t 2 2
3dba680da508 init-test
soto
parents:
diff changeset
50 $ \t @$\rightarrow$@ putTree1 t 3 3
3dba680da508 init-test
soto
parents:
diff changeset
51 $ \t @$\rightarrow$@ putTree1 t 4 4
3dba680da508 init-test
soto
parents:
diff changeset
52 $ \t @$\rightarrow$@ getRedBlackTree t 1
3dba680da508 init-test
soto
parents:
diff changeset
53 $ \t x @$\rightarrow$@ check2 x 1 @$\equiv$@ True
3dba680da508 init-test
soto
parents:
diff changeset
54 test3 = begin
3dba680da508 init-test
soto
parents:
diff changeset
55 check2 (Just (record {key = 1 ; value = 1 ; color = Black ; left = Nothing ; right = Just (leafNode 2 2)})) 1
3dba680da508 init-test
soto
parents:
diff changeset
56 @$\equiv$@@$\langle$@ refl @$\rangle$@
3dba680da508 init-test
soto
parents:
diff changeset
57 True
3dba680da508 init-test
soto
parents:
diff changeset
58 @$\blacksquare$@
3dba680da508 init-test
soto
parents:
diff changeset
59
3dba680da508 init-test
soto
parents:
diff changeset
60 test31 = putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ ) 1 1
3dba680da508 init-test
soto
parents:
diff changeset
61 $ \t @$\rightarrow$@ putTree1 t 2 2
3dba680da508 init-test
soto
parents:
diff changeset
62 $ \t @$\rightarrow$@ putTree1 t 3 3
3dba680da508 init-test
soto
parents:
diff changeset
63 $ \t @$\rightarrow$@ putTree1 t 4 4
3dba680da508 init-test
soto
parents:
diff changeset
64 $ \t @$\rightarrow$@ getRedBlackTree t 4
3dba680da508 init-test
soto
parents:
diff changeset
65 $ \t x @$\rightarrow$@ x
3dba680da508 init-test
soto
parents:
diff changeset
66
3dba680da508 init-test
soto
parents:
diff changeset
67 -- test5 : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)
3dba680da508 init-test
soto
parents:
diff changeset
68 test5 = putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ ) 4 4
3dba680da508 init-test
soto
parents:
diff changeset
69 $ \t @$\rightarrow$@ putTree1 t 6 6
3dba680da508 init-test
soto
parents:
diff changeset
70 $ \t0 @$\rightarrow$@ clearSingleLinkedStack (nodeStack t0)
3dba680da508 init-test
soto
parents:
diff changeset
71 $ \s @$\rightarrow$@ findNode1 t0 s (leafNode 3 3) ( root t0 )
3dba680da508 init-test
soto
parents:
diff changeset
72 $ \t1 s n1 @$\rightarrow$@ replaceNode t1 s n1
3dba680da508 init-test
soto
parents:
diff changeset
73 $ \t @$\rightarrow$@ getRedBlackTree t 3
3dba680da508 init-test
soto
parents:
diff changeset
74 -- $ \t x @$\rightarrow$@ SingleLinkedStack.top (stack s)
3dba680da508 init-test
soto
parents:
diff changeset
75 -- $ \t x @$\rightarrow$@ n1
3dba680da508 init-test
soto
parents:
diff changeset
76 $ \t x @$\rightarrow$@ root t
3dba680da508 init-test
soto
parents:
diff changeset
77 where
3dba680da508 init-test
soto
parents:
diff changeset
78 findNode1 : {n m : Level } {a k : Set n} {t : Set m} @$\rightarrow$@ RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ (Node a k) @$\rightarrow$@ (Maybe (Node a k)) @$\rightarrow$@ (RedBlackTree {n} {m} {t} a k @$\rightarrow$@ SingleLinkedStack (Node a k) @$\rightarrow$@ Node a k @$\rightarrow$@ t) @$\rightarrow$@ t
3dba680da508 init-test
soto
parents:
diff changeset
79 findNode1 t s n1 Nothing next = next t s n1
3dba680da508 init-test
soto
parents:
diff changeset
80 findNode1 t s n1 ( Just n2 ) next = findNode t s n1 n2 next
3dba680da508 init-test
soto
parents:
diff changeset
81
3dba680da508 init-test
soto
parents:
diff changeset
82 -- test51 : putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} {_} {Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ {Set Level.zero} ) 1 1 $ \t @$\rightarrow$@
3dba680da508 init-test
soto
parents:
diff changeset
83 -- putTree1 t 2 2 $ \t @$\rightarrow$@ putTree1 t 3 3 $ \t @$\rightarrow$@ root t @$\equiv$@ Just (record { key = 1; value = 1; left = Just (record { key = 2 ; value = 2 } ); right = Nothing} )
3dba680da508 init-test
soto
parents:
diff changeset
84 -- test51 = refl
3dba680da508 init-test
soto
parents:
diff changeset
85
3dba680da508 init-test
soto
parents:
diff changeset
86 test6 : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)
3dba680da508 init-test
soto
parents:
diff changeset
87 test6 = root (createEmptyRedBlackTree@$\mathbb{N}$@ {_} @$\mathbb{N}$@ {Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)})
3dba680da508 init-test
soto
parents:
diff changeset
88
3dba680da508 init-test
soto
parents:
diff changeset
89
3dba680da508 init-test
soto
parents:
diff changeset
90 test7 : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)
3dba680da508 init-test
soto
parents:
diff changeset
91 test7 = clearSingleLinkedStack (nodeStack tree2) (\ s @$\rightarrow$@ replaceNode tree2 s n2 (\ t @$\rightarrow$@ root t))
3dba680da508 init-test
soto
parents:
diff changeset
92 where
3dba680da508 init-test
soto
parents:
diff changeset
93 tree2 = createEmptyRedBlackTree@$\mathbb{N}$@ {_} @$\mathbb{N}$@ {Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)}
3dba680da508 init-test
soto
parents:
diff changeset
94 k1 = 1
3dba680da508 init-test
soto
parents:
diff changeset
95 n2 = leafNode 0 0
3dba680da508 init-test
soto
parents:
diff changeset
96 value1 = 1
3dba680da508 init-test
soto
parents:
diff changeset
97
3dba680da508 init-test
soto
parents:
diff changeset
98 test8 : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@)
3dba680da508 init-test
soto
parents:
diff changeset
99 test8 = putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@) 1 1
3dba680da508 init-test
soto
parents:
diff changeset
100 $ \t @$\rightarrow$@ putTree1 t 2 2 (\ t @$\rightarrow$@ root t)
3dba680da508 init-test
soto
parents:
diff changeset
101
3dba680da508 init-test
soto
parents:
diff changeset
102
3dba680da508 init-test
soto
parents:
diff changeset
103 test9 : putRedBlackTree {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ {Set Level.zero} ) 1 1 ( \t @$\rightarrow$@ getRedBlackTree t 1 ( \t x @$\rightarrow$@ check2 x 1 @$\equiv$@ True ))
3dba680da508 init-test
soto
parents:
diff changeset
104 test9 = refl
3dba680da508 init-test
soto
parents:
diff changeset
105
3dba680da508 init-test
soto
parents:
diff changeset
106 test10 : putRedBlackTree {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@ {Set Level.zero} ) 1 1 (
3dba680da508 init-test
soto
parents:
diff changeset
107 \t @$\rightarrow$@ putRedBlackTree t 2 2 (
3dba680da508 init-test
soto
parents:
diff changeset
108 \t @$\rightarrow$@ getRedBlackTree t 1 (
3dba680da508 init-test
soto
parents:
diff changeset
109 \t x @$\rightarrow$@ check2 x 1 @$\equiv$@ True )))
3dba680da508 init-test
soto
parents:
diff changeset
110 test10 = refl
3dba680da508 init-test
soto
parents:
diff changeset
111
3dba680da508 init-test
soto
parents:
diff changeset
112 test11 = putRedBlackTree {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (createEmptyRedBlackTree@$\mathbb{N}$@ @$\mathbb{N}$@) 1 1
3dba680da508 init-test
soto
parents:
diff changeset
113 $ \t @$\rightarrow$@ putRedBlackTree t 2 2
3dba680da508 init-test
soto
parents:
diff changeset
114 $ \t @$\rightarrow$@ putRedBlackTree t 3 3
3dba680da508 init-test
soto
parents:
diff changeset
115 $ \t @$\rightarrow$@ getRedBlackTree t 2
3dba680da508 init-test
soto
parents:
diff changeset
116 $ \t x @$\rightarrow$@ root t
3dba680da508 init-test
soto
parents:
diff changeset
117
3dba680da508 init-test
soto
parents:
diff changeset
118
3dba680da508 init-test
soto
parents:
diff changeset
119 redBlackInSomeState : { m : Level } (a : Set Level.zero) (n : Maybe (Node a @$\mathbb{N}$@)) {t : Set m} @$\rightarrow$@ RedBlackTree {Level.zero} {m} {t} a @$\mathbb{N}$@
3dba680da508 init-test
soto
parents:
diff changeset
120 redBlackInSomeState {m} a n {t} = record { root = n ; nodeStack = emptySingleLinkedStack ; compare = compare2 }
3dba680da508 init-test
soto
parents:
diff changeset
121
3dba680da508 init-test
soto
parents:
diff changeset
122 -- compare2 : (x y : @$\mathbb{N}$@ ) @$\rightarrow$@ compareresult
3dba680da508 init-test
soto
parents:
diff changeset
123 -- compare2 zero zero = eq
3dba680da508 init-test
soto
parents:
diff changeset
124 -- compare2 (suc _) zero = gt
3dba680da508 init-test
soto
parents:
diff changeset
125 -- compare2 zero (suc _) = lt
3dba680da508 init-test
soto
parents:
diff changeset
126 -- compare2 (suc x) (suc y) = compare2 x y
3dba680da508 init-test
soto
parents:
diff changeset
127
3dba680da508 init-test
soto
parents:
diff changeset
128 putTest1Lemma2 : (k : @$\mathbb{N}$@) @$\rightarrow$@ compare2 k k @$\equiv$@ EQ
3dba680da508 init-test
soto
parents:
diff changeset
129 putTest1Lemma2 zero = refl
3dba680da508 init-test
soto
parents:
diff changeset
130 putTest1Lemma2 (suc k) = putTest1Lemma2 k
3dba680da508 init-test
soto
parents:
diff changeset
131
3dba680da508 init-test
soto
parents:
diff changeset
132 putTest1Lemma1 : (x y : @$\mathbb{N}$@) @$\rightarrow$@ compare@$\mathbb{N}$@ x y @$\equiv$@ compare2 x y
3dba680da508 init-test
soto
parents:
diff changeset
133 putTest1Lemma1 zero zero = refl
3dba680da508 init-test
soto
parents:
diff changeset
134 putTest1Lemma1 (suc m) zero = refl
3dba680da508 init-test
soto
parents:
diff changeset
135 putTest1Lemma1 zero (suc n) = refl
3dba680da508 init-test
soto
parents:
diff changeset
136 putTest1Lemma1 (suc m) (suc n) with Data.Nat.compare m n
3dba680da508 init-test
soto
parents:
diff changeset
137 putTest1Lemma1 (suc .m) (suc .(Data.Nat.suc m + k)) | less m k = lemma1 m
3dba680da508 init-test
soto
parents:
diff changeset
138 where
3dba680da508 init-test
soto
parents:
diff changeset
139 lemma1 : (m : @$\mathbb{N}$@) @$\rightarrow$@ LT @$\equiv$@ compare2 m (@$\mathbb{N}$@.suc (m + k))
3dba680da508 init-test
soto
parents:
diff changeset
140 lemma1 zero = refl
3dba680da508 init-test
soto
parents:
diff changeset
141 lemma1 (suc y) = lemma1 y
3dba680da508 init-test
soto
parents:
diff changeset
142 putTest1Lemma1 (suc .m) (suc .m) | equal m = lemma1 m
3dba680da508 init-test
soto
parents:
diff changeset
143 where
3dba680da508 init-test
soto
parents:
diff changeset
144 lemma1 : (m : @$\mathbb{N}$@) @$\rightarrow$@ EQ @$\equiv$@ compare2 m m
3dba680da508 init-test
soto
parents:
diff changeset
145 lemma1 zero = refl
3dba680da508 init-test
soto
parents:
diff changeset
146 lemma1 (suc y) = lemma1 y
3dba680da508 init-test
soto
parents:
diff changeset
147 putTest1Lemma1 (suc .(Data.Nat.suc m + k)) (suc .m) | greater m k = lemma1 m
3dba680da508 init-test
soto
parents:
diff changeset
148 where
3dba680da508 init-test
soto
parents:
diff changeset
149 lemma1 : (m : @$\mathbb{N}$@) @$\rightarrow$@ GT @$\equiv$@ compare2 (@$\mathbb{N}$@.suc (m + k)) m
3dba680da508 init-test
soto
parents:
diff changeset
150 lemma1 zero = refl
3dba680da508 init-test
soto
parents:
diff changeset
151 lemma1 (suc y) = lemma1 y
3dba680da508 init-test
soto
parents:
diff changeset
152
3dba680da508 init-test
soto
parents:
diff changeset
153 putTest1Lemma3 : (k : @$\mathbb{N}$@) @$\rightarrow$@ compare@$\mathbb{N}$@ k k @$\equiv$@ EQ
3dba680da508 init-test
soto
parents:
diff changeset
154 putTest1Lemma3 k = trans (putTest1Lemma1 k k) ( putTest1Lemma2 k )
3dba680da508 init-test
soto
parents:
diff changeset
155
3dba680da508 init-test
soto
parents:
diff changeset
156 compareLemma1 : {x y : @$\mathbb{N}$@} @$\rightarrow$@ compare2 x y @$\equiv$@ EQ @$\rightarrow$@ x @$\equiv$@ y
3dba680da508 init-test
soto
parents:
diff changeset
157 compareLemma1 {zero} {zero} refl = refl
3dba680da508 init-test
soto
parents:
diff changeset
158 compareLemma1 {zero} {suc _} ()
3dba680da508 init-test
soto
parents:
diff changeset
159 compareLemma1 {suc _} {zero} ()
3dba680da508 init-test
soto
parents:
diff changeset
160 compareLemma1 {suc x} {suc y} eq = cong ( \z @$\rightarrow$@ @$\mathbb{N}$@.suc z ) ( compareLemma1 ( trans lemma2 eq ) )
3dba680da508 init-test
soto
parents:
diff changeset
161 where
3dba680da508 init-test
soto
parents:
diff changeset
162 lemma2 : compare2 (@$\mathbb{N}$@.suc x) (@$\mathbb{N}$@.suc y) @$\equiv$@ compare2 x y
3dba680da508 init-test
soto
parents:
diff changeset
163 lemma2 = refl
3dba680da508 init-test
soto
parents:
diff changeset
164
3dba680da508 init-test
soto
parents:
diff changeset
165
3dba680da508 init-test
soto
parents:
diff changeset
166 putTest1 :{ m : Level } (n : Maybe (Node @$\mathbb{N}$@ @$\mathbb{N}$@))
3dba680da508 init-test
soto
parents:
diff changeset
167 @$\rightarrow$@ (k : @$\mathbb{N}$@) (x : @$\mathbb{N}$@)
3dba680da508 init-test
soto
parents:
diff changeset
168 @$\rightarrow$@ putTree1 {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} (redBlackInSomeState {_} @$\mathbb{N}$@ n {Set Level.zero}) k x
3dba680da508 init-test
soto
parents:
diff changeset
169 (\ t @$\rightarrow$@ getRedBlackTree t k (\ t x1 @$\rightarrow$@ check2 x1 x @$\equiv$@ True))
3dba680da508 init-test
soto
parents:
diff changeset
170 putTest1 n k x with n
3dba680da508 init-test
soto
parents:
diff changeset
171 ... | Just n1 = lemma2 ( record { top = Nothing } )
3dba680da508 init-test
soto
parents:
diff changeset
172 where
3dba680da508 init-test
soto
parents:
diff changeset
173 lemma2 : (s : SingleLinkedStack (Node @$\mathbb{N}$@ @$\mathbb{N}$@) ) @$\rightarrow$@ putTree1 (record { root = Just n1 ; nodeStack = s ; compare = compare2 }) k x (@$\lambda$@ t @$\rightarrow$@
3dba680da508 init-test
soto
parents:
diff changeset
174 GetRedBlackTree.checkNode t k (@$\lambda$@ t@$\_{1}$@ x1 @$\rightarrow$@ check2 x1 x @$\equiv$@ True) (root t))
3dba680da508 init-test
soto
parents:
diff changeset
175 lemma2 s with compare2 k (key n1)
3dba680da508 init-test
soto
parents:
diff changeset
176 ... | EQ = lemma3 {!!}
3dba680da508 init-test
soto
parents:
diff changeset
177 where
3dba680da508 init-test
soto
parents:
diff changeset
178 lemma3 : compare2 k (key n1) @$\equiv$@ EQ @$\rightarrow$@ getRedBlackTree {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} {Set Level.zero} ( record { root = Just ( record {
3dba680da508 init-test
soto
parents:
diff changeset
179 key = key n1 ; value = x ; right = right n1 ; left = left n1 ; color = Black
3dba680da508 init-test
soto
parents:
diff changeset
180 } ) ; nodeStack = s ; compare = @$\lambda$@ x@$\_{1}$@ y @$\rightarrow$@ compare2 x@$\_{1}$@ y } ) k ( \ t x1 @$\rightarrow$@ check2 x1 x @$\equiv$@ True)
3dba680da508 init-test
soto
parents:
diff changeset
181 lemma3 eq with compare2 x x | putTest1Lemma2 x
3dba680da508 init-test
soto
parents:
diff changeset
182 ... | EQ | refl with compare2 k (key n1) | eq
3dba680da508 init-test
soto
parents:
diff changeset
183 ... | EQ | refl with compare2 x x | putTest1Lemma2 x
3dba680da508 init-test
soto
parents:
diff changeset
184 ... | EQ | refl = refl
3dba680da508 init-test
soto
parents:
diff changeset
185 ... | GT = {!!}
3dba680da508 init-test
soto
parents:
diff changeset
186 ... | LT = {!!}
3dba680da508 init-test
soto
parents:
diff changeset
187
3dba680da508 init-test
soto
parents:
diff changeset
188 ... | Nothing = lemma1
3dba680da508 init-test
soto
parents:
diff changeset
189 where
3dba680da508 init-test
soto
parents:
diff changeset
190 lemma1 : getRedBlackTree {_} {_} {@$\mathbb{N}$@} {@$\mathbb{N}$@} {Set Level.zero} ( record { root = Just ( record {
3dba680da508 init-test
soto
parents:
diff changeset
191 key = k ; value = x ; right = Nothing ; left = Nothing ; color = Red
3dba680da508 init-test
soto
parents:
diff changeset
192 } ) ; nodeStack = record { top = Nothing } ; compare = @$\lambda$@ x@$\_{1}$@ y @$\rightarrow$@ compare2 x@$\_{1}$@ y } ) k
3dba680da508 init-test
soto
parents:
diff changeset
193 ( \ t x1 @$\rightarrow$@ check2 x1 x @$\equiv$@ True)
3dba680da508 init-test
soto
parents:
diff changeset
194 lemma1 with compare2 k k | putTest1Lemma2 k
3dba680da508 init-test
soto
parents:
diff changeset
195 ... | EQ | refl with compare2 x x | putTest1Lemma2 x
3dba680da508 init-test
soto
parents:
diff changeset
196 ... | EQ | refl = refl