rewrite Zplus_comm with (m := x mod 2 ^ p mod M). rewrite Zplus_assoc. elim (mod_plus (x - x mod 2 ^ p) (x mod 2 ^ p) M).
intro H. rewrite H. replace (x - x mod 2 ^ p + x mod 2 ^ p) with x. elim (div_r'_i x M). intro H0. rewrite <- p_M in H0.
rewrite H0. left. ring. intro H0. rewrite <- p_M in H0. rewrite H0. right. left. ring. omega. ring. intro H. rewrite H.
replace (x - x mod 2 ^ p + x mod 2 ^ p) with x. elim (div_r'_i x M). intro H0. rewrite <- p_M in H0. rewrite H0. right. left.
ring. intro H0. rewrite <- p_M in H0. rewrite H0. right. right. ring. omega. ring. omega. auto with a. omega. Qed.

Lemma r''_small : _Z r'' < 2 ^ p.
unfold r''. elim (Zle_or_lt M r'); intro H. rewrite ltw_false. simpl. fold M. rewrite modred. cut (r' < M + 2 ^ p).