Section Sfor.
Context {cs : compspecs}
(Delta: tycontext)
(_i: ident)
(m n: Z)
(init: statement)
(hi: expr)
(inv0: environ -> mpred)
(assert_callee inv1 inv2: Z -> environ -> mpred)
(type_i: type)
(int_min int_max: Z).
Hypothesis EVAL_hi: ENTAIL Delta, inv0 |-- EX n': val, !! (Int6432_val (typeof hi) n' n) && local (` (eq n') (eval_expr hi)).
Hypothesis TC_hi: ENTAIL Delta, inv0 |-- tc_expr Delta hi.
Hypothesis I32_i: is_int32_type type_i = true.
Hypothesis IMM: int_type_min_max type_i (typeof hi) = Some (int_min, int_max).
Hypothesis Range_m: int_min <= m <= int_max.
Hypothesis Range_n: int_min <= n <= int_max.
Hypothesis TI: (temp_types Delta) ! _i = Some type_i.
Hypothesis EQ_inv1: forall i : Z, local (locald_denote (temp _i (Vint (Int.repr i)))) && assert_callee i = inv1 i.
Hypothesis EQ_inv0: (EX i : Z, !! (m <= i <= n) && inv1 i)%assert = inv0.
Hypothesis EQ_inv2: forall i, local (locald_denote (temp _i (Vint (Int.repr i)))) && assert_callee (i+1) = inv2 i.
Hypothesis SUBST_callee: forall v i, subst _i (`v) (assert_callee i) = assert_callee i.

(* Specifications: *)
Lemma CLASSIFY_CMP: classify_cmp type_i (typeof hi) = cmp_default.
Lemma Sfor_loop_cond_tc:
ENTAIL Delta, inv0 |-- tc_expr Delta (Eunop Onotbool (Ebinop Olt (Etempvar _i type_i) hi tint) tint).
Lemma Sfor_comparison_Signed_I32: forall i n',
Int6432_val (typeof hi) n' n ->
classify_binarith type_i (typeof hi) = bin_case_i Signed ->
m <= i <= n ->
force_val (sem_cmp_default Clt type_i (typeof hi) (Vint (Int.repr i)) n') = Vint Int.zero <->
i >= n.
Lemma Sfor_comparison_Unsigned_I32: forall i n',
Int6432_val (typeof hi) n' n ->
classify_binarith type_i (typeof hi) = bin_case_i Unsigned ->
m <= i <= n ->
force_val (sem_cmp_default Clt type_i (typeof hi) (Vint (Int.repr i)) n') = Vint Int.zero <->
i >= n.
Lemma Sfor_comparison_Signed_I64: forall i n',
Int6432_val (typeof hi) n' n ->
classify_binarith type_i (typeof hi) = bin_case_l Signed ->
m <= i <= n ->
force_val (sem_cmp_default Clt type_i (typeof hi) (Vint (Int.repr i)) n') = Vint Int.zero <->
i >= n.
Lemma Sfor_comparison_Unsigned_I64: forall i n',
Int6432_val (typeof hi) n' n ->
classify_binarith type_i (typeof hi) = bin_case_l Unsigned ->
m <= i <= n ->
force_val (sem_cmp_default Clt type_i (typeof hi) (Vint (Int.repr i)) n') = Vint Int.zero <->
i >= n.
Lemma Sfor_loop_cond_true:
ENTAIL Delta, inv0 && local
((` (typed_true (typeof (Ebinop Olt (Etempvar _i type_i) hi tint))))
(eval_expr (Ebinop Olt (Etempvar _i type_i) hi tint))) |--
EX i: Z, !! (m <= i < n) && inv1 i.
Lemma Sfor_loop_cond_false:
ENTAIL Delta, inv0 && local
((` (typed_false (typeof (Ebinop Olt (Etempvar _i type_i) hi tint))))
(eval_expr (Ebinop Olt (Etempvar _i type_i) hi tint))) |--
inv1 n.
Lemma Sfor_inc_tc: forall i s,
m <= i < n ->
ENTAIL Delta, inv2 i
|-- tc_expr Delta (Ebinop Oadd (Etempvar _i type_i) (Econst_int (Int.repr 1) (Tint I32 s noattr)) type_i) &&
tc_temp_id _i (typeof (Ebinop Oadd (Etempvar _i type_i) (Econst_int (Int.repr 1) (Tint I32 s noattr)) type_i))
Delta (Ebinop Oadd (Etempvar _i type_i) (Econst_int (Int.repr 1) (Tint I32 s noattr)) type_i).
Lemma Sfor_inc_entail: forall i s,
m <= i < n ->
EX old : val,
local
((` eq) (eval_id _i)
(subst _i (` old)
(eval_expr (Ebinop Oadd (Etempvar _i type_i) (Econst_int (Int.repr 1) (Tint I32 s noattr)) type_i)))) &&
subst _i (` old) (inv2 i) |--
inv0.