Require Import VST.veric.base.
Require Import VST.veric.Memory.
Require Import VST.veric.juicy_base.
Require Import VST.veric.shares.
Import cjoins.

(* Goal: max_access_cohere m' inflate_free *)
Definition dec_share_nonidentity (sh: Share.t) : {~identity sh}+{identity sh} :=
   (Sumbool.sumbool_not _ _ (dec_share_identity sh)).

Definition perm_of_sh (sh: Share.t): option permission :=
  if writable0_share_dec sh
  then if eq_dec sh Share.top
            then Some Freeable
            else Some Writable
    else if readable_share_dec sh
         then Some Readable
         else if eq_dec sh Share.bot
                   then None
              else Some Nonempty.
Functional Scheme perm_of_sh_ind := Induction for perm_of_sh Sort Prop.

Definition contents_at (m: mem) (loc: address) : memval :=
  ZMap.get (snd loc) (PMap.get (fst loc) (mem_contents m)).

Definition contents_cohere (m: mem) (phi: rmap) :=
  forall rsh sh v loc pp, phi @ loc = YES rsh sh (VAL v) pp -> contents_at m loc = v /\ pp=NoneP.

Definition valshare (r: resource) : share :=
    match r with
      | YES sh rsh _ _ => Share.glb Share.Rsh sh
      | _ => Share.bot
    end.

Definition res_retain' (r: resource) : Share.t :=
 match r with
  | NO sh _ => sh
  | YES sh _ _ _ => Share.glb Share.Lsh sh
  | PURE _ _ => Share.top
 end.

Definition perm_of_res (r: resource) :=
  (*  perm_of_sh (res_retain' r) (valshare r). *)
 match r with
 | NO sh _ => if eq_dec sh Share.bot then None else Some Nonempty
 | PURE _ _ => Some Nonempty
 | YES sh rsh (VAL _) _ => perm_of_sh sh
 | YES sh rsh _ _ => Some Nonempty
 end.

(*To do a case analysis over perm_of_res, use:
functional induction (perm_of_res_explicit r1) using perm_of_res_expl_ind 
We define the induction shceme bellow. *)
Definition perm_of_res_lock_explicit
             (r : compcert_rmaps.RML.R.resource):=
    match r with
    | compcert_rmaps.RML.R.NO _ _ => None
    | compcert_rmaps.RML.R.YES sh _ (compcert_rmaps.VAL _) _ => None
    | compcert_rmaps.RML.R.YES sh _ (compcert_rmaps.LK _ _) _ =>
      if writable0_share_dec (Share.glb Share.Rsh sh)
      then if eq_dec (Share.glb Share.Rsh sh) Share.top then Some Freeable else Some Writable
      else if readable_share_dec (Share.glb Share.Rsh sh) then Some Readable else
             if eq_dec  (Share.glb Share.Rsh sh) Share.bot then None else Some Nonempty
    | compcert_rmaps.RML.R.YES sh _ (compcert_rmaps.FUN _ _) _ => None
    | compcert_rmaps.RML.R.PURE _ _ => None
    end.
      
  Functional Scheme perm_of_res_lock_expl_ind := Induction for perm_of_res_lock_explicit Sort Prop.



Definition perm_of_res' (r: resource) :=
  (*  perm_of_sh (res_retain' r) (valshare r). *)
 match r with
 | NO sh _ => if eq_dec sh Share.bot then None else Some Nonempty
 | PURE _ _ => Some Nonempty
 | YES sh _ _ _ => perm_of_sh sh
 end.

Definition perm_of_res_lock (r: resource) := 
  (*  perm_of_sh (res_retain' r) (valshare r). *)
 match r with
 | YES sh rsh (LK _ _) _ => perm_of_sh (Share.glb Share.Rsh sh)
 | _ => None 
 end.
(*To do a case analysis over perm_of_res_lock, use:
functional induction (perm_of_res_lock_explicit r1) using perm_of_res_lock_expl_ind 
We define the induction shceme bellow. *)
Definition perm_of_res_explicit
               (r : compcert_rmaps.RML.R.resource):=
        match r with
        | compcert_rmaps.RML.R.NO sh _ => if eq_dec sh Share.bot then None else Some Nonempty
           | compcert_rmaps.RML.R.YES sh _ (compcert_rmaps.VAL _) _ =>
             if writable0_share_dec sh
             then if eq_dec sh Share.top then Some Freeable else Some Writable
             else
               if readable_share_dec sh
               then Some Readable
               else if eq_dec sh Share.bot then None else Some Nonempty
           | compcert_rmaps.RML.R.YES sh _ (compcert_rmaps.LK _ _) _ => Some Nonempty
           | compcert_rmaps.RML.R.YES sh _ (compcert_rmaps.FUN _ _) _ => Some Nonempty
           | compcert_rmaps.RML.R.PURE _ _ => Some Nonempty
        end.
      
Functional Scheme perm_of_res_expl_ind := Induction for perm_of_res_explicit Sort Prop.



(*Definition perm_of_res_lock (r: resource) :=
  (*  perm_of_sh (res_retain' r) (valshare r). *)
 match r with
 | NO sh => if eq_dec sh Share.bot then None else Some Nonempty
 | PURE _ _ => Some Nonempty
 | YES rsh sh (LK _) _ => perm_of_sh rsh (pshare_sh sh)
 | YES rsh sh (CT _) _ => perm_of_sh rsh (pshare_sh sh)
 | YES rsh sh _ _ => Some Nonempty
 end. *)

Lemma Rsh_not_top: Share.Rsh <> Share.top.
Proof.
(* Goal: not (@identity Share.t Share.Join_ba Share.Rsh) *)
unfold Share.Rsh.
(* Goal: not (@identity Share.t Share.Join_ba (@snd Share.t Share.t (Share.split Share.top))) *)
case_eq (Share.split Share.top); intros.
(* Goal: not (@identity Share.t Share.Join_ba (@snd Share.t Share.t (@pair Share.t Share.t t t0))) *)
simpl; intro. subst.
(* Goal: False *)
apply nonemp_split_neq2 in H.
(* Goal: False *)
(* Goal: @nonidentity Share.t Share.Join_ba pa_share Share.top *)
apply H; auto.
(* Goal: @nonidentity Share.t Share.Join_ba pa_share Share.top *)
apply top_share_nonidentity.
Qed.

Lemma nonidentity_Rsh: ~identity Share.Rsh.
Proof.
(* Goal: not (@identity Share.t Share.Join_ba Share.Rsh) *)
unfold Share.Rsh.
(* Goal: not (@identity Share.t Share.Join_ba (@snd Share.t Share.t (Share.split Share.top))) *)
case_eq (Share.split Share.top); intros.
(* Goal: not (@identity Share.t Share.Join_ba (@snd Share.t Share.t (@pair Share.t Share.t t t0))) *)
simpl; intro.
(* Goal: False *)
apply split_nontrivial' in H.
(* Goal: False *)
(* Goal: or (@identity Share.t Share.Join_ba t) (@identity Share.t Share.Join_ba t0) *)
apply top_share_nonidentity; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.
Qed.

Lemma perm_of_sh_fullshare: perm_of_sh fullshare = Some Freeable.
(* Goal: @eq (option permission) (perm_of_sh Share.bot) (@None permission) *)
Proof. unfold perm_of_sh.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  rewrite if_true. rewrite if_true by auto. auto.
(* Goal: writable0_share fullshare *)
   unfold fullshare.
(* Goal: writable0_share Share.top *)
   apply writable_writable0.
(* Goal: writable_share Share.top *)
   apply writable_share_top.
Qed.

Lemma nonreadable_extern_retainer: ~readable_share extern_retainer.
(* Goal: not (readable_share extern_retainer) *)
unfold extern_retainer, readable_share.
(* Goal: not (nonempty_share (Share.glb Share.Rsh (@fst Share.t Share.t (Share.split Share.Lsh)))) *)
intro H; apply H; clear H.
assert (Share.glb Share.Rsh
     (fst (Share.split Share.Lsh)) = Share.bot); [ | rewrite H; auto].
(* Goal: @eq Share.t (Share.glb Share.Rsh (@fst Share.t Share.t (Share.split Share.Lsh))) Share.bot *)
apply sub_glb_bot with Share.Lsh.
(* Goal: @join share Share.Join_ba (@fst Share.t Share.t (Share.split Share.Lsh)) (@snd Share.t Share.t (Share.split Share.Lsh)) Share.Lsh *)
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) Share.bot *)
destruct (Share.split Share.Lsh) eqn:H.
(* Goal: Share.Ord t Share.Lsh *)
(* Goal: Share.Ord Share.Rsh Share.Rsh *)
(* Goal: Share.Ord Share.bot (Share.glb (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) *)
apply Share.split_together in H.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
simpl.
(* Goal: @eq (option permission) (access_at m' (@pair block Z b ofs) Cur) (@None permission) *)
rewrite <- H.
(* Goal: writable0_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) *)
apply leq_join_sub.
(* Goal: Share.Ord t (Share.lub t t0) *)
(* Goal: Share.Ord Share.Rsh Share.Rsh *)
(* Goal: Share.Ord Share.bot (Share.glb (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) *)
apply Share.lub_upper1.
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) Share.bot *)
apply glb_Rsh_Lsh.
Qed.

Lemma Lsh_nonreadable: ~readable_share Share.Lsh.
Proof.
(* Goal: not (readable_share Share.Lsh) *)
unfold readable_share; intros.
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) (Share.glb Share.Rsh (@fst Share.t Share.t (Share.split Share.Lsh))) *)
rewrite glb_Rsh_Lsh.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.
Qed.

Lemma perm_of_res_op1:
  forall r,
    perm_order'' (perm_of_res' r) (perm_of_res r).
Proof.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
  destruct r eqn:?; simpl.
  - if_tac; constructor.
(* Goal: @eq (option permission) (perm_of_sh Share.bot) (@None permission) *)
  - unfold perm_of_sh.
(* Goal: @eq resource match (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then YES Share.top readable_share_top (VAL Undef) NoneP else resource_at phi loc) with | NO sh nsh => NO sh nsh | YES sh rsh k p => YES sh rsh k (preds_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) p) | PURE k p => PURE k (preds_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) p) end (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then YES Share.top readable_share_top (VAL Undef) NoneP else resource_at phi loc) *)
    if_tac. if_tac; destruct k; constructor.
(* Goal: @eq resource match (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then YES Share.top readable_share_top (VAL Undef) NoneP else resource_at phi loc) with | NO sh nsh => NO sh nsh | YES sh rsh k p => YES sh rsh k (preds_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) p) | PURE k p => PURE k (preds_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) p) end (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then YES Share.top readable_share_top (VAL Undef) NoneP else resource_at phi loc) *)
    if_tac. destruct k; constructor.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
    rewrite if_false by auto. destruct k; constructor.
  - constructor.
Qed.

Lemma perm_of_res_op2:
  forall r,
    perm_order'' (perm_of_res' r) (perm_of_res_lock r).
Proof.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  destruct r; simpl; auto.
  - if_tac; constructor.
  - destruct k; try solve [destruct (perm_of_sh sh); constructor].
(* Goal: @eq (option permission) (perm_of_sh Share.bot) (@None permission) *)
    unfold perm_of_sh.
(* Goal: @eq resource match (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then YES Share.top readable_share_top (VAL Undef) NoneP else resource_at phi loc) with | NO sh nsh => NO sh nsh | YES sh rsh k p => YES sh rsh k (preds_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) p) | PURE k p => PURE k (preds_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) p) end (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then YES Share.top readable_share_top (VAL Undef) NoneP else resource_at phi loc) *)
    if_tac. if_tac.
(* Goal: perm_order'' (if @eq_dec Share.t Share.EqDec_share sh Share.bot then @None permission else @Some permission Nonempty) (@None permission) *)
    repeat if_tac; constructor.
(* Goal: @eq (option permission) (if writable0_share_dec (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) then if @eq_dec Share.t Share.EqDec_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) Share.top then @Some permission Freeable else @Some permission Writable else if readable_share_dec (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) then @Some permission Readable else if @eq_dec Share.t Share.EqDec_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) Share.bot then @None permission else @Some permission Nonempty) (@Some permission Writable) *)
    rewrite if_true. rewrite if_false. constructor.
(* Goal: not (@eq Share.t (Share.glb Share.Rsh sh) Share.top) *)
(* Goal: writable0_share (Share.glb Share.Rsh sh) *)
(* Goal: perm_order'' (if readable_share_dec sh then @Some permission Readable else if @eq_dec Share.t Share.EqDec_share sh Share.bot then @None permission else @Some permission Nonempty) (if writable0_share_dec (Share.glb Share.Rsh sh) then if @eq_dec Share.t Share.EqDec_share (Share.glb Share.Rsh sh) Share.top then @Some permission Freeable else @Some permission Writable else if readable_share_dec (Share.glb Share.Rsh sh) then @Some permission Readable else if @eq_dec Share.t Share.EqDec_share (Share.glb Share.Rsh sh) Share.bot then @None permission else @Some permission Nonempty) *)
    apply glb_Rsh_not_top.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
    apply writable0_share_glb_Rsh; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
    rewrite if_true by auto.
(* Goal: @eq (option permission) (if writable0_share_dec (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) then if @eq_dec Share.t Share.EqDec_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) Share.top then @Some permission Freeable else @Some permission Writable else if readable_share_dec (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) then @Some permission Readable else if @eq_dec Share.t Share.EqDec_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) Share.bot then @None permission else @Some permission Nonempty) (@Some permission Writable) *)
    rewrite if_false. rewrite if_true. constructor.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
    unfold readable_share. rewrite glb_twice; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
    contradict H. unfold writable0_share in *. eapply join_sub_trans; eauto.
(* Goal: writable0_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) *)
    apply leq_join_sub. apply Share.glb_lower2.
Qed.

Definition access_cohere (m: mem)  (phi: rmap) :=
  forall loc,  access_at m loc Cur = perm_of_res (phi @ loc).

Definition max_access_at m loc := access_at m loc Max.

Definition max_access_cohere (m: mem) (phi: rmap)  :=
  forall loc,
    perm_order'' (max_access_at m loc) (perm_of_res' (phi @ loc)).

(*
Definition max_access_cohere (m: mem) (phi: rmap)  :=
  forall loc,
   match phi @ loc with
   | YES rsh sh _ _ => perm_order'' (max_access_at m loc) (perm_of_sh rsh (pshare_sh sh))
   | NO rsh => perm_order'' (max_access_at m loc) (perm_of_sh rsh Share.bot )
   | PURE _ _ => (fst loc < nextblock m)%positive
  end. *)

Definition alloc_cohere (m: mem) (phi: rmap) :=
 forall loc,  (fst loc >= nextblock m)%positive -> phi @ loc = NO Share.bot bot_unreadable.

Inductive juicy_mem: Type :=
  mkJuicyMem: forall (m: mem) (phi: rmap)
    (JMcontents: contents_cohere m phi)
    (JMaccess: access_cohere m phi)
    (JMmax_access: max_access_cohere m phi)
    (JMalloc: alloc_cohere m phi),
       juicy_mem.

Section selectors.
Variable (j: juicy_mem).
Definition m_dry := match j with mkJuicyMem m _ _ _ _ _ => m end.
Definition m_phi := match j with mkJuicyMem _ phi _ _ _ _ => phi end.
Lemma juicy_mem_contents: contents_cohere m_dry m_phi.
Proof. unfold m_dry, m_phi; destruct j; auto. Qed.
Lemma juicy_mem_access: access_cohere m_dry m_phi.
Proof. unfold m_dry, m_phi; destruct j; auto. Qed.
Lemma juicy_mem_max_access: max_access_cohere m_dry m_phi.
Proof. unfold m_dry, m_phi; destruct j; auto. Qed.
Lemma juicy_mem_alloc_cohere: alloc_cohere m_dry m_phi.
Proof. unfold m_dry, m_phi; destruct j; auto. Qed.
End selectors.

Definition juicy_mem_resource: forall jm m', resource_at m' = resource_at (m_phi jm) ->
(* Goal: max_access_cohere m' inflate_free *)
  {jm' | m_phi jm' = m' /\ m_dry jm' = m_dry jm}.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
  intros.
(* Goal: @sig juicy_mem (fun jm' : juicy_mem => and (@eq rmap (m_phi jm') m') (@eq mem (m_dry jm') (m_dry jm))) *)
  assert (contents_cohere (m_dry jm) m') as Hcontents.
(* Goal: max_access_cohere m' inflate_free *)
  { intros ?????.
(* Goal: forall _ : @eq resource (resource_at m' loc) (YES rsh sh (VAL v) pp), and (@eq memval (contents_at (m_dry jm) loc) v) (@eq preds pp NoneP) *)
    rewrite H; apply juicy_mem_contents. }
(* Goal: @sig juicy_mem (fun jm' : juicy_mem => and (@eq rmap (m_phi jm') m') (@eq mem (m_dry jm') (m_dry jm))) *)
  assert (access_cohere (m_dry jm) m') as Haccess.
(* Goal: max_access_cohere m' inflate_free *)
  { intro.
    rewrite H; apply juicy_mem_access. }
(* Goal: @sig juicy_mem (fun jm' : juicy_mem => and (@eq rmap (m_phi jm') m') (@eq mem (m_dry jm') (m_dry jm))) *)
  assert (max_access_cohere (m_dry jm) m') as Hmax.
(* Goal: max_access_cohere m' inflate_free *)
  { intro.
    rewrite H; apply juicy_mem_max_access. }
(* Goal: @sig juicy_mem (fun jm' : juicy_mem => and (@eq rmap (m_phi jm') m') (@eq mem (m_dry jm') (m_dry jm))) *)
  assert (alloc_cohere (m_dry jm) m') as Halloc.
(* Goal: max_access_cohere m' inflate_free *)
  { intro.
    rewrite H; apply juicy_mem_alloc_cohere. }
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  exists (mkJuicyMem _ _ Hcontents Haccess Hmax Halloc); auto.
Defined.

Lemma perm_of_empty_inv {s} : perm_of_sh s = None -> s = Share.bot.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @eq Share.t s Share.bot *)
unfold perm_of_sh in*.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
if_tac in H; subst; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
if_tac in H; subst; auto.
(* Goal: @eq memval (contents_at m1 (@pair block Z b z)) (contents_at m2 (@pair block Z b z)) *)
inv H. inv H.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
if_tac in H; subst; auto.
(* Goal: @eq memval (contents_at m1 (@pair block Z b z)) (contents_at m2 (@pair block Z b z)) *)
inv H.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
if_tac in H; subst; auto. inv H.
Qed.

Lemma writable_join_sub: forall loc phi1 phi2,
  join_sub phi1 phi2 -> writable loc phi1 -> writable loc phi2.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
hnf in H0|-*.
(* Goal: match resource_at phi2 loc as anonymous' return (forall _ : @eq resource anonymous' (resource_at phi2 loc), Prop) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at phi2 loc) => False | YES sh wildcard' k lp => fun _ : @eq resource (YES sh wildcard' k lp) (resource_at phi2 loc) => and (writable0_share sh) (isVAL k) | PURE k p => fun _ : @eq resource (PURE k p) (resource_at phi2 loc) => False end (@eq_refl resource (resource_at phi2 loc)) *)
destruct H; generalize (resource_at_join _ _ _ loc H); clear H.
(* Goal: forall _ : @join resource Join_resource (resource_at phi1 loc) (resource_at x loc) (resource_at phi2 loc), match resource_at phi2 loc as anonymous' return (forall _ : @eq resource anonymous' (resource_at phi2 loc), Prop) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at phi2 loc) => False | YES sh wildcard' k lp => fun _ : @eq resource (YES sh wildcard' k lp) (resource_at phi2 loc) => and (writable0_share sh) (isVAL k) | PURE k p => fun _ : @eq resource (PURE k p) (resource_at phi2 loc) => False end (@eq_refl resource (resource_at phi2 loc)) *)
revert H0; destruct (phi1 @ loc); intros; try contradiction.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
destruct H0; subst.
(* Goal: @eq memval (contents_at m1 (@pair block Z b z)) (contents_at m2 (@pair block Z b z)) *)
inv H.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
split. eapply join_writable01; eauto. auto.
(* Goal: and (writable0_share sh3) (isVAL k) *)
contradiction (join_writable0_readable RJ H0 rsh2).
Qed.

Lemma writable_inv: forall phi loc, writable loc phi ->
  exists sh, exists rsh, exists k, exists pp, 
       phi @ loc = YES sh rsh k pp /\ 
       writable0_share sh /\
       isVAL k.
Proof.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
simpl.
(* Goal: forall (phi : rmap) (loc : address) (_ : match resource_at phi loc as anonymous' return (forall _ : @eq resource anonymous' (resource_at phi loc), Prop) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at phi loc) => False | YES wildcard' wildcard'0 k wildcard'1 => fun _ : @eq resource (YES wildcard' wildcard'0 k wildcard'1) (resource_at phi loc) => isVAL k | PURE k p => fun _ : @eq resource (PURE k p) (resource_at phi loc) => False end (@eq_refl resource (resource_at phi loc))), @ex Share.t (fun rsh : Share.t => @ex (readable_share rsh) (fun sh : readable_share rsh => @ex memval (fun v : memval => @ex preds (fun pp : preds => @eq resource (resource_at phi loc) (YES rsh sh (VAL v) pp))))) *)
intros phi loc H.
(* Goal: @ex Share.t (fun rsh : Share.t => @ex (readable_share rsh) (fun sh : readable_share rsh => @ex memval (fun v : memval => @ex preds (fun pp : preds => @eq resource (resource_at phi loc) (YES rsh sh (VAL v) pp))))) *)
destruct (phi @ loc); try solve [inversion H].
(* Goal: @eq bool (andb (@proj_sumbool (Z.le lo z) (Z.gt lo z) (zle lo z)) (@proj_sumbool (Z.lt z hi) (Z.ge z hi) (zlt z hi))) true *)
destruct H.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
do 4 eexists. split. reflexivity. split; auto.
Qed.

Lemma nreadable_inv: forall phi loc, ~readable loc phi 
  -> (exists sh, exists nsh, phi @ loc = NO sh nsh)
   \/ (exists sh, exists rsh, exists k, exists pp, phi @ loc = YES sh rsh k pp /\ ~isVAL k)
   \/ (exists k, exists pp, phi @ loc = PURE k pp).
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: or (@ex Share.t (fun sh : Share.t => @ex (not (readable_share sh)) (fun nsh : not (readable_share sh) => @eq resource (resource_at phi loc) (NO sh nsh)))) (or (@ex Share.t (fun sh : Share.t => @ex (readable_share sh) (fun rsh : readable_share sh => @ex AV.kind (fun k : AV.kind => @ex preds (fun pp : preds => and (@eq resource (resource_at phi loc) (YES sh rsh k pp)) (not (isVAL k))))))) (@ex AV.kind (fun k : AV.kind => @ex preds (fun pp : preds => @eq resource (resource_at phi loc) (PURE k pp))))) *)
simpl in H.
(* Goal: or (@ex Share.t (fun sh : Share.t => @ex (not (readable_share sh)) (fun nsh : not (readable_share sh) => @eq resource (resource_at phi loc) (NO sh nsh)))) (or (@ex Share.t (fun sh : Share.t => @ex (readable_share sh) (fun rsh : readable_share sh => @ex AV.kind (fun k : AV.kind => @ex preds (fun pp : preds => and (@eq resource (resource_at phi loc) (YES sh rsh k pp)) (not (isVAL k))))))) (@ex AV.kind (fun k : AV.kind => @ex preds (fun pp : preds => @eq resource (resource_at phi loc) (PURE k pp))))) *)
destruct (phi@loc); eauto 50.
Qed.

(* Goal: max_access_cohere m' inflate_free *)
Lemma age1_joinx {A}  {JA: Join A}{PA: Perm_alg A}{agA: ageable A}{AgeA: Age_alg A} : forall phi1 phi2 phi3 phi1' phi2' phi3',
             age phi1 phi1' -> age phi2 phi2' -> age phi3 phi3' ->
             join phi1 phi2 phi3 -> join phi1' phi2' phi3'.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @join A JA phi1' phi2' phi3' *)
destruct (age1_join _ H2 H) as [phi2'' [phi3'' [? [? ?]]]].
(* Goal: False *)
unfold age in *.
(* Goal: @eq preds pp NoneP *)
congruence.
Qed.

