Section Chinese.
(***********************************************************************)
(*   The chinese remainder theorem                                     *)
(***********************************************************************)
Variables m1 m2 : nat.
Hypothesis co_m12 : coprime m1 m2.
(***********************************************************************)
(*   A function that solves the chinese remainder problem              *)
(***********************************************************************)
Definition chinese r1 r2 :=
r1 * m2 * (egcdn m2 m1).1 + r2 * m1 * (egcdn m1 m2).1.

Lemma chinese_modr r1 r2 : chinese r1 r2 = r2 %[mod m2].