Definition opt_t_aux (x: option (elt * tree))
    (P: match x with Some (_,s) => valid s | None => True end) : option (elt * t) :=
match
  x as o
  return
    (match o with
     | Some (_, s) => valid s
     | None => True
     end -> option (elt * t))
with
| Some (k,s') => fun P0 : valid s' => Some (k, exist valid s' P0)
| None => fun _ : True => None
end P.Definition delete_min (s: t) : option (elt * t) :=
  opt_t_aux (delete'_min (proj1_sig s)) (delete_min_valid _ (proj2_sig s)).

(* Specifications: *)
Lemma delete_min_spec1: forall (s: t) k s', delete_min s = Some (k,s') <-> (min_elt s = Some k /\ remove k s = s').
Lemma delete_min_spec2: forall s, delete_min s = None <-> Empty s.