proposition: Lemma Zdivide_mod_minus a b c: 0 <= c < b -> (b | a - c) -> a mod b = c.
proof: Proof. intros (H1, H2) H3. assert (0 < b) by Z.order. assert (b <> 0) by now apply Z_lt_neq. replace a with ((a - c) + c) by ring. rewrite Z.add_mod; auto. rewrite (Zdivide_mod (a-c) b); try rewrite Z.add_0_l; auto. rewrite Z.mod_mod; try apply Zmod_small; auto. Qed.
imports: ZArith_base ZArithRing Zcomplements Zdiv Wf_nat