elim lt_2pm1_M; intro H0. replace p with (p - 1 + 1). rewrite Zpower_exp. replace (2 ^ 1) with 2. omega. trivial.
cut (1 <= p). omega. elim le_1_p; intro H1. assumption. absurd (1 < M); omega. omega. ring. rewrite p_M. rewrite H0. simpl.
omega. Qed.

Lemma r_i_eq : _Z r_i = (_Z d_i + x' mod 2 ^ p mod M) mod 2 ^ w.
unfold r_i. elim (Zle_or_lt M (_Z l'_i)); intro H. rewrite ltw_false. rewrite Z_from_minusw. rewrite rrr_i_eq. fold M.