Theory Collections.RBTMapImpl
section ‹\isaheader{Map Implementation by Red-Black-Trees}›
theory RBTMapImpl
imports
"../spec/MapSpec"
"../../Lib/RBT_add"
"HOL-Library.RBT"
"../gen_algo/MapGA"
begin
text_raw ‹\label{thy:RBTMapImpl}›
hide_const (open) RBT.map RBT.fold RBT.foldi RBT.empty RBT.insert
type_synonym ('k,'v) rm = "('k,'v) RBT.rbt"
definition rm_basic_ops :: "('k::linorder,'v,('k,'v) rm) omap_basic_ops"
where [icf_rec_def]: "rm_basic_ops ≡ ⦇
bmap_op_α = RBT.lookup,
bmap_op_invar = λ_. True,
bmap_op_empty = (λ_::unit. RBT.empty),
bmap_op_lookup = (λk m. RBT.lookup m k),
bmap_op_update = RBT.insert,
bmap_op_update_dj = RBT.insert,
bmap_op_delete = RBT.delete,
bmap_op_list_it = (λr. RBT_add.rm_iterateoi (RBT.impl_of r)),
bmap_op_ordered_list_it = (λr. RBT_add.rm_iterateoi (RBT.impl_of r)),
bmap_op_rev_list_it = (λr. RBT_add.rm_reverse_iterateoi (RBT.impl_of r))
⦈"
setup Locale_Code.open_block
interpretation rm_basic: StdBasicOMap rm_basic_ops
apply unfold_locales
apply (simp_all add: rm_basic_ops_def map_upd_eq_restrict)
apply (rule map_iterator_linord_is_it)
apply dup_subgoals
unfolding RBT.lookup_def
apply simp_all
apply (rule rm_iterateoi_correct)
apply simp
apply (rule rm_reverse_iterateoi_correct)
apply simp
done
setup Locale_Code.close_block
definition [icf_rec_def]: "rm_ops ≡ rm_basic.dflt_oops⦇map_op_add := RBT.union⦈"
setup Locale_Code.open_block