Section AMap2PMap.
(*Need to build a permission map from a finite map*)
(*The pmap is used in the compcert memory. *)
Context {lock_info: Type}.
Variable am: AMap.t lock_info.
Definition A2PMap (*: Map.PMap*) :=
fold_left
(fun (pmap:access_map) (a:address * lock_info)=>
match a with
| ((b, ofs), _) => setPermBlock (Some Memtype.Writable) b ofs pmap LKSIZE_nat
end)
(AMap.elements am)
(PMap.init (fun _ => None)).
End AMap2PMap.
Instance EqDec_AMap_key : EqDec AMap.key.

Lemma AMap_Raw_add_fold_left A (EQ : A -> A -> Prop) B f k (x : B) l (e : A) :
(forall e, EQ e e) ->
(forall e e', EQ e e' -> EQ e' e) ->
(forall e e' e'', EQ e e' -> EQ e' e'' -> EQ e e'') ->
(forall a e e', EQ e e' -> EQ (f e a) (f e' a)) ->
(forall a b e, fst a = fst b -> EQ (f (f e a) b) (f e a)) ->
(forall a b e, EQ (f (f e a) b) (f (f e b) a)) ->
EQ
(fold_left f (AMap.Raw.add k x l) e)
(fold_left f ((k, x) :: l) e).