(** *SyncStep simulation*)
(** Proof of the step diagram when the step is a synchronization step. TODO: Split the proof in each diagram. *)
Inductive deltaMap_cases (dmap:delta_map) b ofs:=
| DMAPS df p:  dmap ! b = Some df -> df ofs = Some p -> deltaMap_cases dmap b ofs
| DNONE1 df:  dmap ! b = Some df -> df ofs = None -> deltaMap_cases dmap b ofs
| DNONE2:  dmap ! b = None -> deltaMap_cases dmap b ofs.

(* Proof of the step diagram when the step is a synchronization step *)
Lemma sync_step_diagram:
forall (m m':Memory.mem) (U:seq nat) js js' ds i ev
(MATCH: match_st js ds)
(dinv: invariant ds)
(Hi: containsThread js i)
(Hcmpt: mem_compatible js m)
(HschedN: schedPeek U = Some i)
(Htstep:  syncStep true Hi Hcmpt js' m' ev),
exists ds' : dstate, exists ev',
invariant ds' /\ match_st js' ds' /\
syncStep true (MTCH_cnt MATCH Hi) (MTCH_compat _ _ _ MATCH Hcmpt) ds' m' ev'.