(* Blocks that are not mapped by f are set to empty permission. This makes the invariant preservation easier. *)
Definition projectMap (f : memren) (pmap : access_map) : access_map :=
(pmap#1, Maps.PTree.fold (fun acc b bperm =>
match f b with
| Some b' =>
Maps.PTree.set b' bperm acc
| None =>
acc end)
pmap.2 (Maps.PTree.empty _)).

(* Specifications: *)
(** Its proof of correctness under the assumption that f is injective *)
Lemma projectMap_tree:
forall (f:memren) pmap
(Hf_injective: forall b1 b1' b2,
f b1 = Some b2 ->
f b1' = Some b2 ->
b1 = b1') b b'
(Hf: f b = Some b'),
Maps.PTree.get b pmap.2 = Maps.PTree.get b' (projectMap f pmap).2.
Lemma projectMap_correct:
forall (f:memren) pmap
(Hf_injective: forall b1 b1' b2,
f b1 = Some b2 ->
f b1' = Some b2 ->
b1 = b1') b b'
(Hf: f b = Some b'),
Maps.PMap.get b pmap = Maps.PMap.get b' (projectMap f pmap).
Lemma projectMap_tree_2:
forall (f:memren) pmap b'
(Hf: ~ exists b, f b = Some b'),
Maps.PTree.get b' (projectMap f pmap).2 = None.
Lemma projectMap_tree_unchanged :
forall f (pmap : access_map) (b2 : positive)
(Hb1: ~ (exists b1 : block, f b1 = Some b2)),
Maps.PTree.get b2 (projectMap f pmap).2 = None.
Lemma projectMap_correct_2:
forall f pmap b2
(Hb1: ~ (exists b1 : block, f b1 = Some b2)),
(projectMap f pmap) # b2 = pmap.1.
Lemma pmap_inj_incr:
forall f f' pmap pmap'
(Hincr: ren_incr f f')
(Hinjective: forall b1 b1' b2,
f' b1 = Some b2 ->
f' b1' = Some b2 ->
b1 = b1')
(Hinj: pmap_inj f pmap pmap'),
pmap_inj f' pmap pmap'.
Lemma delta_inj_incr:
forall f f' pmap pmap'
(Hincr: ren_incr f f')
(Hinjective: forall b1 b1' b2,
f' b1 = Some b2 ->
f' b1' = Some b2 ->
b1 = b1')
(Hinj: delta_inj f pmap pmap'),
delta_inj f' pmap pmap'.
Lemma memval_obs_eq_incr:
forall (f f': memren) mv1 mv2
(Hincr: ren_incr f f')
(Hobs_eq: memval_obs_eq f mv1 mv2),
memval_obs_eq f' mv1 mv2.
Lemma delta_content_inj_incr:
forall f f' pmap pmap'
(Hincr: ren_incr f f')
(Hinjective: forall b1 b1' b2,
f' b1 = Some b2 ->
f' b1' = Some b2 ->
b1 = b1')
(Hinj: delta_content_inj f pmap pmap'),
delta_content_inj f' pmap pmap'.
Lemma delta_content_inj_correct:
forall f pmapc pmapf dmap mc mf
(Hf_injective: forall b1 b1' b2,
f b1 = Some b2 ->
f b1' = Some b2 ->
b1 = b1')
(Hdelta_inj: delta_inj f dmap (projectAngel f dmap))
(Hltc: permMapLt (computeMap pmapc dmap) (getMaxPerm mc))
(Hltf: permMapLt (computeMap pmapf (projectAngel f dmap)) (getMaxPerm mf))
(Hobs_eq: mem_obs_eq f (restrPermMap Hltc) (restrPermMap Hltf)),
delta_content_inj f (build_delta_content dmap mc)
(build_delta_content (projectAngel f dmap) mf).
Lemma ev_sim_incr:
forall f f' ev ev'
(Hincr: ren_incr f f')
(Hinjective: forall b1 b1' b2,
f' b1 = Some b2 ->
f' b1' = Some b2 ->
b1 = b1')
(Hev_sim: event_sim f ev ev'),
event_sim f' ev ev'.
Lemma trace_sim_incr:
forall f f' trc trf
(Hincr: ren_incr f f')
(Hinjective: forall b1 b1' b2,
f' b1 = Some b2 ->
f' b1' = Some b2 ->
b1 = b1')
(Htr: trace_sim f trc trf),
trace_sim f' trc trf.
Lemma ctlType_inj :
forall st c c' m m' (f fg: memren)
(Hfg:forall b1 b2 : block, fg b1 = Some b2 -> b1 = b2)
(Hincr: ren_incr fg f)
(Hge_wd: ge_wd fg the_ge)
(Hvalid: valid_mem m)
(Hmem: mem_obs_eq f m m')
(Hinj: ctl_inj f c c'),
ctlType c m st <-> ctlType c' m' st.
Lemma stepType_inj:
forall tpc tpf i (pffi:containsThread tpf i) (pfci: containsThread tpc i) m m' f fg st
(Hfg:forall b1 b2 : block, fg b1 = Some b2 -> b1 = b2)
(Hincr: ren_incr fg f)
(Hge_wd: ge_wd fg the_ge)
(Hvalid_mem: valid_mem m)
(Hmem_obs_eq: mem_obs_eq f m m'),
ctl_inj f (getThreadC pfci) (getThreadC pffi) ->
getStepType pfci m st <-> getStepType pffi m' st.
Lemma sim_reduce:
forall tpc trc mc tpf trf mf xs f fg fp n m,
sim tpc trc mc tpf trf mf xs f fg fp n ->
m <= n ->
sim tpc trc mc tpf trf mf xs f fg fp m.
Lemma sim_fail: sim_fail_def.
Existing Instance HybridCoarseMachine.DilMem.