Definition PMap_eq {A} (m m' : PMap.t (Z -> A)) := forall b' ofs', m !! b' ofs' = m' !! b' ofs'.

(* Specifications: *)
Lemma PMap_eq_refl {A} : reflexive _ (@PMap_eq A). intros f g. reflexivity. Qed.
Lemma PMap_eq_sym {A} : symmetric _ (@PMap_eq A). intros f g. unfold PMap_eq; symmetry; auto. Qed.
Lemma PMap_eq_trans {A} : transitive _ (@PMap_eq A). intros ? ? ? E E' ? ?. rewrite E, E'. auto. Qed.
Definition A2P {A} :=
(fun (pmap : access_map) (a : address * A) =>
let (a0, _) := a in let (b0, ofs0) := a0 in setPermBlock (Some Writable) b0 ofs0 pmap LKSIZE_nat).
Lemma setPermBlock_lookup : forall p b o a n b' o', (setPermBlock p b o a n) !! b' o' =
if adr_range_dec (b, o) (Z.of_nat n) (b', o') then p else a !! b' o'.
Lemma A2P_congr A e e' a : PMap_eq e e' -> PMap_eq (A2P e a) (@A2P A e' a).
Lemma A2P_overwrite A : forall a b e, fst a = fst b -> PMap_eq (@A2P A (A2P e a) b) (@A2P A e a).
Lemma setPerm_comm b1 o1 b2 o2 e:
PMap_eq (setPerm (Some Writable) b1 o1 (setPerm (Some Writable) b2 o2 e))
(setPerm (Some Writable) b2 o2 (setPerm (Some Writable) b1 o1 e)).
Lemma setPerm_congr b o e e':
PMap_eq e e' ->
PMap_eq (setPerm (Some Writable) b o e)
(setPerm (Some Writable) b o e').
Lemma A2P_comm A e a b : PMap_eq (@A2P A (A2P e a) b) (@A2P A (A2P e b) a).
Lemma fold_right_cons : forall A B (f : A -> B -> B) (z : B) (x : A) (y : list A),
fold_right f z (x :: y) = f x (fold_right f z y).
Lemma A2PMap_found A m b ofs ofs' o :
AMap.find (elt:=A) (b, ofs) m = Some o ->
(ofs <= ofs' < ofs + LKSIZE)%Z ->
(A2PMap m) !! b ofs' = Some Writable.
Lemma fold_right_rev_left:
forall (A B: Type) (f: A -> B -> A) (l: list B) (i: A),
fold_left f l i = fold_right (fun x y => f y x) i (rev l).
Lemma A2PMap_add_outside T b b' ofs ofs' set o :
(@A2PMap T (AMap.add (b, ofs) o set)) !! b' ofs' =
if adr_range_dec (b, ofs) LKSIZE (b', ofs') then
Some Writable
else
(@A2PMap T set) !! b' ofs'.
Lemma find_too_small A y a x l :
(AddressOrdered.lt y a \/ AddressOrdered.eq y a) ->
Sorted (AMap.Raw.PX.ltk (elt:=A)) l ->
HdRel (AMap.Raw.PX.ltk (elt:=A)) (a, x) l ->
AMap.Raw.find (elt:=A) y l = None.
Lemma sorted_find A a x l l'
(sorted : Sorted (AMap.Raw.PX.ltk (elt:=A)) ((a, x) :: l))
(sorted' : Sorted (AMap.Raw.PX.ltk (elt:=A)) ((a, x) :: l')) :
(forall y : AMap.key,
AMap.Raw.find (elt:=A) y ((a, x) :: l) =
AMap.Raw.find (elt:=A) y ((a, x) :: l')) ->
forall y : AMap.key,
AMap.Raw.find (elt:=A) y l =
AMap.Raw.find (elt:=A) y l'.
Lemma AMap_Equal_PMap_eq {A} m m' : AMap.Equal m m' -> @A2PMap A m = @A2PMap A m'.
Lemma AMap_remove_add {A} (m : AMap.t A) x y :
AMap.find x m = Some y ->
AMap.Equal m (AMap.add x y (AMap.remove x m)).