(* Now, we can specialize these to the history PCM. *)
Inductive hist_el := Load (v : val) | Store (v : val) | CAS (r : val) (c : val) (w : val).
Instance EqDec_hist_el : EqDec hist_el.
Fixpoint apply_hist a h :=
match h with
| [] => Some a
| Load v :: h' => if eq_dec v a then apply_hist a h' else None
| Store v :: h' => apply_hist v h'
| CAS r c w :: h' => if eq_dec r a then if eq_dec c a then apply_hist w h' else apply_hist a h' else None
end.
Notation hist := (list (nat * hist_el)).

(* Specifications: *)
Lemma apply_hist_app : forall h1 i h2, apply_hist i (h1 ++ h2) =
match apply_hist i h1 with Some v => apply_hist v h2 | None => None end.
Lemma apply_hist_app : forall h1 i h2, apply_hist i (h1 ++ h2) =
match apply_hist i h1 with Some v => apply_hist v h2 | None => None end.