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).

Lemma AE_inv_exclusive : forall x g i R, exclusive_mpred (AE_inv x g i R).