rewrite Zmod_plus_distr_l. rewrite Zmod_mult_distr_l. rewrite <- Zmod_plus_distr_l.
apply f_equal2 with (f := Zmod). ring. trivial. assumption. assumption. assumption. ring. Qed.

Lemma modred : forall x m : Z, 0 <= x -> x < m -> x mod m = x.
intros x m H H0. rewrite <- Zdivmod_split with (x := x) (m := m).