rewrite p_M. rewrite H. simpl. fold x_i. replace x_i with (x_i * 1). rewrite Z_div_mult. transitivity x_i. apply modred.
unfold x_i. apply le_0__Z. unfold x_i. apply lt_z__Z. ring. omega. ring. rewrite M1_r'_i_eq. fold c. rewrite c_M. auto with a.
assumption. assumption. Qed.

(* Specifications: *)
Lemma le_0_2pp : forall z : Z, 0 <= z mod 2 ^ p.
intro z. apply Zmod_le_0_z. auto with a. Qed.
Lemma le_0_mod_M : forall z : Z, 0 <= z mod M.
intro z. apply Zmod_le_0_z. omega. Qed.
Lemma lt_plus_M_2p_2w : forall a b : Z, a mod M + b mod 2 ^ p < 2 ^ w.
intros a b. rewrite Zpow_2_w_is_2Zpow_2_wm1. apply Zplus_lt_compat. apply Zlt_le_trans with M. apply Zmod_lt_z_m. omega.