Theory Tree234_Set
section ‹2-3-4 Tree Implementation of Sets›
theory Tree234_Set
imports
Tree234
Cmp
Set_Specs
begin
declare sorted_wrt.simps(2)[simp del]
subsection ‹Set operations on 2-3-4 trees›
definition empty :: "'a tree234" where
"empty = Leaf"
fun isin :: "'a::linorder tree234 ⇒ 'a ⇒ bool" where
"isin Leaf x = False" |
"isin (Node2 l a r) x =
(case cmp x a of LT ⇒ isin l x | EQ ⇒ True | GT ⇒ isin r x)" |
"isin (Node3 l a m b r) x =
(case cmp x a of LT ⇒ isin l x | EQ ⇒ True | GT ⇒ (case cmp x b of
LT ⇒ isin m x | EQ ⇒ True | GT ⇒ isin r x))" |
"isin (Node4 t1 a t2 b t3 c t4) x =
(case cmp x b of
LT ⇒
(case cmp x a of
LT ⇒ isin t1 x |
EQ ⇒ True |
GT ⇒ isin t2 x) |
EQ ⇒ True |
GT ⇒
(case cmp x c of
LT ⇒ isin t3 x |
EQ ⇒ True |
GT ⇒ isin t4 x))"