Section GHist.
(* Ghost histories in the style of Nanevsky *)
Context {hist_el : Type}.
Notation hist_part := (nat -> option hist_el).
Definition hist_sub sh (h : hist_part) hr := sh <> Share.bot /\ if eq_dec sh Tsh then h = hr
else map_incl h hr.
Definition ghost_hist (sh : share) (h : hist_part) g :=
own(RA := ref_PCM map_disj_PCM) g (Some (sh, h), None) NoneP.
Definition hist_incl (h : hist_part) l := forall t e, h t = Some e -> nth_error l t = Some e.
Definition hist_list (h : hist_part) l := forall t e, h t = Some e <-> nth_error l t = Some e.
Definition ghost_ref l g := EX hr : hist_part, !!(hist_list hr l) &&
own(RA := ref_PCM map_disj_PCM) g (None, Some hr) NoneP.
Definition ghost_hist_ref sh (h r : hist_part) g :=
own(RA := ref_PCM map_disj_PCM) g (Some (sh, h), Some r) NoneP.
Definition newer (l : hist_part) t := forall t', l t' <> None -> (t' < t)%nat.

Lemma add_new_inj : forall h h' t t' v v' (Ht : newer h t) (Ht' : newer h' t'),
map_upd h t v = map_upd h' t' v' -> h = h' /\ t = t' /\ v = v'.