unfold s_i. elim (Zle_or_lt c r'_i); intro H. rewrite ltw_false. rewrite ltw_false. simpl. fold p. fold x_i. fold p.
fold M''. fold M. transitivity ((((r'_i - M) mod 2 ^ w * 2 ^ (w - p + p) + x_i) / 2 ^ p) mod 2 ^ w). rewrite Zpower_exp.
rewrite Zmult_assoc. rewrite Zdiv_times_plus. rewrite M''_M. rewrite <- Zmod_minus_distr_r. rewrite Zplus_comm.
rewrite Zmod_plus_distr_l with (b := x_i / 2 ^ p). rewrite <- Zmod_mult_distr_l. rewrite <- Zmod_plus_distr_l.
rewrite <- Zmod_plus_distr_l. rewrite Zmult_minus_distr_r. rewrite Ht. apply f_equal2 with (f := Zmod). ring. trivial.
exact lt02w. exact lt02w. exact lt02w. exact lt02w. exact lt02w. apply lt_0_Zpow. auto with a. cut (p < w). omega. auto with a.
apply Zle_ge. auto with a. replace (w - p + p) with w. trivial. ring. assumption. assumption. rewrite ltw_true. rewrite ltw_true.
rewrite Zmult_comm. (* replace w with (w - p + p). *)  (* Does not work... *)
transitivity (((r'_i * 2 ^ (w - p + p) + x_i) / 2 ^ p) mod 2 ^ w). (* ... *)
rewrite Zpower_exp. rewrite Zmult_assoc. rewrite Zdiv_times_plus. rewrite Ht. simpl. fold x_i. fold p. trivial. apply lt_0_Zpow.
auto with a. cut (p < w). omega. auto with a. apply Zle_ge. auto with a. replace (w - p + p) with w. trivial. ring. assumption.
assumption. auto with a. tauto. Qed.

Lemma M1_r'a : M = 1 \/ _Z h'_i = x' / 2 ^ p.
elim h'_i_eq_mod; intro H. tauto. right. rewrite H. apply modred. apply Zle_0_div. exact le_0_x'. apply lt_0_Zpow.