Definition union' (s1 s2: tree) : tree :=
   match compare_height s1 s1 s2 s2 with
      | Lt => fold' _ insert s1 s2
      | Gt => fold' _ insert s2 s1
      | Eq => linear_union s1 s2
    end.

(* Specifications: *)
Lemma fold'_searchtree: forall (f: key -> tree -> tree) (Hf: forall k s, searchtree None None s -> searchtree None None (f k s)) s1 s2, searchtree None None s1 -> searchtree None None s2 -> searchtree None None (fold' _ f s1 s2).
Lemma fold'_valid: forall (f: key -> tree -> tree) (f_valid: forall k s, valid s -> valid (f k s)) s1 s2, valid s1 -> valid s2 -> valid (fold' _ f s1 s2).
Lemma union_valid: forall s1 s2, valid s1 -> valid s2 -> valid (union' s1 s2).