unfold modNat.
rewrite N.mod_small.
apply Nnat.Nat2N.id.
specialize (Nnat.N2Nat.inj_compare); intuition.
specialize (N.compare_lt_iff (N.of_nat x) (N.of_nat n)); intuition.
apply H2.
rewrite H0.
repeat rewrite Nnat.Nat2N.id.
apply nat_compare_lt.
trivial.
Qed.
Definition modNatAddInverse (n : nat)(p : posnat) :=
(p - (modNat n p))%nat.

Lemma modNatAddInverse_correct_gen : forall x y p,
modNat x p = modNat y p ->
modNat (x + modNatAddInverse y p) p = O.