unfold offset_in_range; intros.
destruct d; simpl in *; trivial.
split; try omega.
apply Z.add_nonneg_nonneg. apply (Ptrofs.unsigned_range i). omega.
Qed.

(* Lemma offset_in_range_offset_val' n off v: offset_in_range off v -> offset_in_range (off+1) v -> offset_in_range n (offset_val off v) = offset_in_range (n+off) v. intros. destruct v; trivial. unfold offset_in_range, offset_val in *. rewrite  (Z.add_comm n), Z.add_assoc in *. destruct (Ptrofs.unsigned_range i). rewrite Ptrofs.add_unsigned. rewrite (Ptrofs.unsigned_repr off). rewrite <- initialize.max_unsigned_modulus in H0. rewrite Ptrofs.unsigned_repr; trivial. omega. split; try omega. 2: destruct (Ptrofs.unsigned_range i); try omega. rewrite Ptrofs.unsigned_repr; trivial. rewrite <- initialize.max_unsigned_modulus in H0. omega. rewrite (Ptrofs.unsigned_repr off); trivial. 2: destruct (Ptrofs.unsigned_range i); try omega. rewrite Ptrofs.unsigned_repr; trivial. rewrite <- initialize.max_unsigned_modulus in H0. omega. Qed.  Lemma offset_in_range_offset_val' n off v: offset_in_range (Ptrofs.unsigned off) v -> offset_in_range ((Ptrofs.unsigned off)+1) v -> offset_in_range n (offset_val off v) = offset_in_range (n+Ptrofs.unsigned off) v. intros. destruct v; trivial. unfold offset_in_range, offset_val in *. rewrite  (Z.add_comm n), Z.add_assoc in *. rewrite Ptrofs.add_unsigned. rewrite Ptrofs.unsigned_repr; trivial. rewrite <- initialize.max_unsigned_modulus in H0. omega. Qed. *)(* Lemma offset_in_range_offset_val z1 z2 v (Z1: 0 <= z1) (Z2: 0 <= z2) (Off : offset_in_range (z1 + z2) v): offset_in_range z2 (offset_val (Ptrofs.repr z1) v). *)
Lemma offset_in_range_offset_val z1 z2 v
(Z1: 0 <= z1) (Z2: 0 <= z2)
(Off : offset_in_range (z1 + z2) v):
offset_in_range z2 (offset_val z1 v).