(** Apply a [delta_map] to an [access_map]*)
Definition computeMap (pmap : access_map) (delta : delta_map) : access_map :=
(pmap.1,
@Maps.PTree.combine (Z -> option permission) (Z -> option (option permission))
(Z -> option permission)
(fun p1 pd => match pd, p1 with
| Some pd', Some p1' =>
Some (fun z => match pd' z with
Some pd'' => pd''
| _ => p1' z
end)
| Some pd', None =>
Some (fun z => match pd' z with
Some pd'' => pd''
| _ => pmap.1 z
end)
| None, _ => p1
end)
pmap.2 delta).

(* Specifications: *)
(** If the [delta_map] changes the [access_map] at a specific [address] *)
Lemma computeMap_1 :
forall (pmap : access_map) (dmap : delta_map) b ofs df (p : option permission),
Maps.PTree.get b dmap = Some df ->
df ofs = Some p ->
Maps.PMap.get b (computeMap pmap dmap) ofs = p.
(** If the [delta_map] changes the [access_map] at this [block] but not at this [offset] *)
Lemma computeMap_2 :
forall (pmap : access_map) (dmap : delta_map) b ofs df,
Maps.PTree.get b dmap = Some df ->
df ofs = None ->
Maps.PMap.get b (computeMap pmap dmap) ofs = Maps.PMap.get b pmap ofs.
(** If the [delta_map] does not change the [access_map] at this [block] *)
Lemma computeMap_3 :
forall (pmap : access_map) (dmap : delta_map) b ofs,
Maps.PTree.get b dmap = None ->
Maps.PMap.get b (computeMap pmap dmap) ofs = Maps.PMap.get b pmap ofs.