Ltac replace_in_pre S S' :=
 match goal with |- @semax _ _ _ ?P _ _ =>
  match P with context C[S] =>
     let P' := context C[S'] in
      apply semax_pre with P'; [ | ]
  end
 end.

Lemma extract_exists_post: forall {Espec: OracleKind} {cs: compspecs} {A: Type} (x: A) Delta (P: environ -> mpred) c (R: A -> environ -> mpred), semax Delta P c (normal_ret_assert (R x)) -> semax Delta P c (normal_ret_assert (exp R)).