(** Composing two memory injections *)
Definition compose_meminj (f f': meminj) : meminj :=
fun b =>
match f b with
| None => None
| Some(b', delta) =>
match f' b' with
| None => None
| Some(b'', delta') => Some(b'', delta + delta')
end
end.

(* Specifications: *)
Lemma val_inject_compose:
forall f f' v1 v2 v3,
Val.inject f v1 v2 -> Val.inject f' v2 v3 ->
Val.inject (compose_meminj f f') v1 v3.
Lemma val_inject_compose:
forall f f' v1 v2 v3,
Val.inject f v1 v2 -> Val.inject f' v2 v3 ->
Val.inject (compose_meminj f f') v1 v3.