(* KEEP TOGETHER> *)
rewrite Zmod_minus_distr_l with (a := x mod 2 ^ w - x mod 2 ^ p).
rewrite <- Zmod_minus_distr_l with (a := x). rewrite <- Zmod_minus_distr_l. rewrite <- Zmod_plus_distr_l.
replace (x - x mod 2 ^ p - _Z y + x mod 2 ^ p) with (x - _Z y). rewrite l_eq. (* explicit coercion needed here *)
rewrite <- Zmod_minus_distr_l. trivial. auto with a. ring. auto with a. auto with a. auto with a.
auto with a. Qed.

(* <KEEP TOGETHER - r'_eq *)
Lemma r'_eq : _Z r' = x / 2 ^ p * 2 ^ p mod M + x mod 2 ^ p.
unfold r'. elim d_eq; intro H. rewrite ltw_true. rewrite r_eq. rewrite H. apply modred. fold (0 + 0).