(** *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.

(* 'Decaying memory' preserves invariant. Note that the invariant doesnt depend on the "core" c. so we can cahnge it to any c' *)
Lemma step_decay_invariant:
forall (tp : dstate)  (m : Mem.mem) i
(Hi : containsThread tp i) m1 m1' c'
(Hinv: invariant tp)
(Hcompatible: DryHybridMachine.mem_compatible tp m)
(Hrestrict_pmap :restrPermMap ((DryHybridMachine.compat_th _ _ Hcompatible) Hi).1 = m1)
(Hdecay: decay m1 m1'),
invariant
(updThread Hi (Krun c')
(getCurPerm m1', (getThreadR Hi).2)).