Require Export VST.veric.environ_lemmas.
(** Definitions of some environments **)
Definition empty_genv cenv := Build_genv (Globalenvs.Genv.empty_genv fundef type nil) cenv.
Definition empty_tenv := PTree.empty val.
Definition empty_environ cenv : environ :=
mkEnviron (filter_genv (empty_genv cenv)) (Map.empty _) (Map.empty _).
(** Typechecking soundness **)
Transparent Float.to_int.
Transparent Float.to_intu.
Transparent Float32.to_int.
Transparent Float32.to_intu.
Definition general_offloat (prec emax : Z)
(f:  Binary.binary_float prec emax) : option Z :=
match f with
| Binary.B754_zero _ => Some 0
| Binary.B754_infinity _ => None
| Binary.B754_nan _ _ _ => None
| Binary.B754_finite s m 0 _ => Some (Zaux.cond_Zopp s (Z.pos m))
| Binary.B754_finite s m (Z.pos e) _ =>
Some (Zaux.cond_Zopp s (Z.pos m) * Z.pow_pos 2 e)
| Binary.B754_finite s m (Z.neg e) _ =>
Some (Zaux.cond_Zopp s (Z.pos m / Z.pow_pos 2 e))
end.
Definition general_float_to_int (prec emax : Z) (lo hi: Z) (f: Binary.binary_float prec emax) : option int :=
option_map Int.repr
(IEEE754_extra.ZofB_range prec emax f lo hi).
Goal Zoffloat = general_offloat 53 1024.
reflexivity.
Qed.
Goal Zofsingle = general_offloat 24 128.
reflexivity.
Qed.
Goal Float.to_int = general_float_to_int 53 1024 Int.min_signed Int.max_signed.
reflexivity.
Qed.
Goal Float.to_intu = general_float_to_int 53 1024 0 Int.max_unsigned.
reflexivity.
Qed.
Goal Float32.to_int = general_float_to_int 24 128 Int.min_signed Int.max_signed.
reflexivity.
Qed.
Goal Float32.to_intu = general_float_to_int 24 128 0 Int.max_unsigned.
reflexivity.
Qed.

(* not necessary if rewrite denote_tc_assert_andp *)
(* Lemma denote_tc_assert_andp_e: forall a b rho, denote_tc_assert Delta (tc_andp a b) rho -> denote_tc_assert Delta a rho /\ denote_tc_assert Delta b rho. *)
Lemma andb_zleb:
forall i j k : Z,  i <= j <= k ->
(i <=? j) && (j <=? k) = true.