Definition Z__from_Mset (M : Mset) := exist (in_Z_ (2 ^ w)) M (in_Z__if_in_Mset M).(* <KEEP TOGETHER - Cdef *)
Definition C (M : Mset) :=
      ( exist (in_Z_ w)       (Zlog_sup M)                       (pex M),
        exist (in_Z_ w)       (w - Zlog_sup M - 1 / M)           (tex M),
        exist (in_Z_ (2 ^ w)) (2 ^ (Zlog_sup M + w) / M - 2 ^ w) (M'ex M)).

(* Specifications: *)
Theorem ModRed_eq : forall (M : Mset) (x : Z_ (2 ^ (Zlog_sup M + w))), ModRed M (C M) (exist (in_Z_ (2 ^ w)) (x / 2 ^ w) (xhex M x)) (exist (in_Z_ (2 ^ w)) (x mod 2 ^ w) (xlex x)) = x mod M.
Lemma xheex : forall (M : Mset) (h : Z_ (2 ^ Zlog_sup M)), in_Z_ (2 ^ w) h.
Lemma xleex : forall (u : Z_ (2 ^ w)), in_Z_ (2 ^ w) u.
Theorem ModRed_eq2 : forall (M : Mset) (v : Z_ (2 ^ Zlog_sup M)) (u : Z_ (2 ^ w)), ModRed M (C M) (exist (in_Z_ (2 ^ w)) v (xheex M v)) (exist (in_Z_ (2 ^ w)) u (xleex u)) = (2 ^ w * v + u) mod M.