(* Goal: max_access_cohere m' inflate_free *)
Lemma constructive_age1_join  {A}  {JA: Join A}{PA: Perm_alg A}{agA: ageable A}{AgeA: Age_alg A} : forall x y z x' : A,
       join x y z ->
       age x x' ->
(* Goal: max_access_cohere m' inflate_free *)
       { yz' : A*A | join x' (fst yz') (snd yz') /\ age y (fst yz') /\ age z (snd yz')}.
Proof.
(* Goal: forall (x y z x' : A) (_ : @join A JA x y z) (_ : @age A agA x x'), @sig (prod A A) (fun yz' : prod A A => and (@join A JA x' (@fst A A yz') (@snd A A yz')) (and (@age A agA y (@fst A A yz')) (@age A agA z (@snd A A yz')))) *)
pose proof I.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @sig (prod A A) (fun yz' : prod A A => and (@join A JA x' (@fst A A yz') (@snd A A yz')) (and (@age A agA y (@fst A A yz')) (@age A agA z (@snd A A yz')))) *)
case_eq (age1 y); [intros y' ? | intros].
(* Goal: @sig (prod A A) (fun yz' : prod A A => and (@join A JA x' (@fst A A yz') (@snd A A yz')) (and (@age A agA y (@fst A A yz')) (@age A agA z (@snd A A yz')))) *)
(* Goal: @sig (prod A A) (fun yz' : prod A A => and (@join A JA x' (@fst A A yz') (@snd A A yz')) (and (@age A agA y (@fst A A yz')) (@age A agA z (@snd A A yz')))) *)
case_eq (age1 z); [intros z' ? | intros].
(* Goal: @sig (prod A A) (fun yz' : prod A A => and (@join A JA x' (@fst A A yz') (@snd A A yz')) (and (@age A agA y (@fst A A yz')) (@age A agA z (@snd A A yz')))) *)
(* Goal: @sig (prod A A) (fun yz' : prod A A => and (@join A JA x' (@fst A A yz') (@snd A A yz')) (and (@age A agA y (@fst A A yz')) (@age A agA z (@snd A A yz')))) *)
(* Goal: @sig (prod A A) (fun yz' : prod A A => and (@join A JA x' (@fst A A yz') (@snd A A yz')) (and (@age A agA y (@fst A A yz')) (@age A agA z (@snd A A yz')))) *)
exists (y',z').
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
simpl.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
split; auto.
(* Goal: @join A JA x' y' z' *)
(* Goal: @sig (prod A A) (fun yz' : prod A A => and (@join A JA x' (@fst A A yz') (@snd A A yz')) (and (@age A agA y (@fst A A yz')) (@age A agA z (@snd A A yz')))) *)
(* Goal: @sig (prod A A) (fun yz' : prod A A => and (@join A JA x' (@fst A A yz') (@snd A A yz')) (and (@age A agA y (@fst A A yz')) (@age A agA z (@snd A A yz')))) *)
apply (age1_joinx x y z x' y' z' H1 H2 H3 H0).
(* Goal: @sig (prod A A) (fun yz' : prod A A => and (@join A JA x' (@fst A A yz') (@snd A A yz')) (and (@age A agA y (@fst A A yz')) (@age A agA z (@snd A A yz')))) *)
elimtype False.
(* Goal: False *)
destruct (age1_join _ H0 H1) as [? [? [? [? ?]]]].
(* Goal: False *)
unfold age in *.
(* Goal: @eq preds pp NoneP *)
congruence.
(* Goal: @sig (prod A A) (fun yz' : prod A A => and (@join A JA x' (@fst A A yz') (@snd A A yz')) (and (@age A agA y (@fst A A yz')) (@age A agA z (@snd A A yz')))) *)
elimtype False.
(* Goal: False *)
destruct (age1_join _ H0 H1) as [? [? [? [? ?]]]].
(* Goal: False *)
unfold age in *.
(* Goal: @eq preds pp NoneP *)
congruence.
Qed.

