Instance EqDec_ident: EqDec ident := ident_eq.Instance EqDec_byte: EqDec byte := Byte.eq_dec.(*Moved to base.v so that this file does not need to Import Clightdefs ad Ctypes
  Instance EqDec_type: EqDec type := type_eq.*)
Instance EqDec_int: EqDec int := Int.eq_dec.Instance EqDec_int64: EqDec int64 := Int64.eq_dec.Instance EqDec_float: EqDec float := Float.eq_dec.Instance EqDec_float32: EqDec float32 := Float32.eq_dec.Instance EqDex_ptr : EqDec ptrofs := Ptrofs.eq_dec.(*NEW*)

Instance EqDec_memval: EqDec memval.Instance EqDec_val: EqDec val.Instance EqDec_quantity: EqDec quantity.Definition access_at (m: mem) (loc: address) (k: perm_kind): option permission :=
   PMap.get (fst loc) (Mem.mem_access m) (snd loc) k.

(* Specifications: *)
Lemma perm_access: forall m b ofs k p, Mem.perm m b ofs k p <-> (Mem.perm_order'' (access_at m (b,ofs) k) (Some p)).
Lemma access_perm: forall m b ofs k p, access_at m (b, ofs) k = Some p -> Mem.perm m b ofs k p.
Lemma access_cur_max: forall m a, Mem.perm_order'' (access_at m a Max) (access_at m a Cur).
Lemma invalid_noaccess: forall m b ofs k, ~Mem.valid_block m b -> access_at m (b, ofs) k = None.
Lemma access_empty: forall a k, access_at Mem.empty a k = None.
Theorem alloc_access_other: forall m1 lo hi m2 b, Mem.alloc m1 lo hi = (m2, b) -> forall b' ofs k, b'<>b \/ (ofs < lo \/ ofs >= hi) -> access_at m1 (b', ofs) k = access_at m2 (b', ofs) k.
Theorem alloc_access_same: forall m1 lo hi m2 b, Mem.alloc m1 lo hi = (m2, b) -> forall ofs k, lo <= ofs < hi -> access_at m2 (b,ofs) k = Some Freeable.
Lemma access_free: forall m1 b lo hi, (forall ofs, lo <= ofs < hi -> access_at m1 (b,ofs) Cur = Some Freeable) -> { m2: mem | Mem.free m1 b lo hi = Some m2 }.
Lemma free_access: forall m1 b lo hi m2, Mem.free m1 b lo hi = Some m2 -> (forall ofs, lo <= ofs < hi -> access_at m1 (b,ofs) Cur = Some Freeable /\ access_at m2 (b,ofs) Max = None).
Lemma free_access_other: forall m1 bf lo hi m2, Mem.free m1 bf lo hi = Some m2 -> forall b ofs k, b <> bf \/ ofs < lo \/ hi <= ofs -> access_at m1 (b,ofs) k = access_at m2 (b,ofs) k.
Lemma access_drop_1: forall m b lo hi p m', Mem.drop_perm m b lo hi p = Some m' -> (forall ofs, lo <= ofs < hi -> forall k, access_at m (b, ofs) k = Some Freeable /\ access_at m' (b, ofs) k = Some p).
Lemma access_drop_2: forall m b lo hi p, (forall ofs, lo <= ofs < hi -> access_at m (b,ofs) Cur = Some Freeable) -> { m' | Mem.drop_perm m b lo hi p = Some m' }.
Lemma access_drop_3: forall m b lo hi p m', Mem.drop_perm m b lo hi p = Some m' -> forall b' ofs k, b' <> b \/ ofs < lo \/ hi <= ofs -> access_at m (b', ofs) k = access_at m' (b',ofs) k.
Lemma storebytes_access: forall m1 b ofs bytes m2 (STORE: Mem.storebytes m1 b ofs bytes = Some m2), access_at m1 = access_at m2.
Lemma store_access: forall chunk m1 b ofs v m2 (STORE: Mem.store chunk m1 b ofs v = Some m2), access_at m1 = access_at m2.
Lemma perm_order'_dec_fiddle: forall y x, y = Some x -> proj_sumbool (Mem.perm_order'_dec y Nonempty) = true.
Lemma access_at_valid_pointer: forall m b ofs p, access_at m (b,ofs) Cur = Some p -> Mem.valid_pointer m b ofs = true.