Section Fcalc_bracket_step.
Variable start step : R.
Variable nb_steps : Z.
Variable Hstep : (0 < step)%R.
Hypothesis (Hnb_steps : (1 < nb_steps)%Z).
(** Computes a new location when the interval containing a real number is split into nb_steps subintervals and the real is in the k-th one. (Even radix.) *)
Definition new_location_even k l :=
if Zeq_bool k 0 then
match l with loc_Exact => l | _ => loc_Inexact Lt end
else
loc_Inexact
match Z.compare (2 * k) nb_steps with
| Lt => Lt
| Eq => match l with loc_Exact => Eq | _ => Gt end
| Gt => Gt
end.
(** Computes a new location when the interval containing a real number is split into nb_steps subintervals and the real is in the k-th one. (Odd radix.) *)
Definition new_location_odd k l :=
if Zeq_bool k 0 then
match l with loc_Exact => l | _ => loc_Inexact Lt end
else
loc_Inexact
match Z.compare (2 * k + 1) nb_steps with
| Lt => Lt
| Eq => match l with loc_Inexact l => l | loc_Exact => Lt end
| Gt => Gt
end.

Theorem new_location_odd_correct :
Z.even nb_steps = false ->
forall x k l, (0 <= k < nb_steps)%Z ->
inbetween (start + IZR k * step) (start + IZR (k + 1) * step) x l ->
inbetween start (start + IZR nb_steps * step) x (new_location_odd k l).