intros H H0. replace (Z_of_nat 0 * w) with 0 in H0. simpl in H0. cut (x = 0). intro H1. rewrite H1.
rewrite Zdiv_small_0. unfold P. split. left. simpl. rewrite H1. rewrite Zdiv_small_0. replace (0 * 2 ^ p) with 0. symmetry.
apply modred. omega. omega. ring. rewrite Zdiv_small_0. replace (0 mod 2 ^ w) with 0. omega. symmetry. apply modred. omega.
exact lt02w. omega. omega. rewrite Zdiv_small_0. rewrite modred. apply lt_0_Zpow. unfold p. unfold p_in_Z_w. apply le_0_p.
omega. exact lt02w. omega. omega. simpl. rewrite H1. rewrite Zdiv_small_0. rewrite modred. rewrite modred. symmetry.
apply modred. omega. exact lt02w. rewrite modred. omega. omega. exact lt02w. rewrite modred. apply lt_0_Zpow. unfold p.
unfold p_in_Z_w. apply le_0_p. omega. exact lt02w. rewrite modred. rewrite modred. omega. omega.
exact lt02w. rewrite modred. omega. omega. exact lt02w. rewrite modred. apply lt_0_Zpow. unfold p. unfold p_in_Z_w.
apply le_0_p. omega. exact lt02w. rewrite modred. rewrite modred. exact lt02w. omega. exact lt02w. rewrite modred.
omega. omega. exact lt02w. rewrite modred. apply lt_0_Zpow. unfold p. unfold p_in_Z_w. apply le_0_p. omega. exact lt02w.
omega. omega. omega. exact lt02w. omega. ring. Qed.

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).