Module TraceErasure.
Inductive mem_event_erasure : mem_event -> mem_event -> Prop :=
| WriteErasure: forall b ofs mvals mvals',
memval_erasure_list mvals mvals' ->
mem_event_erasure (Write b ofs mvals) (Write b ofs mvals')
| ReadErasure: forall b ofs sz mvals mvals',
memval_erasure_list mvals mvals' ->
mem_event_erasure (Read b ofs sz mvals) (Read b ofs sz mvals')
| AllocErasure: forall b ofs sz,
mem_event_erasure (Alloc b ofs sz) (Alloc b ofs sz)
| FreeErasure: forall ls,
mem_event_erasure (Free ls) (Free ls).
Inductive mem_event_list_erasure: list mem_event -> list mem_event -> Prop :=
| nilMemEvent: mem_event_list_erasure nil nil
| consMemEvent: forall mev mev' ls ls'
(Hev_erasure: mem_event_erasure mev mev')
(Hls_erasure: mem_event_list_erasure ls ls'),
mem_event_list_erasure (mev :: ls) (mev' :: ls').
(** Removing the footprints from a [sync_event] *)
Definition eraseSyncEvent ev :=
match ev with
| Events.release addr _ => Events.release addr None
| Events.acquire addr _ => Events.acquire addr None
| Events.spawn addr _ _ => Events.spawn addr None None
| _ => ev
end.
Inductive event_erasure : Events.machine_event -> Events.machine_event -> Prop :=
| InternalErasure: forall tid mev mev',
mem_event_erasure mev mev' ->
event_erasure (Events.internal tid mev) (Events.internal tid mev')
| ExternalErasure: forall tid ev,
event_erasure (Events.external tid ev)
(Events.external tid (eraseSyncEvent ev)).
Inductive trace_erasure : list Events.machine_event ->
list Events.machine_event -> Prop :=
| NilErasure: trace_erasure nil nil
| ConsErasure: forall ev ev' tr tr'
(Hev_erasure: event_erasure ev ev')
(Htr_erasure: trace_erasure tr tr'),
trace_erasure (ev :: tr) (ev' :: tr').

Lemma trace_erasure_map:
forall ev ev' tid,
mem_event_list_erasure ev ev' ->
trace_erasure (map [eta Events.internal tid] ev)
(map [eta Events.internal tid] ev').