mem_unchanged_on,loc_out-of_bounds etc etc*)
Goal forall m b ofs p (H: ~ Mem.perm m b ofs p Nonempty), PMap.get b (Mem.mem_access m) ofs p = None.
intros. unfold Mem.perm in *.
remember (PMap.get b (Mem.mem_access m) ofs p) as pp.
destruct pp; simpl in *. exfalso. apply H. apply perm_any_N.
trivial.
Qed.
Definition isSource j m1 (b2:block) (ofs2:Z) b : option Z :=
match j b with None => None
| Some (bb,delta) => if eq_block b2 bb
then if Mem.perm_dec m1 b (ofs2 - delta) Max Nonempty
then Some (ofs2 - delta)  else None
else None
end.
Definition sourceN (n:block) (j:meminj) (m:mem)
(b2:block) (ofs2:Z): option(block * Z) :=
Pos.peano_rect
(fun p => option(block * Z))
(match isSource j m b2 ofs2 1%positive
with Some ofs1 => Some(1%positive, ofs1)
| None => None
end)
(fun p Hp => match isSource j m b2 ofs2 (Pos.succ p)
with Some ofs1 => Some (Pos.succ p, ofs1)
| None => Hp
end)
n.
Definition  source j m (b2:block) (ofs2:Z) : option(block * Z) :=
if plt 1%positive (Mem.nextblock m)
then sourceN (Pos.pred (Mem.nextblock m)) j m b2 ofs2
else None.

Lemma perm_splitA: forall m b ofs k' p m2' m2 m3' k b3 ofs3
(SPLIT: (Mem.perm m b ofs k' p-> PMap.get b (Mem.mem_access m2') ofs k = PMap.get b (Mem.mem_access m2) ofs k) /\
(~Mem.perm m b ofs k' p -> PMap.get b (Mem.mem_access m2') ofs k = PMap.get b3 (Mem.mem_access m3') ofs3 k))
(P:Prop)
(HA: Mem.perm m b ofs k' p -> Mem.perm m2' b ofs k = Mem.perm m2 b ofs k -> P)
(HB: ~Mem.perm m b ofs k' p -> Mem.perm m2' b ofs k = Mem.perm m3' b3 ofs3 k  -> P), P.