Notation val_inject:=Val.inject.
(*A value that is (if its a pointer) not dangling wrt m - a condition like this will probably be need to imposed on after-external return values (and thus also on the values returned by halted)*)
Definition val_valid (v:val) (m:mem):Prop :=
match v with Vptr b ofs => Mem.valid_block m b | _ => True
end.

(* Specifications: *)
(*In fact val_valid is a slight relaxtion of valid_pointer*)
Lemma valid_ptr_val_valid: forall b ofs m,
Mem.valid_pointer m b ofs = true -> val_valid (Vptr b (Ptrofs.repr ofs)) m.
Lemma extends_valvalid: forall m1 m2 (Ext: Mem.extends m1 m2) v,
val_valid v m1 <-> val_valid v m2.
Lemma inject_valvalid: forall j m1 m2 (Inj: Mem.inject j m1 m2) v2 (V:val_valid v2 m2) v1,
val_inject j v1 v2 -> val_valid v1 m1.
(*Preservation of val_valid along an injection only holds if the LHS value is defined*)
Lemma inject_valvalid_1:
forall (j : meminj) (m1 m2 : mem),
Mem.inject j m1 m2 ->
forall v1 : val,
val_valid v1 m1 -> forall v2 : val, val_inject j v1 v2 ->
match v1 with Vundef => True
| _ => val_valid v2 m2
end.