Module CConseqFacts :=
SeparationLogicFacts.GenCConseqFacts
(SeparationLogicAsLogicSoundness.MainTheorem.CSHL_PracticalLogic.CSHL_MinimumLogic.CSHL_Def)
(SeparationLogicAsLogicSoundness.MainTheorem.CSHL_PracticalLogic.CSHL_MinimumLogic).
Module Conseq :=
SeparationLogicFacts.GenConseq
(SeparationLogicAsLogicSoundness.MainTheorem.CSHL_PracticalLogic.CSHL_MinimumLogic.CSHL_Def)
(SeparationLogicAsLogicSoundness.MainTheorem.CSHL_PracticalLogic.CSHL_MinimumLogic).
Module ConseqFacts :=
SeparationLogicFacts.GenConseqFacts
(SeparationLogicAsLogicSoundness.MainTheorem.CSHL_PracticalLogic.CSHL_MinimumLogic.CSHL_Def)
(Conseq).

(* Specifications: *)
Lemma extract_exists_pre_later {CS: compspecs} {Espec: OracleKind}:
forall  (A : Type) (Q: assert) (P : A -> assert) c Delta (R: ret_assert),
(forall x, semax Delta (Q && |> P x) c R) ->
semax Delta (Q && |> exp P) c R.
Lemma semax_pre_post_bupd:
forall {CS: compspecs} {Espec: OracleKind} (Delta: tycontext),
forall P' (R': ret_assert) P c (R: ret_assert) ,
local (tc_environ Delta) && P |-- |==> P' ->
local (tc_environ Delta) && RA_normal R' |-- |==> RA_normal R ->
local (tc_environ Delta) && RA_break R' |-- |==> RA_break R ->
local (tc_environ Delta) && RA_continue R' |-- |==> RA_continue R ->
(forall vl, local (tc_environ Delta) && RA_return R' vl |-- |==> RA_return R vl) ->
@semax CS Espec Delta P' c R' -> @semax CS Espec Delta P c R.
Lemma semax_pre_post : forall {Espec: OracleKind}{CS: compspecs},
forall P' (R': ret_assert) Delta P c (R: ret_assert) ,
(local (tc_environ Delta) && P |-- P') ->
local (tc_environ Delta) && RA_normal R' |-- RA_normal R ->
local (tc_environ Delta) && RA_break R' |-- RA_break R ->
local (tc_environ Delta) && RA_continue R' |-- RA_continue R ->
(forall vl, local (tc_environ Delta) && RA_return R' vl |-- RA_return R vl) ->
@semax CS Espec Delta P' c R' -> @semax CS Espec Delta P c R.
Lemma semax_frame_PQR:
forall Q2 R2 Espec {cs: compspecs} Delta R1 P Q P' Q' R1' c,
closed_wrt_modvars c (LOCALx Q2 (SEPx R2)) ->
@semax cs Espec Delta (PROPx P (LOCALx Q (SEPx R1))) c
(normal_ret_assert (PROPx P' (LOCALx Q' (SEPx R1')))) ->
@semax cs Espec Delta (PROPx P (LOCALx (Q++Q2) (SEPx (R1++R2)))) c
(normal_ret_assert (PROPx P' (LOCALx (Q'++Q2) (SEPx (R1'++R2))))).
Lemma semax_frame1:
forall {Espec: OracleKind} {cs: compspecs} QFrame Frame Delta Delta1
P Q c R P1 Q1 R1 P2 Q2 R2,
semax Delta1 (PROPx P1 (LOCALx Q1 (SEPx R1))) c
(normal_ret_assert (PROPx P2 (LOCALx Q2 (SEPx R2)))) ->
Delta1 = Delta ->
ENTAIL Delta, PROPx P (LOCALx Q (SEPx R)) |--
PROPx P1 (LOCALx (Q1++QFrame) (SEPx (R1 ++ Frame))) ->
closed_wrt_modvars c (LOCALx QFrame (SEPx Frame)) ->
semax Delta (PROPx P (LOCALx Q (SEPx R))) c
(normal_ret_assert (PROPx P2 (LOCALx (Q2++QFrame) (SEPx (R2++Frame))))).
Lemma semax_post_bupd:
forall (R': ret_assert) Espec {cs: compspecs} Delta (R: ret_assert) P c,
ENTAIL Delta, RA_normal R' |-- |==> RA_normal R ->
ENTAIL Delta, RA_break R' |-- |==> RA_break R ->
ENTAIL Delta, RA_continue R' |-- |==> RA_continue R ->
(forall vl, ENTAIL Delta, RA_return R' vl |-- |==> RA_return R vl) ->
@semax cs Espec Delta P c R' ->  @semax cs Espec Delta P c R.
Lemma semax_post:
forall (R': ret_assert) Espec {cs: compspecs} Delta (R: ret_assert) P c,
ENTAIL Delta, RA_normal R' |-- RA_normal R ->
ENTAIL Delta, RA_break R' |-- RA_break R ->
ENTAIL Delta, RA_continue R' |-- RA_continue R ->
(forall vl, ENTAIL Delta, RA_return R' vl |-- RA_return R vl) ->
@semax cs Espec Delta P c R' ->  @semax cs Espec Delta P c R.
Lemma semax_post_flipped:
forall (R' : ret_assert) Espec {cs: compspecs} (Delta : tycontext) (R : ret_assert)
(P : environ->mpred) (c : statement),
@semax cs Espec Delta P c R' ->
ENTAIL Delta, RA_normal R' |-- RA_normal R ->
ENTAIL Delta, RA_break R' |-- RA_break R ->
ENTAIL Delta, RA_continue R' |-- RA_continue R ->
(forall vl, ENTAIL Delta, RA_return R' vl |-- RA_return R vl) ->
@semax cs Espec Delta P c R.
Lemma semax_pre_post': forall P' R' Espec {cs: compspecs} Delta R P c,
ENTAIL Delta, P |-- P' ->
ENTAIL Delta, R' |-- R ->
@semax cs Espec Delta P' c (normal_ret_assert R') ->
@semax cs Espec Delta P c (normal_ret_assert R).