rewrite Zmod_mult_distr_l. rewrite Zmod_plus_distr_l. rewrite Zmod_mult_distr_l with (a := a). rewrite <- Zmod_plus_distr_l.
rewrite <- Zmod_mult_distr_l. rewrite <- Zdiv_times_plus. rewrite <- Zmult_assoc. rewrite <- Zpower_exp.
replace (w - p + p) with w. trivial. ring. cut (p < w). omega. auto with a. apply Zle_ge. auto with a. auto with a. omega. omega.
omega. omega. omega. auto with a. cut (p < w). omega. auto with a. apply Zle_ge. auto with a. ring. Qed.

Lemma r'0plus : forall a b : Z, (a * 2 ^ w + b) mod 2 ^ p = b mod 2 ^ p.
intros a b. replace w with (w - p + p). rewrite Zpower_exp. rewrite Zmult_assoc. rewrite Zplus_comm. rewrite Z_mod_plus. trivial.