Definition partition'  (f: key -> bool) (s: tree) : (tree*tree) :=
  match partition_aux f s (1%positive, nil) (1%positive,  nil)
   with ((n1,l1),(n2,l2)) => (fst (treeify_g n1 l1), fst (treeify_g n2 l2))
  end.

(* Specifications: *)
Lemma partition_valid1: forall f s, valid s -> valid (fst (partition' f s)).
Lemma partition_valid2: forall f s, valid s -> valid (snd (partition' f s)).
Lemma fold'_app: forall s d ar, fold' (list key) (@cons key) s (app d ar) = app (fold' (list key) (@cons key) s d) ar.
Lemma fold'_spec: forall s (A : Type) (i : A) (f : key -> A -> A), fold' _ f s i = List.fold_left (fun a e => f e a) (List.rev (fold' _ (@cons _) s nil)) i.
Lemma mem_add_valid: forall x s, valid s -> forall s', Some s' = mem_add' x s -> valid s'.
Lemma InA_rev_fold'_range: forall k s lo hi, searchtree lo hi s -> SetoidList.InA E.eq k (List.rev (fold' (list key) (@cons _) s nil)) -> (ltopt lo (Some k) /\ ltopt (Some k) hi).
Lemma tree_similar_lemma': forall c c' k k' s s' lo hi lo' hi', searchtree lo hi (T c EE k s) -> searchtree lo' hi' (T c' EE k' s') -> (forall x : key, interp (T c EE k s) x <-> interp (T c' EE k' s') x) -> K.eq k k' /\ (forall x, interp s x -> interp s' x).
Lemma tree_similar_lemma: forall c c' k k' s s' lo hi lo' hi', searchtree lo hi (T c EE k s) -> searchtree lo' hi' (T c' EE k' s') -> (forall x : key, interp (T c EE k s) x <-> interp (T c' EE k' s') x) -> K.eq k k' /\ (forall x, interp s x <-> interp s' x).