Require Export VST.veric.Clight_base.
Local Open Scope pred.
Definition tc_expr {CS: compspecs} (Delta: tycontext) (e: expr) : environ -> mpred:=
fun rho => denote_tc_assert (typecheck_expr Delta e) rho.
Definition tc_exprlist {CS: compspecs} (Delta: tycontext) (t : list type) (e: list expr) : environ -> mpred :=
fun rho => denote_tc_assert (typecheck_exprlist Delta t e) rho.
Definition tc_lvalue {CS: compspecs} (Delta: tycontext) (e: expr) : environ -> mpred :=
fun rho => denote_tc_assert (typecheck_lvalue Delta e) rho.
Definition tc_temp_id {CS: compspecs} (id : positive) (ty : type)
(Delta : tycontext) (e : expr) : environ -> mpred  :=
fun rho => denote_tc_assert (typecheck_temp_id id ty Delta e) rho.
Definition tc_expropt {CS: compspecs} Delta (e: option expr) (t: type) : environ -> mpred :=
match e with None => `!!(t=Tvoid)
| Some e' => tc_expr Delta (Ecast e' t)
end.
Definition tc_temp_id_load id tfrom Delta v : environ -> mpred  :=
fun rho => !! (exists tto, (temp_types Delta) ! id = Some tto
/\ tc_val tto (eval_cast tfrom tto (v rho))).
Hint Resolve extend_prop : core.
Ltac extend_tc_prover :=
match goal with
| |- _ => solve [immediate]
| |- _ => apply extend_prop
| |- _ => first
[ simple apply extend_tc_bool
| simple apply extend_tc_int_or_ptr_type
| simple apply extend_tc_andp
| simple apply extend_tc_andp'
| simple apply extend_tc_Zge
| simple apply extend_tc_Zle
| simple apply extend_tc_iszero
| simple apply extend_tc_nonzero
| simple apply extend_tc_nodivover
| simple apply extend_tc_nobinover
| simple apply extend_tc_samebase
| simple apply extend_tc_ilt
| simple apply extend_tc_llt
| simple apply extend_isCastResultType
| simple apply extend_tc_test_eq
| simple apply extend_tc_test_order]
| |- boxy _ (denote_tc_assert (if ?A then _ else _) _) => destruct A
| |- boxy _ (denote_tc_assert match tc_bool ?A _ with _ => _ end _) =>
destruct A
| |- boxy _ (denote_tc_assert match ?A with Some _ => _ | None => _ end _) =>
destruct A
end.

Lemma extend_tc_binop: forall {CS: compspecs} Delta e1 e2 b t rho,
boxy extendM (denote_tc_assert (typecheck_expr Delta e1) rho) ->
boxy extendM (denote_tc_assert (typecheck_expr Delta e2) rho) ->
boxy extendM (denote_tc_assert (isBinOpResultType b e1 e2 t) rho).