intros d r n H.
rewrite Z_div_mod_eq with (a := x / 2 ^ ((Z_of_nat n + 1) * w)) (b := 2 ^ w). rewrite Zdivdivdiv. rewrite <- Zpower_exp.
replace ((Z_of_nat n + 1) * w + w) with ((Z_of_nat n + 2) * w). replace (Z_of_nat n + 1) with (Z_of_nat (S n)).
replace ((x / 2 ^ (Z_of_nat (S n) * w)) mod 2 ^ w) with (_Z (x_ (S n))). rewrite Zmult_comm.
apply P'f'. trivial. trivial. trivial.
trivial. rewrite inj_S. ring. ring. apply Zle_ge. apply Zmult_le_0_compat. omega. exact le_0_w.
apply Zle_ge. exact le_0_w. apply lt_0_Zpow. apply Zmult_le_0_compat. omega. exact le_0_w. exact lt02w. apply Zlt_gt.
exact lt02w. Qed.

(* Specifications: *)
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'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).