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.