author | kuncar |
Fri, 19 Oct 2012 17:54:16 +0200 | |
changeset 49939 | eb8b434158c8 |
parent 49927 | cde0a46b4224 |
child 51375 | d9e62d9c98de |
permissions | -rw-r--r-- |
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
1 |
(* Title: HOL/Library/RBT.thy |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
2 |
Author: Lukas Bulwahn and Ondrej Kuncar |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
3 |
*) |
35617 | 4 |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
5 |
header {* Abstract type of RBT trees *} |
35617 | 6 |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
7 |
theory RBT |
43124 | 8 |
imports Main RBT_Impl |
35617 | 9 |
begin |
10 |
||
11 |
subsection {* Type definition *} |
|
12 |
||
49834 | 13 |
typedef ('a, 'b) rbt = "{t :: ('a\<Colon>linorder, 'b) RBT_Impl.rbt. is_rbt t}" |
36147
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
14 |
morphisms impl_of RBT |
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
15 |
proof - |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
16 |
have "RBT_Impl.Empty \<in> ?rbt" by simp |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
17 |
then show ?thesis .. |
35617 | 18 |
qed |
19 |
||
39380
5a2662c1e44a
established emerging canonical names *_eqI and *_eq_iff
haftmann
parents:
39302
diff
changeset
|
20 |
lemma rbt_eq_iff: |
5a2662c1e44a
established emerging canonical names *_eqI and *_eq_iff
haftmann
parents:
39302
diff
changeset
|
21 |
"t1 = t2 \<longleftrightarrow> impl_of t1 = impl_of t2" |
5a2662c1e44a
established emerging canonical names *_eqI and *_eq_iff
haftmann
parents:
39302
diff
changeset
|
22 |
by (simp add: impl_of_inject) |
5a2662c1e44a
established emerging canonical names *_eqI and *_eq_iff
haftmann
parents:
39302
diff
changeset
|
23 |
|
5a2662c1e44a
established emerging canonical names *_eqI and *_eq_iff
haftmann
parents:
39302
diff
changeset
|
24 |
lemma rbt_eqI: |
5a2662c1e44a
established emerging canonical names *_eqI and *_eq_iff
haftmann
parents:
39302
diff
changeset
|
25 |
"impl_of t1 = impl_of t2 \<Longrightarrow> t1 = t2" |
5a2662c1e44a
established emerging canonical names *_eqI and *_eq_iff
haftmann
parents:
39302
diff
changeset
|
26 |
by (simp add: rbt_eq_iff) |
5a2662c1e44a
established emerging canonical names *_eqI and *_eq_iff
haftmann
parents:
39302
diff
changeset
|
27 |
|
36147
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
28 |
lemma is_rbt_impl_of [simp, intro]: |
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
29 |
"is_rbt (impl_of t)" |
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
30 |
using impl_of [of t] by simp |
35617 | 31 |
|
39380
5a2662c1e44a
established emerging canonical names *_eqI and *_eq_iff
haftmann
parents:
39302
diff
changeset
|
32 |
lemma RBT_impl_of [simp, code abstype]: |
36147
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
33 |
"RBT (impl_of t) = t" |
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
34 |
by (simp add: impl_of_inverse) |
35617 | 35 |
|
36 |
subsection {* Primitive operations *} |
|
37 |
||
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
38 |
setup_lifting type_definition_rbt |
35617 | 39 |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
40 |
lift_definition lookup :: "('a\<Colon>linorder, 'b) rbt \<Rightarrow> 'a \<rightharpoonup> 'b" is "rbt_lookup" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
41 |
by simp |
35617 | 42 |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
43 |
lift_definition empty :: "('a\<Colon>linorder, 'b) rbt" is RBT_Impl.Empty |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
44 |
by (simp add: empty_def) |
35617 | 45 |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
46 |
lift_definition insert :: "'a\<Colon>linorder \<Rightarrow> 'b \<Rightarrow> ('a, 'b) rbt \<Rightarrow> ('a, 'b) rbt" is "rbt_insert" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
47 |
by simp |
35617 | 48 |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
49 |
lift_definition delete :: "'a\<Colon>linorder \<Rightarrow> ('a, 'b) rbt \<Rightarrow> ('a, 'b) rbt" is "rbt_delete" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
50 |
by simp |
35617 | 51 |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
52 |
lift_definition entries :: "('a\<Colon>linorder, 'b) rbt \<Rightarrow> ('a \<times> 'b) list" is RBT_Impl.entries |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
53 |
by simp |
35617 | 54 |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
55 |
lift_definition keys :: "('a\<Colon>linorder, 'b) rbt \<Rightarrow> 'a list" is RBT_Impl.keys |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
56 |
by simp |
35617 | 57 |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
58 |
lift_definition bulkload :: "('a\<Colon>linorder \<times> 'b) list \<Rightarrow> ('a, 'b) rbt" is "rbt_bulkload" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
59 |
by simp |
35617 | 60 |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
61 |
lift_definition map_entry :: "'a \<Rightarrow> ('b \<Rightarrow> 'b) \<Rightarrow> ('a\<Colon>linorder, 'b) rbt \<Rightarrow> ('a, 'b) rbt" is rbt_map_entry |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
62 |
by simp |
35617 | 63 |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
64 |
lift_definition map :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> ('a\<Colon>linorder, 'b) rbt \<Rightarrow> ('a, 'b) rbt" is RBT_Impl.map |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
65 |
by simp |
35617 | 66 |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
67 |
lift_definition fold :: "('a \<Rightarrow> 'b \<Rightarrow> 'c \<Rightarrow> 'c) \<Rightarrow> ('a\<Colon>linorder, 'b) rbt \<Rightarrow> 'c \<Rightarrow> 'c" is RBT_Impl.fold |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
68 |
by simp |
35617 | 69 |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
70 |
lift_definition union :: "('a\<Colon>linorder, 'b) rbt \<Rightarrow> ('a, 'b) rbt \<Rightarrow> ('a, 'b) rbt" is "rbt_union" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
71 |
by (simp add: rbt_union_is_rbt) |
35617 | 72 |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
73 |
lift_definition foldi :: "('c \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'b \<Rightarrow> 'c \<Rightarrow> 'c) \<Rightarrow> ('a :: linorder, 'b) rbt \<Rightarrow> 'c \<Rightarrow> 'c" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
74 |
is RBT_Impl.foldi by simp |
35617 | 75 |
|
76 |
subsection {* Derived operations *} |
|
77 |
||
36147
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
78 |
definition is_empty :: "('a\<Colon>linorder, 'b) rbt \<Rightarrow> bool" where |
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
79 |
[code]: "is_empty t = (case impl_of t of RBT_Impl.Empty \<Rightarrow> True | _ \<Rightarrow> False)" |
35617 | 80 |
|
81 |
||
82 |
subsection {* Abstract lookup properties *} |
|
83 |
||
36147
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
84 |
lemma lookup_RBT: |
47450
2ada2be850cb
move RBT implementation into type class contexts
Andreas Lochbihler
parents:
46565
diff
changeset
|
85 |
"is_rbt t \<Longrightarrow> lookup (RBT t) = rbt_lookup t" |
36147
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
86 |
by (simp add: lookup_def RBT_inverse) |
35617 | 87 |
|
36147
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
88 |
lemma lookup_impl_of: |
47450
2ada2be850cb
move RBT implementation into type class contexts
Andreas Lochbihler
parents:
46565
diff
changeset
|
89 |
"rbt_lookup (impl_of t) = lookup t" |
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
90 |
by transfer (rule refl) |
35617 | 91 |
|
36147
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
92 |
lemma entries_impl_of: |
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
93 |
"RBT_Impl.entries (impl_of t) = entries t" |
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
94 |
by transfer (rule refl) |
35617 | 95 |
|
36147
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
96 |
lemma keys_impl_of: |
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
97 |
"RBT_Impl.keys (impl_of t) = keys t" |
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
98 |
by transfer (rule refl) |
36111 | 99 |
|
49927 | 100 |
lemma lookup_keys: |
101 |
"dom (lookup t) = set (keys t)" |
|
102 |
by transfer (simp add: rbt_lookup_keys) |
|
103 |
||
35617 | 104 |
lemma lookup_empty [simp]: |
105 |
"lookup empty = Map.empty" |
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
106 |
by (simp add: empty_def lookup_RBT fun_eq_iff) |
35617 | 107 |
|
36147
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
108 |
lemma lookup_insert [simp]: |
b43b22f63665
theory RBT with abstract type of red-black trees backed by implementation RBT_Impl
haftmann
parents:
36111
diff
changeset
|
109 |
"lookup (insert k v t) = (lookup t)(k \<mapsto> v)" |
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
110 |
by transfer (rule rbt_lookup_rbt_insert) |
35617 | 111 |
|
112 |
lemma lookup_delete [simp]: |
|
113 |
"lookup (delete k t) = (lookup t)(k := None)" |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
114 |
by transfer (simp add: rbt_lookup_rbt_delete restrict_complement_singleton_eq) |
35617 | 115 |
|
116 |
lemma map_of_entries [simp]: |
|
117 |
"map_of (entries t) = lookup t" |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
118 |
by transfer (simp add: map_of_entries) |
35617 | 119 |
|
36111 | 120 |
lemma entries_lookup: |
121 |
"entries t1 = entries t2 \<longleftrightarrow> lookup t1 = lookup t2" |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
122 |
by transfer (simp add: entries_rbt_lookup) |
36111 | 123 |
|
35617 | 124 |
lemma lookup_bulkload [simp]: |
125 |
"lookup (bulkload xs) = map_of xs" |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
126 |
by transfer (rule rbt_lookup_rbt_bulkload) |
35617 | 127 |
|
128 |
lemma lookup_map_entry [simp]: |
|
129 |
"lookup (map_entry k f t) = (lookup t)(k := Option.map f (lookup t k))" |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
130 |
by transfer (rule rbt_lookup_rbt_map_entry) |
35617 | 131 |
|
132 |
lemma lookup_map [simp]: |
|
133 |
"lookup (map f t) k = Option.map (f k) (lookup t k)" |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
134 |
by transfer (rule rbt_lookup_map) |
35617 | 135 |
|
136 |
lemma fold_fold: |
|
46133
d9fe85d3d2cd
incorporated canonical fold combinator on lists into body of List theory; refactored passages on List.fold(l/r)
haftmann
parents:
45928
diff
changeset
|
137 |
"fold f t = List.fold (prod_case f) (entries t)" |
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
138 |
by transfer (rule RBT_Impl.fold_def) |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
139 |
|
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
140 |
lemma impl_of_empty: |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
141 |
"impl_of empty = RBT_Impl.Empty" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
142 |
by transfer (rule refl) |
35617 | 143 |
|
36111 | 144 |
lemma is_empty_empty [simp]: |
145 |
"is_empty t \<longleftrightarrow> t = empty" |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
146 |
unfolding is_empty_def by transfer (simp split: rbt.split) |
36111 | 147 |
|
148 |
lemma RBT_lookup_empty [simp]: (*FIXME*) |
|
47450
2ada2be850cb
move RBT implementation into type class contexts
Andreas Lochbihler
parents:
46565
diff
changeset
|
149 |
"rbt_lookup t = Map.empty \<longleftrightarrow> t = RBT_Impl.Empty" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
150 |
by (cases t) (auto simp add: fun_eq_iff) |
36111 | 151 |
|
152 |
lemma lookup_empty_empty [simp]: |
|
153 |
"lookup t = Map.empty \<longleftrightarrow> t = empty" |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
154 |
by transfer (rule RBT_lookup_empty) |
36111 | 155 |
|
156 |
lemma sorted_keys [iff]: |
|
157 |
"sorted (keys t)" |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
158 |
by transfer (simp add: RBT_Impl.keys_def rbt_sorted_entries) |
36111 | 159 |
|
160 |
lemma distinct_keys [iff]: |
|
161 |
"distinct (keys t)" |
|
48622
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
162 |
by transfer (simp add: RBT_Impl.keys_def distinct_entries) |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
163 |
|
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
164 |
lemma finite_dom_lookup [simp, intro!]: "finite (dom (lookup t))" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
165 |
by transfer simp |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
166 |
|
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
167 |
lemma lookup_union: "lookup (union s t) = lookup s ++ lookup t" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
168 |
by transfer (simp add: rbt_lookup_rbt_union) |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
169 |
|
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
170 |
lemma lookup_in_tree: "(lookup t k = Some v) = ((k, v) \<in> set (entries t))" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
171 |
by transfer (simp add: rbt_lookup_in_tree) |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
172 |
|
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
173 |
lemma keys_entries: "(k \<in> set (keys t)) = (\<exists>v. (k, v) \<in> set (entries t))" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
174 |
by transfer (simp add: keys_entries) |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
175 |
|
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
176 |
lemma fold_def_alt: |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
177 |
"fold f t = List.fold (prod_case f) (entries t)" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
178 |
by transfer (auto simp: RBT_Impl.fold_def) |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
179 |
|
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
180 |
lemma distinct_entries: "distinct (List.map fst (entries t))" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
181 |
by transfer (simp add: distinct_entries) |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
182 |
|
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
183 |
lemma non_empty_keys: "t \<noteq> empty \<Longrightarrow> keys t \<noteq> []" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
184 |
by transfer (simp add: non_empty_rbt_keys) |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
185 |
|
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
186 |
lemma keys_def_alt: |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
187 |
"keys t = List.map fst (entries t)" |
caaa1a02c650
use lifting/transfer formalization of RBT from Lift_RBT
kuncar
parents:
47450
diff
changeset
|
188 |
by transfer (simp add: RBT_Impl.keys_def) |
36111 | 189 |
|
45928
874845660119
adding quickcheck generators in some HOL-Library theories
bulwahn
parents:
45694
diff
changeset
|
190 |
subsection {* Quickcheck generators *} |
874845660119
adding quickcheck generators in some HOL-Library theories
bulwahn
parents:
45694
diff
changeset
|
191 |
|
46565 | 192 |
quickcheck_generator rbt predicate: is_rbt constructors: empty, insert |
36111 | 193 |
|
35617 | 194 |
end |