(***********************************************************************)
(*   A function that solves the chinese remainder problem              *)
(***********************************************************************)
Definition chinese r1 r2 :=
r1 * m2 * (egcdn m2 m1).1 + r2 * m1 * (egcdn m1 m2).1.

(* Specifications: *)
Lemma chinese_modl r1 r2 : chinese r1 r2 = r1 %[mod m1].
Lemma chinese_modr r1 r2 : chinese r1 r2 = r2 %[mod m2].
Lemma chinese_mod x : x = chinese (x %% m1) (x %% m2) %[mod m1 * m2].
End Chinese.