(** Valid values are the ones that have no pointers outside the domain of f*)
  Definition valid_val (f: memren) (v : val) : Prop :=
    match v with
    | Vptr b _ =>
      exists b', f b = Some b'
    | _ => True
    end.Definition valid_memval (f: memren) (mv : memval) : Prop :=
    match mv with
    | Fragment v _ _ =>
      valid_val f v
    | _ => True
    end.

Lemma valid_val_encode: forall v m chunk (Hval_wd: mem_wd.val_valid v m), forall v', List.In v' (encode_val chunk v) -> match v' with | Undef => True | Byte _ => True | Fragment v'' _ _ => mem_wd.val_valid v'' m end.