(* Goal: max_access_cohere m' inflate_free *)
Lemma age1_constructive_joins_eq : forall {A}  {JA: Join A}{PA: Perm_alg A}{agA: ageable A}{AgeA: Age_alg A}  {phi1 phi2},
  constructive_joins phi1 phi2
  -> forall {phi1'}, age1 phi1 = Some phi1'
  -> forall {phi2'}, age1 phi2 = Some phi2'
  -> constructive_joins phi1' phi2'.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @constructive_joins A JA phi1' phi2' *)
destruct X as [? ?H].
(* Goal: @constructive_joins A JA phi1' phi2' *)
destruct (constructive_age1_join _ _ _ _ H1 H) as [[y z] [? [? ?]]].
(* Goal: forall (rsh : Share.t) (sh : readable_share rsh) (mv : memval) (loc' : address) (_ : not (adr_range (@pair block Z b ofs) (@Zlength memval bytes) loc')) (_ : @eq resource (resource_at (m_phi (mkJuicyMem m phi JMcontents JMaccess JMmax_access JMalloc)) loc') (YES rsh sh (VAL mv) NoneP)), @eq memval (contents_at m' loc') mv *)
simpl in *.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
unfold age in H3. rewrite H0 in H3; inv H3; econstructor; eauto.
Qed.


Program Definition age1_juicy_mem (j: juicy_mem): option juicy_mem :=
      match age1 (m_phi j) with
        | Some phi' => Some (mkJuicyMem (m_dry j) phi' _ _ _ _)
        | None => None
      end.
Next Obligation.  (* contents_cohere *)
 assert (necR (m_phi j) phi')
   by (constructor 1; symmetry in Heq_anonymous; apply Heq_anonymous).
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
 destruct j; hnf; simpl in *; intros.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
 case_eq (phi @ loc); intros.
(* Goal: @eq preds pp NoneP *)
 apply (necR_NO _ _ _ _ _ H) in H1. congruence.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
 generalize (necR_YES _ _ _ _ _ _ _ H H1); intros.
(* Goal: and (@eq memval (contents_at m loc) v) (@eq preds pp NoneP) *)
(* Goal: and (@eq memval (contents_at m loc) v) (@eq preds pp NoneP) *)
 rewrite H0 in H2. inv H2.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 destruct (JMcontents sh0 r v loc _ H1). subst; split; auto.
(* Goal: and (@eq memval (contents_at m loc) v) (@eq preds pp NoneP) *)
 rewrite (necR_PURE _ _ _ _ _ H H1) in H0. inv H0.
Qed.
Next Obligation. (* access_cohere *)
 assert (necR (m_phi j) phi')
   by (constructor 1; symmetry in Heq_anonymous; apply Heq_anonymous).
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
 destruct j; hnf; simpl in *; intros.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
 generalize (JMaccess loc); case_eq (phi @ loc); intros.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 apply (necR_NO _ _ loc _ _ H) in H0. rewrite H0; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 rewrite (necR_YES _ _ _ _ _ _ _ H H0); auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 rewrite (necR_PURE _ _ _ _ _ H H0); auto.
Qed.
Next Obligation. (* max_access_cohere *)
 assert (necR (m_phi j) phi')
   by (constructor 1; symmetry in Heq_anonymous; apply Heq_anonymous).
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
 destruct j; hnf; simpl in *; intros.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
 generalize (JMmax_access loc); case_eq (phi @ loc); intros.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 apply (necR_NO _ _ loc _ _ H) in H0. rewrite H0; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 rewrite (necR_YES _ _ _ _ _ _ _ H H0); auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 rewrite (necR_PURE _ _ _ _ _ H H0); auto.
Qed.
Next Obligation. (* alloc_cohere *)
 assert (necR (m_phi j) phi')
   by (constructor 1; symmetry in Heq_anonymous; apply Heq_anonymous).
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
 destruct j; hnf; simpl in *; intros.
(* Goal: @eq resource (resource_at phi' loc) (NO Share.bot bot_unreadable) *)
 specialize (JMalloc loc H0).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 apply (necR_NO _ _ loc _ _ H). auto.
Qed.

Lemma age1_juicy_mem_unpack: forall j j',
  age1_juicy_mem j = Some j' ->
  age (m_phi j)  (m_phi j')
  /\ m_dry j = m_dry j'.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: and (@age rmap ag_rmap (m_phi j) (m_phi j')) (@eq mem (m_dry j) (m_dry j')) *)
unfold age1_juicy_mem in H.
(* Goal: and (@age rmap ag_rmap (m_phi j) (m_phi j')) (@eq mem (m_dry j) (m_dry j')) *)
invSome.
(* Goal: @eq memval (contents_at m1 (@pair block Z b z)) (contents_at m2 (@pair block Z b z)) *)
inv H.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
split; simpl; auto.
(* Goal: @age rmap ag_rmap (m_phi j) r *)
symmetry in H0; apply H0.
Qed.

Lemma age1_juicy_mem_unpack': forall j j',
  age (m_phi j)  (m_phi j')  /\ m_dry j = m_dry j' ->
  age1_juicy_mem j = Some j'.
Proof.
(* Goal: forall j : juicy_mem, @eq nat (@level juicy_mem juicy_mem_ageable j) (@level rmap ag_rmap (m_phi j)) *)
  intuition.
(* Goal: @eq (option juicy_mem) (age1_juicy_mem j) (@None juicy_mem) *)
  unfold age1_juicy_mem.
(* Goal: @eq (option juicy_mem) (match @age1 rmap ag_rmap (m_phi j) as anonymous' return (forall _ : @eq (option rmap) anonymous' (@age1 rmap ag_rmap (m_phi j)), option juicy_mem) with | Some phi' => fun Heq_anonymous : @eq (option rmap) (@Some rmap phi') (@age1 rmap ag_rmap (m_phi j)) => @Some juicy_mem (mkJuicyMem (m_dry j) phi' (age1_juicy_mem_obligation_1 j phi' Heq_anonymous) (age1_juicy_mem_obligation_2 j phi' Heq_anonymous) (age1_juicy_mem_obligation_3 j phi' Heq_anonymous) (age1_juicy_mem_obligation_4 j phi' Heq_anonymous)) | None => fun _ : @eq (option rmap) (@None rmap) (@age1 rmap ag_rmap (m_phi j)) => @None juicy_mem end (@eq_refl (option rmap) (@age1 rmap ag_rmap (m_phi j)))) (@None juicy_mem) *)
  generalize (eq_refl (age1 (m_phi j))).
(* Goal: forall e : @eq (option rmap) (@age1 rmap ag_rmap (m_phi j)) (@age1 rmap ag_rmap (m_phi j)), @eq (option juicy_mem) (match @age1 rmap ag_rmap (m_phi j) as anonymous' return (forall _ : @eq (option rmap) anonymous' (@age1 rmap ag_rmap (m_phi j)), option juicy_mem) with | Some phi' => fun Heq_anonymous : @eq (option rmap) (@Some rmap phi') (@age1 rmap ag_rmap (m_phi j)) => @Some juicy_mem (mkJuicyMem (m_dry j) phi' (age1_juicy_mem_obligation_1 j phi' Heq_anonymous) (age1_juicy_mem_obligation_2 j phi' Heq_anonymous) (age1_juicy_mem_obligation_3 j phi' Heq_anonymous) (age1_juicy_mem_obligation_4 j phi' Heq_anonymous)) | None => fun _ : @eq (option rmap) (@None rmap) (@age1 rmap ag_rmap (m_phi j)) => @None juicy_mem end e) (@None juicy_mem) *)
  pattern (age1 (m_phi j)) at 1 3.
(* Goal: forall e : @eq (option rmap) (@Some rmap (m_phi j')) (@age1 rmap ag_rmap (m_phi j)), @eq (option juicy_mem) (@Some juicy_mem (mkJuicyMem (m_dry j) (m_phi j') (age1_juicy_mem_obligation_1 j (m_phi j') e) (age1_juicy_mem_obligation_2 j (m_phi j') e) (age1_juicy_mem_obligation_3 j (m_phi j') e) (age1_juicy_mem_obligation_4 j (m_phi j') e))) (@Some juicy_mem j') *)
  rewrite H0;  clear H0. intros H0.
(* Goal: @eq resource (YES sh2 (@writable0_readable sh2 wsh2) (VAL v2') NoneP) (YES sh2 (@writable0_readable sh2 wsh) (VAL v2') NoneP) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
  f_equal.
(* Goal: @eq juicy_mem (mkJuicyMem (m_dry j) (m_phi j') (age1_juicy_mem_obligation_1 j (m_phi j') H0) (age1_juicy_mem_obligation_2 j (m_phi j') H0) (age1_juicy_mem_obligation_3 j (m_phi j') H0) (age1_juicy_mem_obligation_4 j (m_phi j') H0)) j' *)
  destruct j, j'; simpl in *; subst; repeat f_equal; try apply proof_irr.
Qed.

Lemma age1_juicy_mem_unpack'': forall j j',
  age (m_phi j)  (m_phi j')  -> m_dry j = m_dry j' ->
  age1_juicy_mem j = Some j'.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
  intros.
  apply age1_juicy_mem_unpack'.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 split; auto.
Qed.

(* TODO: move into rmaps_lemmas *)
Lemma rmap_join_eq_level: forall phi1 phi2: rmap, joins phi1 phi2 -> level phi1 = level phi2.
Proof.
(* Goal: forall (phi1 phi2 : rmap) (_ : @join_sub rmap Join_rmap phi1 phi2), @eq nat (@level rmap ag_rmap phi1) (@level rmap ag_rmap phi2) *)
intros until phi2; intro H.
(* Goal: @eq nat (@level rmap ag_rmap phi1) (@level rmap ag_rmap phi2) *)
destruct H as [? H].
(* Goal: @eq preds pp NoneP *)
apply join_level in H; destruct H; congruence.
Qed.

Lemma rmap_join_sub_eq_level: forall phi1 phi2: rmap,
          join_sub phi1 phi2 -> level phi1 = level phi2.
Proof.
(* Goal: forall (phi1 phi2 : rmap) (_ : @join_sub rmap Join_rmap phi1 phi2), @eq nat (@level rmap ag_rmap phi1) (@level rmap ag_rmap phi2) *)
intros until phi2; intro H.
(* Goal: @eq preds pp NoneP *)
destruct H; apply join_level in H; destruct H; congruence.
Qed.

Lemma age1_juicy_mem_None1:
  forall j, age1_juicy_mem j = None -> age1 (m_phi j) = None.
Proof.
(* Goal: forall (j : juicy_mem) (_ : @eq (option juicy_mem) (age1_juicy_mem j) (@None juicy_mem)), @eq (option rmap) (@age1 rmap ag_rmap (m_phi j)) (@None rmap) *)
intros j H.
(* Goal: @eq (option rmap) (@age1 rmap ag_rmap (m_phi j)) (@None rmap) *)
destruct j.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
simpl.
(* Goal: or (@ex Share.t (fun sh : Share.t => @ex (not (readable_share sh)) (fun nsh : not (readable_share sh) => @eq resource (resource_at phi loc) (NO sh nsh)))) (or (@ex Share.t (fun sh : Share.t => @ex (readable_share sh) (fun rsh : readable_share sh => @ex AV.kind (fun k : AV.kind => @ex preds (fun pp : preds => and (@eq resource (resource_at phi loc) (YES sh rsh k pp)) (not (isVAL k))))))) (@ex AV.kind (fun k : AV.kind => @ex preds (fun pp : preds => @eq resource (resource_at phi loc) (PURE k pp))))) *)
unfold age1_juicy_mem in H; simpl in H.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
revert H; generalize (refl_equal (age1 phi)); pattern (age1 phi) at 1 3; destruct (age1 phi); intros; auto.
(* Goal: @eq memval (contents_at m1 (@pair block Z b z)) (contents_at m2 (@pair block Z b z)) *)
inv H.
Qed.

Lemma age1_juicy_mem_None2:
  forall j, age1 (m_phi j) = None -> age1_juicy_mem j = None.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @eq (option juicy_mem) (age1_juicy_mem j) (@None juicy_mem) *)
unfold age1_juicy_mem.
(* Goal: @eq (option juicy_mem) (match @age1 rmap ag_rmap (m_phi j) as anonymous' return (forall _ : @eq (option rmap) anonymous' (@age1 rmap ag_rmap (m_phi j)), option juicy_mem) with | Some phi' => fun Heq_anonymous : @eq (option rmap) (@Some rmap phi') (@age1 rmap ag_rmap (m_phi j)) => @Some juicy_mem (mkJuicyMem (m_dry j) phi' (age1_juicy_mem_obligation_1 j phi' Heq_anonymous) (age1_juicy_mem_obligation_2 j phi' Heq_anonymous) (age1_juicy_mem_obligation_3 j phi' Heq_anonymous) (age1_juicy_mem_obligation_4 j phi' Heq_anonymous)) | None => fun _ : @eq (option rmap) (@None rmap) (@age1 rmap ag_rmap (m_phi j)) => @None juicy_mem end (@eq_refl (option rmap) (@age1 rmap ag_rmap (m_phi j)))) (@None juicy_mem) *)
generalize (eq_refl (age1 (m_phi j))).
(* Goal: forall e : @eq (option rmap) (@age1 rmap ag_rmap (m_phi j)) (@age1 rmap ag_rmap (m_phi j)), @eq (option juicy_mem) (match @age1 rmap ag_rmap (m_phi j) as anonymous' return (forall _ : @eq (option rmap) anonymous' (@age1 rmap ag_rmap (m_phi j)), option juicy_mem) with | Some phi' => fun Heq_anonymous : @eq (option rmap) (@Some rmap phi') (@age1 rmap ag_rmap (m_phi j)) => @Some juicy_mem (mkJuicyMem (m_dry j) phi' (age1_juicy_mem_obligation_1 j phi' Heq_anonymous) (age1_juicy_mem_obligation_2 j phi' Heq_anonymous) (age1_juicy_mem_obligation_3 j phi' Heq_anonymous) (age1_juicy_mem_obligation_4 j phi' Heq_anonymous)) | None => fun _ : @eq (option rmap) (@None rmap) (@age1 rmap ag_rmap (m_phi j)) => @None juicy_mem end e) (@None juicy_mem) *)
pattern (age1 (m_phi j)) at 1 3.
(* Goal: (fun o : option rmap => forall e : @eq (option rmap) o (@age1 rmap ag_rmap (m_phi j)), @eq (option juicy_mem) (match o as anonymous' return (forall _ : @eq (option rmap) anonymous' (@age1 rmap ag_rmap (m_phi j)), option juicy_mem) with | Some phi' => fun Heq_anonymous : @eq (option rmap) (@Some rmap phi') (@age1 rmap ag_rmap (m_phi j)) => @Some juicy_mem (mkJuicyMem (m_dry j) phi' (age1_juicy_mem_obligation_1 j phi' Heq_anonymous) (age1_juicy_mem_obligation_2 j phi' Heq_anonymous) (age1_juicy_mem_obligation_3 j phi' Heq_anonymous) (age1_juicy_mem_obligation_4 j phi' Heq_anonymous)) | None => fun _ : @eq (option rmap) (@None rmap) (@age1 rmap ag_rmap (m_phi j)) => @None juicy_mem end e) (@None juicy_mem)) (@age1 rmap ag_rmap (m_phi j)) *)
rewrite H.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.
Qed.

Lemma age1_juicy_mem_Some:
  forall j j', age1_juicy_mem j = Some j' -> age1 (m_phi j) = Some (m_phi j').
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: forall j : juicy_mem, @eq nat (@level juicy_mem juicy_mem_ageable j) (@level rmap ag_rmap (m_phi j)) *)
apply age1_juicy_mem_unpack in H; intuition.
Qed.


Lemma unage_juicy_mem: forall j' : juicy_mem,
   exists j : juicy_mem, age1_juicy_mem j = Some j'.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @ex juicy_mem (fun j : juicy_mem => @eq (option juicy_mem) (age1_juicy_mem j) (@Some juicy_mem j')) *)
destruct j' as [m phi'].
(* Goal: @ex juicy_mem (fun j : juicy_mem => @eq (option juicy_mem) (age1_juicy_mem j) (@Some juicy_mem (mkJuicyMem m phi' JMcontents JMaccess JMmax_access JMalloc))) *)
destruct (af_unage age_facts phi') as [phi ?].
assert (NEC: necR phi phi')  by (constructor 1; auto).
(* Goal: @ex juicy_mem (fun j : juicy_mem => @eq (option juicy_mem) (age1_juicy_mem j) (@Some juicy_mem (mkJuicyMem m phi' JMcontents JMaccess JMmax_access JMalloc))) *)
 rename H into Hage.
(* Goal: @ex juicy_mem (fun j : juicy_mem => @eq (option juicy_mem) (age1_juicy_mem j) (@Some juicy_mem (mkJuicyMem m phi' JMcontents JMaccess JMmax_access JMalloc))) *)
assert (contents_cohere m phi).
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
  hnf; intros.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
  generalize (necR_YES phi phi' loc rsh sh (VAL v) pp NEC H); intro.
(* Goal: and (@eq memval (contents_at m loc) v) (@eq preds pp NoneP) *)
(* Goal: @ex juicy_mem (fun j : juicy_mem => @eq (option juicy_mem) (age1_juicy_mem j) (@Some juicy_mem (mkJuicyMem m phi' JMcontents JMaccess JMmax_access JMalloc))) *)
  destruct (JMcontents _ _ _ _ _ H0).
(* Goal: and (@eq memval (contents_at m loc) v) (@eq preds pp NoneP) *)
(* Goal: @ex juicy_mem (fun j : juicy_mem => @eq (option juicy_mem) (age1_juicy_mem j) (@Some juicy_mem (mkJuicyMem m phi' JMcontents JMaccess JMmax_access JMalloc))) *)
  rewrite H2 in H0.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  split; auto.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
  generalize (necR_YES' _ _ loc rsh sh (VAL v) NEC); intro.
(* Goal: @eq preds pp NoneP *)
  apply H3 in H0. congruence.
(* Goal: @ex juicy_mem (fun j : juicy_mem => @eq (option juicy_mem) (age1_juicy_mem j) (@Some juicy_mem (mkJuicyMem m phi' JMcontents JMaccess JMmax_access JMalloc))) *)
assert (access_cohere m phi).
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
  hnf; intros.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
  generalize (JMaccess loc); intros.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
  case_eq (phi @ loc); intros.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  apply (necR_NO _ _ loc _ _ NEC) in H1. rewrite H1 in H0; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  apply (necR_YES _ _ _ _ _ _ _ NEC) in H1. rewrite H1 in H0; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  apply (necR_PURE _ _ _ _ _ NEC) in H1. rewrite H1 in H0; auto.
(* Goal: @ex juicy_mem (fun j : juicy_mem => @eq (option juicy_mem) (age1_juicy_mem j) (@Some juicy_mem (mkJuicyMem m phi' JMcontents JMaccess JMmax_access JMalloc))) *)
assert (max_access_cohere m phi).
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
  hnf; intros.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
  generalize (JMmax_access loc); intros.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
  case_eq (phi @ loc); intros.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  apply (necR_NO _ _ _ _ _ NEC) in H2; rewrite H2 in H1; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  rewrite (necR_YES _ _ _ _ _ _ _ NEC H2) in H1; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  rewrite (necR_PURE _ _ _ _ _ NEC H2) in H1; auto.
(* Goal: @ex juicy_mem (fun j : juicy_mem => @eq (option juicy_mem) (age1_juicy_mem j) (@Some juicy_mem (mkJuicyMem m phi' JMcontents JMaccess JMmax_access JMalloc))) *)
assert (alloc_cohere m phi).
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
  hnf; intros.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
  generalize (JMalloc loc H2); intros.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
  case_eq (phi @ loc); intros.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  apply (necR_NO _ _ _ _ _ NEC) in H4; rewrite H4 in H3; auto.
(* Goal: @eq resource (YES sh r k p) (NO Share.bot bot_unreadable) *)
(* Goal: @eq resource (PURE k p) (NO Share.bot bot_unreadable) *)
(* Goal: @ex juicy_mem (fun j : juicy_mem => @eq (option juicy_mem) (age1_juicy_mem j) (@Some juicy_mem (mkJuicyMem m phi' JMcontents JMaccess JMmax_access JMalloc))) *)
  rewrite (necR_YES _ _ _ _ _ _ _ NEC H4) in H3; inv H3.
(* Goal: @eq resource (PURE k p) (NO Share.bot bot_unreadable) *)
(* Goal: @ex juicy_mem (fun j : juicy_mem => @eq (option juicy_mem) (age1_juicy_mem j) (@Some juicy_mem (mkJuicyMem m phi' JMcontents JMaccess JMmax_access JMalloc))) *)
  rewrite (necR_PURE _ _ _ _ _ NEC H4) in H3; inv H3.
(* Goal: @ex juicy_mem (fun j : juicy_mem => @eq (option juicy_mem) (age1_juicy_mem j) (@Some juicy_mem (mkJuicyMem m phi' JMcontents JMaccess JMmax_access JMalloc))) *)
exists (mkJuicyMem m phi H H0 H1 H2).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
apply age1_juicy_mem_unpack''; simpl; auto.
Qed.

Lemma level1_juicy_mem: forall j: juicy_mem,
  age1_juicy_mem j = None <-> level (m_phi j) = 0%nat.
Proof.
(* Goal: forall j : juicy_mem, iff (@eq (option juicy_mem) (age1_juicy_mem j) (@None juicy_mem)) (@eq nat (@level rmap ag_rmap (m_phi j)) O) *)
intro x.
(* Goal: iff (@eq (option juicy_mem) (age1_juicy_mem x) (@None juicy_mem)) (@eq nat (@level rmap ag_rmap (m_phi x)) O) *)
split; intro H.
(* Goal: @eq nat (@level rmap ag_rmap (m_phi x)) O *)
(* Goal: @eq (option juicy_mem) (age1_juicy_mem x) (@None juicy_mem) *)
apply age1_level0.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
apply age1_juicy_mem_None1; auto.
(* Goal: @eq (option juicy_mem) (age1_juicy_mem x) (@None juicy_mem) *)
apply age1_level0 in H.
(* Goal: @eq (option juicy_mem) (age1_juicy_mem x) (@None juicy_mem) *)
apply age1_juicy_mem_None2.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.
Qed.

Lemma level2_juicy_mem: forall j1 j2: juicy_mem,
   age1_juicy_mem j1 = Some j2 -> level (m_phi j1) = S (level (m_phi j2)).
Proof.
(* Goal: forall (j1 j2 : juicy_mem) (_ : @eq (option juicy_mem) (age1_juicy_mem j1) (@Some juicy_mem j2)), @eq nat (@level rmap ag_rmap (m_phi j1)) (S (@level rmap ag_rmap (m_phi j2))) *)
intros x y H.
(* Goal: @eq nat (@level rmap ag_rmap (m_phi x)) (S (@level rmap ag_rmap (m_phi y))) *)
destruct (age1_juicy_mem_unpack x y H).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 apply age_level in H0. auto.
Qed.

Lemma juicy_mem_ageable_facts: ageable_facts juicy_mem (fun j => level (m_phi j)) age1_juicy_mem.
Proof.
(* Goal: perm_order Readable Readable *)
constructor.
(*apply age1_juicy_mem_wf.*)
(* Goal: forall x' : juicy_mem, @ex juicy_mem (fun x : juicy_mem => @eq (option juicy_mem) (age1_juicy_mem x) (@Some juicy_mem x')) *)
(* Goal: forall x : juicy_mem, iff (@eq (option juicy_mem) (age1_juicy_mem x) (@None juicy_mem)) (@eq nat (@level rmap ag_rmap (m_phi x)) O) *)
(* Goal: forall (x y : juicy_mem) (_ : @eq (option juicy_mem) (age1_juicy_mem x) (@Some juicy_mem y)), @eq nat (@level rmap ag_rmap (m_phi x)) (S (@level rmap ag_rmap (m_phi y))) *)
apply unage_juicy_mem.
(* Goal: forall x : juicy_mem, iff (@eq (option juicy_mem) (age1_juicy_mem x) (@None juicy_mem)) (@eq nat (@level rmap ag_rmap (m_phi x)) O) *)
(* Goal: forall (x y : juicy_mem) (_ : @eq (option juicy_mem) (age1_juicy_mem x) (@Some juicy_mem y)), @eq nat (@level rmap ag_rmap (m_phi x)) (S (@level rmap ag_rmap (m_phi y))) *)
apply level1_juicy_mem.
(* Goal: forall (x y : juicy_mem) (_ : @eq (option juicy_mem) (age1_juicy_mem x) (@Some juicy_mem y)), @eq nat (@level rmap ag_rmap (m_phi x)) (S (@level rmap ag_rmap (m_phi y))) *)
apply level2_juicy_mem.
Qed.

Instance juicy_mem_ageable: ageable juicy_mem :=
  mkAgeable _ (fun j => level (m_phi j)) age1_juicy_mem juicy_mem_ageable_facts.

Lemma level_juice_level_phi: forall (j: juicy_mem), level j = level (m_phi j).
Proof. intuition. Qed.

Lemma juicy_mem_ext: forall j1 j2,
       m_dry j1 = m_dry j2  ->
       m_phi j1 = m_phi j2 ->
       j1=j2.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: forall (rsh : Share.t) (sh : readable_share rsh) (mv : memval) (loc' : address) (_ : not (adr_range (@pair block Z b ofs) (@Zlength memval bytes) loc')) (_ : @eq resource (resource_at (m_phi (mkJuicyMem m phi JMcontents JMaccess JMmax_access JMalloc)) loc') (YES rsh sh (VAL mv) NoneP)), @eq memval (contents_at m' loc') mv *)
destruct j1; destruct j2; simpl in *.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
subst.
(* Goal: @eq resource (YES Share.top r (VAL m) p) (YES Share.top readable_share_top (VAL m) p) *)
f_equal; apply proof_irr.
Qed.

Lemma unage_writable: forall (phi phi': rmap) loc,
  age phi phi' -> writable loc phi' -> writable loc phi.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: forall (rsh : Share.t) (sh : readable_share rsh) (mv : memval) (loc' : address) (_ : not (adr_range (@pair block Z b ofs) (@Zlength memval bytes) loc')) (_ : @eq resource (resource_at (m_phi (mkJuicyMem m phi JMcontents JMaccess JMmax_access JMalloc)) loc') (YES rsh sh (VAL mv) NoneP)), @eq memval (contents_at m' loc') mv *)
simpl in *.
(* Goal: match resource_at phi loc as anonymous' return (forall _ : @eq resource anonymous' (resource_at phi loc), Prop) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at phi loc) => False | YES sh wildcard' k lp => fun _ : @eq resource (YES sh wildcard' k lp) (resource_at phi loc) => and (writable0_share sh) (isVAL k) | PURE k p => fun _ : @eq resource (PURE k p) (resource_at phi loc) => False end (@eq_refl resource (resource_at phi loc)) *)
apply age1_resource_at with (loc := loc) (r := phi @ loc) in H.
(* Goal: match resource_at phi loc as anonymous' return (forall _ : @eq resource anonymous' (resource_at phi loc), Prop) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at phi loc) => False | YES sh wildcard' k lp => fun _ : @eq resource (YES sh wildcard' k lp) (resource_at phi loc) => and (writable0_share sh) (isVAL k) | PURE k p => fun _ : @eq resource (PURE k p) (resource_at phi loc) => False end (@eq_refl resource (resource_at phi loc)) *)
(* Goal: @eq resource (resource_at phi loc) (resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (resource_at phi loc)) *)
destruct (phi' @ loc); try contradiction.
(* Goal: match resource_at phi loc as anonymous' return (forall _ : @eq resource anonymous' (resource_at phi loc), Prop) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at phi loc) => False | YES sh wildcard' k lp => fun _ : @eq resource (YES sh wildcard' k lp) (resource_at phi loc) => and (writable0_share sh) (isVAL k) | PURE k p => fun _ : @eq resource (PURE k p) (resource_at phi loc) => False end (@eq_refl resource (resource_at phi loc)) *)
(* Goal: @eq resource (resource_at phi loc) (resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (resource_at phi loc)) *)
unfold writable.
(* Goal: match resource_at phi loc as anonymous' return (forall _ : @eq resource anonymous' (resource_at phi loc), Prop) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at phi loc) => False | YES sh wildcard' k lp => fun _ : @eq resource (YES sh wildcard' k lp) (resource_at phi loc) => and (writable0_share sh) (isVAL k) | PURE k p => fun _ : @eq resource (PURE k p) (resource_at phi loc) => False end (@eq_refl resource (resource_at phi loc)) *)
(* Goal: @eq resource (resource_at phi loc) (resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (resource_at phi loc)) *)
destruct (phi @ loc); try discriminate.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
inv H. auto.
(* Goal: and (@eq memval (contents_at m loc) v) (@eq preds pp NoneP) *)
destruct (phi' @ loc); inv H0.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite resource_at_approx. auto.
Qed.

Lemma unage_readable: forall (phi phi': rmap) loc,
  age phi phi' -> readable loc phi' -> readable loc phi.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: forall (rsh : Share.t) (sh : readable_share rsh) (mv : memval) (loc' : address) (_ : not (adr_range (@pair block Z b ofs) (@Zlength memval bytes) loc')) (_ : @eq resource (resource_at (m_phi (mkJuicyMem m phi JMcontents JMaccess JMmax_access JMalloc)) loc') (YES rsh sh (VAL mv) NoneP)), @eq memval (contents_at m' loc') mv *)
simpl in *.
(* Goal: match resource_at phi loc as anonymous' return (forall _ : @eq resource anonymous' (resource_at phi loc), Prop) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at phi loc) => False | YES sh wildcard' k lp => fun _ : @eq resource (YES sh wildcard' k lp) (resource_at phi loc) => and (writable0_share sh) (isVAL k) | PURE k p => fun _ : @eq resource (PURE k p) (resource_at phi loc) => False end (@eq_refl resource (resource_at phi loc)) *)
apply age1_resource_at with (loc := loc) (r := phi @ loc) in H.
 2: symmetry; apply resource_at_approx.
(* Goal: and (@eq memval (contents_at m loc) v) (@eq preds pp NoneP) *)
destruct (phi' @ loc); try inv H0.
(* Goal: @eq memval (contents_at m1 (@pair block Z b z)) (contents_at m2 (@pair block Z b z)) *)
destruct (phi @ loc); try inv H.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.
Qed.

Lemma readable_inv: forall phi loc, readable loc phi ->
  exists rsh, exists sh, exists v, exists pp, phi @ loc = YES rsh sh (VAL v) pp.
Proof.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
simpl.
(* Goal: forall (phi : rmap) (loc : address) (_ : match resource_at phi loc as anonymous' return (forall _ : @eq resource anonymous' (resource_at phi loc), Prop) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at phi loc) => False | YES wildcard' wildcard'0 k wildcard'1 => fun _ : @eq resource (YES wildcard' wildcard'0 k wildcard'1) (resource_at phi loc) => isVAL k | PURE k p => fun _ : @eq resource (PURE k p) (resource_at phi loc) => False end (@eq_refl resource (resource_at phi loc))), @ex Share.t (fun rsh : Share.t => @ex (readable_share rsh) (fun sh : readable_share rsh => @ex memval (fun v : memval => @ex preds (fun pp : preds => @eq resource (resource_at phi loc) (YES rsh sh (VAL v) pp))))) *)
intros phi loc H.
(* Goal: @ex Share.t (fun rsh : Share.t => @ex (readable_share rsh) (fun sh : readable_share rsh => @ex memval (fun v : memval => @ex preds (fun pp : preds => @eq resource (resource_at phi loc) (YES rsh sh (VAL v) pp))))) *)
destruct (phi @ loc); try solve [inversion H].
(* Goal: @eq memval (contents_at m1 (@pair block Z b z)) (contents_at m2 (@pair block Z b z)) *)
destruct k; try inv H.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
eauto.
Qed.

(* resource coherence *)

(* FIXME: put somewhere else. *)
Definition fmap_option {A B} (v: option A) (m: B) (f: A -> B): B :=
  match v with
    | None => m
    | Some v' => f v'
  end.

Lemma resource_at_make_rmap: forall f g lev H Hg, resource_at (proj1_sig (make_rmap f g lev H Hg)) = f.
refine (fun f g lev H Hg => match proj2_sig (make_rmap f g lev H Hg) with
                           | conj _ (conj RESOURCE_AT _) => RESOURCE_AT
                         end).
Qed.

Lemma resource_at_remake_rmap: forall f g lev H Hg, resource_at (proj1_sig (remake_rmap f g lev H Hg)) = f.
refine (fun f g lev H Hg => match proj2_sig (remake_rmap f g lev H Hg) with
                           | conj _ (conj RESOURCE_AT _) => RESOURCE_AT
                         end).
Qed.

Lemma ghost_of_make_rmap: forall f g lev H Hg, ghost_of (proj1_sig (make_rmap f g lev H Hg)) = g.
refine (fun f g lev H Hg => match proj2_sig (make_rmap f g lev H Hg) with
                           | conj _ (conj _ RESOURCE_AT) => RESOURCE_AT
                         end).
Qed.

Lemma ghost_of_remake_rmap: forall f g lev H Hg, ghost_of (proj1_sig (remake_rmap f g lev H Hg)) = g.
refine (fun f g lev H Hg => match proj2_sig (remake_rmap f g lev H Hg) with
                           | conj _ (conj _ RESOURCE_AT) => RESOURCE_AT
                         end).
Qed.

Lemma level_make_rmap: forall f g lev H Hg, @level rmap _ (proj1_sig (make_rmap f g lev H Hg)) = lev.
refine (fun f g lev H Hg => match proj2_sig (make_rmap f g lev H Hg) with
                           | conj LEVEL _ => LEVEL
                         end).
Qed.

Lemma level_remake_rmap: forall f g lev H Hg, @level rmap _ (proj1_sig (remake_rmap f g lev H Hg)) = lev.
refine (fun f g lev H Hg => match proj2_sig (remake_rmap f g lev H Hg) with
                           | conj LEVEL _ => LEVEL
                         end).
Qed.

(* Here we build the [rmap]s that correspond to [store]s, [alloc]s and [free]s on the dry memory. *)
Section inflate.
Variables (m: mem) (phi: rmap).

Definition inflate_initial_mem' (w: rmap) (loc: address) :=
   match access_at m loc Cur with
           | Some Freeable => YES Share.top readable_share_top (VAL (contents_at m loc)) NoneP
           | Some Writable => YES Ews (writable_readable writable_Ews) (VAL (contents_at m loc)) NoneP
           | Some Readable => YES Ers readable_Ers (VAL (contents_at m loc)) NoneP
           | Some Nonempty => 
                         match w @ loc with PURE _ _ => w @ loc | _ => NO _ nonreadable_extern_retainer end
           | None =>  NO Share.bot bot_unreadable
         end.

Lemma inflate_initial_mem'_fmap:
 forall w, resource_fmap (approx (level w)) (approx (level w)) oo inflate_initial_mem' w =
                inflate_initial_mem' w.
Proof.
(* Goal: @eq (forall _ : AV.address, resource) (@compose AV.address resource resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc)) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) *)
unfold compose.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @eq (forall _ : address, resource) (fun x : address => resource_fmap (approx (@level rmap ag_rmap w)) (approx (@level rmap ag_rmap w)) (inflate_initial_mem' w x)) (inflate_initial_mem' w) *)
unfold inflate_initial_mem'.
(* Goal: @eq (forall _ : address, resource) (fun x : address => match (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) x then YES Share.top readable_share_top (VAL Undef) NoneP else resource_at (@core rmap Join_rmap Sep_rmap phi) x) with | NO sh nsh => NO sh nsh | YES sh rsh k p => YES sh rsh k (preds_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) p) | PURE k p => PURE k (preds_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) p) end) (fun loc : address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then YES Share.top readable_share_top (VAL Undef) NoneP else resource_at (@core rmap Join_rmap Sep_rmap phi) loc) *)
extensionality loc.
destruct (access_at m loc); try destruct p;
  try solve [unfold resource_fmap; f_equal; try apply preds_fmap_NoneP].
rewrite <- level_core.
(* Goal: @eq (option permission) (perm_of_res (PURE k p)) (@Some permission Nonempty) *)
(* Goal: @eq (option permission) (if @eq_dec Share.t Share.EqDec_share Share.bot Share.bot then @None permission else @Some permission Nonempty) (@None permission) *)
  case_eq (w @ loc);intros; try reflexivity.
(* Goal: @eq (option permission) (access_at m' (@pair block Z b ofs) Cur) (@None permission) *)
  rewrite <- H. rewrite level_core. apply resource_at_approx.
Qed.

Definition inflate_initial_mem (w: rmap): rmap :=
    proj1_sig (make_rmap (inflate_initial_mem' w) (ghost_of w) _
            (inflate_initial_mem'_fmap w) (ghost_of_approx w)).

Lemma inflate_initial_mem_level: forall w, level (inflate_initial_mem w) = level w.
Proof.
(* Goal: forall w : rmap, @eq nat (@level rmap ag_rmap (inflate_initial_mem w)) (@level rmap ag_rmap w) *)
intros; unfold inflate_initial_mem, inflate_initial_mem'.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite level_make_rmap; auto.
Qed.

Definition all_VALs (phi: rmap) :=
  forall l, match phi @ l with
              | YES _ _ k _ => isVAL k
              | _ => True
            end.

Lemma inflate_initial_mem_all_VALs: forall lev, all_VALs (inflate_initial_mem lev).
Proof.
(* Goal: forall lev : rmap, all_VALs (inflate_initial_mem lev) *)
unfold inflate_initial_mem, inflate_initial_mem', all_VALs.
(* Goal: forall (lev : rmap) (l : AV.address), match resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap lev)) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : address => match access_at m loc Cur with | Some (Freeable as p) => YES Share.top readable_share_top (VAL (contents_at m loc)) NoneP | Some (Writable as p) => YES Ews (@writable_readable Ews writable_Ews) (VAL (contents_at m loc)) NoneP | Some (Readable as p) => YES Ers readable_Ers (VAL (contents_at m loc)) NoneP | Some (Nonempty as p) => match resource_at lev loc with | NO sh n => NO extern_retainer nonreadable_extern_retainer | YES sh r k p0 => NO extern_retainer nonreadable_extern_retainer | PURE k p0 => resource_at lev loc end | None => NO Share.bot bot_unreadable end)) (@eq ghost (ghost_of phi) (ghost_of lev)))) (make_rmap (fun loc : address => match access_at m loc Cur with | Some (Freeable as p) => YES Share.top readable_share_top (VAL (contents_at m loc)) NoneP | Some (Writable as p) => YES Ews (@writable_readable Ews writable_Ews) (VAL (contents_at m loc)) NoneP | Some (Readable as p) => YES Ers readable_Ers (VAL (contents_at m loc)) NoneP | Some (Nonempty as p) => match resource_at lev loc with | NO sh n => NO extern_retainer nonreadable_extern_retainer | YES sh r k p0 => NO extern_retainer nonreadable_extern_retainer | PURE k p0 => resource_at lev loc end | None => NO Share.bot bot_unreadable end) (ghost_of lev) (@level rmap ag_rmap lev) (inflate_initial_mem'_fmap lev) (ghost_of_approx lev))) l with | NO sh n => True | YES sh r k p => isVAL k | PURE k p => True end *)
intros; rewrite resource_at_make_rmap.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
destruct (access_at m l); try destruct p; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 case (lev @ l); simpl; intros; auto.
Qed.

(* FIXME
   Build an rmap that's identical to phi except where m has allocated. *)
Definition inflate_alloc: rmap.
 refine (proj1_sig (remake_rmap (fun loc =>
   fmap_option (res_option (phi @ loc))

  (* phi = NO *)
  (fmap_option (access_at m loc Cur)
    (NO Share.bot bot_unreadable)
    (fun p => 
      match p with
        | Freeable => YES Share.top readable_share_top (VAL (contents_at m loc)) NoneP
        | _ => NO Share.Lsh Lsh_nonreadable
      end))

  (* phi = YES *)
  (fun _ => phi @ loc)) (ghost_of phi) (level phi) _ (ghost_of_approx phi))).
Proof.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
hnf; auto.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
intro.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
case_eq (phi @ l); simpl; intros; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
case_eq (access_at m l Cur); simpl; intros; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
right; destruct p; simpl; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
left; exists phi; split; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
right; destruct  (access_at m l Cur); simpl; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
destruct p0; simpl; auto.
Defined.

Lemma approx_map_idem: forall n (lp: preds),
  preds_fmap (approx n) (approx n) (preds_fmap (approx n) (approx n) lp) =
  preds_fmap (approx n) (approx n) lp.
Proof.
(* Goal: forall (n : nat) (lp : preds), @eq preds (preds_fmap (approx n) (approx n) (preds_fmap (approx n) (approx n) lp)) (preds_fmap (approx n) (approx n) lp) *)
intros n ls.
change (preds_fmap (approx n) (approx n) (preds_fmap (approx n) (approx n) ls))
with (((preds_fmap (approx n) (approx n)) oo (preds_fmap (approx n) (approx n))) ls).
(* Goal: @eq preds (@compose preds preds preds (preds_fmap (approx n) (approx n)) (preds_fmap (approx n) (approx n)) ls) (preds_fmap (approx n) (approx n) ls) *)
rewrite preds_fmap_comp.
(* Goal: @eq preds (preds_fmap (@compose (@pred rmap ag_rmap) (@pred rmap ag_rmap) (@pred rmap ag_rmap) (approx n) (approx n)) (@compose (@pred rmap ag_rmap) (@pred rmap ag_rmap) (@pred rmap ag_rmap) (approx n) (approx n)) ls) (preds_fmap (approx n) (approx n) ls) *)
rewrite (approx_oo_approx n).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.
Qed.

(* Build an [rmap] that's identical to [phi] except where [m] has stored. *)
Definition inflate_store: rmap. refine (
proj1_sig (make_rmap (fun loc =>
  match phi @ loc with
    | YES sh rsh (VAL _) _ => YES sh rsh (VAL (contents_at m loc)) NoneP
    | YES _ _ _ _ => resource_fmap (approx (level phi)) (approx (level phi)) (phi @ loc)
    | _ => phi @ loc
  end) (ghost_of phi) (level phi) _ (ghost_of_approx phi))).
Proof.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
hnf; auto.

(* Goal: @eq (forall _ : AV.address, resource) (@compose AV.address resource resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc)) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) *)
unfold compose.
(* Goal: @eq (forall _ : AV.address, resource) (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) x then NO Share.bot bot_unreadable else resource_at (m_phi jm) x)) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) *)
extensionality l.
(* Goal: @eq resource (resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) match resource_at phi l with | NO sh n => resource_at phi l | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m l)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (resource_at phi l) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (resource_at phi l) | PURE k p => resource_at phi l end) match resource_at phi l with | NO sh n => resource_at phi l | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m l)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (resource_at phi l) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (resource_at phi l) | PURE k p => resource_at phi l end *)
destruct l as (b, ofs).
(* Goal: @eq resource (resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) match resource_at phi (@pair block Z b ofs) with | NO sh n => resource_at phi (@pair block Z b ofs) | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (resource_at phi (@pair block Z b ofs)) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (resource_at phi (@pair block Z b ofs)) | PURE k p => resource_at phi (@pair block Z b ofs) end) match resource_at phi (@pair block Z b ofs) with | NO sh n => resource_at phi (@pair block Z b ofs) | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (resource_at phi (@pair block Z b ofs)) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (resource_at phi (@pair block Z b ofs)) | PURE k p => resource_at phi (@pair block Z b ofs) end *)
remember (phi @ (b, ofs)) as HPHI.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
destruct HPHI; auto.
(* YES *)
destruct k; try solve
  [ unfold resource_fmap; rewrite preds_fmap_NoneP; auto
  | unfold resource_fmap; rewrite approx_map_idem; auto ].
(* Goal: @eq resource (resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (PURE k p)) (PURE k p) *)
rewrite HeqHPHI.
(* Goal: @eq resource (resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (resource_at phi l)) (resource_at phi l) *)
apply resource_at_approx.
Defined.

End inflate.

Lemma adr_inv0: forall (b b': block) (ofs ofs': Z) (sz: Z),
  ~ adr_range (b, ofs) sz (b', ofs') ->
  b <> b' \/ ~ ofs <= ofs' < ofs + sz.
Proof.
(* Goal: forall (b b' : block) (ofs ofs' sz : Z) (_ : not (adr_range (@pair block Z b ofs) sz (@pair block Z b' ofs'))), or (not (@eq block b b')) (not (and (Z.le ofs ofs') (Z.lt ofs' (Z.add ofs sz)))) *)
intros until sz.
(* Goal: forall _ : not (adr_range loc n loc'), or (not (@eq block (@fst block Z loc) (@fst block Z loc'))) (and (@eq block (@fst block Z loc) (@fst block Z loc')) (not (and (Z.le (@snd block Z loc) (@snd block Z loc')) (Z.lt (@snd block Z loc') (Z.add (@snd block Z loc) n))))) *)
intro H.
(* Goal: or (not (@eq block b b')) (not (and (Z.le ofs ofs') (Z.lt ofs' (Z.add ofs sz)))) *)
destruct (peq b b').
(* Goal: or (not (@eq block b b')) (not (and (Z.le ofs ofs') (Z.lt ofs' (Z.add ofs sz)))) *)
(* Goal: or (not (@eq block b b')) (not (and (Z.le ofs ofs') (Z.lt ofs' (Z.add ofs sz)))) *)
right; intro Contra.
(* Goal: False *)
(* Goal: or (not (@eq block (@fst block Z loc) (@fst block Z loc'))) (and (@eq block (@fst block Z loc) (@fst block Z loc')) (not (and (Z.le (@snd block Z loc) (@snd block Z loc')) (Z.lt (@snd block Z loc') (Z.add (@snd block Z loc) n))))) *)
apply H.
(* Goal: forall (b : block) (lo hi : Z) (loc : address) (_ : adr_range (@pair block Z b lo) (Z.sub hi lo) loc), @eq bool (andb (@proj_sumbool (Z.le lo (@snd block Z loc)) (Z.gt lo (@snd block Z loc)) (zle lo (@snd block Z loc))) (@proj_sumbool (Z.lt (@snd block Z loc) hi) (Z.ge (@snd block Z loc) hi) (zlt (@snd block Z loc) hi))) true *)
unfold adr_range.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.
(* Goal: or (not (@eq block (@fst block Z loc) (@fst block Z loc'))) (and (@eq block (@fst block Z loc) (@fst block Z loc')) (not (and (Z.le (@snd block Z loc) (@snd block Z loc')) (Z.lt (@snd block Z loc') (Z.add (@snd block Z loc) n))))) *)
left; intro Contra.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
apply n; auto.
Qed.

Lemma adr_inv: forall (b b': block) (ofs ofs': Z) ch,
  ~ adr_range (b, ofs) (size_chunk ch) (b', ofs') ->
  b <> b' \/ ~ ofs <= ofs' < ofs + size_chunk ch.
Proof. intros until ch; intros H1; eapply adr_inv0; eauto. Qed.

Lemma range_inv0: forall ofs ofs' sz,
  ~ ofs <= ofs' < ofs + sz ->
  ofs' < ofs \/ ofs' >= ofs + sz.
Proof.
(* Goal: forall _ : not (adr_range loc n loc'), or (not (@eq block (@fst block Z loc) (@fst block Z loc'))) (and (@eq block (@fst block Z loc) (@fst block Z loc')) (not (and (Z.le (@snd block Z loc) (@snd block Z loc')) (Z.lt (@snd block Z loc') (Z.add (@snd block Z loc) n))))) *)
intros until sz; intro H.
(* Goal: or (Z.lt ofs' ofs) (Z.ge ofs' (Z.add ofs sz)) *)
destruct (zle ofs ofs'); destruct (zlt ofs' (ofs + sz)); omega.
Qed.

Lemma range_inv: forall ofs ofs' ch,
  ~ ofs <= ofs' < ofs + size_chunk ch ->
  ofs' < ofs \/ ofs' >= ofs + size_chunk ch.
Proof. intros; eapply range_inv0; eauto. Qed.

Lemma perm_of_sh_Freeable_top: forall sh, perm_of_sh sh = Some Freeable -> 
     sh = Share.top.
Proof.
(* Goal: forall (sh : Share.t) (_ : @eq (option permission) (perm_of_sh sh) (@Some permission Freeable)), @eq Share.t sh Share.top *)
intros sh H.
(* Goal: @eq Share.t sh Share.top *)
unfold perm_of_sh in H.
(* Goal: @eq Share.t sh Share.top *)
repeat if_tac in H; solve [inversion H | auto].
Qed.

Lemma nextblock_access_empty: forall m b ofs k, (b >= nextblock m)%positive
  -> access_at m (b, ofs) k = None.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
unfold access_at. simpl.
(* Goal: @eq (option permission) (@PMap.get (forall (_ : Z) (_ : perm_kind), option permission) b (mem_access m) ofs k) (@None permission) *)
apply (nextblock_noaccess m b ofs k).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.
Qed.

Section initial_mem.
Variables (m: mem) (w: rmap).

Definition initial_rmap_ok := 
   forall loc, ((fst loc >= nextblock m)%positive -> core w @ loc = NO Share.bot bot_unreadable) /\
                   (match w @ loc with 
                    | PURE _ _ => (fst loc < nextblock m)%positive /\ 
                                           access_at m loc Cur = Some Nonempty /\  
                                            max_access_at m loc = Some Nonempty 
                    | _ => True end).
Hypothesis IOK: initial_rmap_ok.
End initial_mem.

Definition empty_retainer (loc: address) := Share.bot.

Lemma perm_of_freeable: perm_of_sh Share.top = Some Freeable.
Proof.
(* Goal: @eq (option permission) (perm_of_sh Share.bot) (@None permission) *)
unfold perm_of_sh.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite if_true. rewrite if_true; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.
Qed.

Lemma perm_of_writable: 
   forall sh, writable_share sh -> sh <> Share.top -> perm_of_sh sh = Some Writable.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @eq (option permission) (perm_of_sh Share.bot) (@None permission) *)
unfold perm_of_sh.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite if_true by auto. rewrite if_false; auto.
Qed.

Lemma perm_of_readable:
  forall sh (rsh: readable_share sh), ~writable0_share sh -> perm_of_sh sh = Some Readable.
Proof.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
intros. unfold perm_of_sh. rewrite if_false by auto. rewrite if_true; auto.
Qed.

Lemma perm_of_nonempty:
  forall sh, sh <> Share.bot -> ~readable_share sh -> perm_of_sh sh = Some Nonempty.
Proof.
(* Goal: @eq (option permission) (perm_of_sh Share.bot) (@None permission) *)
intros. unfold perm_of_sh.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite if_false by auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite if_false by auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite if_false by auto; auto.
Qed.

Lemma perm_of_empty:
    perm_of_sh Share.bot = None.
Proof.
(* Goal: @eq (option permission) (perm_of_sh Share.bot) (@None permission) *)
intros. unfold perm_of_sh.
(* Goal: @eq (option permission) (if writable0_share_dec (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) (@fst Share.t Share.t (Share.split Share.Rsh))) then if @eq_dec Share.t Share.EqDec_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) (@fst Share.t Share.t (Share.split Share.Rsh))) Share.top then @Some permission Freeable else @Some permission Writable else if readable_share_dec (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) (@fst Share.t Share.t (Share.split Share.Rsh))) then @Some permission Readable else if @eq_dec Share.t Share.EqDec_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) (@fst Share.t Share.t (Share.split Share.Rsh))) Share.bot then @None permission else @Some permission Nonempty) (@Some permission Readable) *)
rewrite if_false. rewrite if_false.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite if_true; auto.
(* Goal: not (readable_share Share.bot) *)
(* Goal: not (writable0_share Share.bot) *)
apply bot_unreadable.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
intro.
(* Goal: False *)
apply writable0_readable in H.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
apply bot_unreadable in H; auto.
Qed.

Lemma perm_of_Ews: perm_of_sh Ews = Some Writable.
Proof.
(* Goal: @eq (option permission) (perm_of_sh Ews) (@Some permission Writable) *)
unfold perm_of_sh, Ews, extern_retainer.
(* Goal: @eq (option permission) (if writable0_share_dec (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) then if @eq_dec Share.t Share.EqDec_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) Share.top then @Some permission Freeable else @Some permission Writable else if readable_share_dec (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) then @Some permission Readable else if @eq_dec Share.t Share.EqDec_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) Share.bot then @None permission else @Some permission Nonempty) (@Some permission Writable) *)
rewrite if_true.
*
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite if_false; auto.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
intro.
(* Goal: False *)
rewrite Share.lub_commute in H.
(* Goal: False *)
pose proof lub_Lsh_Rsh. rewrite Share.lub_commute in H0.
rewrite <- H in H0.
(* Goal: False *)
apply Share.distrib_spec in H0.
(* Goal: forall (rsh : Share.t) (sh : readable_share rsh) (mv : memval) (loc' : address) (_ : not (adr_range (@pair block Z b ofs) (@Zlength memval bytes) loc')) (_ : @eq resource (resource_at (m_phi (mkJuicyMem m phi JMcontents JMaccess JMmax_access JMalloc)) loc') (YES rsh sh (VAL mv) NoneP)), @eq memval (contents_at m' loc') mv *)
destruct (Share.split Share.Lsh) eqn:?H; simpl in *.
(* Goal: False *)
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) (Share.glb Share.Rsh (@fst Share.t Share.t (Share.split Share.Lsh))) *)
pose proof (nonemp_split_neq1 Share.Lsh t t0).
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
spec H2. intro.
(* Goal: False *)
(* Goal: False *)
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) (Share.glb Share.Rsh (@fst Share.t Share.t (Share.split Share.Lsh))) *)
apply identity_share_bot in H3. contradiction Lsh_bot_neq.
(* Goal: False *)
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) (Share.glb Share.Rsh (@fst Share.t Share.t (Share.split Share.Lsh))) *)
subst t.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
apply H2; auto.
(* Goal: @nonidentity Share.t Share.Join_ba pa_share Share.Lsh *)
clear.
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) (Share.glb Share.Rsh (@fst Share.t Share.t (Share.split Share.Lsh))) *)
rewrite glb_Rsh_Lsh.
(* Goal: @eq Share.t Share.bot (Share.glb Share.Rsh (@fst Share.t Share.t (Share.split Share.Lsh))) *)
rewrite Share.glb_commute.
(* Goal: @eq (option permission) (perm_of_res (resource_at x addr)) (perm_of_res (resource_at y addr)) *)
symmetry.
(* Goal: @eq Share.t (Share.glb (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) Share.bot *)
apply Share.ord_antisym.
rewrite <- glb_Lsh_Rsh.
(* Goal: Share.Ord (Share.glb (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) (Share.glb Share.Lsh Share.Rsh) *)
(* Goal: Share.Ord Share.bot (Share.glb (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) *)
apply glb_less_both.
(* Goal: @join share Share.Join_ba (@fst Share.t Share.t (Share.split Share.Lsh)) (@snd Share.t Share.t (Share.split Share.Lsh)) Share.Lsh *)
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) Share.bot *)
destruct (Share.split Share.Lsh) eqn:H.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
simpl.
(* Goal: Share.Ord t Share.Lsh *)
(* Goal: Share.Ord Share.Rsh Share.Rsh *)
(* Goal: Share.Ord Share.bot (Share.glb (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) *)
apply Share.split_together in H.
(* Goal: @eq (option permission) (access_at m' (@pair block Z b ofs) Cur) (@None permission) *)
rewrite <- H.
(* Goal: Share.Ord t (Share.lub t t0) *)
(* Goal: Share.Ord Share.Rsh Share.Rsh *)
(* Goal: Share.Ord Share.bot (Share.glb (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) *)
apply Share.lub_upper1.
(* Goal: Share.Ord Share.Rsh Share.Rsh *)
(* Goal: Share.Ord Share.bot (Share.glb (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) *)
apply Share.ord_refl.
(* Goal: Share.Ord Share.bot (Share.glb (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) *)
apply Share.bot_correct.
*
(* Goal: not (writable0_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) (@fst Share.t Share.t (Share.split Share.Rsh)))) *)
unfold writable_share.
(* Goal: writable0_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) *)
apply leq_join_sub.
(* Goal: Share.Ord Share.Rsh (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Rsh) *)
apply Share.lub_upper2.
Qed.

Lemma perm_of_Ers: perm_of_sh Ers = Some Readable.
Proof.
(* Goal: @eq (option permission) (perm_of_sh Ers) (@Some permission Readable) *)
unfold perm_of_sh, Ers, extern_retainer.
(* Goal: @eq (option permission) (if writable0_share_dec (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) (@fst Share.t Share.t (Share.split Share.Rsh))) then if @eq_dec Share.t Share.EqDec_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) (@fst Share.t Share.t (Share.split Share.Rsh))) Share.top then @Some permission Freeable else @Some permission Writable else if readable_share_dec (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) (@fst Share.t Share.t (Share.split Share.Rsh))) then @Some permission Readable else if @eq_dec Share.t Share.EqDec_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) (@fst Share.t Share.t (Share.split Share.Rsh))) Share.bot then @None permission else @Some permission Nonempty) (@Some permission Readable) *)
rewrite if_false.
*
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite if_true; auto.
(* Goal: readable_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) (@fst Share.t Share.t (Share.split Share.Rsh))) *)
apply readable_share_lub.
(* Goal: readable_share (@fst Share.t Share.t (Share.split Share.Rsh)) *)
unfold readable_share.
(* Goal: nonempty_share (Share.glb Share.Rsh (@fst Share.t Share.t (Share.split Share.Rsh))) *)
rewrite glb_split_x.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
intro.
(* Goal: False *)
apply identity_share_bot in H.
(* Goal: False *)
(* Goal: @join_sub share Share.Join_ba (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Lsh *)
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) Share.bot *)
destruct (Share.split Share.Rsh) eqn:H0.
(* Goal: False *)
apply Share.split_nontrivial in H0.
(* Goal: False *)
(* Goal: or (@eq Share.t t Share.bot) (@eq Share.t t0 Share.bot) *)
unfold Share.Rsh in H0.
(* Goal: False *)
(* Goal: or (@eq Share.t t Share.bot) (@eq Share.t t0 Share.bot) *)
destruct (Share.split Share.top) eqn:H1.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
simpl in *. subst.
(* Goal: False *)
(* Goal: or (@eq Share.t t Share.bot) (@eq Share.t t0 Share.bot) *)
apply Share.split_nontrivial in H1.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
apply Share.nontrivial; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
simpl in H; auto.
*
(* Goal: not (writable0_share (Share.lub (@fst Share.t Share.t (Share.split Share.Lsh)) (@fst Share.t Share.t (Share.split Share.Rsh)))) *)
unfold writable_share.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
intro.
(* Goal: False *)
apply leq_join_sub in H.
(* Goal: False *)
apply Share.ord_spec2 in H.
(* Goal: False *)
apply (f_equal (Share.glb Share.Rsh)) in H.
(* Goal: False *)
rewrite Share.distrib1 in H.
(* Goal: False *)
rewrite Share.glb_idem in H.
(* Goal: False *)
rewrite Share.lub_absorb in H.
(* Goal: False *)
rewrite Share.distrib1 in H.
rewrite (@sub_glb_bot Share.Rsh (fst (Share.split Share.Lsh)) Share.Lsh)
 in H.
(* Goal: False *)
rewrite Share.lub_commute, Share.lub_bot in H.
(* Goal: False *)
(* Goal: @join_sub share Share.Join_ba (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Lsh *)
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) Share.bot *)
rewrite glb_split_x in H.
(* Goal: False *)
(* Goal: @join_sub share Share.Join_ba (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Lsh *)
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) Share.bot *)
destruct (Share.split Share.Rsh) eqn:H0.
(* Goal: False *)
(* Goal: @join_sub share Share.Join_ba (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Lsh *)
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) Share.bot *)
apply nonemp_split_neq1 in H0.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
simpl in *; subst. congruence.
(* Goal: @nonidentity Share.t Share.Join_ba pa_share Share.Rsh *)
(* Goal: @join_sub share Share.Join_ba (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Lsh *)
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) Share.bot *)
apply nonidentity_Rsh.
(* Goal: @nonidentity Share.t Share.Join_ba pa_share Share.Lsh *)
clear.
(* Goal: @join_sub share Share.Join_ba (@fst Share.t Share.t (Share.split Share.Lsh)) Share.Lsh *)
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) Share.bot *)
exists (snd (Share.split Share.Lsh)).
(* Goal: @join share Share.Join_ba (@fst Share.t Share.t (Share.split Share.Lsh)) (@snd Share.t Share.t (Share.split Share.Lsh)) Share.Lsh *)
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) Share.bot *)
destruct (Share.split Share.Lsh) eqn:H.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
simpl.
(* Goal: and (forall _ : Pos.ge (@fst block Z l) (nextblock (m_dry jm)), @eq resource (resource_at (m_phi jm) l) (NO Share.bot bot_unreadable)) (or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable)))))))) *)
split.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
eapply Share.split_disjoint; eauto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
eapply Share.split_together; eauto.
(* Goal: @eq Share.t (Share.glb Share.Rsh Share.Lsh) Share.bot *)
apply glb_Rsh_Lsh.
Qed.

Lemma extern_retainer_neq_bot: extern_retainer <> Share.bot.
Proof.
(* Goal: not (@eq Share.t extern_retainer Share.bot) *)
unfold extern_retainer.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
intro.
(* Goal: False *)
destruct (Share.split Share.Lsh) eqn:H0.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
simpl in *. subst.
(* Goal: False *)
pose proof (Share.split_together _ _ _ H0).
(* Goal: False *)
rewrite Share.lub_commute, Share.lub_bot in H.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
subst.
(* Goal: False *)
apply nonemp_split_neq2 in H0.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
contradiction H0; auto.
(* Goal: @nonidentity Share.t Share.Join_ba pa_share Share.Lsh *)
clear.
(* Goal: @nonidentity Share.t Share.Join_ba pa_share Share.Lsh *)
unfold Share.Lsh.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
intro.
(* Goal: False *)
apply identity_share_bot in H.
(* Goal: False *)
destruct (Share.split Share.top) eqn:H0.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
simpl in *; subst.
(* Goal: False *)
apply split_nontrivial' in H0.
(* Goal: False *)
(* Goal: or (@identity Share.t Share.Join_ba Share.bot) (@identity Share.t Share.Join_ba t0) *)
apply identity_share_bot in H0.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
apply Share.nontrivial; auto.
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) (@pair block Z b0 z))) (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z))) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) (@pair block Z b0 z))) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z (@pair block Z b0 z)) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) (@pair block Z b0 z)) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (NO Share.bot bot_unreadable))))))) *)
left.
(* Goal: @identity Share.t Share.Join_ba Share.bot *)
apply bot_identity.
Qed.

Lemma perm_order''_trans: forall a b c, Mem.perm_order'' a b ->  Mem.perm_order'' b c ->
                               Mem.perm_order'' a c.
Proof.
   intros a b c H1 H2; destruct a, b, c; inversion H1; inversion H2; subst; eauto;
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
             eapply perm_order_trans; eauto.
Qed.

Definition initial_mem (m: mem) lev (IOK: initial_rmap_ok m lev) : juicy_mem.
 refine (mkJuicyMem m  (inflate_initial_mem m lev) _ _ _ _);
  unfold inflate_initial_mem, inflate_initial_mem';
  hnf; intros;  try rewrite resource_at_make_rmap in *.
* (* contents_cohere *)
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
revert H; case_eq (access_at m loc Cur); intros.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 destruct p; inv H0; auto.
(* Goal: @eq preds pp NoneP *)
 revert H2; case_eq (lev @ loc); intros; congruence.
(* Goal: @eq preds pp NoneP *)
 destruct (max_access_at m loc); try destruct p; try congruence.
* (* access_cohere *)
(* Goal: @eq (option permission) (perm_of_res (resource_at x addr)) (perm_of_res (resource_at y addr)) *)
 symmetry.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
 destruct (access_at m loc) eqn:?; try destruct p; auto; simpl.
(* Goal: @eq (option permission) (perm_of_sh Share.top) (@Some permission Freeable) *)
(* Goal: @eq (option permission) (perm_of_sh Ews) (@Some permission Writable) *)
(* Goal: @eq (option permission) (perm_of_sh Ers) (@Some permission Readable) *)
(* Goal: @eq (option permission) (perm_of_res match resource_at lev loc with | NO sh n => NO extern_retainer nonreadable_extern_retainer | YES sh r k p => NO extern_retainer nonreadable_extern_retainer | PURE k p => resource_at lev loc end) (@Some permission Nonempty) *)
(* Goal: @eq (option permission) (if @eq_dec Share.t Share.EqDec_share Share.bot Share.bot then @None permission else @Some permission Nonempty) (@None permission) *)
 apply perm_of_freeable.
(* Goal: @eq (option permission) (perm_of_sh Ews) (@Some permission Writable) *)
(* Goal: @eq (option permission) (perm_of_sh Ers) (@Some permission Readable) *)
(* Goal: @eq (option permission) (perm_of_res match resource_at lev loc with | NO sh n => NO extern_retainer nonreadable_extern_retainer | YES sh r k p => NO extern_retainer nonreadable_extern_retainer | PURE k p => resource_at lev loc end) (@Some permission Nonempty) *)
(* Goal: @eq (option permission) (if @eq_dec Share.t Share.EqDec_share Share.bot Share.bot then @None permission else @Some permission Nonempty) (@None permission) *)
 apply perm_of_Ews.
(* Goal: @eq (option permission) (perm_of_sh Ers) (@Some permission Readable) *)
(* Goal: @eq (option permission) (perm_of_res match resource_at lev loc with | NO sh n => NO extern_retainer nonreadable_extern_retainer | YES sh r k p => NO extern_retainer nonreadable_extern_retainer | PURE k p => resource_at lev loc end) (@Some permission Nonempty) *)
(* Goal: @eq (option permission) (if @eq_dec Share.t Share.EqDec_share Share.bot Share.bot then @None permission else @Some permission Nonempty) (@None permission) *)
 apply perm_of_Ers.
(* Goal: perm_order'' (max_access_at m loc) (perm_of_res' match resource_at lev loc with | NO sh n => NO extern_retainer nonreadable_extern_retainer | YES sh r k p => NO extern_retainer nonreadable_extern_retainer | PURE k p => resource_at lev loc end) *)
 destruct (IOK loc).
(* Goal: @eq (option permission) (perm_of_res match resource_at lev loc with | NO sh n => NO extern_retainer nonreadable_extern_retainer | YES sh r k p => NO extern_retainer nonreadable_extern_retainer | PURE k p => resource_at lev loc end) (@Some permission Nonempty) *)
(* Goal: @eq (option permission) (if @eq_dec Share.t Share.EqDec_share Share.bot Share.bot then @None permission else @Some permission Nonempty) (@None permission) *)
 destruct (lev @ loc).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 simpl; rewrite if_false by apply extern_retainer_neq_bot; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 simpl; rewrite if_false by apply extern_retainer_neq_bot; auto.
(* Goal: @eq (option permission) (perm_of_res (PURE k p)) (@Some permission Nonempty) *)
(* Goal: @eq (option permission) (if @eq_dec Share.t Share.EqDec_share Share.bot Share.bot then @None permission else @Some permission Nonempty) (@None permission) *)
 reflexivity.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 rewrite if_true; auto.
* (* max_access_cohere *)
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
  { generalize (perm_cur_max m (fst loc) (snd loc)); unfold perm; intros.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
    case_eq (access_at m loc Cur); try destruct p; intros.
    - unfold perm_order'', perm_order', max_access_at in *.
(* Goal: match access_at m loc Max with | Some p1 => match perm_of_res' (YES Share.top readable_share_top (VAL (contents_at m loc)) NoneP) with | Some p2 => perm_order p1 p2 | None => True end | None => match perm_of_res' (YES Share.top readable_share_top (VAL (contents_at m loc)) NoneP) with | Some p => False | None => True end end *)
    simpl; rewrite perm_of_freeable.
(* Goal: False *)
(* Goal: or (not (@eq block (@fst block Z loc) (@fst block Z loc'))) (and (@eq block (@fst block Z loc) (@fst block Z loc')) (not (and (Z.le (@snd block Z loc) (@snd block Z loc')) (Z.lt (@snd block Z loc') (Z.add (@snd block Z loc) n))))) *)
    apply H.
(* Goal: perm_order Readable Readable *)
    unfold access_at in H0. rewrite H0. constructor.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
    - simpl. rewrite perm_of_Ews.
    unfold perm_order'', perm_order', max_access_at, access_at in *.
    rewrite H0 in *.
(* Goal: perm_order Readable Readable *)
    specialize (H Writable). spec H. constructor.
(* Goal: False *)
(* Goal: or (not (@eq block (@fst block Z loc) (@fst block Z loc'))) (and (@eq block (@fst block Z loc) (@fst block Z loc')) (not (and (Z.le (@snd block Z loc) (@snd block Z loc')) (Z.lt (@snd block Z loc') (Z.add (@snd block Z loc) n))))) *)
    apply H.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
     - simpl. rewrite perm_of_Ers.
    unfold perm_order'', perm_order', max_access_at, access_at in *.
    rewrite H0 in *.
(* Goal: perm_order Readable Readable *)
    apply H. constructor.
    - destruct (IOK loc).
(* Goal: perm_order'' (max_access_at m loc) (perm_of_res' match resource_at lev loc with | NO sh n => NO extern_retainer nonreadable_extern_retainer | YES sh r k p => NO extern_retainer nonreadable_extern_retainer | PURE k p => resource_at lev loc end) *)
    eapply perm_order''_trans; [apply (access_max m (fst loc) (snd loc))|].
(* Goal: match @PMap.get (forall (_ : Z) (_ : perm_kind), option permission) (@fst block Z loc) (mem_access m) (@snd block Z loc) Cur with | Some p' => perm_order p' Freeable | None => False end *)
    unfold access_at in H0; rewrite H0.
    destruct (lev @ loc) ; simpl;
(* Goal: perm_order Readable Readable *)
    try destruct (@eq_dec Share.t Share.EqDec_share extern_retainer Share.bot); try constructor.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
    - simpl. destruct (eq_dec Share.bot Share.bot) as [e|n]; [| exfalso; apply n; reflexivity].
      rewrite <- H0.
(* Goal: perm_order'' (max_access_at m loc) (access_at m loc Cur) *)
      apply (access_max m).
  }
* (* alloc_cohere *)
(* Goal: @eq resource match access_at m loc Cur with | Some (Freeable as p) => YES Share.top readable_share_top (VAL (contents_at m loc)) NoneP | Some (Writable as p) => YES Ews (@writable_readable Ews writable_Ews) (VAL (contents_at m loc)) NoneP | Some (Readable as p) => YES Ers readable_Ers (VAL (contents_at m loc)) NoneP | Some (Nonempty as p) => match resource_at lev loc with | NO sh n => NO extern_retainer nonreadable_extern_retainer | YES sh r k p0 => NO extern_retainer nonreadable_extern_retainer | PURE k p0 => resource_at lev loc end | None => NO Share.bot bot_unreadable end (NO Share.bot bot_unreadable) *)
unfold access_at.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
unfold block; rewrite (nextblock_noaccess m (fst loc) (snd loc) Cur); auto.
Defined.

Definition juicy_mem_level (j: juicy_mem) (lev: nat) :=
  level (m_phi j) = lev.

Lemma initial_mem_level: forall lev m j IOK,
  j = initial_mem m lev IOK -> juicy_mem_level j (level lev).
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
destruct j; simpl.
(* Goal: juicy_mem_level (mkJuicyMem m0 phi JMcontents JMaccess JMmax_access JMalloc) (@level rmap ag_rmap lev) *)
unfold initial_mem in H.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
inversion H; subst.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
unfold juicy_mem_level. simpl.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
erewrite inflate_initial_mem_level; eauto.
Qed.

Lemma initial_mem_all_VALs: forall lev m j IOK, j = initial_mem m lev IOK
  -> all_VALs (m_phi j).
Proof.
(* Goal: forall (lev : rmap) (m : mem) (j : juicy_mem) (IOK : initial_rmap_ok m lev) (_ : @eq juicy_mem j (initial_mem m lev IOK)), all_VALs (m_phi j) *)
intros until 1; intros (b, ofs).
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
destruct j; unfold initial_mem in H; inversion H; subst.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
simpl.
(* Goal: match resource_at (inflate_initial_mem m lev) (@pair block Z b ofs) with | NO sh n => True | YES sh r k p => isVAL k | PURE k p => True end *)
unfold inflate_initial_mem, inflate_initial_mem'; rewrite resource_at_make_rmap.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
destruct (access_at m (b, ofs)); try destruct p; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
case_eq (lev @ (b,ofs)); intros; auto.
Qed.

Lemma perm_mem_access: forall m b ofs p,
  perm m b ofs Cur p ->
  exists p', (perm_order p' p /\ access_at m (b, ofs) Cur = Some p').
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @ex permission (fun p' : permission => and (perm_order p' p) (@eq (option permission) (access_at m (@pair block Z b ofs) Cur) (@Some permission p'))) *)
rewrite perm_access in H. red in H.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
destruct (access_at m (b, ofs) Cur); try contradiction; eauto.
Qed.

Section store.
Variables (jm: juicy_mem) (m': mem)
          (ch: memory_chunk) (b: block) (ofs: Z) (v: val)
          (STORE: store ch (m_dry jm) b ofs v = Some m').

Lemma store_phi_elsewhere_eq: forall rsh sh mv loc',
  ~ adr_range (b, ofs) (size_chunk ch) loc'
  -> (m_phi jm) @ loc' = YES rsh sh (VAL mv) NoneP -> contents_at m' loc' = mv.
Proof.
(* Goal: forall (rsh : Share.t) (sh : readable_share rsh) (mv : memval) (loc' : address) (_ : not (adr_range (@pair block Z b ofs) (@Zlength memval bytes) loc')) (_ : @eq resource (resource_at (m_phi (mkJuicyMem m phi JMcontents JMaccess JMmax_access JMalloc)) loc') (YES rsh sh (VAL mv) NoneP)), @eq memval (contents_at m' loc') mv *)
destruct jm. simpl in *. clear jm.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @eq memval (contents_at m' loc') mv *)
unfold contents_at.
rewrite store_mem_contents with
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  (chunk := ch) (m1 := m) (b := b) (ofs := ofs) (v := v); auto.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
destruct loc' as [b' ofs']. simpl.
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
destruct (peq b' b).
(* b' = b *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN (encode_val ch v) ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN (encode_val ch v) ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
destruct (adr_inv b b' ofs ofs' ch H).
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
symmetry in e.
(* Goal: and (@eq block (nextblock m1) (nextblock m1)) (and (Z.le lo z) (Z.lt z (Z.add lo (Z.sub hi lo)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
contradiction.
(* b' = b /\ ~ ofs <= ofs' < ofs + size_chunk ch *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
subst.
(* Goal: @eq memval (@ZMap.get memval z' (@PMap.get (ZMap.t memval) (nextblock m1) (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) Undef *)
rewrite PMap.gss.
(* Goal: @eq memval (@ZMap.get memval ofs' (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m)))) mv *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
rewrite setN_outside.
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b (mem_contents m))) mv *)
(* Goal: or (Z.lt ofs' ofs) (Z.ge ofs' (Z.add ofs (Z.of_nat (@Datatypes.length memval bytes)))) *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
destruct (JMcontents _ _ _ _ _ H0) as [H5 _].
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b (mem_contents m))) mv *)
(* Goal: or (Z.lt ofs' ofs) (Z.ge ofs' (Z.add ofs (Z.of_nat (@Datatypes.length memval bytes)))) *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
apply H5.
(* Goal: or (Z.lt ofs' ofs) (Z.ge ofs' (Z.add ofs (Z.of_nat (@Datatypes.length memval (encode_val ch v))))) *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN (encode_val ch v) ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
destruct (range_inv _ _ _ H1) as [H1'|H1'].
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
left; auto.
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (NO Share.bot bot_unreadable) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (NO Share.bot bot_unreadable) (NO Share.bot bot_unreadable))))) *)
right.
(* Goal: Z.ge ofs' (Z.add ofs (Z.of_nat (@Datatypes.length memval (encode_val ch v)))) *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN (encode_val ch v) ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
rewrite encode_val_length.
rewrite <- size_chunk_conv.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.

(* b' <> b *)
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite PMap.gso; auto.
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (mem_contents m))) mv *)
destruct (JMcontents _ _ _ _ _ H0) as [H1 _].
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (mem_contents m))) mv *)
apply H1.
Qed.

Definition store_juicy_mem: juicy_mem.
(* Goal: juicy_mem *)
 refine (mkJuicyMem m' (inflate_store m' (m_phi jm)) _ _ _ _).
(* contents_cohere *)
(* Goal: contents_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: max_access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
intros rsh sh' v' loc' pp H2.
(* Goal: and (@eq memval (contents_at m' loc') v') (@eq preds pp NoneP) *)
(* Goal: access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: max_access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
unfold inflate_store in H2; rewrite resource_at_make_rmap in H2.
(* Goal: and (@eq memval (contents_at m' loc') v') (@eq preds pp NoneP) *)
(* Goal: access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: max_access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
destruct (m_phi jm @ loc'); try destruct k; try solve [inversion H2].
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
inversion H2; auto.
(* access_cohere *)
(* Goal: access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: max_access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
intro loc; generalize (juicy_mem_access jm loc); intro H0.
(* Goal: perm_order'' (max_access_at m' loc) (perm_of_res' (resource_at (inflate_store m' (m_phi jm)) loc)) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
unfold inflate_store; rewrite resource_at_make_rmap.
rewrite <- (Memory.store_access _ _ _ _ _ _ STORE).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
destruct (m_phi jm @ loc); try destruct k; auto.
(* max_access_cohere *)
(* Goal: max_access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
intro loc; generalize (juicy_mem_max_access jm loc); intro H1.
(* Goal: perm_order'' (max_access_at m' loc) (perm_of_res' (resource_at (inflate_store m' (m_phi jm)) loc)) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
unfold inflate_store; rewrite resource_at_make_rmap.
unfold max_access_at in *.
rewrite <- (Memory.store_access _ _ _ _ _ _ STORE).
(* Goal: perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m' loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
apply nextblock_store in STORE.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
destruct (m_phi jm @ loc); auto.
(* Goal: perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k with | VAL m0 => YES sh r (VAL (contents_at m' loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
destruct k; simpl; try assumption.
(* alloc_cohere *)
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
hnf; intros.
(* Goal: @eq resource (resource_at (inflate_store m' (m_phi jm)) loc) (NO Share.bot bot_unreadable) *)
unfold inflate_store. rewrite resource_at_make_rmap.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
generalize (juicy_mem_alloc_cohere jm loc); intro.
(* Goal: @eq resource match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m' loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end (NO Share.bot bot_unreadable) *)
rewrite (nextblock_store _ _ _ _ _ _ STORE) in H.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite (H0 H). auto.
Defined.

End store.

Section storebytes.
Variables (jm: juicy_mem) (m': mem) (b: block) (ofs: Z) (bytes: list memval)
  (STOREBYTES: storebytes (m_dry jm) b ofs bytes = Some m').

Lemma storebytes_phi_elsewhere_eq: forall rsh sh mv loc',
  ~ adr_range (b, ofs) (Zlength bytes) loc' ->
  (m_phi jm) @ loc' = YES rsh sh (VAL mv) NoneP ->
  contents_at m' loc' = mv.
Proof.
(* Goal: forall (rsh : Share.t) (sh : readable_share rsh) (mv : memval) (loc' : address) (_ : not (adr_range (@pair block Z b ofs) (@Zlength memval bytes) loc')) (_ : @eq resource (resource_at (m_phi (mkJuicyMem m phi JMcontents JMaccess JMmax_access JMalloc)) loc') (YES rsh sh (VAL mv) NoneP)), @eq memval (contents_at m' loc') mv *)
destruct jm. simpl in *. clear jm.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @eq memval (contents_at m' loc') mv *)
unfold contents_at.
rewrite storebytes_mem_contents with
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  (m1 := m) (b := b) (ofs := ofs) (bytes := bytes); auto.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
destruct loc' as [b' ofs']. simpl.
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
destruct (peq b' b).
(* b' = b *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
destruct (adr_inv0 b b' ofs ofs' (Zlength bytes) H).
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
symmetry in e.
(* Goal: and (@eq block (nextblock m1) (nextblock m1)) (and (Z.le lo z) (Z.lt z (Z.add lo (Z.sub hi lo)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
contradiction.
(* b' = b /\ ~ ofs <= ofs' < ofs + size_chunk ch *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
subst.
(* Goal: @eq memval (@ZMap.get memval z' (@PMap.get (ZMap.t memval) (nextblock m1) (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) Undef *)
rewrite PMap.gss.
(* Goal: @eq memval (@ZMap.get memval ofs' (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m)))) mv *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
rewrite setN_outside.
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b (mem_contents m))) mv *)
(* Goal: or (Z.lt ofs' ofs) (Z.ge ofs' (Z.add ofs (Z.of_nat (@Datatypes.length memval bytes)))) *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
destruct (JMcontents _ _ _ _ _ H0) as [H5 _].
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b (mem_contents m))) mv *)
(* Goal: or (Z.lt ofs' ofs) (Z.ge ofs' (Z.add ofs (Z.of_nat (@Datatypes.length memval bytes)))) *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
apply H5.
(* Goal: or (Z.lt ofs' ofs) (Z.ge ofs' (Z.add ofs (Z.of_nat (@Datatypes.length memval bytes)))) *)
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (@PMap.set (ZMap.t memval) b (setN bytes ofs (@PMap.get (ZMap.t memval) b (mem_contents m))) (mem_contents m)))) mv *)
destruct (range_inv0 _ _ _ H1) as [H1'|H1'].
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
left; auto.
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (NO Share.bot bot_unreadable) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (NO Share.bot bot_unreadable) (NO Share.bot bot_unreadable))))) *)
right.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite <-Zlength_correct; auto.
(* b' <> b *)
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite PMap.gso; auto.
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (mem_contents m))) mv *)
destruct (JMcontents _ _ _ _ _ H0) as [H1 _].
(* Goal: @eq memval (@ZMap.get memval ofs' (@PMap.get (ZMap.t memval) b' (mem_contents m))) mv *)
apply H1.
Qed.

Definition storebytes_juicy_mem: juicy_mem.
(* Goal: juicy_mem *)
 refine (mkJuicyMem m' (inflate_store m' (m_phi jm)) _ _ _ _).
(* contents_cohere *)
(* Goal: contents_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: max_access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
intros rsh sh' v' loc' pp H2.
(* Goal: and (@eq memval (contents_at m' loc') v') (@eq preds pp NoneP) *)
(* Goal: access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: max_access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
unfold inflate_store in H2; rewrite resource_at_make_rmap in H2.
(* Goal: and (@eq memval (contents_at m' loc') v') (@eq preds pp NoneP) *)
(* Goal: access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: max_access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
destruct (m_phi jm @ loc'); try destruct k; try solve [inversion H2].
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
inversion H2; auto.
(* access_cohere *)
(* Goal: access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: max_access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
intro loc; generalize (juicy_mem_access jm loc); intro H0.
(* Goal: perm_order'' (max_access_at m' loc) (perm_of_res' (resource_at (inflate_store m' (m_phi jm)) loc)) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
unfold inflate_store; rewrite resource_at_make_rmap.
rewrite <- (Memory.storebytes_access _ _ _ _ _ STOREBYTES).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
destruct (m_phi jm @ loc); try destruct k; auto.
(* max_access_cohere *)
(* Goal: max_access_cohere m' (inflate_store m' (m_phi jm)) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
intro loc; generalize (juicy_mem_max_access jm loc); intro H1.
(* Goal: perm_order'' (max_access_at m' loc) (perm_of_res' (resource_at (inflate_store m' (m_phi jm)) loc)) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
unfold inflate_store; rewrite resource_at_make_rmap.
unfold max_access_at in *.
rewrite <- (Memory.storebytes_access _ _ _ _ _ STOREBYTES).
(* Goal: perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m' loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) *)
(* Goal: alloc_cohere m' (inflate_store m' (m_phi jm)) *)
assert (H88:=nextblock_storebytes _ _ _ _ _ STOREBYTES).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
destruct (m_phi jm @ loc); try rewrite H88; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
destruct k; simpl; try rewrite H88; auto.
(* alloc_cohere *)
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
hnf; intros.
(* Goal: @eq resource (resource_at (inflate_store m' (m_phi jm)) loc) (NO Share.bot bot_unreadable) *)
unfold inflate_store. rewrite resource_at_make_rmap.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
generalize (juicy_mem_alloc_cohere jm loc); intro.
(* Goal: @eq resource match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m' loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end (NO Share.bot bot_unreadable) *)
rewrite (nextblock_storebytes _ _ _ _ _ STOREBYTES) in H.
(* Goal: @eq resource match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m' loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end (NO Share.bot bot_unreadable) *)
rewrite (H0 H).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.
Defined.

End storebytes.

Lemma free_smaller_None : forall m b b' ofs lo hi m',
  access_at m (b, ofs) Cur = None
  -> free m b' lo hi = Some m'
  -> access_at m' (b, ofs) Cur = None.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
destruct (adr_range_dec (b',lo) (hi-lo) (b,ofs)).
(* Goal: forall (rsh : Share.t) (sh : readable_share rsh) (mv : memval) (loc' : address) (_ : not (adr_range (@pair block Z b ofs) (@Zlength memval bytes) loc')) (_ : @eq resource (resource_at (m_phi (mkJuicyMem m phi JMcontents JMaccess JMmax_access JMalloc)) loc') (YES rsh sh (VAL mv) NoneP)), @eq memval (contents_at m' loc') mv *)
destruct a; simpl in *.
(* Goal: @eq (option permission) (access_at m' (@pair block Z b ofs) Cur) (@None permission) *)
(* Goal: @eq (option permission) (access_at m' (@pair block Z b ofs) Cur) (@None permission) *)
subst b'; apply free_access with (ofs:=ofs) in H0; [ | omega].
(* Goal: @eq (option permission) (access_at m2 (@pair block Z b' z') Cur) (@Some permission Freeable) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
destruct H0.
(* Goal: @eq (option permission) (access_at m' (@pair block Z b ofs) Cur) (@None permission) *)
(* Goal: @eq (option permission) (access_at m' (@pair block Z b ofs) Cur) (@None permission) *)
pose proof (Memory.access_cur_max m' (b,ofs)).
(* Goal: @eq (option permission) (access_at m' (@pair block Z b ofs) Cur) (@None permission) *)
(* Goal: @eq (option permission) (access_at m' (@pair block Z b ofs) Cur) (@None permission) *)
rewrite H1 in H3; simpl in H3.
(* Goal: and (@eq block (nextblock m1) (nextblock m1)) (and (Z.le lo z) (Z.lt z (Z.add lo (Z.sub hi lo)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
destruct (access_at m' (b, ofs) Cur); auto; contradiction.
(* Goal: @eq (option permission) (access_at m' (@pair block Z b ofs) Cur) (@None permission) *)
rewrite <- H. symmetry.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
eapply free_access_other; eauto.
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (NO Share.bot bot_unreadable) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (NO Share.bot bot_unreadable) (NO Share.bot bot_unreadable))))) *)
destruct (eq_block b b'); auto; right.
(* Goal: or (Z.lt ofs' lo) (Z.le hi ofs') *)
simpl in n.
assert (~(lo <= ofs < lo + (hi - lo))) by intuition.
(* Goal: and (Z.le lo z') (Z.lt z' hi) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
omega.
Qed.

Lemma free_nadr_range_eq : forall m b b' ofs' lo hi m',
  ~ adr_range (b, lo) (hi - lo) (b', ofs')
  -> free m b lo hi = Some m'
  -> access_at m (b', ofs') = access_at m' (b', ofs')
  /\  contents_at m (b', ofs') = contents_at m' (b', ofs').
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: and (forall _ : Pos.ge (@fst block Z l) (nextblock (m_dry jm)), @eq resource (resource_at (m_phi jm) l) (NO Share.bot bot_unreadable)) (or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable)))))))) *)
split.
(* Goal: @eq (forall _ : perm_kind, option permission) (access_at m1 (@pair block Z b z)) (access_at m2 (@pair block Z b z)) *)
(* Goal: forall _ : not (@eq (option permission) (access_at m1 (@pair block Z b z) Cur) (@None permission)), @eq memval (contents_at m1 (@pair block Z b z)) (contents_at m2 (@pair block Z b z)) *)
extensionality k.
apply (free_access_other _ _ _ _ _ H0 b' ofs' k).
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (NO Share.bot bot_unreadable) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (NO Share.bot bot_unreadable) (NO Share.bot bot_unreadable))))) *)
destruct (eq_block b b'); auto; right.
(* Goal: or (@ex Share.t (fun sh : Share.t => @ex (not (readable_share sh)) (fun nsh : not (readable_share sh) => @eq resource (resource_at phi loc) (NO sh nsh)))) (or (@ex Share.t (fun sh : Share.t => @ex (readable_share sh) (fun rsh : readable_share sh => @ex AV.kind (fun k : AV.kind => @ex preds (fun pp : preds => and (@eq resource (resource_at phi loc) (YES sh rsh k pp)) (not (isVAL k))))))) (@ex AV.kind (fun k : AV.kind => @ex preds (fun pp : preds => @eq resource (resource_at phi loc) (PURE k pp))))) *)
simpl in H.
assert (~(lo <= ofs' < lo + (hi - lo))) by intuition.
(* Goal: and (Z.le lo z') (Z.lt z' hi) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
omega.
(* Goal: @eq memval (contents_at m' loc') mv *)
unfold contents_at.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
simpl.
Transparent free.
unfold free in H0.
Opaque free.
(* Goal: and (@eq memval (contents_at m loc) v) (@eq preds pp NoneP) *)
if_tac in H0; inv H0.
unfold unchecked_free.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
simpl.
(* Goal: @eq (option permission) (perm_of_res (PURE k p)) (@Some permission Nonempty) *)
(* Goal: @eq (option permission) (if @eq_dec Share.t Share.EqDec_share Share.bot Share.bot then @None permission else @Some permission Nonempty) (@None permission) *)
reflexivity.
Qed.

Section free.
Variables (jm :juicy_mem) (m': mem)
          (b: block) (lo hi: Z)
          (FREE: free (m_dry jm) b lo hi = Some m')
          (PERM: forall ofs, lo <= ofs < hi ->
                      perm_of_res (m_phi jm @ (b,ofs)) = Some Freeable).

Definition inflate_free: rmap. refine (
proj1_sig (make_rmap (fun loc =>
  if adr_range_dec (b,lo) (hi-lo) loc then NO Share.bot bot_unreadable else m_phi jm @ loc)
    (ghost_of (m_phi jm))
     (level (m_phi jm)) _ (ghost_of_approx (m_phi jm)))).
Proof.
(* Goal: @eq (forall _ : AV.address, resource) (@compose AV.address resource resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc)) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) *)
unfold compose.
(* Goal: @eq (forall _ : AV.address, resource) (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) x then NO Share.bot bot_unreadable else resource_at (m_phi jm) x)) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) *)
extensionality l.
(* Goal: @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) l then NO Share.bot bot_unreadable else resource_at (m_phi jm) l)) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) l then NO Share.bot bot_unreadable else resource_at (m_phi jm) l) *)
destruct l as (b', ofs').
(* Goal: @eq (option permission) (perm_of_res (PURE k p)) (@Some permission Nonempty) *)
(* Goal: @eq (option permission) (if @eq_dec Share.t Share.EqDec_share Share.bot Share.bot then @None permission else @Some permission Nonempty) (@None permission) *)
if_tac; try reflexivity.
(* Goal: @eq resource (resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (resource_at phi l)) (resource_at phi l) *)
apply resource_at_approx.
Defined.


Definition free_juicy_mem: juicy_mem.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
 generalize (juicy_mem_contents jm); intro.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
 generalize (juicy_mem_access jm); intro.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
 generalize (juicy_mem_max_access jm); intro.
(* Goal: juicy_mem *)
 refine (mkJuicyMem m' inflate_free _ _ _ _).
* (* contents_cohere *)
unfold contents_cohere in *.
(* Goal: forall (rsh : Share.t) (sh : readable_share rsh) (v : memval) (loc : AV.address) (pp : preds) (_ : @eq resource (resource_at inflate_free loc) (YES rsh sh (VAL v) pp)), and (@eq memval (contents_at m' loc) v) (@eq preds pp NoneP) *)
intros rsh' sh' v' [b' ofs'] pp H2.
(* Goal: and (@eq memval (contents_at m' (@pair block Z b' ofs')) v') (@eq preds pp NoneP) *)
unfold access_cohere in H0.
(* Goal: and (@eq memval (contents_at m' (@pair block Z b' ofs')) v') (@eq preds pp NoneP) *)
specialize (H0 (b', ofs')).
(* Goal: and (@eq memval (contents_at m' (@pair block Z b' ofs')) v') (@eq preds pp NoneP) *)
unfold inflate_free in H2; rewrite resource_at_make_rmap in H2.
(* Goal: and (@eq memval (contents_at m' (@pair block Z b' ofs')) v') (@eq preds pp NoneP) *)
if_tac in H2; [inv H2 | ]. rename H3 into H8.
(* Goal: and (@eq memval (contents_at m' (@pair block Z b' ofs')) v') (@eq preds pp NoneP) *)
remember (m_phi jm @ (b', ofs')) as HPHI.
(* Goal: @eq resource (YES sh2 (@writable0_readable sh2 wsh2) (VAL v2') NoneP) (YES sh (@writable0_readable sh wsh) (VAL v2') NoneP) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
destruct HPHI; try destruct k; inv H2.
(* Goal: and (@eq memval (contents_at m' (@pair block Z b' ofs')) v') (@eq preds pp NoneP) *)
assert (H3: contents_at (m_dry jm) (b', ofs') = v') by (eapply H; eauto).
(* Goal: and (@eq memval (contents_at m' (@pair block Z b' ofs')) v') (@eq preds pp NoneP) *)
assert (H4: m' = unchecked_free (m_dry jm) b lo hi) by (apply free_result; auto).
(* Goal: @eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v2') NoneP) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
rewrite H4.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
unfold unchecked_free, contents_at; simpl.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
split; auto.
(* Goal: @eq preds pp NoneP *)
symmetry in HeqHPHI.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
destruct (H _ _ _ _ _ HeqHPHI); auto.
* (* access_cohere *)
(* Goal: access_cohere m' inflate_free *)
intros [b' ofs']; specialize ( H0 (b', ofs')).
(* Goal: @eq resource (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) x then NO Share.bot bot_unreadable else resource_at (m_phi jm) x)) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (fun l : AV.address => let (b', ofs') as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) p then NO Share.bot bot_unreadable else resource_at (m_phi jm) p)) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) p then NO Share.bot bot_unreadable else resource_at (m_phi jm) p)) := l in if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) (@pair block Z b' ofs') as s return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if s then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b' ofs'))) (if s then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b' ofs'))) then @eq_refl resource (NO Share.bot bot_unreadable) else resource_at_approx (m_phi jm) (@pair block Z b' ofs'))) (ghost_of_approx (m_phi jm)))) loc) (NO Share.bot bot_unreadable) *)
unfold inflate_free; rewrite resource_at_make_rmap.
destruct (adr_range_dec (b,lo) (hi-lo) (b',ofs')).
 + (* adr_range *)
(* Goal: @eq (option permission) (access_at m' (@pair block Z b' ofs') Cur) (perm_of_res (NO Share.bot bot_unreadable)) *)
destruct a as [H2 H3].
replace (lo+(hi-lo)) with hi in H3 by omega.
(* Goal: @eq (option permission) (access_at m2 (@pair block Z b' z') Cur) (@Some permission Freeable) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
subst b'.
(* Goal: @eq (option permission) (access_at m' (@pair block Z b ofs') Cur) (perm_of_res (NO Share.bot bot_unreadable)) *)
replace (access_at m' (b, ofs') Cur) with (@None permission).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
simpl. rewrite if_true by auto. auto.
(* Goal: @eq (option permission) (@None permission) (access_at m' (@pair block Z b ofs') Cur) *)
destruct (free_access _ _ _ _ _ FREE ofs' H3).
(* Goal: @eq (option permission) (@None permission) (access_at m' (@pair block Z b ofs') Cur) *)
pose proof (Memory.access_cur_max m' (b,ofs')). rewrite H4 in H5.
simpl  in H5.
(* Goal: and (@eq block (nextblock m1) (nextblock m1)) (and (Z.le lo z) (Z.lt z (Z.add lo (Z.sub hi lo)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
destruct (access_at m' (b, ofs') Cur); auto; contradiction.
+ (* ~adr_range *)
(* Goal: perm_order'' (access_at m' (@pair block Z b' ofs') Max) (perm_of_res' (resource_at (m_phi jm) (@pair block Z b' ofs'))) *)
destruct (free_nadr_range_eq _ _ _ _ _ _ _ n FREE) as [H2 H3].
rewrite H2 in *. clear H2 H3.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
case_eq (m_phi jm @ (b', ofs')); intros; rewrite H2 in *; auto.
* (* max_access_cohere *)
(* Goal: max_access_cohere m' inflate_free *)
{ intros [b' ofs']. specialize (H1 (b',ofs')).
(* Goal: @eq resource (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) x then NO Share.bot bot_unreadable else resource_at (m_phi jm) x)) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (fun l : AV.address => let (b', ofs') as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) p then NO Share.bot bot_unreadable else resource_at (m_phi jm) p)) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) p then NO Share.bot bot_unreadable else resource_at (m_phi jm) p)) := l in if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) (@pair block Z b' ofs') as s return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if s then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b' ofs'))) (if s then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b' ofs'))) then @eq_refl resource (NO Share.bot bot_unreadable) else resource_at_approx (m_phi jm) (@pair block Z b' ofs'))) (ghost_of_approx (m_phi jm)))) loc) (NO Share.bot bot_unreadable) *)
  unfold inflate_free. unfold max_access_at. rewrite resource_at_make_rmap.
  destruct (adr_range_dec (b,lo) (hi-lo) (b',ofs')).
  - simpl; destruct (eq_dec Share.bot Share.bot) as [e|n]; [| exfalso; apply n; reflexivity].
(* Goal: perm_order Readable Readable *)
    destruct (access_at m' (b', ofs') Max); constructor.
  - clear PERM.
(* Goal: perm_order'' (access_at m' (@pair block Z b' ofs') Max) (perm_of_res' (resource_at (m_phi jm) (@pair block Z b' ofs'))) *)
    unfold max_access_at.
(* Goal: perm_order'' (access_at m' (@pair block Z b' ofs') Max) (perm_of_res' (resource_at (m_phi jm) (@pair block Z b' ofs'))) *)
    destruct (free_nadr_range_eq _ _ _ _ _ _ _ n FREE) as [H2 H3].
    rewrite <- H2. assumption. }
* (* alloc_cohere *)
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
hnf; intros.
(* Goal: @eq resource (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) x then NO Share.bot bot_unreadable else resource_at (m_phi jm) x)) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (fun l : AV.address => let (b', ofs') as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) p then NO Share.bot bot_unreadable else resource_at (m_phi jm) p)) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) p then NO Share.bot bot_unreadable else resource_at (m_phi jm) p)) := l in if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) (@pair block Z b' ofs') as s return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if s then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b' ofs'))) (if s then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b' ofs'))) then @eq_refl resource (NO Share.bot bot_unreadable) else resource_at_approx (m_phi jm) (@pair block Z b' ofs'))) (ghost_of_approx (m_phi jm)))) loc) (NO Share.bot bot_unreadable) *)
unfold inflate_free. rewrite resource_at_make_rmap.
(* Goal: @eq resource (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (NO Share.bot bot_unreadable) *)
pose proof (juicy_mem_alloc_cohere jm loc).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite (nextblock_free _ _ _ _ _ FREE) in H2; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite H3; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
if_tac; auto.
Defined.

End free.

Lemma free_not_freeable_eq : forall m b lo hi m' b' ofs',
  free m b lo hi = Some m'
  -> access_at m (b', ofs') Cur <> Some Freeable
  -> access_at m (b', ofs') Cur = access_at m' (b', ofs') Cur.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
destruct (adr_range_dec (b,lo) (hi-lo) (b',ofs')).
(* Goal: @eq (option permission) (access_at m (@pair block Z b' ofs') Cur) (access_at m' (@pair block Z b' ofs') Cur) *)
(* Goal: @eq (option permission) (access_at m (@pair block Z b' ofs') Cur) (access_at m' (@pair block Z b' ofs') Cur) *)
destruct a.
(* Goal: @eq (option permission) (access_at m2 (@pair block Z b' z') Cur) (@Some permission Freeable) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
subst b'.
(* Goal: @eq (option permission) (access_at m (@pair block Z b ofs') Cur) (access_at m' (@pair block Z b ofs') Cur) *)
(* Goal: @eq (option permission) (access_at m (@pair block Z b' ofs') Cur) (access_at m' (@pair block Z b' ofs') Cur) *)
destruct (free_access _ _ _ _ _ H ofs'); [omega |].
(* Goal: and (@eq block (nextblock m1) (nextblock m1)) (and (Z.le lo z) (Z.lt z (Z.add lo (Z.sub hi lo)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
contradiction.
(* Goal: @eq (option permission) (access_at m (@pair block Z b' ofs') Cur) (access_at m' (@pair block Z b' ofs') Cur) *)
apply (free_access_other _ _ _ _ _ H).
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (NO Share.bot bot_unreadable) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (NO Share.bot bot_unreadable) (NO Share.bot bot_unreadable))))) *)
destruct (eq_block b' b); auto; right.
(* Goal: @eq (option permission) (access_at m2 (@pair block Z b' z') Cur) (@Some permission Freeable) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
subst b'.
simpl in n. assert (~( lo <= ofs' < lo + (hi - lo))) by intuition; omega.
Qed.

(* The empty juicy memory *)

Definition after_alloc' 
  (lo hi: Z) (b: block) (phi: rmap)(H: forall ofs, phi @ (b,ofs) = NO Share.bot bot_unreadable)
  : address -> resource := fun loc =>
    if adr_range_dec (b,lo) (hi-lo) loc 
      then YES Share.top readable_share_top (VAL Undef) NoneP
      else phi @ loc.

Lemma adr_range_eq_block : forall b ofs n b' ofs',
  adr_range (b,ofs) n (b',ofs') ->
  b=b'.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
unfold adr_range; intros.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
destruct H; auto.
Qed.

Lemma after_alloc'_ok : forall lo hi b phi H,
  resource_fmap (approx (level phi)) (approx (level phi)) oo (after_alloc' lo hi b phi H)
  = after_alloc' lo hi b phi H.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @eq (forall _ : address, resource) (@compose address resource resource (resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi))) (after_alloc' lo hi b phi H)) (after_alloc' lo hi b phi H) *)
unfold resource_fmap, compose, after_alloc'.
(* Goal: @eq (forall _ : address, resource) (fun x : address => match (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) x then YES Share.top readable_share_top (VAL Undef) NoneP else resource_at (@core rmap Join_rmap Sep_rmap phi) x) with | NO sh nsh => NO sh nsh | YES sh rsh k p => YES sh rsh k (preds_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) p) | PURE k p => PURE k (preds_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) p) end) (fun loc : address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then YES Share.top readable_share_top (VAL Undef) NoneP else resource_at (@core rmap Join_rmap Sep_rmap phi) loc) *)
extensionality loc.
(* Goal: @eq resource match (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then YES Share.top readable_share_top (VAL Undef) NoneP else resource_at phi loc) with | NO sh nsh => NO sh nsh | YES sh rsh k p => YES sh rsh k (preds_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) p) | PURE k p => PURE k (preds_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) p) end (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then YES Share.top readable_share_top (VAL Undef) NoneP else resource_at phi loc) *)
if_tac.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite preds_fmap_NoneP; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
case_eq (phi @ loc); intros; auto.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
generalize H1; intros.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
apply necR_YES with (phi':=phi) in H1; eauto.
rewrite <- H1.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
generalize (resource_at_approx phi loc); rewrite H1; auto.
Qed.

Definition after_alloc
  (lo hi: Z) (b: block) (phi: rmap)(H: forall ofs, phi @ (b,ofs) = NO Share.bot bot_unreadable) : rmap :=
  proj1_sig (make_rmap (after_alloc' lo hi b phi H) (ghost_of phi)
    (level phi)
    (after_alloc'_ok lo hi b phi H) (ghost_of_approx phi)).

Definition mod_after_alloc' (phi: rmap) (lo hi: Z) (b: block)
  : address -> resource := fun loc =>
    if adr_range_dec (b,lo) (hi-lo) loc 
      then YES Share.top readable_share_top (VAL Undef) NoneP
      else core phi @ loc.

Lemma mod_after_alloc'_ok : forall phi lo hi b,
  resource_fmap (approx (level phi)) (approx (level phi)) oo (mod_after_alloc'  phi lo hi b)
  = mod_after_alloc' phi lo hi b.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @eq (forall _ : address, resource) (@compose address resource resource (resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi))) (mod_after_alloc' phi lo hi b)) (mod_after_alloc' phi lo hi b) *)
unfold resource_fmap, compose, mod_after_alloc'.
(* Goal: @eq (forall _ : address, resource) (fun x : address => match (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) x then YES Share.top readable_share_top (VAL Undef) NoneP else resource_at (@core rmap Join_rmap Sep_rmap phi) x) with | NO sh nsh => NO sh nsh | YES sh rsh k p => YES sh rsh k (preds_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) p) | PURE k p => PURE k (preds_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) p) end) (fun loc : address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then YES Share.top readable_share_top (VAL Undef) NoneP else resource_at (@core rmap Join_rmap Sep_rmap phi) loc) *)
extensionality loc.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
if_tac; auto.
case_eq (core phi @ loc); intros; auto; f_equal;
rewrite <- level_core;
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
generalize (resource_at_approx (core phi) loc); rewrite H0; intro; injection H1; auto.
Qed.

Definition mod_after_alloc (phi: rmap) (lo hi: Z) (b: block) :=
  proj1_sig (make_rmap (mod_after_alloc' phi lo hi b) (ghost_of phi)
    _
    (mod_after_alloc'_ok phi lo hi b) (ghost_of_approx phi)).

Transparent alloc.

Lemma adr_range_inv: forall loc loc' n,
  ~ adr_range loc n loc' ->
  fst loc <> fst loc' \/ (fst loc=fst loc' /\ ~snd loc <= snd loc' < snd loc + n).
Proof.
(* Goal: forall (loc loc' : address) (n : Z) (_ : not (adr_range loc n loc')), or (not (@eq block (@fst block Z loc) (@fst block Z loc'))) (and (@eq block (@fst block Z loc) (@fst block Z loc')) (not (and (Z.le (@snd block Z loc) (@snd block Z loc')) (Z.lt (@snd block Z loc') (Z.add (@snd block Z loc) n))))) *)
intros until n.
(* Goal: forall _ : not (adr_range loc n loc'), or (not (@eq block (@fst block Z loc) (@fst block Z loc'))) (and (@eq block (@fst block Z loc) (@fst block Z loc')) (not (and (Z.le (@snd block Z loc) (@snd block Z loc')) (Z.lt (@snd block Z loc') (Z.add (@snd block Z loc) n))))) *)
intro H.
(* Goal: or (not (@eq block (@fst block Z loc) (@fst block Z loc'))) (and (@eq block (@fst block Z loc) (@fst block Z loc')) (not (and (Z.le (@snd block Z loc) (@snd block Z loc')) (Z.lt (@snd block Z loc') (Z.add (@snd block Z loc) n))))) *)
destruct (peq (fst loc) (fst loc')).
(* Goal: or (not (@eq block (@fst block Z loc) (@fst block Z loc'))) (and (@eq block (@fst block Z loc) (@fst block Z loc')) (not (and (Z.le (@snd block Z loc) (@snd block Z loc')) (Z.lt (@snd block Z loc') (Z.add (@snd block Z loc) n))))) *)
(* Goal: or (not (@eq block (@fst block Z loc) (@fst block Z loc'))) (and (@eq block (@fst block Z loc) (@fst block Z loc')) (not (and (Z.le (@snd block Z loc) (@snd block Z loc')) (Z.lt (@snd block Z loc') (Z.add (@snd block Z loc) n))))) *)
right; split; auto; intro Contra.
(* Goal: False *)
(* Goal: or (not (@eq block (@fst block Z loc) (@fst block Z loc'))) (and (@eq block (@fst block Z loc) (@fst block Z loc')) (not (and (Z.le (@snd block Z loc) (@snd block Z loc')) (Z.lt (@snd block Z loc') (Z.add (@snd block Z loc) n))))) *)
apply H.
(* Goal: forall (b : block) (lo hi : Z) (loc : address) (_ : adr_range (@pair block Z b lo) (Z.sub hi lo) loc), @eq bool (andb (@proj_sumbool (Z.le lo (@snd block Z loc)) (Z.gt lo (@snd block Z loc)) (zle lo (@snd block Z loc))) (@proj_sumbool (Z.lt (@snd block Z loc) hi) (Z.ge (@snd block Z loc) hi) (zlt (@snd block Z loc) hi))) true *)
unfold adr_range.
(* Goal: let (b, ofs) := loc in let (b', ofs') := loc' in and (@eq block b b') (and (Z.le ofs ofs') (Z.lt ofs' (Z.add ofs n))) *)
(* Goal: or (not (@eq block (@fst block Z loc) (@fst block Z loc'))) (and (@eq block (@fst block Z loc) (@fst block Z loc')) (not (and (Z.le (@snd block Z loc) (@snd block Z loc')) (Z.lt (@snd block Z loc') (Z.add (@snd block Z loc) n))))) *)
destruct loc,loc'.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.
(* Goal: or (not (@eq block (@fst block Z loc) (@fst block Z loc'))) (and (@eq block (@fst block Z loc) (@fst block Z loc')) (not (and (Z.le (@snd block Z loc) (@snd block Z loc')) (Z.lt (@snd block Z loc') (Z.add (@snd block Z loc) n))))) *)
left; intro Contra.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
apply n0; auto.
Qed.

Lemma dry_noperm_juicy_nonreadable : forall m loc,
  access_at (m_dry m) loc Cur = None ->   ~readable loc (m_phi m).
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
rewrite (juicy_mem_access m loc) in H.
(* Goal: not (@app_pred rmap ag_rmap (readable loc) (m_phi m)) *)
intro. hnf in H0.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
destruct (m_phi m @loc); simpl in *; auto.
(* Goal: @eq memval (contents_at m1 (@pair block Z b z)) (contents_at m2 (@pair block Z b z)) *)
destruct k as [x | |]; try inv H.
(* Goal: False *)
unfold perm_of_sh in H2.
(* Goal: @eq resource (YES sh2 (@writable0_readable sh2 wsh2) (VAL v2') NoneP) (YES sh (@writable0_readable sh wsh) (VAL v2') NoneP) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
if_tac in H2. if_tac in H2; inv H2.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite if_true in H2 by auto.
(* Goal: @eq resource (YES sh2 (@writable0_readable sh2 wsh2) (VAL v2') NoneP) (YES sh (@writable0_readable sh wsh) (VAL v2') NoneP) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
inv H2.
Qed.

Lemma fullempty_after_alloc : forall m1 m2 lo n b ofs,
  alloc m1 lo n = (m2, b) ->
  access_at m2 (b, ofs) Cur = None \/ access_at m2 (b, ofs) Cur = Some Freeable.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: or (@eq (option permission) (access_at m2 (@pair block Z b ofs) Cur) (@None permission)) (@eq (option permission) (access_at m2 (@pair block Z b ofs) Cur) (@Some permission Freeable)) *)
pose proof (alloc_access_same _ _ _ _ _ H ofs Cur).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
destruct (range_dec lo ofs n). auto.
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) (@pair block Z b0 z))) (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z))) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) (@pair block Z b0 z))) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z (@pair block Z b0 z)) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) (@pair block Z b0 z)) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (NO Share.bot bot_unreadable))))))) *)
left.
rewrite <- (alloc_access_other _ _ _ _ _ H b ofs Cur) by (right; omega).
(* Goal: @eq (option permission) (access_at m1 (@pair block Z b ofs) Cur) (@None permission) *)
apply alloc_result in H.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
subst.
(* Goal: @eq (option permission) (access_at m1 (@pair block Z (nextblock m1) ofs) Cur) (@None permission) *)
apply nextblock_access_empty.
(* Goal: Pos.ge (nextblock m1) (nextblock m1) *)
apply Pos.le_ge, Pos.le_refl.
Qed.

Lemma alloc_dry_unchanged_on : forall m1 m2 loc lo hi b0,
  alloc m1 lo hi = (m2, b0) ->
  ~adr_range (b0,lo) (hi-lo) loc ->
  access_at m1 loc = access_at m2 loc /\
  (access_at m1 loc Cur <> None -> contents_at m1 loc= contents_at m2 loc).
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
destruct loc as [b z]; simpl.
(* Goal: and (forall _ : Pos.ge (@fst block Z l) (nextblock (m_dry jm)), @eq resource (resource_at (m_phi jm) l) (NO Share.bot bot_unreadable)) (or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable)))))))) *)
split.
(* Goal: @eq (forall _ : perm_kind, option permission) (access_at m1 (@pair block Z b z)) (access_at m2 (@pair block Z b z)) *)
(* Goal: forall _ : not (@eq (option permission) (access_at m1 (@pair block Z b z) Cur) (@None permission)), @eq memval (contents_at m1 (@pair block Z b z)) (contents_at m2 (@pair block Z b z)) *)
extensionality k.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
eapply Memory.alloc_access_other; eauto.
(* Goal: or (not (@eq block b b0)) (or (Z.lt z lo) (Z.ge z hi)) *)
(* Goal: forall _ : not (@eq (option permission) (access_at m1 (@pair block Z b z) Cur) (@None permission)), @eq memval (contents_at m1 (@pair block Z b z)) (contents_at m2 (@pair block Z b z)) *)
simpl in H0.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
destruct (eq_block b b0); auto. subst. right.
assert (~(lo <= z < lo + (hi - lo))) by intuition; omega.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @eq memval (contents_at m1 (@pair block Z b z)) (contents_at m2 (@pair block Z b z)) *)
unfold alloc in H.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
inv H. unfold contents_at; simpl.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
unfold adr_range in H0.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
destruct (eq_dec b (nextblock m1)).
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
subst.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) (nextblock m1) (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) (nextblock m1) (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
rewrite invalid_noaccess in H1; [ congruence |].
(* Goal: not (valid_block m1 (nextblock m1)) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
contradict H0.
(* Goal: and (@eq block (nextblock m1) (nextblock m1)) (and (Z.le lo z) (Z.lt z (Z.add lo (Z.sub hi lo)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
red in H0. apply Pos.lt_irrefl in H0. contradiction.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite PMap.gso by auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
auto.
Qed.

Lemma adr_range_zle_fact : forall b lo hi loc,
  adr_range (b,lo) (hi-lo) loc ->
  zle lo (snd loc) && zlt (snd loc) hi = true.
Proof.
(* Goal: forall (b : block) (lo hi : Z) (loc : address) (_ : adr_range (@pair block Z b lo) (Z.sub hi lo) loc), @eq bool (andb (@proj_sumbool (Z.le lo (@snd block Z loc)) (Z.gt lo (@snd block Z loc)) (zle lo (@snd block Z loc))) (@proj_sumbool (Z.lt (@snd block Z loc) hi) (Z.ge (@snd block Z loc) hi) (zlt (@snd block Z loc) hi))) true *)
unfold adr_range.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: forall (rsh : Share.t) (sh : readable_share rsh) (mv : memval) (loc' : address) (_ : not (adr_range (@pair block Z b ofs) (@Zlength memval bytes) loc')) (_ : @eq resource (resource_at (m_phi (mkJuicyMem m phi JMcontents JMaccess JMmax_access JMalloc)) loc') (YES rsh sh (VAL mv) NoneP)), @eq memval (contents_at m' loc') mv *)
destruct loc; simpl in *.
(* Goal: @eq bool (andb (@proj_sumbool (Z.le lo z) (Z.gt lo z) (zle lo z)) (@proj_sumbool (Z.lt z hi) (Z.ge z hi) (zlt z hi))) true *)
destruct H.
(* Goal: @eq (option permission) (access_at m2 (@pair block Z b' z') Cur) (@Some permission Freeable) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
destruct H0.
(* Goal: @eq bool (andb (@proj_sumbool (Z.le lo z) (Z.gt lo z) (zle lo z)) (@proj_sumbool (Z.lt z hi) (Z.ge z hi) (zlt z hi))) true *)
apply andb_true_iff.
(* Goal: and (forall _ : Pos.ge (@fst block Z l) (nextblock (m_dry jm)), @eq resource (resource_at (m_phi jm) l) (NO Share.bot bot_unreadable)) (or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable)))))))) *)
split.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
apply zle_true; auto.
(* Goal: and (Z.le lo z') (Z.lt z' hi) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
apply zlt_true; omega.
Qed.

Lemma alloc_dry_updated_on : forall m1 m2 lo hi b loc,
  alloc m1 lo hi = (m2, b) ->
  adr_range (b, lo) (hi - lo) loc ->
  access_at m2 loc Cur=Some Freeable /\
  contents_at m2 loc=Undef.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: and (@eq (option permission) (access_at m2 loc Cur) (@Some permission Freeable)) (@eq memval (contents_at m2 loc) Undef) *)
destruct loc as [b' z'].
(* Goal: and (forall _ : Pos.ge (@fst block Z l) (nextblock (m_dry jm)), @eq resource (resource_at (m_phi jm) l) (NO Share.bot bot_unreadable)) (or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable)))))))) *)
split.
(* Goal: @eq (option permission) (access_at m2 (@pair block Z b' z') Cur) (@Some permission Freeable) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
destruct H0. subst b'.
(* Goal: and (Z.le lo z') (Z.lt z' hi) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
apply (alloc_access_same _ _ _ _ _ H). omega.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
unfold contents_at; unfold alloc in H; inv H. simpl.
(* Goal: @eq (option permission) (access_at m2 (@pair block Z b' z') Cur) (@Some permission Freeable) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
destruct H0; subst b'.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite PMap.gss. rewrite ZMap.gi; auto.
Qed.

Definition resource_decay (nextb: block) (phi1 phi2: rmap) :=
  (level phi1 >= level phi2)%nat /\
 forall l: address,
  ((fst l >= nextb)%positive -> phi1 @ l = NO Share.bot bot_unreadable) /\
  (resource_fmap (approx (level phi2)) (approx (level phi2)) (phi1 @ l) = (phi2 @ l) \/
  (exists sh, exists (wsh: writable0_share sh), exists v, exists v',
       resource_fmap (approx (level phi2)) (approx (level phi2)) (phi1 @ l) = 
                       YES sh (writable0_readable wsh) (VAL v) NoneP /\ 
       phi2 @ l = YES sh (writable0_readable wsh) (VAL v') NoneP)
  \/ ((fst l >= nextb)%positive /\ exists v, phi2 @ l = YES Share.top readable_share_top (VAL v) NoneP)
  \/ (exists v, exists pp, phi1 @ l = YES Share.top readable_share_top (VAL v) pp 
                        /\ phi2 @ l = NO Share.bot bot_unreadable)).

Definition resource_nodecay (nextb: block) (phi1 phi2: rmap) :=
  (level phi1 >= level phi2)%nat /\
  forall l: address,
  ((fst l >= nextb)%positive -> phi1 @ l = NO Share.bot bot_unreadable) /\
  (resource_fmap (approx (level phi2)) (approx (level phi2)) (phi1 @ l) = (phi2 @ l) \/
  (exists sh, exists (wsh: writable0_share sh), exists v, exists v',
       resource_fmap (approx (level phi2)) (approx (level phi2)) (phi1 @ l) = YES sh (writable0_readable wsh) (VAL v) NoneP
      /\ phi2 @ l = YES sh (writable0_readable wsh) (VAL v') NoneP)).

Lemma resource_nodecay_decay:
   forall b phi1 phi2, resource_nodecay b phi1 phi2 -> resource_decay b phi1 phi2.
Proof.
(* Goal: and (Z.le lo z') (Z.lt z' hi) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
 unfold resource_decay, resource_nodecay; intros; destruct H; split; intros; try omega.
(* Goal: forall j : juicy_mem, @eq nat (@level juicy_mem juicy_mem_ageable j) (@level rmap ag_rmap (m_phi j)) *)
specialize (H0 l); intuition.
Qed.

Lemma resource_decay_refl: forall b phi, 
  (forall l, (fst l >= b)%positive -> phi @ l = NO Share.bot bot_unreadable) ->
  resource_decay b phi phi.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
split; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
intros; split; auto.
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) (@pair block Z b0 z))) (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z))) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) (@pair block Z b0 z))) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z (@pair block Z b0 z)) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) (@pair block Z b0 z)) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (NO Share.bot bot_unreadable))))))) *)
left.
(* Goal: @eq resource (resource_fmap (approx (@level rmap ag_rmap phi)) (approx (@level rmap ag_rmap phi)) (resource_at phi l)) (resource_at phi l) *)
apply resource_at_approx.
Qed.

Lemma resource_decay_trans: forall b b' m1 m2 m3,
  (b <= b')%positive ->
  resource_decay b m1 m2 -> resource_decay b' m2 m3 -> resource_decay b m1 m3.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
 intros until m3; intro Hbb; intros.
(* Goal: resource_decay b m1 m3 *)
 destruct H as [H' H]; destruct H0 as [H0' H0]; split; [omega |].
(* Goal: forall l : address, and (forall _ : Pos.ge (@fst block Z l) b, @eq resource (resource_at m1 l) (NO Share.bot bot_unreadable)) (or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable)))))))) *)
 intro l; specialize (H l); specialize (H0 l).
(* Goal: and (forall _ : Pos.ge (@fst block Z l) b, @eq resource (resource_at m1 l) (NO Share.bot bot_unreadable)) (or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable)))))))) *)
 destruct H,H0.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 split.  auto.
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 destruct H1.
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 destruct H2.
 left. rewrite <- H2.
 replace (resource_fmap (approx (level m3)) (approx (level m3)) (m1 @ l))
    with (resource_fmap (approx (level m3)) (approx (level m3))
              (resource_fmap (approx (level m2)) (approx (level m2)) (m1 @ l)))
  by (rewrite resource_fmap_fmap; rewrite approx_oo_approx' by auto; rewrite approx'_oo_approx by auto; auto).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite H1. auto.
 clear - Hbb H H1 H0 H2 H' H0'.
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (NO Share.bot bot_unreadable) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (NO Share.bot bot_unreadable) (NO Share.bot bot_unreadable))))) *)
 right.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
 destruct H2 as [[sh2 [wsh2 [v2 [v2' [? ?]]]]]|[[? [v ?]] |?]]; subst.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 left; exists sh2, wsh2,v2,v2'; split; auto.
 rewrite <- H1 in H2.
(* Goal: @eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh2 (@writable0_readable sh2 wsh2) (VAL v2) NoneP) *)
(* Goal: or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable)))))) *)
(* Goal: or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable)))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 rewrite resource_fmap_fmap in H2.
(* Goal: and (Z.le lo z') (Z.lt z' hi) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
 rewrite approx_oo_approx' in H2 by omega.
(* Goal: and (Z.le lo z') (Z.lt z' hi) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
 rewrite approx'_oo_approx in H2 by omega.
(* Goal: @eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh2 (@writable0_readable sh2 wsh2) (VAL v2) NoneP) *)
(* Goal: or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable)))))) *)
(* Goal: or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable)))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 assumption.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 right; left. split. xomega. exists v; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 right; right; auto.
(* Goal: @ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable)))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 destruct H2 as [v [pp [? ?]]].
(* Goal: @ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable)))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 rewrite H2 in H1. destruct (m1 @ l); inv H1.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 exists v, p. split; auto. f_equal. apply proof_irr.
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 destruct H2.
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 destruct H1 as [[sh [wsh [v [v' [? ?]]]]]|[[? [v ?]] |?]].
(* Goal: and (forall _ : Pos.ge (@fst block Z l) (nextblock (m_dry jm)), @eq resource (resource_at (m_phi jm) l) (NO Share.bot bot_unreadable)) (or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable)))))))) *)
 right; left; exists sh,wsh,v,v'; split. 
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 rewrite <- (approx_oo_approx' (level m3) (level m2)) at 1 by auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 rewrite <- (approx'_oo_approx (level m3) (level m2)) at 2 by auto.
 rewrite <- resource_fmap_fmap. rewrite H1.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 unfold resource_fmap. rewrite preds_fmap_NoneP. auto.
 rewrite H3 in H2. rewrite <- H2.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 unfold resource_fmap. rewrite preds_fmap_NoneP. auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 right; right; left; split; auto. exists v. rewrite <- H2; rewrite <- H3.
