Definition  binary_operation_to_comparison (op: Cop.binary_operation) :=
match op with
| Cop.Oeq => Some (@eq Z)
| Cop.One => Some Zne
| Cop.Olt => Some Z.lt
| Cop.Ole => Some Z.le
| Cop.Ogt => Some Z.gt
| Cop.Oge => Some Z.ge
| _ => None
end.
(* Lemma typed_true_binop_int: forall op op' e1 e2 Espec  {cs: compspecs} Delta P Q R c Post, binary_operation_to_comparison op = Some op' -> typeof e1 = tint -> typeof e2 = tint -> (PROPx P (LOCALx (tc_env Delta :: Q) (SEPx R))) |--  tc_expr Delta e1 -> (PROPx P (LOCALx (tc_env Delta :: Q) (SEPx R))) |-- tc_expr Delta e2 -> @semax cs Espec Delta (PROPx P (LOCALx (`op' (`force_signed_int (eval_expr e1)) (`force_signed_int (eval_expr e2)) :: Q) (SEPx R))) c Post -> @semax cs Espec Delta (PROPx P (LOCALx (`(typed_true (typeof (Ebinop op e1 e2 tint))) (eval_expr (Ebinop op e1 e2 tint)) :: Q) (SEPx R))) c Post. *)
Definition  binary_operation_to_opp_comparison (op: Cop.binary_operation) :=
match op with
| Cop.Oeq => Some Zne
| Cop.One => Some (@eq Z)
| Cop.Olt => Some Z.ge
| Cop.Ole => Some Z.gt
| Cop.Ogt => Some Z.le
| Cop.Oge => Some Z.lt
| _ => None
end.
(* Lemma typed_false_binop_int: forall op op' e1 e2 Espec  {cs: compspecs} Delta P Q R c Post, binary_operation_to_opp_comparison op = Some op' -> typeof e1 = tint -> typeof e2 = tint -> (PROPx P (LOCALx (tc_environ Delta :: Q) (SEPx R))) |-- (tc_expr Delta e1) -> (PROPx P (LOCALx (tc_environ Delta :: Q) (SEPx R))) |-- (tc_expr Delta e2) -> @semax cs Espec Delta (PROPx P (LOCALx (`op' (`force_signed_int (eval_expr e1)) (`force_signed_int (eval_expr e2)) :: Q) (SEPx R))) c Post -> @semax cs Espec Delta (PROPx P (LOCALx (`(typed_false (typeof (Ebinop op e1 e2 tint))) (eval_expr (Ebinop op e1 e2 tint)) :: Q) (SEPx R))) c Post. *)

(* Specifications: *)
Lemma typed_false_One_nullval:
forall  {cs: compspecs}  v t t',
local (`(typed_false tint) (`(eval_binop Cop.One (tptr t) (tptr t')) v `(nullval))) |--
local (`(eq nullval) v).
Lemma typed_true_One_nullval:
forall  {cs: compspecs}  v t t',
local (`(typed_true tint) (`(eval_binop Cop.One (tptr t) (tptr t')) v `(nullval))) |--
local (`(ptr_neq nullval) v).
Lemma typed_false_Oeq_nullval:
forall  {cs: compspecs} v t t',
local (`(typed_false tint) (`(eval_binop Cop.Oeq (tptr t) (tptr t')) v `(nullval))) |--
local (`(ptr_neq nullval) v).
Lemma local_entail_at:
forall n S T (H: local (locald_denote S) |-- local (locald_denote T))
P Q R,
nth_error Q n = Some S ->
PROPx P (LOCALx Q (SEPx R)) |--
PROPx P (LOCALx (replace_nth n Q T) (SEPx R)).
Lemma local_entail_at_semax_0:
forall Espec {cs: compspecs}Delta P Q1 Q1' Q R c Post,
local (locald_denote Q1) |-- local (locald_denote Q1') ->
@semax cs Espec Delta (PROPx P (LOCALx (Q1'::Q) (SEPx R))) c Post  ->
@semax cs Espec Delta (PROPx P (LOCALx (Q1::Q) (SEPx R))) c Post.