unfold q'_i. rewrite Z_from_plusw. rewrite q_i_eq. rewrite <- h'_i'h'_i_eq. rewrite h'_i'_eq. rewrite Zplus_comm.
rewrite <- Zdiv_times_plus. rewrite <- Zmult_plus_distr_r. rewrite large_M'_eq. trivial. auto with a. Qed.

Lemma mod_ab_mod : forall z a b m : Z, 0 < m ->
z = a \/ z = b -> z mod m = a mod m \/ z mod m = b mod m.