(* Goal: @eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m2 l)) (resource_at m2 l) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 rewrite H3.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 unfold resource_fmap. rewrite preds_fmap_NoneP. auto.
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (NO Share.bot bot_unreadable) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (NO Share.bot bot_unreadable) (NO Share.bot bot_unreadable))))) *)
 right; right; right.
(* Goal: @ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable)))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 destruct H1 as [v [pp [? ?]]].
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 rewrite H3 in H2. simpl in H2. eauto.
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 destruct H1 as [[sh [wsh [v [v' [? ?]]]]]|[[? [v ?]] |?]].
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 destruct H2 as [[sh2 [wsh2 [v2 [v2' [? ?]]]]]|[[? [v2 ?]] |?]].
(* Goal: and (forall _ : Pos.ge (@fst block Z l) (nextblock (m_dry jm)), @eq resource (resource_at (m_phi jm) l) (NO Share.bot bot_unreadable)) (or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable)))))))) *)
 right; left; exists sh,wsh,v,v2'; split.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 rewrite <- (approx_oo_approx' (level m3) (level m2)) at 1 by auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 rewrite <- (approx'_oo_approx (level m3) (level m2)) at 2 by auto.
 rewrite <- resource_fmap_fmap. rewrite H1.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 unfold resource_fmap. rewrite preds_fmap_NoneP. auto.
(* Goal: @eq resource (YES sh2 (@writable0_readable sh2 wsh2) (VAL v2') NoneP) (YES sh (@writable0_readable sh wsh) (VAL v2') NoneP) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 rewrite H3 in H2. rewrite H4. simpl in H2. inv H2.
(* Goal: @eq resource (YES sh2 (@writable0_readable sh2 wsh2) (VAL v2') NoneP) (YES sh2 (@writable0_readable sh2 wsh) (VAL v2') NoneP) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 f_equal. apply proof_irr.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 right; right; left. split. xomega. exists v2; auto.
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (NO Share.bot bot_unreadable) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (NO Share.bot bot_unreadable) (NO Share.bot bot_unreadable))))) *)
 right; right; right.
