Section AEHist.
(* These histories should be usable for any atomically accessed location. *)
Inductive AE_hist_el := AE (r : val) (w : val).
Fixpoint apply_hist a h :=
match h with
| [] => Some a
| AE r w :: h' => if eq_dec r a then apply_hist w h' else None
end.
Arguments eq_dec _ _ _ _ : simpl never.
End AEHist.
Notation hist := (nat -> option AE_hist_el).
(* the lock invariant used to encode an atomic invariant *)
Definition AE_inv x g i R := EX h : list AE_hist_el, EX v : val,
!!(apply_hist i h = Some v /\ tc_val tint v) &&
(data_at Ews tint v x * ghost_ref h g * R h v).
Hint Resolve AE_inv_exclusive.
Definition AE_loc sh l p g i R (h : hist) := lock_inv sh l (AE_inv p g i R) * ghost_hist sh h g.

Lemma AE_loc_super_non_expansive : forall n sh l p g i R h,
compcert_rmaps.RML.R.approx n (AE_loc sh l p g i R h) =
compcert_rmaps.RML.R.approx n (AE_loc sh l p g i (fun h v => compcert_rmaps.RML.R.approx n (R h v)) h).