Notation ACAS_witness sh p g R h c v P Q :=
(sh%logic, p%logic, c%logic, v%logic, (ghost_hist sh h g * P)%logic, hist_R g%logic R,
fun v' => EX h' : hist, !!(add_events h [CAS v' c v] h') && ghost_hist sh h' g * Q v').

Lemma ACAS_hist_spec : forall sh g R h v c P Q
(HPQR : forall h' v' (Hhist : hist_incl h h'), apply_hist (vint 0) h' = Some v' ->
view_shift (valid (R h') v' * P) (valid (R (h' ++ [CAS v' c v])) (if eq_dec c v' then v else v') * Q v'))
(Hsh : sh <> Share.bot) (Hprecise : forall v, precise (EX h : _, R h v)),
ACAS_spec c v (ghost_hist sh h g * P) (hist_R g R)
(fun v' => EX h' : hist, !!(add_events h [CAS v' c v] h') && ghost_hist sh h' g * Q v').