(* KE EP 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. fold x_i.
replace (x' - x' mod 2 ^ p - _Z y_i + x' mod 2 ^ p) with (x' - _Z y_i). rewrite x_i_eq.
rewrite <- Zmod_minus_distr_l. trivial. auto with a. ring. auto with a. auto with a. auto with a.
auto with a. Qed.
Definition d_ir_i := (d_i, r_i).

(* Specifications: *)
Lemma d_i_r_i_eq : P M p d_i r_i x x_i_in_Z_.
unfold P. split. elim d_i_eq; unfold x'. elim r''0_eq; intro H; rewrite H. tauto. tauto. elim r''0_eq; intro H; rewrite H. tauto.