replace (x_i - (x_i - (r'a * 2 ^ w + x_i) mod 2 ^ p)) with ((r'a * 2 ^ w + x_i) mod 2 ^ p). apply modred.
apply Zmod_le_0_z. apply lt_0_Zpow. auto with a. apply Zlt_le_trans with (2 ^ p). apply Zmod_lt_z_m. apply lt_0_Zpow.
auto with a. apply Zle_pow_le. auto with a. cut (p < w). omega. auto with a. ring. unfold x_i. apply le_0__Z. unfold x_i.
apply lt_z__Z. auto with a. Qed.

(* Specifications: *)
Lemma le2ppMM : 2 ^ p < M + M.
elim (Zle_or_lt M 1); intro H. cut (M = 1). intro H0. rewrite p_M. rewrite H0. simpl. omega. omega.