Definition x_ (i : nat) := exist (in_Z_ (2 ^ w)) (x / 2 ^ (Z_of_nat i * w) mod 2 ^ w) (mod_in_Z__ (x / 2 ^ (Z_of_nat i * w))).Definition f' (d_Sir_Si : Z_ (2 ^ w) * Z_ (2 ^ w)) (xi : Z_ (2 ^ w)) :=
  (d_i M_in_Z_ ptM'cM'' d_Sir_Si xi, r_i M_in_Z_ ptM'cM'' d_Sir_Si xi).Fixpoint foldlz (f : Z_ (2 ^ w) * Z_ (2 ^ w) -> Z_ (2 ^ w) -> Z_ (2 ^ w) * Z_ (2 ^ w)) (d_Sir_Si : Z_ (2 ^ w) * Z_ (2 ^ w)) (a:nat) {struct a} : 
 Z_ (2 ^ w) * Z_ (2 ^ w) :=
  match a with
  | O   => d_Sir_Si
  | S i => foldlz f (f d_Sir_Si (x_ i)) i
  end.

(* Specifications: *)
Lemma P'f' : forall (d r : Z_ (2 ^ w)) (h : Z) (l x_i : Z_ (2 ^ w)), P M p d r h l -> P M p (fst (f' (d, r) x_i)) (snd (f' (d, r) x_i)) (h * 2 ^ w + l) x_i.
Lemma P'f'x : forall (d r : Z_ (2 ^ w)) (n : nat), P M p d r (x / 2 ^ ((Z_of_nat n + 2) * w)) (x_ (S n)) -> P M p (fst (f' (d, r) (x_ n))) (snd (f' (d, r) (x_ n))) (x / 2 ^ ((Z_of_nat n + 1) * w)) (x_ n).
Lemma P'foldlz : forall (n : nat) (d r : Z_ (2 ^ w)), P M p d r (x / 2 ^ ((Z_of_nat n + 2) * w)) (x_ (S n)) -> P M p (fst (foldlz f' (d, r) (S n))) (snd (foldlz f' (d, r) (S n))) (x / 2 ^ w) (x_ O).
Lemma P_S : forall (n : nat), 0 <= x -> x < 2 ^ (Z_of_nat (S n) * w) -> P M p (fst (foldlz f' (zero_in_Z_, zero_in_Z_) (S n))) (snd (foldlz f' (zero_in_Z_, zero_in_Z_) (S n))) (x / 2 ^ w) (x_ 0).
Lemma P_O : 0 <= x -> x < 2 ^ (Z_of_nat O * w) -> P M p (fst (foldlz f' (zero_in_Z_, zero_in_Z_) O)) (snd (foldlz f' (zero_in_Z_, zero_in_Z_) O)) (x / 2 ^ w) (x_ 0).
Lemma P_all : forall (n : nat), 0 <= x -> x < 2 ^ (Z_of_nat n * w) -> P M p (fst (foldlz f' (zero_in_Z_, zero_in_Z_) n)) (snd (foldlz f' (zero_in_Z_, zero_in_Z_) n)) (x / 2 ^ w) (x_ 0).
Lemma Q_lem : forall (n : nat), 0 <= x -> x < 2 ^ (Z_of_nat n * w) -> _Z (r'''0 M_in_Z_ ptM'cM'' (foldlz f' (zero_in_Z_, zero_in_Z_) n)) = x mod M.
Lemma cex : forall M : Mset, in_Z_ (2 ^ w) (2 ^ Zlog_sup M).
Lemma M''ex : forall M : Mset, in_Z_ (2 ^ w) (2 ^ (w - Zlog_sup M - 1 / M) * M mod 2 ^ w).
Lemma M'mod : forall M : Mset, 2 ^ (Zlog_sup M + w) / M - 2 ^ w = (2 ^ (Zlog_sup M + w) / M) mod 2 ^ w.
Lemma P'f' : forall (d r : Z_ (2 ^ w)) (h : Z) (l x_i : Z_ (2 ^ w)), P' M p d r h l -> P' M p (fst (f' (d, r) x_i)) (snd (f' (d, r) x_i)) (h * 2 ^ w + l) x_i.
Lemma P'f'x : forall (d r : Z_ (2 ^ w)) (n : nat), P' M p d r (x / 2 ^ ((Z_of_nat n + 2) * w)) (x_ (S n)) -> P' M p (fst (f' (d, r) (x_ n))) (snd (f' (d, r) (x_ n))) (x / 2 ^ ((Z_of_nat n + 1) * w)) (x_ n).
Lemma P'foldlz : forall (n : nat) (d r : Z_ (2 ^ w)), P' M p d r (x / 2 ^ ((Z_of_nat n + 2) * w)) (x_ (S n)) -> P' M p (fst (foldlz f' (d, r) (S n))) (snd (foldlz f' (d, r) (S n))) (x / 2 ^ w) (x_ O).
Lemma P_S : forall (n : nat), 0 <= x -> x < 2 ^ (Z_of_nat (S n) * w) -> P' M p (fst (foldlz f' (zero_in_Z_, zero_in_Z_) (S n))) (snd (foldlz f' (zero_in_Z_, zero_in_Z_) (S n))) (x / 2 ^ w) (x_ 0).
Lemma P_O : 0 <= x -> x < 2 ^ (Z_of_nat O * w) -> P' M p (fst (foldlz f' (zero_in_Z_, zero_in_Z_) O)) (snd (foldlz f' (zero_in_Z_, zero_in_Z_) O)) (x / 2 ^ w) (x_ 0).
Lemma P_all : forall (n : nat), 0 <= x -> x < 2 ^ (Z_of_nat n * w) -> P' M p (fst (foldlz f' (zero_in_Z_, zero_in_Z_) n)) (snd (foldlz f' (zero_in_Z_, zero_in_Z_) n)) (x / 2 ^ w) (x_ 0).
Lemma Q_lem : forall (n : nat), 0 <= x -> x < 2 ^ (Z_of_nat n * w) -> _Z (r''0 M_in_Z_ (* ptM'cM'' *) (foldlz f' (zero_in_Z_, zero_in_Z_) n)) = x mod M.
Lemma cex : forall M : Mset, in_Z_ (2 ^ w) (2 ^ Zlog_sup M).
Lemma M''ex : forall M : Mset, in_Z_ (2 ^ w) (2 ^ (w - Zlog_sup M - 1 / M) * M mod 2 ^ w).
Lemma M'mod : forall M : Mset, 2 ^ (Zlog_sup M + w) / M - 2 ^ w = (2 ^ (Zlog_sup M + w) / M) mod 2 ^ w.