I've managed to prove
Theorem modulo_inv : forall m n : Z, rel_prime m n -> exists x : Z, (m * x == 1 [n]). Admitted.
My question is how to finish the following proof (maybe using the modulo_inv
theorem?):
Variables m n : Z.
Hypothesis co_prime : rel_prime m n.
Theorem SimpleChineseRemainder :
forall a b : Z, exists x : Z, (x == a [m]) /\ (x == b [n]).
Here is what I tried, but I don't know whether it is correct or not.
Proof.
intros a b.
exists ((a * n) * (n ^ (-1) mod m) + (b * m) * (m ^ (-1) mod n)).
refine (conj _ _).
(* case : ((a * n) * (n ^ (-1) mod m) + (b * m) * (m ^ (-1) mod n) == a [m]) *)
red.
rewrite Z.add_sub_swap.
apply Z.divide_add_r.
(* case : ((a * n) * (n ^ (-1) mod m) + (b * m) * (m ^ (-1) mod n) == b [n]) *)
Can anybody provide any suggestions?
Reusing the proof from Wikipedia which is based on Bézout's lemma, we get the following:
Code-golfing Anton's answer, I was hoping that
ring
would be clever enough to use theEq
information, and that the proof would simply beUnfortunately it didn't automatically exploit that
u * m + v * n = 1 -> u * m = 1 - v * n
. So until we have a stronger tactic, I guess that has to be added manually, like so:EDIT: The
nsatz
tactic is able to solve the equation system. However, it introduces a notation for[ ... ]
that conflicts with the notation introduced above, and I don't know how to handle that. However, by changing the notation to i.e.[[ ... ]]
, the proof becomes just two lines: