Section parm_sec.
Variable M_in_Z_ : Z_ (2 ^ w).
Variable ptM' : Z_ w * Z_ w * Z_ (2 ^ w).
Variables v_in_Z_ u_in_Z_ : Z_ (2 ^ w).
Let p_in_Z_w := fst (fst ptM').
Let t_in_Z_w := snd (fst ptM').
Let M'_in_Z_ := snd ptM'.
Let M := _Z M_in_Z_.
Let p := _Z p_in_Z_w.
Let t := _Z t_in_Z_w.
Let M' := _Z M'_in_Z_.
Let v := _Z v_in_Z_.
Let u := _Z u_in_Z_.
Hypothesis le_1_M : 1 <= M.
Hypothesis le_M_max : M <= 2 ^ (w - 1).
Hypothesis p_M : p = Zlog_sup M.
Hypothesis t_M : t = w - p \/ M = 1.
Hypothesis M'_M : M' = 2 ^ (p + w) / M mod 2 ^ w.
Hypothesis v_M : v < 2 ^ p.
Let x := v * 2 ^ w + u.
unfold p. apply le_0__Z. Qed.
unfold u. apply le_0__Z. Qed.
unfold u. apply lt_z__Z. Qed.
unfold v. apply le_0__Z. Qed.
unfold v. apply lt_z__Z. Qed.
apply Zlt_le_weak. exact lt02w. Qed.
Local Hint Resolve le_0_w lt02w le02w : a.
Local Hint Resolve le_0_p le_0_l lt_l_2w le_0_v lt_v_2w : a.
unfold x. fold (0 + 0). apply Zplus_le_compat; auto with a. apply Zmult_le_0_compat; auto with a. Qed.
Local Hint Resolve le_0_x : a.
(* <KEEP TOGETHER - modred_equations *)
Let s := ursh u_in_Z_ p_in_Z_w.
Let s' := multp2 s p_in_Z_w.
Let h := multp2 v_in_Z_ t_in_Z_w.
Let h' := plusw h s.
Let q := uhwm h' M'_in_Z_.
Let q' := plusw q h'.
Let y := multw q' M_in_Z_.
Let d := minusw s' y.
Let r := minusw u_in_Z_ y.
Let r' := ltw d M_in_Z_ r (minusw r M_in_Z_).
Let r'' := ltw r' M_in_Z_ r' (minusw r' M_in_Z_).
Let r''' := ltw r'' M_in_Z_ r'' (minusw r'' M_in_Z_).
(* KEEP TOGETHER> *)
Definition ModRed := _Z r'''. (* keeps _Z out of ModRed_eq *)
unfold x. rewrite Zmod_km_plus. symmetry. apply modred. auto with a. auto with a. auto with a. Qed.
unfold x. rewrite Zdiv_times_plus. rewrite Zdiv_small_0. ring. auto with a. auto with a. auto with a. Qed.
(* KEEP TOGETHER> *)
simpl. fold u. fold p. rewrite l_eq. trivial. Qed.
apply lt_0_Zpow. fold (0 + 0). apply Zplus_le_compat; auto with a. Qed.

Lemma lt_0_2pp : 0 < 2 ^ p.