(* Goal: @ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable)))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 destruct (m1 @ l); inv H1.
(* Goal: @ex memval (fun v0 : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL v) p) (YES Share.top readable_share_top (VAL v0) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable)))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 destruct H2 as [vx [pp [? ?]]]. inversion2 H3 H1.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 exists v,p. split; auto. f_equal; apply proof_irr.
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 destruct H2 as [[sh2 [wsh2 [v2 [v2' [? ?]]]]]|[[? [v2 ?]] |?]].
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 right; right; left; split; auto. exists v2'. rewrite H3 in H2; inv H2.
(* Goal: @eq resource (YES Share.top r (VAL m) p) (YES Share.top readable_share_top (VAL m) p) *)
 rewrite H4; f_equal; apply proof_irr.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 right; right; left; split; auto; exists v2; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 left. destruct H2 as [v' [pp [? ?]]]. rewrite H4; rewrite H; auto.
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 destruct H2 as [[sh2 [wsh2 [v2 [v2' [? ?]]]]]|[[? [v2 ?]] |?]].
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 destruct H1 as [v' [pp [? ?]]].
(* Goal: @eq resource (YES sh2 (@writable0_readable sh2 wsh2) (VAL v2') NoneP) (YES sh (@writable0_readable sh wsh) (VAL v2') NoneP) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 rewrite H4 in H2; inv H2.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 right; right; left; split. xomega. eauto.
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (NO Share.bot bot_unreadable) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (NO Share.bot bot_unreadable) (NO Share.bot bot_unreadable))))) *)
 right; right; right.
(* Goal: @ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable)))) *)
 destruct H1 as [v1 [pp1 [? ?]]].
(* Goal: @ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable)))) *)
 destruct H2 as [v2 [pp2 [? ?]]].
