(* KE EP TOGETHER> *)
unfold r'''0. elim r''0_eq; intro H. rewrite ltw_true. trivial. rewrite H. apply Zmod_lt_z_m. fold M. omega. rewrite ltw_false.
simpl. rewrite H. fold M. replace (x mod M + M - M) with (x mod M). apply modred.
apply Zmod_le_0_z. omega. apply Zlt_trans with M. apply Zmod_lt_z_m. omega. unfold M. apply lt_z__Z. ring. rewrite H. fold M.
cut (0 <= x mod M). omega. apply Zmod_le_0_z. omega. Qed.

(* Specifications: *)
Lemma lt_x'_x'max : x' < 2 ^ (p + w).
unfold x'. apply Zle_lt_trans with ((2 ^ p - 1) * 2 ^ w + (2 ^ w - 1)). apply Zplus_le_compat.