(* KE EP TOGETHER> *)
unfold r''0.
unfold r'0. unfold d0. unfold r0. fold r'_i. (* too long *) elim (Zle_or_lt c r'_i); intro H. rewrite ltw_false. simpl. fold M.
rewrite modred. elim r'_i_eq'_i; intro H0. absurd (c <= r'_i). apply Zlt_not_le. rewrite H0. apply Zlt_le_trans with M.
apply Zmod_lt_z_m. omega. rewrite c_M. exact le_M_2pp. assumption. elim H0; intro H1. left. omega. right. omega.
cut (M <= 2 ^ p). omega. exact le_M_2pp. cut (r'_i < 2 ^ w). cut (0 < M). omega. omega. apply lt_z__Z. assumption.
rewrite ltw_true. elim r'_i_eq'_i. intro H0. tauto. intro H0. elim H0; intro H1. tauto. absurd (r'_i < c). apply Zle_not_lt.
rewrite H1. apply Zle_trans with (M + M). rewrite c_M. elim (Zle_lt_or_eq 1 M). intro H2. elim lt_2pm1_M; intro H3.
replace p with (p - 1 + 1). rewrite Zpower_exp. simpl. unfold Zpower_pos. simpl. omega. cut (1 <= p). omega.
replace 1 with (Zlog_sup 2). rewrite p_M. apply Zlog_sup_seq. omega. trivial. omega. ring. rewrite p_M. rewrite H3. omega.
intro H2. rewrite p_M. rewrite <- H2. simpl. omega. omega. cut (0 <= x mod M). omega. apply Zmod_le_0_z. omega. assumption.
assumption. Qed.

(* Specifications: *)
(* <KE EP TOGETHER - r'''0_eq *)
Lemma r'''0_eq : _Z r'''0 = x mod M.
clear x_i_in_Z_ x_i s_i s'_i s''_i h'_i q_i q'_i y_i h'_i h'_i' x'.