(** Test (conservatively) whether some locations in the range delimited by [p] and [sz] can be live in [nm]. *)
Definition nmem_contains (nm: nmem) (p: aptr) (sz: Z) :=
match nm with
| NMemDead => false
| NMem stk gl =>
match p with
| Gl id ofs =>
match gl!id with
| Some iv => negb (ISet.contains (Ptrofs.unsigned ofs) (Ptrofs.unsigned ofs + sz) iv)
| None => true
end
| Stk ofs =>
negb (ISet.contains (Ptrofs.unsigned ofs) (Ptrofs.unsigned ofs + sz) stk)
| _ => true  (**r conservative answer *)
end
end.

Lemma nlive_contains:
forall bc b ofs p nm sz i,
genv_match bc ge ->
bc sp = BCstack ->
pmatch bc b ofs p ->
nmem_contains nm p sz = false ->
Ptrofs.unsigned ofs <= i < Ptrofs.unsigned ofs + sz ->
~(nlive nm b i).