Require Export VST.veric.environ_lemmas.
Require Export VST.veric.expr_lemmas3.
(** Main soundness result for the typechecker **)
Ltac unfold_cop2_sem_cmp :=
unfold Clight_Cop2.sem_cmp, Clight_Cop2.sem_cmp_pl, Clight_Cop2.sem_cmp_lp, Clight_Cop2.sem_cmp_pp.
(*        (Hcenv: genv_cenv ge = @cenv_cs CS)*)
Definition some_pt_type := Tpointer Tvoid noattr.
Opaque tc_andp.
(** Equivalence of CompCert eval_expr and our function eval_expr on programs that typecheck **)
Ltac destruct_eqb_type :=
match goal with H: context [eqb_type ?t1 ?t2] |- _ =>
let J := fresh "J" in
destruct (eqb_type t1 t2) eqn:?J;
[apply eqb_type_true in J | apply eqb_type_false in J]
end.
Definition cast_pointer_to_bool t1 t2 :=
match t1 with (Tpointer _ _ | Tarray _ _ _ | Tfunction _ _ _) =>
match t2 with Tint IBool _ _ => true | _ => false end
| _ => false
end.

Lemma eval_unop_relate:
forall {CS: compspecs} Delta (ge: genv) te ve rho u e t m
(Hcenv: cenv_sub (@cenv_cs CS) (genv_cenv ge))
(H : rho = construct_rho (filter_genv ge) ve te)
(H0 : typecheck_environ Delta rho)
(H1 : (denote_tc_assert (typecheck_expr Delta e) rho) (m_phi m) ->
Clight.eval_expr ge ve te (m_dry m) e (eval_expr e rho))
(H2 : (denote_tc_assert (typecheck_lvalue Delta e) rho) (m_phi m) ->
exists (b : block) (ofs : ptrofs),
Clight.eval_lvalue ge ve te (m_dry m) e b ofs /\
eval_lvalue e rho = Vptr b ofs)
(H3 : (denote_tc_assert (typecheck_expr Delta (Eunop u e t)) rho)
(m_phi m)),
Clight.eval_expr ge ve te (m_dry m) (Eunop u e t)
(eval_expr (Eunop u e t) rho).