Section CD.
Variable n : nat.
(**********************************************************************)
Inductive congruent : nat -> nat -> Prop :=
congruentDef :
forall a b u v : nat, a + u * n = b + v * n -> congruent a b.
intros a b c H; inversion_clear H.
apply congruentDef with (u := u * c) (v := v * c); auto.
repeat rewrite mult_comm with (m := c); repeat rewrite mult_assoc_reverse;
repeat rewrite (mult_comm c).
repeat rewrite <- mult_plus_distr_r.
rewrite H0; auto.
Qed.
intros a b c d H' H'0; inversion_clear H'; inversion_clear H'0.
apply
congruentDef
with (u := u0 * a + u * u0 * n + u * c) (v := v0 * b + v * v0 * n + v * d).
repeat rewrite mult_plus_distr_r.
repeat rewrite plus_assoc.
rewrite (mult_comm u0); rewrite (mult_comm v0).
repeat rewrite mult_assoc_reverse.
repeat rewrite (mult_comm a); repeat rewrite (mult_comm b).
repeat rewrite <- mult_plus_distr_r.
repeat rewrite mult_assoc.
repeat rewrite mult_comm with (m := n).
rewrite (mult_assoc n u); rewrite (mult_assoc n v).
repeat rewrite mult_assoc.
repeat rewrite (mult_assoc_reverse n n).
rewrite mult_comm with (m := n * u); rewrite mult_comm with (m := n * v).
repeat rewrite mult_assoc_reverse with (m := n).
repeat rewrite (mult_comm (n * u)); repeat rewrite (mult_comm (n * v)).
repeat rewrite plus_assoc_reverse; repeat rewrite <- mult_plus_distr_r.
rewrite plus_comm with (m := c); rewrite plus_comm with (m := d).
repeat rewrite (mult_comm (c + n * u0));
repeat rewrite (mult_comm (d + n * v0)).
repeat rewrite (mult_comm (c + n * u0));
repeat rewrite (mult_comm (d + n * v0)).
repeat rewrite <- mult_plus_distr_r.
repeat rewrite (mult_comm n); rewrite H; auto.
Qed.
intros a b c; elim c; simpl in |- *; auto.
intros H'; apply cong_ref.
intros n0 H' H'0.
apply cong_mult; auto.
Qed.
intros a b H' H'0; inversion_clear H'0.
exists (v - u).
rewrite mult_minus_distr_r; auto.
rewrite plus_minus_assoc.
rewrite plus_comm; rewrite <- H; rewrite plus_comm; auto with arith.
apply le_plus_le with (a := b) (b := a); auto.
Qed.

Theorem cong_divides :
forall a b : nat, b <= a -> congruent a b -> divides n (a - b).