Theory IntervalTree_Impl
section ‹Implementation of interval tree›
theory IntervalTree_Impl
  imports SepAuto "../Functional/Interval_Tree"
begin
text ‹Imperative version of interval tree.›
subsection ‹Interval and IdxInterval›
fun interval_encode :: "('a::heap) interval ⇒ nat" where
  "interval_encode (Interval l h) = to_nat (l, h)"
instance interval :: (heap) heap
  apply (rule heap_class.intro)
  apply (rule countable_classI [of "interval_encode"])
  apply (case_tac x, simp_all, case_tac y, simp_all)
  ..
fun idx_interval_encode :: "('a::heap) idx_interval ⇒ nat" where
  "idx_interval_encode (IdxInterval it i) = to_nat (it, i)"
instance idx_interval :: (heap) heap
  apply (rule heap_class.intro)
  apply (rule countable_classI [of "idx_interval_encode"])
  apply (case_tac x, simp_all, case_tac y, simp_all)
  ..
subsection ‹Tree nodes›