(* Demonstration of data abstraction via subsume_funspec. *)
(* Definitions of [combine] and [Abs] taken from Verified Functional Algorithms (Software Foundations Volume 3), chapter SearchTree *)
Section TREE_ABS.
Definition total_map (A:Type) := key -> A.
Definition t_empty {A:Type} (v : A) : total_map A :=
(fun _ => v).
Definition t_update {A:Type} (m : total_map A)
(x : key) (v : A) :=
fun x' => if x =? x' then v else m x'.
Definition combine {A} (pivot: key) (m1 m2: total_map A) : total_map A :=
fun x : key => if zlt x pivot  then m1 x else m2 x.
Inductive Abs:  tree val -> total_map val -> Prop :=
| Abs_E: Abs E (t_empty nullval)
| Abs_T: forall a b l k v r,
Abs l a ->
Abs r b ->
Abs (T l k v r)  (t_update (combine k a b) k v).

(* Specifications: *)
Theorem insert_relate:
forall k v t cts,
Abs t cts ->
Abs (insert k v t) (t_update cts k v).