(* Goal: @ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable)))) *)
 inversion2 H3 H2.
Qed.

Lemma level_store_juicy_mem:
 forall jm m ch b i v H, level (store_juicy_mem jm m ch b i v H) = level jm.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
unfold store_juicy_mem. simpl.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
unfold inflate_store; simpl. rewrite level_make_rmap. auto.
Qed.

Lemma level_storebytes_juicy_mem:
 forall jm m b i bytes H, level (storebytes_juicy_mem jm m b i bytes H) = level jm.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
unfold storebytes_juicy_mem. simpl.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
unfold inflate_store; simpl. rewrite level_make_rmap. auto.
Qed.

Lemma inflate_store_resource_nodecay:
  forall (jm: juicy_mem) (m': mem)
          (ch: memory_chunk) (b: block) (ofs: Z) (v: val)
          (STORE: store ch (m_dry jm) b ofs v = Some m')
          (PERM: forall z, ofs <= z < ofs + size_chunk ch ->
                      perm_order'' (perm_of_res (m_phi jm @ (b,z))) (Some Writable))
          phi',
  inflate_store m' (m_phi jm) = phi' -> resource_nodecay (nextblock (m_dry jm)) (m_phi jm) phi'.
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: and (forall _ : Pos.ge (@fst block Z l) (nextblock (m_dry jm)), @eq resource (resource_at (m_phi jm) l) (NO Share.bot bot_unreadable)) (or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable)))))))) *)
split.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
subst; unfold inflate_store; simpl. rewrite level_make_rmap. auto.
intro l'.
(* Goal: and (forall _ : Pos.ge (@fst block Z l) (nextblock (m_dry jm)), @eq resource (resource_at (m_phi jm) l) (NO Share.bot bot_unreadable)) (or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable)))))))) *)
split.
(* Goal: forall _ : Pos.ge (@fst block Z l) (nextblock (m_dry jm)), @eq resource (resource_at (m_phi jm) l) (NO Share.bot bot_unreadable) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable))))))) *)
apply juicy_mem_alloc_cohere.
destruct (adr_range_dec (b, ofs) (size_chunk ch) l') as [HA | HA].
* (* adr_range *)
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (NO Share.bot bot_unreadable) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (NO Share.bot bot_unreadable) (NO Share.bot bot_unreadable))))) *)
right.
unfold adr_range in HA.
destruct l' as (b', ofs').
destruct HA as [HA0 HA1].
(* Goal: @eq (option permission) (access_at m2 (@pair block Z b' z') Cur) (@Some permission Freeable) *)
(* Goal: @eq memval (contents_at m2 (@pair block Z b' z')) Undef *)
subst b'.
assert (H0: range_perm (m_dry jm) b ofs (ofs + size_chunk ch) Cur Writable).
  cut (valid_access (m_dry jm) ch b ofs Writable).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  intros [? ?]; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  eapply store_valid_access_3; eauto.
