Definition value_of e :=
match e with
| Load v => v
| Store v => v
| CAS r c w => if eq_dec r c then w else r
end.

(* Specifications: *)
Lemma apply_one_value : forall i a v, apply_hist i [a] = Some v -> value_of a = v.
Definition last_value (h : hist) v :=
(h = [] /\ v = vint 0) \/
exists n e, In (n, e) h /\ value_of e = v /\ Forall (fun x => let '(m, _) := x in m <= n)%nat h.
Lemma apply_one_value : forall i a v, apply_hist i [a] = Some v -> value_of a = v.
Definition last_value (h : hist) v :=
(h = [] /\ v = vint 0) \/
exists n e, In (n, e) h /\ value_of e = v /\ Forall (fun x => let '(m, _) := x in m <= n)%nat h.