Local Open Scope pred.
(* This file contains two parts: 1. Proof of semax_conseq. 2. Deriving simpler and older version of consequence rules from semax_conseq. *)
(* Part 1: Proof of semax_conseq *)
Definition bupd_ret_assert (Q: ret_assert): ret_assert :=
{| RA_normal := fun rho => bupd (RA_normal Q rho);
RA_break := fun rho => bupd (RA_break Q rho);
RA_continue := fun rho => bupd (RA_continue Q rho);
RA_return := fun v rho => bupd (RA_return Q v rho) |}.
(* The following four lemmas is not now used. but after deep embedded hoare logic (SL_as_Logic) is ported, the frame does not need to be quantified in the semantic definition of semax. Then, these two lemmas can replace the other two afterwards. *)
Definition except_0_ret_assert (Q: ret_assert): ret_assert :=
{| RA_normal := fun rho => (|> FF || RA_normal Q rho);
RA_break := fun rho => (|> FF || RA_break Q rho);
RA_continue := fun rho => (|> FF || RA_continue Q rho);
RA_return := fun v rho => (|> FF || RA_return Q v rho) |}.
(* Lemma rguard_except_0: forall {Espec: OracleKind} ge Delta f (F: environ -> pred rmap) Q k, rguard Espec ge Delta f (frame_ret_assert Q F) k = rguard Espec ge Delta f (frame_ret_assert (except_0_ret_assert Q) F) k. *)

Lemma rguard_tc_environ: forall {Espec: OracleKind} ge Delta' Delta f (F: environ -> pred rmap) P k,
tycontext_sub Delta Delta' ->
rguard Espec ge Delta' f (frame_ret_assert P F) k = rguard Espec ge Delta'  f (frame_ret_assert (conj_ret_assert P (fun rho => !! typecheck_environ Delta rho)) F) k.