eapply mem_forward_preserve; trivial.
Qed.

(* Specifications: *)
Lemma freelist_perm_inv: forall l m m' (L : Mem.free_list m l = Some m') b (B: Mem.valid_block m b)
ofs k p (P: Mem.perm m b ofs k p),
Mem.perm m b ofs Max Freeable \/ Mem.perm m' b ofs k p.
Theorem preserves_max_eq_or_free:
memstep_preserve (fun m m' =>  mem_forward m m' /\
forall b (VB: Mem.valid_block m b) ofs,
(forall k p, Mem.perm m b ofs k p <-> Mem.perm m' b ofs k p) \/
(Mem.perm m b ofs Max Freeable /\
Mem.perm_order'' None ((Mem.mem_access m') !! b ofs Max))).
Theorem mem_step_max_eq_or_free m m' (STEP: mem_step m m') b (VB: Mem.valid_block m b) ofs:
(forall k p, Mem.perm m b ofs k p <-> Mem.perm m' b ofs k p) \/
(Mem.perm m b ofs Max Freeable /\ None = ((Mem.mem_access m') !! b ofs Max)).
Lemma memsem_preserves {C} (s: @MemSem C) P (HP:memstep_preserve P):
forall c m c' m', corestep s c m c' m'-> P m m'.
Lemma corestep_fwd {C} (s:@MemSem C) c m c' m'
(CS:corestep s c m c' m' ): mem_forward m m'.
Lemma corestep_rdonly {C} (s:@MemSem C) c m c' m'
(CS:corestep s c m c' m') b (VB:Mem.valid_block m b): readonly m b m'.
Lemma mem_step_nextblock:  memstep_preserve (fun m m' => Mem.nextblock m <= Mem.nextblock m')%positive.
constructor.
Lemma freelist_perm_inv: forall l m m' (L : Mem.free_list m l = Some m') b (B: Mem.valid_block m b)
ofs k p (P: Mem.perm m b ofs k p),
Mem.perm m b ofs Max Freeable \/ Mem.perm m' b ofs k p.
Theorem preserves_max_eq_or_free:
memstep_preserve (fun m m' =>  mem_forward m m' /\
forall b (VB: Mem.valid_block m b) ofs,
(forall k p, Mem.perm m b ofs k p <-> Mem.perm m' b ofs k p) \/
(Mem.perm m b ofs Max Freeable /\
Mem.perm_order'' None ((Mem.mem_access m') !! b ofs Max))).
Theorem mem_step_max_eq_or_free m m' (STEP: mem_step m m') b (VB: Mem.valid_block m b) ofs:
(forall k p, Mem.perm m b ofs k p <-> Mem.perm m' b ofs k p) \/
(Mem.perm m b ofs Max Freeable /\ None = ((Mem.mem_access m') !! b ofs Max)).
Lemma memsem_preserves {C} (s: @MemSem C) P (HP:memstep_preserve P):
forall c m c' m', corestep s c m c' m'-> P m m'.
Lemma corestep_fwd {C} (s:@MemSem C) c m c' m'
(CS:corestep s c m c' m' ): mem_forward m m'.
Lemma corestep_rdonly {C} (s:@MemSem C) c m c' m'
(CS:corestep s c m c' m') b (VB:Mem.valid_block m b): readonly m b m'.
Lemma mem_step_nextblock:  memstep_preserve (fun m m' => Mem.nextblock m <= Mem.nextblock m')%positive.
constructor.