assert (H1: perm (m_dry jm) b ofs' Cur Writable) by (apply H0; auto).
generalize (juicy_mem_access jm (b, ofs')); intro ACCESS.
unfold perm, perm_order' in H1.
unfold access_at in ACCESS.
(* Goal: forall (rsh : Share.t) (sh : readable_share rsh) (mv : memval) (loc' : address) (_ : not (adr_range (@pair block Z b ofs) (@Zlength memval bytes) loc')) (_ : @eq resource (resource_at (m_phi (mkJuicyMem m phi JMcontents JMaccess JMmax_access JMalloc)) loc') (YES rsh sh (VAL mv) NoneP)), @eq memval (contents_at m' loc') mv *)
simpl in *.
(* Goal: and (@eq block (nextblock m1) (nextblock m1)) (and (Z.le lo z) (Z.lt z (Z.add lo (Z.sub hi lo)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
destruct ((mem_access (m_dry jm)) !! b ofs' Cur) eqn:?H; try contradiction.
specialize (PERM ofs' HA1).
destruct ( m_phi jm @ (b, ofs') ) eqn:?H; try destruct k; simpl in PERM; try if_tac in PERM; try inv PERM.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
destruct (juicy_mem_contents _ _ _ _ _ _ H3); subst.
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
simpl.
(* Goal: max_access_cohere m' inflate_free *)
assert (writable0_share sh). {
 clear - PERM.
 unfold perm_of_sh in PERM.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 if_tac in PERM; auto. if_tac in PERM. inv PERM.
 if_tac in PERM; inv PERM.
}
(* Goal: @eq resource (YES sh2 (@writable0_readable sh2 wsh2) (VAL v2') NoneP) (YES sh2 (@writable0_readable sh2 wsh) (VAL v2') NoneP) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 exists sh,H; do 2 econstructor; split; simpl; f_equal.
(* Goal: @eq (readable_share sh2) (@writable0_readable sh2 wsh2) (@writable0_readable sh2 wsh) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (resource_at m3 l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap m3)) (approx (@level rmap ag_rmap m3)) (resource_at m1 l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at m3 l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) b) (@ex memval (fun v : memval => @eq resource (resource_at m3 l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at m1 l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at m3 l) (NO Share.bot bot_unreadable))))))) *)
 apply proof_irr.
(* Goal: @eq resource (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) x then NO Share.bot bot_unreadable else resource_at (m_phi jm) x)) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (fun l : AV.address => let (b', ofs') as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) p then NO Share.bot bot_unreadable else resource_at (m_phi jm) p)) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) p then NO Share.bot bot_unreadable else resource_at (m_phi jm) p)) := l in if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) (@pair block Z b' ofs') as s return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if s then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b' ofs'))) (if s then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b' ofs'))) then @eq_refl resource (NO Share.bot bot_unreadable) else resource_at_approx (m_phi jm) (@pair block Z b' ofs'))) (ghost_of_approx (m_phi jm)))) loc) (NO Share.bot bot_unreadable) *)
unfold inflate_store;  rewrite resource_at_make_rmap.
(* Goal: @eq resource (YES Share.top r (VAL m) p) (YES Share.top readable_share_top (VAL m) p) *)
rewrite H3. f_equal; apply proof_irr.
* (* ~ adr_range *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) (@pair block Z b0 z))) (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z))) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) (@pair block Z b0 z))) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z (@pair block Z b0 z)) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) (@pair block Z b0 z)) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (NO Share.bot bot_unreadable))))))) *)
left.
assert (H0: level (m_phi jm) = level phi').
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  rewrite <- H; unfold inflate_store; rewrite level_make_rmap; auto.
(* Goal: @eq (option permission) (access_at m' (@pair block Z b ofs) Cur) (@None permission) *)
rewrite <- H.
(* Goal: @eq resource (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) x then NO Share.bot bot_unreadable else resource_at (m_phi jm) x)) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (fun l : AV.address => let (b', ofs') as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) p then NO Share.bot bot_unreadable else resource_at (m_phi jm) p)) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) p then NO Share.bot bot_unreadable else resource_at (m_phi jm) p)) := l in if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) (@pair block Z b' ofs') as s return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if s then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b' ofs'))) (if s then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b' ofs'))) then @eq_refl resource (NO Share.bot bot_unreadable) else resource_at_approx (m_phi jm) (@pair block Z b' ofs'))) (ghost_of_approx (m_phi jm)))) loc) (NO Share.bot bot_unreadable) *)
unfold inflate_store; rewrite level_make_rmap; rewrite resource_at_make_rmap.
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
(* Goal: @eq memval (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (mem_contents m1))) (@ZMap.get memval z (@PMap.get (ZMap.t memval) b (@PMap.set (prod memval (PTree.t memval)) (nextblock m1) (@ZMap.init memval Undef) (mem_contents m1)))) *)
case_eq l'; intros b' ofs' e'; subst.
remember (m_phi jm @ (b', ofs')) as HPHI; destruct HPHI; try destruct k; auto;
  try solve [rewrite HeqHPHI; rewrite resource_at_approx; auto].
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite (store_phi_elsewhere_eq jm _ _ _ _ _ STORE _ r m (b', ofs')); auto.
assert (H: p = NoneP).
  symmetry in HeqHPHI; 
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  destruct  (juicy_mem_contents jm _ _ _ _ _ HeqHPHI); auto.
(* Goal: (fun o : option rmap => forall e : @eq (option rmap) o (@age1 rmap ag_rmap (m_phi j)), @eq (option juicy_mem) (match o as anonymous' return (forall _ : @eq (option rmap) anonymous' (@age1 rmap ag_rmap (m_phi j)), option juicy_mem) with | Some phi' => fun Heq_anonymous : @eq (option rmap) (@Some rmap phi') (@age1 rmap ag_rmap (m_phi j)) => @Some juicy_mem (mkJuicyMem (m_dry j) phi' (age1_juicy_mem_obligation_1 j phi' Heq_anonymous) (age1_juicy_mem_obligation_2 j phi' Heq_anonymous) (age1_juicy_mem_obligation_3 j phi' Heq_anonymous) (age1_juicy_mem_obligation_4 j phi' Heq_anonymous)) | None => fun _ : @eq (option rmap) (@None rmap) (@age1 rmap ag_rmap (m_phi j)) => @None juicy_mem end e) (@None juicy_mem)) (@age1 rmap ag_rmap (m_phi j)) *)
rewrite H.
(* Goal: @eq (option permission) (perm_of_res (PURE k p)) (@Some permission Nonempty) *)
(* Goal: @eq (option permission) (if @eq_dec Share.t Share.EqDec_share Share.bot Share.bot then @None permission else @Some permission Nonempty) (@None permission) *)
unfold resource_fmap; f_equal; try reflexivity.
assert (H: p = NoneP).
  symmetry in HeqHPHI;
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  destruct  (juicy_mem_contents jm _ _ _ _ _ HeqHPHI); auto.
rewrite H in HeqHPHI; clear H.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite HeqHPHI; auto.
Qed.

Lemma inflate_free_resource_decay:
 forall (jm :juicy_mem) (m': mem)
          (b: block) (lo hi: Z)
          (FREE: free (m_dry jm) b lo hi = Some m')
          (PERM: forall ofs : Z,
             lo <= ofs < hi -> perm_of_res (m_phi jm @ (b, ofs)) = Some Freeable),
   resource_decay (nextblock (m_dry jm)) (m_phi jm) (inflate_free jm b lo hi).
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
intros.
(* Goal: and (forall _ : Pos.ge (@fst block Z l) (nextblock (m_dry jm)), @eq resource (resource_at (m_phi jm) l) (NO Share.bot bot_unreadable)) (or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable)))))))) *)
split.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
unfold inflate_free; rewrite level_make_rmap; auto.
(* Goal: forall l : address, and (forall _ : Pos.ge (@fst block Z l) (nextblock (m_dry jm)), @eq resource (resource_at (m_phi jm) l) (NO Share.bot bot_unreadable)) (or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable)))))))) *)
intros l.
(* Goal: and (forall _ : Pos.ge (@fst block Z l) (nextblock (m_dry jm)), @eq resource (resource_at (m_phi jm) l) (NO Share.bot bot_unreadable)) (or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable)))))))) *)
split.
(* Goal: forall _ : Pos.ge (@fst block Z l) (nextblock (m_dry jm)), @eq resource (resource_at (m_phi jm) l) (NO Share.bot bot_unreadable) *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable))))))) *)
apply juicy_mem_alloc_cohere.
destruct (adr_range_dec (b, lo) (hi-lo) l) as [HA | HA].
* (* adr_range *)
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (NO Share.bot bot_unreadable) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (NO Share.bot bot_unreadable) (NO Share.bot bot_unreadable))))) *)
right. right.
destruct l; simpl in HA|-*.
(* Goal: or (and (Pos.ge b0 (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) (@pair block Z b0 z)) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (NO Share.bot bot_unreadable))))) *)
destruct HA as [H0 H1]. subst b0.
assert (lo + (hi - lo) = hi) by omega.
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b z)) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) (@pair block Z b z)) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b z)) (NO Share.bot bot_unreadable))))) *)
rewrite H in H1. clear H.
(* Goal: @eq resource (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) x then NO Share.bot bot_unreadable else resource_at (m_phi jm) x)) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (fun l : AV.address => let (b', ofs') as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) p then NO Share.bot bot_unreadable else resource_at (m_phi jm) p)) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) p then NO Share.bot bot_unreadable else resource_at (m_phi jm) p)) := l in if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) (@pair block Z b' ofs') as s return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if s then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b' ofs'))) (if s then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b' ofs'))) then @eq_refl resource (NO Share.bot bot_unreadable) else resource_at_approx (m_phi jm) (@pair block Z b' ofs'))) (ghost_of_approx (m_phi jm)))) loc) (NO Share.bot bot_unreadable) *)
unfold inflate_free; simpl; rewrite resource_at_make_rmap.
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) (@pair block Z b z) then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b z)) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) (@pair block Z b z)) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) (@pair block Z b z) then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b z)) (NO Share.bot bot_unreadable))))) *)
specialize (PERM _ H1).
destruct (m_phi jm @ (b,z)) eqn:?; try destruct k; inv PERM.
(* Goal: and (@eq memval (contents_at m loc) v) (@eq preds pp NoneP) *)
if_tac in H0; inv H0.
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) (@pair block Z b z) then NO Share.bot bot_unreadable else YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) (@pair block Z b z) then NO Share.bot bot_unreadable else YES sh r (VAL m) p) (NO Share.bot bot_unreadable))))) *)
rewrite if_true by (split; auto; omega).
(* Goal: or (and (Pos.ge b (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (NO Share.bot bot_unreadable) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (NO Share.bot bot_unreadable) (NO Share.bot bot_unreadable))))) *)
right.
(* Goal: @ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (NO Share.bot bot_unreadable) (NO Share.bot bot_unreadable)))) *)
exists m, p.
(* Goal: and (@eq resource (YES sh r (VAL m) p) (YES Share.top readable_share_top (VAL m) p)) (@eq resource (NO Share.bot bot_unreadable) (NO Share.bot bot_unreadable)) *)
unfold perm_of_sh in H0.
(* Goal: and (@eq memval (contents_at m loc) v) (@eq preds pp NoneP) *)
repeat if_tac in H0; inv H0.
(* Goal: @eq (option permission) (perm_of_res (PURE k p)) (@Some permission Nonempty) *)
(* Goal: @eq (option permission) (if @eq_dec Share.t Share.EqDec_share Share.bot Share.bot then @None permission else @Some permission Nonempty) (@None permission) *)
split; try reflexivity. f_equal; apply proof_irr.
* (* ~adr_range *)
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (resource_at (inflate_free jm b lo hi) l)) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) l)) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z l) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) l) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) l) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) l) (NO Share.bot bot_unreadable))))))) *)
destruct l.
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) (@pair block Z b0 z))) (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z))) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) (@pair block Z b0 z))) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z (@pair block Z b0 z)) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) (@pair block Z b0 z)) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (NO Share.bot bot_unreadable))))))) *)
destruct (free_nadr_range_eq _ _ _ _ _ _ _ HA FREE).
(* Goal: or (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) (@pair block Z b0 z))) (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z))) (or (@ex share (fun sh : share => @ex (writable0_share sh) (fun wsh : writable0_share sh => @ex memval (fun v : memval => @ex memval (fun v' : memval => and (@eq resource (resource_fmap (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (approx (@level rmap ag_rmap (inflate_free jm b lo hi))) (resource_at (m_phi jm) (@pair block Z b0 z))) (YES sh (@writable0_readable sh wsh) (VAL v) NoneP)) (@eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (YES sh (@writable0_readable sh wsh) (VAL v') NoneP))))))) (or (and (Pos.ge (@fst block Z (@pair block Z b0 z)) (nextblock (m_dry jm))) (@ex memval (fun v : memval => @eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (YES Share.top readable_share_top (VAL v) NoneP)))) (@ex memval (fun v : memval => @ex preds (fun pp : preds => and (@eq resource (resource_at (m_phi jm) (@pair block Z b0 z)) (YES Share.top readable_share_top (VAL v) pp)) (@eq resource (resource_at (inflate_free jm b lo hi) (@pair block Z b0 z)) (NO Share.bot bot_unreadable))))))) *)
left.
(* Goal: @eq resource (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) x then NO Share.bot bot_unreadable else resource_at (m_phi jm) x)) (fun loc : AV.address => if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) loc then NO Share.bot bot_unreadable else resource_at (m_phi jm) loc) (fun l : AV.address => let (b', ofs') as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) p then NO Share.bot bot_unreadable else resource_at (m_phi jm) p)) (if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) p then NO Share.bot bot_unreadable else resource_at (m_phi jm) p)) := l in if adr_range_dec (@pair block Z b lo) (Z.sub hi lo) (@pair block Z b' ofs') as s return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (if s then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b' ofs'))) (if s then NO Share.bot bot_unreadable else resource_at (m_phi jm) (@pair block Z b' ofs'))) then @eq_refl resource (NO Share.bot bot_unreadable) else resource_at_approx (m_phi jm) (@pair block Z b' ofs'))) (ghost_of_approx (m_phi jm)))) loc) (NO Share.bot bot_unreadable) *)
unfold inflate_free; rewrite level_make_rmap; rewrite resource_at_make_rmap.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
rewrite if_false by auto.
(* Goal: @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) (@pair block Z b0 z))) (resource_at (m_phi jm) (@pair block Z b0 z)) *)
generalize (juicy_mem_contents jm); intro Hc.
(* Goal: @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) (@pair block Z b0 z))) (resource_at (m_phi jm) (@pair block Z b0 z)) *)
generalize (juicy_mem_access jm (b0,z)); intro Ha.
(* Goal: @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) (@pair block Z b0 z))) (resource_at (m_phi jm) (@pair block Z b0 z)) *)
rewrite resource_at_approx.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
case_eq (m_phi jm @ (b0, z)); intros; rewrite H1 in Ha; auto.
Qed.

Lemma juicy_store_nodecay:
  forall jm m' ch b ofs v
       (H: store ch (m_dry jm) b ofs v = Some m')
          (PERM: forall z, ofs <= z < ofs + size_chunk ch ->
                      perm_order'' (perm_of_res (m_phi jm @ (b,z))) (Some Writable)),
       resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm _ _ _ _ _ H)).
Proof.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
 intros.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
 eapply inflate_store_resource_nodecay; eauto.
Qed.

Lemma can_age1_juicy_mem: forall j r,
  age (m_phi j) r -> exists j', age1 j = Some j'.
Proof.
(* Goal: forall (j : juicy_mem) (r : rmap) (_ : @age rmap ag_rmap (m_phi j) r), @ex juicy_mem (fun j' : juicy_mem => @eq (option juicy_mem) (@age1 juicy_mem juicy_mem_ageable j) (@Some juicy_mem j')) *)
intros j r H.
(* Goal: @ex juicy_mem (fun j' : juicy_mem => @eq (option juicy_mem) (@age1 juicy_mem juicy_mem_ageable j) (@Some juicy_mem j')) *)
unfold age in H.
(* Goal: forall (jm : juicy_mem) (m' : mem) (ch : memory_chunk) (b : block) (ofs : Z) (v : val) (H : @eq (option mem) (store ch (m_dry jm) b ofs v) (@Some mem m')) (_ : forall (z : Z) (_ : and (Z.le ofs z) (Z.lt z (Z.add ofs (size_chunk ch)))), perm_order'' (perm_of_res (resource_at (m_phi jm) (@pair block Z b z))) (@Some permission Writable)), resource_nodecay (nextblock (m_dry jm)) (m_phi jm) (m_phi (store_juicy_mem jm m' ch b ofs v H)) *)
case_eq (age1_juicy_mem j); intros.
(* Goal: @ex juicy_mem (fun j' : juicy_mem => @eq (option juicy_mem) (@age1 juicy_mem juicy_mem_ageable j) (@Some juicy_mem j')) *)
(* Goal: @ex juicy_mem (fun j' : juicy_mem => @eq (option juicy_mem) (@age1 juicy_mem juicy_mem_ageable j) (@Some juicy_mem j')) *)
destruct (age1_juicy_mem_unpack _ _ H0).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
eexists; eauto.
(* Goal: @ex juicy_mem (fun j' : juicy_mem => @eq (option juicy_mem) (@age1 juicy_mem juicy_mem_ageable j) (@Some juicy_mem j')) *)
apply age1_juicy_mem_None1 in H0.
(* Goal: @ex juicy_mem (fun j' : juicy_mem => @eq (option juicy_mem) (@age1 juicy_mem juicy_mem_ageable j) (@Some juicy_mem j')) *)
rewrite H0 in H.
(* Goal: @ex juicy_mem (fun j' : juicy_mem => @eq (option juicy_mem) (@age1 juicy_mem juicy_mem_ageable j) (@Some juicy_mem j')) *)
elimtype False; inversion H.
Qed.


Lemma can_age_jm:
  forall jm, age1 (m_phi jm) <> None -> exists jm', age jm jm'.
Proof.
(* Goal: @eq preds pp NoneP *)
 intro jm; case_eq (age1 (m_phi jm)); intros; try congruence.
(* Goal: @ex juicy_mem (fun jm' : juicy_mem => @age juicy_mem juicy_mem_ageable jm jm') *)
 apply (can_age1_juicy_mem _ _ H).
Qed.


Lemma age_jm_dry: forall {jm jm'}, age jm jm' -> m_dry jm = m_dry jm'.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
Proof. intros; destruct (age1_juicy_mem_unpack _ _ H); auto.
Qed.

Lemma age_jm_phi: forall {jm jm'}, age jm jm' -> age (m_phi jm) (m_phi jm').
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
Proof. intros; destruct (age1_juicy_mem_unpack _ _ H); auto.
Qed.

(** * Results about aging in juicy memory coherence properties *)

(* Goal: max_access_cohere m' inflate_free *)
Lemma age1_YES'_1 {phi phi' l rsh sh k P} :
  age1 phi = Some phi' ->
  phi @ l = YES rsh sh k P ->
  (exists P, phi' @ l = YES rsh sh k P).
Proof.
(* Goal: forall (_ : @eq (option rmap) (@age1 rmap ag_rmap phi') (@Some rmap phi)) (_ : @eq resource (resource_at phi' l) (PURE k P)), @ex preds (fun P : preds => @eq resource (resource_at phi l) (PURE k P)) *)
  intros A E.
(* Goal: @ex preds (fun P : preds => @eq resource (resource_at phi' l) (YES rsh sh k P)) *)
  apply (proj1 (age1_YES' phi phi' l rsh sh k A)).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  eauto.
Qed.

(* Goal: max_access_cohere m' inflate_free *)
Lemma age1_YES'_2 {phi phi' l rsh sh k P} :
  age1 phi = Some phi' ->
  phi' @ l = YES rsh sh k P ->
  (exists P, phi @ l = YES rsh sh k P).
Proof.
(* Goal: forall (_ : @eq (option rmap) (@age1 rmap ag_rmap phi') (@Some rmap phi)) (_ : @eq resource (resource_at phi' l) (PURE k P)), @ex preds (fun P : preds => @eq resource (resource_at phi l) (PURE k P)) *)
  intros A E.
(* Goal: @ex preds (fun P : preds => @eq resource (resource_at phi l) (YES rsh sh k P)) *)
  apply (proj2 (age1_YES' phi phi' l rsh sh k A)).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  eauto.
Qed.

(* Goal: max_access_cohere m' inflate_free *)
Lemma age1_PURE_2 {phi phi' l k P} :
  age1 phi = Some phi' ->
  phi' @ l = PURE k P ->
  (exists P, phi @ l = PURE k P).
Proof.
(* Goal: forall (_ : @eq (option rmap) (@age1 rmap ag_rmap phi') (@Some rmap phi)) (_ : @eq resource (resource_at phi' l) (PURE k P)), @ex preds (fun P : preds => @eq resource (resource_at phi l) (PURE k P)) *)
  intros A E.
(* Goal: @ex preds (fun P : preds => @eq resource (resource_at phi l) (PURE k P)) *)
  apply (proj2 (age1_PURE phi phi' l k A)).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  eauto.
Qed.

Lemma perm_of_res_age x y loc :
  age x y -> perm_of_res (x @ loc) = perm_of_res (y @ loc).
Proof.
(* Goal: forall _ : @age rmap ag_rmap x y, @eq (option permission) (perm_of_res (resource_at x loc)) (perm_of_res (resource_at y loc)) *)
  intros A.
(* Goal: @eq (option permission) (perm_of_res (resource_at x loc)) (perm_of_res (resource_at y loc)) *)
  destruct (x @ loc) as [sh | rsh sh k p | k p] eqn:E.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  - destruct (age1_NO x y loc sh n A) as [[]_]; eauto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  - destruct (age1_YES' x y loc rsh sh k A) as [[p' ->] _]; eauto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  - destruct (age1_PURE x y loc k A) as [[p' ->] _]; eauto.
Qed.

Lemma contents_cohere_age m : hereditary age (contents_cohere m).
Proof.
(* Goal: @hereditary rmap (@unage rmap ag_rmap) (contents_cohere m) *)
  intros x y E A.
(* Goal: contents_cohere m y *)
  intros rsh sh v loc pp H.
(* Goal: and (@eq memval (contents_at m loc) v) (@eq preds pp NoneP) *)
  destruct (proj2 (age1_YES' _ _ loc rsh sh (VAL v) E)) as [pp' E'].
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  now eauto.
(* Goal: and (@eq memval (contents_at m loc) v) (@eq preds pp NoneP) *)
  specialize (A rsh sh v loc _ E').
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  destruct A as [A ->]. split; auto.
(* Goal: @eq preds pp NoneP *)
  apply (proj1 (age1_YES _ _ loc rsh sh (VAL v) E)) in E'.
(* Goal: @eq preds pp NoneP *)
  congruence.
Qed.

Lemma access_cohere_age m : hereditary age (access_cohere m).
Proof.
(* Goal: @hereditary rmap (@unage rmap ag_rmap) (access_cohere m) *)
  intros x y E B.
(* Goal: access_cohere m y *)
  intros addr.
(* Goal: @eq (option permission) (access_at m addr Cur) (perm_of_res (resource_at y addr)) *)
  destruct (age1_levelS _ _ E) as [n L].
(* Goal: @eq (option permission) (access_at m addr Cur) (perm_of_res (resource_at y addr)) *)
  rewrite (B addr).
(* Goal: @eq (option permission) (perm_of_res (resource_at y addr)) (perm_of_res (resource_at x addr)) *)
  apply perm_of_res_age, E.
Qed.

Lemma max_access_cohere_age m : hereditary age (max_access_cohere m).
Proof.
(* Goal: @hereditary rmap (@unage rmap ag_rmap) (max_access_cohere m) *)
  intros x y E C.
(* Goal: max_access_cohere m y *)
  intros addr; specialize (C addr).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (resource_at y addr)) *)
  destruct (y @ addr) as [sh | sh p k pp | k p] eqn:AT.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  - eapply (age1_NO x) in AT; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
    rewrite AT in C; auto.
  - destruct (age1_YES'_2 E AT) as [P Ex].
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k pp)) *)
    rewrite Ex in C.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
    auto.
  - destruct (age1_PURE_2 E AT) as [P Ex].
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
    rewrite Ex in C; auto.
Qed.

Lemma alloc_cohere_age m : hereditary age (alloc_cohere m).
Proof.
(* Goal: @hereditary rmap (@unage rmap ag_rmap) (alloc_cohere m) *)
  intros x y E D.
(* Goal: alloc_cohere m y *)
  intros loc G; specialize (D loc G).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  eapply (age1_NO x); eauto.
Qed.


(** * Results in the opposite direction *)

(* Goal: max_access_cohere m' inflate_free *)
Definition unage {A} {_:ageable A} x y := age y x.

(* Goal: max_access_cohere m' inflate_free *)
Lemma unage_YES'_1 {phi phi' l rsh sh k P} :
  age1 phi' = Some phi ->
  phi @ l = YES rsh sh k P ->
  (exists P, phi' @ l = YES rsh sh k P).
Proof.
(* Goal: forall (_ : @eq (option rmap) (@age1 rmap ag_rmap phi') (@Some rmap phi)) (_ : @eq resource (resource_at phi' l) (PURE k P)), @ex preds (fun P : preds => @eq resource (resource_at phi l) (PURE k P)) *)
  intros A E.
(* Goal: @ex preds (fun P : preds => @eq resource (resource_at phi' l) (YES rsh sh k P)) *)
  apply (proj2 (age1_YES' phi' phi l rsh sh k A)).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  eauto.
Qed.

(* Goal: max_access_cohere m' inflate_free *)
Lemma unage_YES'_2 {phi phi' l rsh sh k P} :
  age1 phi' = Some phi ->
  phi' @ l = YES rsh sh k P ->
  (exists P, phi @ l = YES rsh sh k P).
Proof.
(* Goal: forall (_ : @eq (option rmap) (@age1 rmap ag_rmap phi') (@Some rmap phi)) (_ : @eq resource (resource_at phi' l) (PURE k P)), @ex preds (fun P : preds => @eq resource (resource_at phi l) (PURE k P)) *)
  intros A E.
(* Goal: @ex preds (fun P : preds => @eq resource (resource_at phi l) (YES rsh sh k P)) *)
  apply (proj1 (age1_YES' phi' phi l rsh sh k A)).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  eauto.
Qed.

(* Goal: max_access_cohere m' inflate_free *)
Lemma unage_PURE_2 {phi phi' l k P} :
  age1 phi' = Some phi ->
  phi' @ l = PURE k P ->
  (exists P, phi @ l = PURE k P).
Proof.
(* Goal: forall (_ : @eq (option rmap) (@age1 rmap ag_rmap phi') (@Some rmap phi)) (_ : @eq resource (resource_at phi' l) (PURE k P)), @ex preds (fun P : preds => @eq resource (resource_at phi l) (PURE k P)) *)
  intros A E.
(* Goal: @ex preds (fun P : preds => @eq resource (resource_at phi l) (PURE k P)) *)
  apply (proj1 (age1_PURE phi' phi l k A)).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  eauto.
Qed.

Lemma contents_cohere_unage m : hereditary unage (contents_cohere m).
Proof.
(* Goal: @hereditary rmap (@unage rmap ag_rmap) (contents_cohere m) *)
  intros x y E A.
(* Goal: contents_cohere m y *)
  intros rsh sh v loc pp H.
(* Goal: and (@eq memval (contents_at m loc) v) (@eq preds pp NoneP) *)
  destruct (proj1 (age1_YES' _ _ loc rsh sh (VAL v) E)) as [pp' E'].
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  eauto.
(* Goal: and (@eq memval (contents_at m loc) v) (@eq preds pp NoneP) *)
  specialize (A rsh sh v loc _ E').
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  destruct A as [A ->]. split; auto.
(* Goal: @eq preds pp NoneP *)
  apply (proj2 (age1_YES _ _ loc rsh sh (VAL v) E)) in E'.
(* Goal: @eq preds pp NoneP *)
  congruence.
Qed.

Lemma access_cohere_unage m : hereditary unage (access_cohere m).
Proof.
(* Goal: @hereditary rmap (@unage rmap ag_rmap) (access_cohere m) *)
  intros x y E B.
(* Goal: access_cohere m y *)
  intros addr.
(* Goal: @eq (option permission) (access_at m addr Cur) (perm_of_res (resource_at y addr)) *)
  destruct (age1_levelS _ _ E) as [n L].
(* Goal: @eq (option permission) (access_at m addr Cur) (perm_of_res (resource_at y addr)) *)
  rewrite (B addr).
(* Goal: @eq (option permission) (perm_of_res (resource_at x addr)) (perm_of_res (resource_at y addr)) *)
  symmetry.
(* Goal: @eq (option permission) (perm_of_res (resource_at y addr)) (perm_of_res (resource_at x addr)) *)
  apply perm_of_res_age, E.
Qed.

Lemma max_access_cohere_unage m : hereditary unage (max_access_cohere m).
Proof.
(* Goal: @hereditary rmap (@unage rmap ag_rmap) (max_access_cohere m) *)
  intros x y E C.
(* Goal: max_access_cohere m y *)
  intros addr; specialize (C addr).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (resource_at y addr)) *)
  destruct (x @ addr) as [sh | sh p k pp | k p] eqn:AT.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  - eapply (age1_NO y) in AT; auto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
    rewrite AT; auto.
  - destruct (@age1_YES'_2 y x addr sh p k pp E AT) as [P ->].
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
    auto.
  - destruct (age1_PURE_2 E AT) as [P Ex].
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
    rewrite Ex; auto.
Qed.

Lemma alloc_cohere_unage m : hereditary unage (alloc_cohere m).
Proof.
(* Goal: @hereditary rmap (@unage rmap ag_rmap) (alloc_cohere m) *)
  intros x y E D.
(* Goal: alloc_cohere m y *)
  intros loc G; specialize (D loc G).
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  eapply (age1_NO y); eauto.
Qed.

(* Goal: max_access_cohere m' inflate_free *)
Lemma juicy_mem_unage jm' : { jm | age jm jm' }.
Proof.
  pose proof (rmap_unage_age (m_phi jm')) as A.
  remember (rmap_unage (m_phi jm')) as phi.
  unshelve eexists (mkJuicyMem (m_dry jm') phi _ _ _ _).
(* Goal: @eq nat (@level juicy_mem juicy_mem_ageable (mkJuicyMem m (inflate_store m (m_phi jm)) (fun (rsh : Share.t) (sh' : readable_share rsh) (v' : memval) (loc' : AV.address) (pp : preds) (H2 : @eq resource (resource_at (inflate_store m (m_phi jm)) loc') (YES rsh sh' (VAL v') pp)) => match resource_at (m_phi jm) loc' as r return (forall _ : @eq resource match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc')) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | NO sh n => fun H3 : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => match H3 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (NO sh n) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (NO sh n) (fun e : resource => match e with | NO sh0 x => True | YES sh0 x x0 x1 => False | PURE x x0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | YES sh r k p => fun H3 : @eq resource match k with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k p) end (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc')) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) => @eq_ind_r Share.t rsh (fun _ : Share.t => forall (_ : @eq memval (contents_at m loc') v') (_ : @eq preds NoneP pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (fun H1 : @eq memval (contents_at m loc') v' => @eq_ind memval (contents_at m loc') (fun m1 : memval => forall _ : @eq preds NoneP pp, and (@eq memval (contents_at m loc') m1) (@eq preds pp NoneP)) (fun H5 : @eq preds NoneP pp => @eq_ind preds NoneP (fun p0 : preds => and (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds p0 NoneP)) (@conj (@eq memval (contents_at m loc') (contents_at m loc')) (@eq preds NoneP NoneP) (@eq_refl memval (contents_at m loc')) (@eq_refl preds NoneP)) pp H5) v' H1) sh (@f_equal resource Share.t (fun e : resource => match e with | NO sh0 n => sh | YES sh0 r0 k0 p0 => sh0 | PURE k0 p0 => sh end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource memval (fun e : resource => match e with | NO sh0 n => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p0 => xO p0 | Zneg p0 => xI p0 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (VAL m as k0) p0 => m | YES sh0 r0 (LK n i as k0) p0 => match (fix get (A : Type) (i0 : positive) (m : PTree.t A) {struct i0} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i0 with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | YES sh0 r0 (FUN f c as k0) p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r1 => match i with | xI ii => get A ii r1 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end | PURE k0 p0 => match (fix get (A : Type) (i : positive) (m : PTree.t A) {struct i} : option A := match m with | PTree.Leaf => @None A | PTree.Node l o r0 => match i with | xI ii => get A ii r0 | xO ii => get A ii l | xH => o end end) memval match (let (_, y) := loc' in y) with | Z0 => xH | Zpos p1 => xO p1 | Zneg p1 => xI p1 end (@snd memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m))) with | Some x => x | None => @fst memval (PTree.t memval) (@PMap.get (ZMap.t memval) (@fst block Z loc') (mem_contents m)) end end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) (@f_equal resource preds (fun e : resource => match e with | NO sh0 n => SomeP (ConstType unit) (fun _ : list Type => tt) | YES sh0 r0 k0 p0 => p0 | PURE k0 p0 => SomeP (ConstType unit) (fun _ : list Type => tt) end) (YES sh r (VAL (contents_at m loc')) NoneP) (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (LK n i) p)) (fun e : resource => match e with | NO sh0 n0 => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n0 i0 as k0) p0 => True | YES sh0 r0 (FUN x x0 as k0) p0 => False | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r (FUN f c) p)) (fun e : resource => match e with | NO sh0 n => False | YES sh0 r0 (VAL x as k0) p0 => False | YES sh0 r0 (LK n i as k0) p0 => False | YES sh0 r0 (FUN x x0 as k0) p0 => True | PURE k0 p0 => False end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 | PURE k p => fun H3 : @eq resource (PURE k p) (YES rsh sh' (VAL v') pp) => match k as k0 return (forall _ : @eq resource (PURE k0 p) (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | VAL m0 => fun H4 : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (VAL m0) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (VAL m0) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | LK n i => fun H4 : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (LK n i) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (LK n i) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) | FUN f c => fun H4 : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => match H4 in (eq _ y) return (forall _ : @eq resource y (YES rsh sh' (VAL v') pp), and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) with | eq_refl => fun H : @eq resource (PURE (FUN f c) p) (YES rsh sh' (VAL v') pp) => False_ind (and (@eq memval (contents_at m loc') v') (@eq preds pp NoneP)) (@eq_ind resource (PURE (FUN f c) p) (fun e : resource => match e with | NO sh x => False | YES sh x x0 x1 => False | PURE x x0 => True end) I (YES rsh sh' (VAL v') pp) H) end (@eq_refl resource (YES rsh sh' (VAL v') pp)) end H3 end (@eq_ind (forall _ : AV.address, resource) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun r : forall _ : AV.address, resource => @eq resource (r loc') (YES rsh sh' (VAL v') pp)) H2 (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (resource_at_make_rmap (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m x)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc : AV.address => match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m loc)) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh0 (VAL m0 as k) p0 => YES sh rsh0 (VAL (contents_at m p)) NoneP | YES sh rsh0 (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh0 (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh0 (VAL m0 as k) p => YES sh rsh0 (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh0 (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh0 (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq (option permission) (access_at m loc Cur) (perm_of_res (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => @eq (option permission) (o loc Cur) (perm_of_res match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res r), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (NO sh n)) => H0 | YES sh r k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (YES sh r (FUN f c) p)) => H1 end H0 | PURE k p => fun H0 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k p)) => match k as k0 return (forall _ : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p)), @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE k0 p))) with | VAL m => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (VAL m) p)) => H1 | LK n i => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (LK n i) p)) => H1 | FUN f c => fun H1 : @eq (option permission) (access_at (m_dry jm) loc Cur) (perm_of_res (PURE (FUN f c) p)) => H1 end H0 end (juicy_mem_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun loc : address => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => perm_order'' (max_access_at m loc) (perm_of_res' (r loc))) (@eq_ind (forall (_ : address) (_ : perm_kind), option permission) (access_at (m_dry jm)) (fun o : forall (_ : address) (_ : perm_kind), option permission => perm_order'' (o loc Max) (perm_of_res' match resource_at (m_phi jm) loc with | NO sh n => resource_at (m_phi jm) loc | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc) | PURE k p => resource_at (m_phi jm) loc end)) (match resource_at (m_phi jm) loc as r return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' r), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end)) with | NO sh n => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (NO sh n)) => H1 | YES sh r k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k p)) => match k as k0 return (forall _ : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r k0 p)), perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' match k0 with | VAL m0 => YES sh r (VAL (contents_at m loc)) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end)) with | VAL m => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (VAL m) p)) => H2 | LK n i => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (LK n i) p)) => H2 | FUN f c => fun H2 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (YES sh r (FUN f c) p)) => H2 end H1 | PURE k p => fun H1 : perm_order'' (access_at (m_dry jm) loc Max) (perm_of_res' (PURE k p)) => H1 end (juicy_mem_max_access jm loc)) (access_at m) (Memory.storebytes_access (m_dry jm) b i bytes m H)) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))) (fun (loc : prod positive Z) (H0 : Pos.ge (@fst positive Z loc) (nextblock m)) => @eq_ind_r (forall _ : AV.address, resource) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun r : forall _ : AV.address, resource => @eq resource (r loc) (NO Share.bot bot_unreadable)) (@eq_ind_r resource (NO Share.bot bot_unreadable) (fun r : resource => @eq resource match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end (NO Share.bot bot_unreadable)) (@eq_refl resource (NO Share.bot bot_unreadable)) (resource_at (m_phi jm) loc) (juicy_mem_alloc_cohere jm loc (@eq_ind block (nextblock m) (fun b : block => Pos.ge (@fst positive Z loc) b) H0 (nextblock (m_dry jm)) (nextblock_storebytes (m_dry jm) b i bytes m H)))) (resource_at (@proj1_sig rmap (fun phi : rmap => and (@eq nat (@level rmap ag_rmap phi) (@level rmap ag_rmap (m_phi jm))) (and (@eq (forall _ : AV.address, resource) (resource_at phi) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end)) (@eq ghost (ghost_of phi) (ghost_of (m_phi jm))))) (make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm))))) (resource_at_make_rmap (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (ghost_of (m_phi jm)) (@level rmap ag_rmap (m_phi jm)) (@functional_extensionality AV.address resource (fun x : AV.address => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) x with | NO sh n => resource_at (m_phi jm) x | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m x)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) x) | PURE k p => resource_at (m_phi jm) x end) (fun loc0 : AV.address => match resource_at (m_phi jm) loc0 with | NO sh n => resource_at (m_phi jm) loc0 | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m loc0)) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) loc0) | PURE k p => resource_at (m_phi jm) loc0 end) (fun l : AV.address => let (b, ofs) as p return (@eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) match resource_at (m_phi jm) p with | NO sh n => resource_at (m_phi jm) p | YES sh rsh (VAL m0 as k) p0 => YES sh rsh (VAL (contents_at m p)) NoneP | YES sh rsh (LK n i as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | YES sh rsh (FUN f c as k) p0 => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (resource_at (m_phi jm) p) | PURE k p0 => resource_at (m_phi jm) p end) := l in match resource_at (m_phi jm) (@pair block Z b ofs) as r return (forall _ : @eq resource r (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) match r with | NO sh n => r | YES sh rsh (VAL m0 as k) p => YES sh rsh (VAL (contents_at m (@pair block Z b ofs))) NoneP | YES sh rsh (LK n i as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | YES sh rsh (FUN f c as k) p => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r | PURE k p => r end) with | NO sh n => fun _ : @eq resource (NO sh n) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_refl resource (NO sh n) | YES sh r k p => fun HeqHPHI : @eq resource (YES sh r k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => match k as k0 return (forall _ : @eq resource (YES sh r k0 p) (resource_at (m_phi jm) (@pair block Z b ofs)), @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) match k0 with | VAL m0 => YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP | LK n i => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) | FUN f c => resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (YES sh r k0 p) end) with | VAL m0 => fun _ : @eq resource (YES sh r (VAL m0) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds NoneP (fun p0 : preds => @eq resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) p0) (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (@eq_refl resource (YES sh r (VAL (contents_at m (@pair block Z b ofs))) NoneP)) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) NoneP) (preds_fmap_NoneP (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm)))) | LK n i => fun _ : @eq resource (YES sh r (LK n i) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (LK n i) p0) (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (LK n i) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) | FUN f c => fun _ : @eq resource (YES sh r (FUN f c) p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r preds (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p) (fun p0 : preds => @eq resource (YES sh r (FUN f c) p0) (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (@eq_refl resource (YES sh r (FUN f c) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) (preds_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) p)) (approx_map_idem (@level rmap ag_rmap (m_phi jm)) p) end HeqHPHI | PURE k p => fun HeqHPHI : @eq resource (PURE k p) (resource_at (m_phi jm) (@pair block Z b ofs)) => @eq_ind_r resource (resource_at (m_phi jm) (@pair block Z b ofs)) (fun r : resource => @eq resource (resource_fmap (approx (@level rmap ag_rmap (m_phi jm))) (approx (@level rmap ag_rmap (m_phi jm))) r) r) (resource_at_approx (m_phi jm) (@pair block Z b ofs)) (PURE k p) HeqHPHI end (@eq_refl resource (resource_at (m_phi jm) (@pair block Z b ofs))))) (ghost_of_approx (m_phi jm)))))) (@level juicy_mem juicy_mem_ageable jm) *)
  all: destruct jm' as [m phi' Co Ac Ma N]; simpl.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  - eapply contents_cohere_unage; eauto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  - eapply access_cohere_unage; eauto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  - eapply max_access_cohere_unage; eauto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  - eapply alloc_cohere_unage; eauto.
(* Goal: perm_order'' (max_access_at m addr) (perm_of_res' (YES sh p k P)) *)
  - apply age1_juicy_mem_unpack''; auto.
Qed.
