Ltac exploit_match:=
      unfold match_thread_target,match_thread_source,match_thread_compiled in *;
      match goal with
      | [ H: getThreadC ?i = _ ?c,
             H0: context[match_state2match_thread] |- _ ] =>
        rewrite H in H0; inversion H0; subst; simpl in *; clear H0
      end;
      fold match_thread_target in *;
      fold match_thread_source in *;
      fold match_thread_compiled in *.(* Build the concur_match *)
    Ltac destroy_ev_step_sum:=
      match goal with
      | [ H: ev_step_sum _ _ _ _ _ _ _ |- _ ] => inversion H; clear H
      end.

(* Specifications: *)
Lemma self_simulation_plus: forall state coresem (SIM: self_simulation.self_simulation state coresem), forall (f : meminj) (t : Events.trace) (c1 : state) (m1 : mem) (c2 : state) (m2 : mem), self_simulation.match_self (self_simulation.code_inject _ _ SIM) f c1 m1 c2 m2 -> forall (c1' : state) (m1' : mem), (corestep_plus coresem) c1 m1 c1' m1' -> exists (c2' : state) (f' : meminj) (t' : Events.trace) (m2' : mem), (corestep_plus coresem) c2 m2 c2' m2' /\ self_simulation.match_self (self_simulation.code_inject _ _ SIM) f' c1' m1' c2' m2' /\ inject_incr f f' /\ self_simulation.is_ext f (Mem.nextblock m1) f' (Mem.nextblock m2) /\ Events.inject_trace f' t t'.
Lemma thread_step_plus_from_corestep: forall (m : option mem) (tge : ClightSemanticsForMachines.G * Asm.genv) (U : list nat) (st1 : t) (m1 : mem) (Htid : containsThread st1 hb) (st2 : t) (mu : meminj) (m2 : mem) (cd0 : compiler_index) (H0 : concur_match (Some cd0) mu st1 m1 st2 m2) (code2 : Asm.state) (s4' : Smallstep.state (Asm.part_semantics Asm_g)) (m4' : mem), corestep_plus (Asm_core.Asm_core_sem Asm_g) code2 (restrPermMap (proj1 ((memcompat2 H0) hb (contains12 H0 Htid)))) s4' m4' -> forall Htid' : containsThread st2 hb, machine_semantics_lemmas.thread_step_plus (HybConcSem (Some (S hb)) m) tge U st2 m2 (updThread Htid' (Krun (TState Clight.state Asm.state s4')) (getCurPerm m4', snd (getThreadR Htid'))) m4'.
Lemma step2corestep_plus: forall (s1 s2: Smallstep.state (Asm.part_semantics Asm_g)) m1 t, Smallstep.plus (Asm.step (Genv.globalenv Asm_program)) (Smallstep.set_mem s1 m1) t s2 -> (corestep_plus (Asm_core.Asm_core_sem Asm_g)) s1 m1 s2 (Smallstep.get_mem s2).
Lemma Forall2_impl: forall {A B} (P Q : A -> B -> Prop) l1 l2, (forall a b, P a b -> Q a b) -> List.Forall2 P l1 l2 -> List.Forall2 Q l1 l2.
Lemma inject_incr_trace: forall (tr1 tr2 : list Events.machine_event) (mu f' : meminj), inject_incr mu f' -> List.Forall2 (inject_mevent mu) tr1 tr2 -> List.Forall2 (inject_mevent f') tr1 tr2.
Lemma internal_step_diagram: forall (m : option mem) (sge tge : HybridMachineSig.G) (U : list nat) tr1 (st1 : ThreadPool (Some hb)) (m1 : mem) (st1' : ThreadPool (Some hb)) (m1' : mem), machine_semantics.thread_step (HybConcSem (Some hb) m) sge U st1 m1 st1' m1' -> forall (cd : option compiler_index) tr2 (st2 : ThreadPool (Some (S hb))) (mu : meminj) (m2 : mem), concur_match cd mu st1 m1 st2 m2 -> forall (Hmatch_event : List.Forall2 (inject_mevent mu) tr1 tr2), exists (st2' : ThreadPool (Some (S hb))) (m2' : mem) (cd' : option compiler_index) (mu' : meminj), concur_match cd' mu' st1' m1' st2' m2' /\ List.Forall2 (inject_mevent mu') tr1 tr2 /\ (machine_semantics_lemmas.thread_step_plus (HybConcSem (Some (S hb)) m) tge U st2 m2 st2' m2' \/ machine_semantics_lemmas.thread_step_star (HybConcSem (Some (S hb)) m) tge U st2 m2 st2' m2' /\ ord_opt (Injorder compiler_sim) cd' cd).
Lemma acquire_step_diagram: forall (cd : option compiler_index) (m1 : mem) (st1 : ThreadPool (Some hb)) (st2 : ThreadPool.t) (mu : meminj) (m2 : mem) (tr1 tr2 : HybridMachineSig.event_trace) (Hmatch : concur_match cd mu st1 m1 st2 m2) (Htr : List.Forall2 (inject_mevent mu) tr1 tr2) (U : list nat) (m1' : mem) (tid : nat) (Htid : ThreadPool.containsThread st1 tid) (Hpeek : HybridMachineSig.schedPeek U = Some tid) (c : semC) (b : block) (ofs : Integers.Ptrofs.int) (virtueThread : delta_map * delta_map) (newThreadPerm : access_map * access_map) (pmap : lock_info) (Hcmpt: mem_compatible st1 m1) (Hlt': permMapLt (setPermBlock (Some Writable) b (Integers.Ptrofs.intval ofs) (snd (ThreadPool.getThreadR Htid)) LKSIZE_nat) (getMaxPerm m1)) (Hbounded : bounded_maps.sub_map (fst virtueThread) (snd (getMaxPerm m1)) /\ bounded_maps.sub_map (snd virtueThread) (snd (getMaxPerm m1))) (Hinv : invariant st1), semantics.at_external (semantics.csem (event_semantics.msem semSem)) c (restrPermMap (fst (ssrfun.pair_of_and (Hcmpt tid Htid)))) = Some (LOCK, (Vptr b ofs :: nil)%list) -> getThreadC Htid = Kblocked c -> Mem.load AST.Mint32 (restrPermMap (snd (ssrfun.pair_of_and (Hcmpt tid Htid)))) b (Integers.Ptrofs.intval ofs) = Some (Vint Integers.Int.one) -> Mem.range_perm (restrPermMap (snd (ssrfun.pair_of_and (Hcmpt tid Htid)))) b (Integers.Ptrofs.intval ofs) (BinInt.Z.add (Integers.Ptrofs.intval ofs) LKSIZE) Cur Readable -> Mem.store AST.Mint32 (restrPermMap Hlt') b (Integers.Ptrofs.intval ofs) (Vint Integers.Int.zero) = Some m1' -> ThreadPool.lockRes st1 (b, Integers.Ptrofs.intval ofs) = Some pmap -> permMapJoin (fst pmap) (fst (ThreadPool.getThreadR Htid)) (fst newThreadPerm) -> permMapJoin (snd pmap) (snd (ThreadPool.getThreadR Htid)) (snd newThreadPerm) -> exists e' (st2' : ThreadPool.t) (m2' : mem) (cd' : option compiler_index) (mu' : meminj), concur_match cd' mu' (ThreadPool.updLockSet (ThreadPool.updThread Htid (Kresume c Vundef) newThreadPerm) (b, Integers.Ptrofs.intval ofs) (empty_map, empty_map)) m1' st2' m2' /\ List.Forall2 (inject_mevent mu') (seq.cat tr1 (Events.external tid (Events.acquire (b, Integers.Ptrofs.intval ofs) (Some (build_delta_content (fst virtueThread) m1'))) :: nil)) (seq.cat tr2 (Events.external tid e' :: nil)) /\ HybridMachineSig.external_step(scheduler:=HybridMachineSig.HybridCoarseMachine.scheduler) U tr2 st2 m2 (HybridMachineSig.schedSkip U) (seq.cat tr2 (Events.external tid e' :: nil)) st2' m2'.
Lemma map_map1: forall {A B} f m, @PTree.map1 A B f m = PTree.map (fun _=> f) m.
Lemma strong_tree_leq_xmap: forall {A B} f1 f2 t (leq: option B -> option A -> Prop), (forall a p, leq (Some (f1 p a)) (Some (f2 p a))) -> leq None None -> forall p, bounded_maps.strong_tree_leq (PTree.xmap f1 t p) (@PTree.xmap A A f2 t p) leq.
Lemma strong_tree_leq_map: forall {A B} f1 f2 t (leq: option B -> option A -> Prop), (forall a p, leq (Some (f1 p a)) (Some (f2 p a))) -> leq None None -> bounded_maps.strong_tree_leq (@PTree.map A B f1 t) (@PTree.map A A f2 t) leq.
Lemma strong_tree_leq_xmap': forall {A B} f1 f2 t (leq: option B -> option A -> Prop), forall p, (forall a p0, PTree.get p0 t = Some a -> leq (Some (f1 (PTree.prev_append p p0)%positive a)) (Some (f2 (PTree.prev_append p p0)%positive a))) -> leq None None -> bounded_maps.strong_tree_leq (@PTree.xmap A B f1 t p) (@PTree.xmap A A f2 t p) leq.
Lemma strong_tree_leq_map': forall {A B} f1 f2 t (leq: option B -> option A -> Prop), (forall a p0, PTree.get p0 t = Some a -> leq (Some (f1 (PTree.prev_append 1 p0)%positive a)) (Some (f2 (PTree.prev_append 1 p0)%positive a))) -> leq None None -> bounded_maps.strong_tree_leq (@PTree.map A B f1 t) (@PTree.map A A f2 t) leq.
Lemma setPermBlock_inject_permMapLt: forall {Sem1 Sem2} n (NZ: 0 < n) (st1 : t(resources:=dryResources)(Sem:=Sem1)) (m1 : mem) (tid : nat) (cd : option compiler_index) (st2 : t(resources:=dryResources)(Sem:=Sem2)) (mu : meminj) (m2 : mem) (Htid1 : containsThread st1 tid) (b : block) (ofs : ptrofs), permMapLt (setPermBlock (Some Writable) b (intval ofs) (snd (getThreadR Htid1)) n) (getMaxPerm m1) -> Mem.inject mu m1 m2 -> forall (b' : block) (delt : Z), mu b = Some (b', delt) -> forall Htid2 : containsThread st2 tid, permMapLt (snd (getThreadR Htid2)) (getMaxPerm m2) -> permMapLt (setPermBlock (Some Writable) b' (intval ofs + delt) (snd (getThreadR Htid2)) n) (getMaxPerm m2).
Lemma cat_app: forall {T} (l1 l2:list T), seq.cat l1 l2 = app l1 l2.
Lemma strong_tree_leq_spec: forall {A B} (leq: option A -> option B -> Prop), leq None None -> forall t1 t2, bounded_maps.strong_tree_leq t1 t2 leq -> forall b, leq (@PTree.get A b t1) (@PTree.get B b t2).
Lemma trivial_map1: forall {A} (t : PTree.t A), PTree.map1 (fun (a : A) => a) t = t.
Lemma trivial_map: forall {A} (t : PTree.t A), PTree.map (fun (_ : positive) (a : A) => a) t = t.
Lemma inject_virtue_sub_map: forall {Sem1 Sem2} (st1 : ThreadPool.t(resources:=dryResources)(Sem:=Sem1)) (m1 : mem) (tid : nat) (st2 : ThreadPool.t(resources:=dryResources)(Sem:=Sem2)) (mu : meminj) (m2 : mem) (Htid1 : ThreadPool.containsThread st1 tid) (Htid2 : ThreadPool.containsThread st2 tid) {A} (virtue1 : PTree.t (Z -> option A)) (* H0 : concur_match cd mu st1 m1 st2 m2 *) (Hcmpt1: mem_compatible st1 m1)(Hcmpt2: mem_compatible st2 m2), Mem.inject mu (restrPermMap (proj1 (Hcmpt1 tid Htid1))) (restrPermMap (proj1 (Hcmpt2 tid Htid2))) -> bounded_maps.sub_map virtue1 (snd (getMaxPerm m1)) -> bounded_maps.sub_map (tree_map_inject_over_mem m2 mu virtue1) (snd (getMaxPerm m2)).
Lemma Create_step_diagram: forall (U : list nat) (tr1 tr2 : HybridMachineSig.event_trace) (st1 : ThreadPool (Some hb)) (m1' : mem) (tid : nat) (cd : option compiler_index) (st2 : ThreadPool (Some (S hb))) (mu : meminj) (m2 : mem) (Htid : ThreadPool.containsThread st1 tid) (c : semC) (b : block) (ofs : Integers.Ptrofs.int) (arg : val) (virtue1 virtue2 : PTree.t (BinNums.Z -> option (option permission)) * PTree.t (BinNums.Z -> option (option permission))) (threadPerm' newThreadPerm : access_map * access_map), HybridMachineSig.schedPeek U = Some tid -> forall Hcmpt : mem_compatible st1 m1', concur_match cd mu st1 m1' st2 m2 -> List.Forall2 (inject_mevent mu) tr1 tr2 -> bounded_maps.sub_map (fst virtue2) (snd (getMaxPerm m1')) /\ bounded_maps.sub_map (snd virtue2) (snd (getMaxPerm m1')) -> bounded_maps.sub_map (fst virtue1) (snd (getMaxPerm m1')) /\ bounded_maps.sub_map (snd virtue1) (snd (getMaxPerm m1')) -> invariant st1 -> ThreadPool.getThreadC Htid = Kblocked c -> Val.inject (Mem.flat_inj (Mem.nextblock m1')) arg arg -> semantics.at_external (semantics.csem (event_semantics.msem semSem)) c (restrPermMap (fst (ssrfun.pair_of_and (Hcmpt tid Htid)))) = Some (CREATE, (Vptr b ofs :: arg :: nil)%list) -> permMapJoin (fst newThreadPerm) (fst threadPerm') (fst (ThreadPool.getThreadR Htid)) -> permMapJoin (snd newThreadPerm) (snd threadPerm') (snd (ThreadPool.getThreadR Htid)) -> exists e' (st2' : t) (m2' : mem) (cd' : option compiler_index) (mu' : meminj), concur_match cd' mu' (ThreadPool.addThread (ThreadPool.updThread Htid (Kresume c Vundef) threadPerm') (Vptr b ofs) arg newThreadPerm) m1' st2' m2' /\ List.Forall2 (inject_mevent mu') (seq.cat tr1 (Events.external tid (Events.spawn (b, Integers.Ptrofs.intval ofs) (*Some (ThreadPool.getThreadR Htid, virtue1)*) (Some (build_delta_content (fst virtue1) m1')) (*Some virtue2*) (Some (build_delta_content (fst virtue2) m1'))) :: nil)) (seq.cat tr2 (Events.external tid e' :: nil)) /\ HybridMachineSig.external_step (scheduler:=HybridMachineSig.HybridCoarseMachine.scheduler) U tr2 st2 m2 (HybridMachineSig.schedSkip U) (seq.cat tr2 (Events.external tid e' :: nil)) st2' m2'.
Lemma make_step_diagram: forall (U : list nat) (tr1 tr2 : HybridMachineSig.event_trace) (st1 : ThreadPool (Some hb)) (m1 m1' : mem) (tid : nat) (cd : option compiler_index) (st2 : ThreadPool (Some (S hb))) (mu : meminj) (m2 : mem) (Htid : ThreadPool.containsThread st1 tid) (c : semC) (b : block) (ofs : Integers.Ptrofs.int) (pmap_tid' : access_map * access_map), concur_match cd mu st1 m1 st2 m2 -> List.Forall2 (inject_mevent mu) tr1 tr2 -> forall Hcmpt : mem_compatible st1 m1, HybridMachineSig.schedPeek U = Some tid -> invariant st1 -> ThreadPool.getThreadC Htid = Kblocked c -> semantics.at_external (semantics.csem (event_semantics.msem semSem)) c (restrPermMap (fst (ssrfun.pair_of_and (Hcmpt tid Htid)))) = Some (MKLOCK, (Vptr b ofs :: nil)%list) -> Mem.store AST.Mint32 (restrPermMap (fst (ssrfun.pair_of_and (Hcmpt tid Htid)))) b (Integers.Ptrofs.intval ofs) (Vint Integers.Int.zero) = Some m1' -> Mem.range_perm (restrPermMap (fst (ssrfun.pair_of_and (Hcmpt tid Htid)))) b (Integers.Ptrofs.intval ofs) (BinInt.Z.add (Integers.Ptrofs.intval ofs) LKSIZE) Cur Writable -> setPermBlock (Some Nonempty) b (Integers.Ptrofs.intval ofs) (fst (ThreadPool.getThreadR Htid)) LKSIZE_nat = fst pmap_tid' -> setPermBlock (Some Writable) b (Integers.Ptrofs.intval ofs) (snd (ThreadPool.getThreadR Htid)) LKSIZE_nat = snd pmap_tid' -> ThreadPool.lockRes st1 (b, Integers.Ptrofs.intval ofs) = None -> exists e' (st2' : t) (m2' : mem) (cd' : option compiler_index) (mu' : meminj), concur_match cd' mu' (ThreadPool.updLockSet (ThreadPool.updThread Htid (Kresume c Vundef) pmap_tid') (b, Integers.Ptrofs.intval ofs) (empty_map, empty_map)) m1' st2' m2' /\ List.Forall2 (inject_mevent mu') (seq.cat tr1 (Events.external tid (Events.mklock (b, Integers.Ptrofs.intval ofs)) :: nil)) (seq.cat tr2 (Events.external tid e' :: nil)) /\ HybridMachineSig.external_step (scheduler:=HybridMachineSig.HybridCoarseMachine.scheduler) U tr2 st2 m2 (HybridMachineSig.schedSkip U) (seq.cat tr2 (Events.external tid e' :: nil)) st2' m2'.
Lemma acquire_fail_step_diagram: forall (U : list nat) (tr1 tr2 : HybridMachineSig.event_trace) (st1' : ThreadPool (Some hb)) (m1' : mem) (tid : nat) (cd : option compiler_index) (st2 : ThreadPool (Some (S hb))) (mu : meminj) (m2 : mem) (Htid : ThreadPool.containsThread st1' tid) (b : block) (ofs : Integers.Ptrofs.int) (c : semC) (Hcmpt : mem_compatible st1' m1'), concur_match cd mu st1' m1' st2 m2 -> List.Forall2 (inject_mevent mu) tr1 tr2 -> HybridMachineSig.schedPeek U = Some tid -> semantics.at_external (semantics.csem (event_semantics.msem semSem)) c (restrPermMap (fst (ssrfun.pair_of_and (Hcmpt tid Htid)))) = Some (LOCK, (Vptr b ofs :: nil)%list) -> Mem.load AST.Mint32 (restrPermMap (snd (ssrfun.pair_of_and (Hcmpt tid Htid)))) b (Integers.Ptrofs.intval ofs) = Some (Vint Integers.Int.zero) -> Mem.range_perm (restrPermMap (snd (ssrfun.pair_of_and (Hcmpt tid Htid)))) b (Integers.Ptrofs.intval ofs) (BinInt.Z.add (Integers.Ptrofs.intval ofs) LKSIZE) Cur Readable -> ThreadPool.getThreadC Htid = Kblocked c -> invariant st1' -> exists e' (st2' : t) (m2' : mem) (cd' : option compiler_index) (mu' : meminj), concur_match cd' mu' st1' m1' st2' m2' /\ List.Forall2 (inject_mevent mu') (seq.cat tr1 (Events.external tid (Events.failacq (b, Integers.Ptrofs.intval ofs)) :: nil)) (seq.cat tr2 (Events.external tid e' :: nil)) /\ HybridMachineSig.external_step (scheduler:=HybridMachineSig.HybridCoarseMachine.scheduler) U tr2 st2 m2 (HybridMachineSig.schedSkip U) (seq.cat tr2 (Events.external tid e' :: nil)) st2' m2'.
Lemma external_step_diagram: forall (U : list nat) (tr1 tr2 : HybridMachineSig.event_trace) (st1 : ThreadPool.t) (m1 : mem) (st1' : ThreadPool.t) (m1' : mem) (tid : nat) (ev : Events.sync_event), forall (cd : option compiler_index) (st2 : ThreadPool.t) (mu : meminj) (m2 : mem), concur_match cd mu st1 m1 st2 m2 -> List.Forall2 (inject_mevent mu) tr1 tr2 -> forall (Htid : ThreadPool.containsThread st1 tid) (Hcmpt : mem_compatible st1 m1), HybridMachineSig.schedPeek U = Some tid -> syncStep true Htid Hcmpt st1' m1' ev -> exists ev' (st2' : t) (m2' : mem) (cd' : option compiler_index) (mu' : meminj), concur_match cd' mu' st1' m1' st2' m2' /\ List.Forall2 (inject_mevent mu') (seq.cat tr1 (Events.external tid ev :: nil)) (seq.cat tr2 (Events.external tid ev' :: nil)) /\ HybridMachineSig.external_step (scheduler:=HybridMachineSig.HybridCoarseMachine.scheduler) U tr2 st2 m2 (HybridMachineSig.schedSkip U) (seq.cat tr2 (Events.external tid ev' :: nil)) st2' m2'.
Lemma start_step_diagram: forall (m : option mem) (tge : HybridMachineSig.G) (U : list nat) (st1 : ThreadPool (Some hb)) (m1 : mem) (tr1 tr2 : HybridMachineSig.event_trace) (st1' : ThreadPool (Some hb)) (m' : mem) (cd : option compiler_index) (st2 : ThreadPool (Some (S hb))) (mu : meminj) (m2 : mem) (tid : nat) (Htid : ThreadPool.containsThread st1 tid), concur_match cd mu st1 m1 st2 m2 -> List.Forall2 (inject_mevent mu) tr1 tr2 -> HybridMachineSig.schedPeek U = Some tid -> HybridMachineSig.start_thread m1 Htid st1' m' -> exists (st2' : ThreadPool (Some (S hb))) (m2' : mem) (cd' : option compiler_index) (mu' : meminj), concur_match cd' mu' st1' (HybridMachineSig.diluteMem m') st2' m2' /\ List.Forall2 (inject_mevent mu') tr1 tr2 /\ machine_semantics.machine_step(HybConcSem (Some (S hb)) m) tge U tr2 st2 m2 (HybridMachineSig.yield (Scheduler:=HybridMachineSig.HybridCoarseMachine.scheduler) U) tr2 st2' m2'.
Lemma resume_step_diagram: forall (m : option mem) (tge : HybridMachineSig.G) (U : list nat) (st1 : ThreadPool (Some hb)) (tr1 tr2 : HybridMachineSig.event_trace) (st1' : ThreadPool (Some hb)) (m1' : mem) (cd : option compiler_index) (st2 : ThreadPool (Some (S hb))) (mu : meminj) (m2 : mem) (tid : nat) (Htid : ThreadPool.containsThread st1 tid), concur_match cd mu st1 m1' st2 m2 -> List.Forall2 (inject_mevent mu) tr1 tr2 -> HybridMachineSig.schedPeek U = Some tid -> HybridMachineSig.resume_thread m1' Htid st1' -> exists (st2' : ThreadPool (Some (S hb))) (m2' : mem) (cd' : option compiler_index) (mu' : meminj), concur_match cd' mu' st1' m1' st2' m2' /\ List.Forall2 (inject_mevent mu') tr1 tr2 /\ machine_semantics.machine_step (HybConcSem (Some (S hb)) m) tge U tr2 st2 m2 (HybridMachineSig.yield(Scheduler:=HybridMachineSig.HybridCoarseMachine.scheduler) U) tr2 st2' m2'.
Lemma suspend_step_diagram: forall (m : option mem) (tge : HybridMachineSig.G) (U : list nat) (st1 : ThreadPool (Some hb)) (tr1 tr2 : HybridMachineSig.event_trace) (st1' : ThreadPool (Some hb)) (m1' : mem) (cd : option compiler_index) (st2 : ThreadPool (Some (S hb))) (mu : meminj) (m2 : mem) (tid : nat) (Htid : ThreadPool.containsThread st1 tid), concur_match cd mu st1 m1' st2 m2 -> List.Forall2 (inject_mevent mu) tr1 tr2 -> HybridMachineSig.schedPeek U = Some tid -> HybridMachineSig.suspend_thread m1' Htid st1' -> exists (st2' : ThreadPool (Some (S hb))) (m2' : mem) (cd' : option compiler_index) (mu' : meminj), concur_match cd' mu' st1' m1' st2' m2' /\ List.Forall2 (inject_mevent mu') tr1 tr2 /\ machine_semantics.machine_step (HybConcSem (Some (S hb)) m) tge U tr2 st2 m2 (HybridMachineSig.schedSkip U) tr2 st2' m2'.
Lemma schedfail_step_diagram: forall (m : option mem) (tge : HybridMachineSig.G) (U : list nat) (tr1 tr2 : HybridMachineSig.event_trace) (st1' : ThreadPool (Some hb)) (m1' : mem) (st2 : ThreadPool (Some (S hb))) (m2 : mem) (tid : nat) cd mu, concur_match cd mu st1' m1' st2 m2 -> List.Forall2 (inject_mevent mu) tr1 tr2 -> HybridMachineSig.schedPeek U = Some tid -> ~ ThreadPool.containsThread st1' tid -> HybridMachineSig.invariant st1' -> HybridMachineSig.mem_compatible st1' m1' -> exists (st2' : ThreadPool (Some (S hb))) (m2' : mem) (cd' : option compiler_index) (mu' : meminj), concur_match cd' mu' st1' m1' st2' m2' /\ List.Forall2 (inject_mevent mu') tr1 tr2 /\ machine_semantics.machine_step (HybConcSem (Some (S hb)) m) tge U tr2 st2 m2 (HybridMachineSig.schedSkip U) tr2 st2' m2'.
Lemma machine_step_diagram: forall (m : option mem) (sge tge : HybridMachineSig.G) (U : list nat) (tr1 : HybridMachineSig.event_trace) (st1 : ThreadPool (Some hb)) (m1 : mem) (U' : list nat) (tr1' : HybridMachineSig.event_trace) (st1' : ThreadPool (Some hb)) (m1' : mem), machine_semantics.machine_step (HybConcSem (Some hb) m) sge U tr1 st1 m1 U' tr1' st1' m1' -> forall (cd : option compiler_index) tr2 (st2 : ThreadPool (Some (S hb))) (mu : meminj) (m2 : mem), concur_match cd mu st1 m1 st2 m2 -> List.Forall2 (inject_mevent mu) tr1 tr2 -> exists tr2' (st2' : ThreadPool (Some (S hb))) (m2' : mem) (cd' : option compiler_index) (mu' : meminj), concur_match cd' mu' st1' m1' st2' m2' /\ List.Forall2 (inject_mevent mu') tr1' tr2' /\ machine_semantics.machine_step (HybConcSem (Some (S hb)) m) tge U tr2 st2 m2 U' tr2' st2' m2'.
Lemma initial_diagram: forall (m : option mem) (s_mem s_mem' : mem) (main : val) (main_args : list val) (s_mach_state : ThreadPool (Some hb)) (r1 : option res), machine_semantics.initial_machine (HybConcSem (Some hb) m) r1 s_mem s_mach_state s_mem' main main_args -> exists (j : meminj) (cd : option compiler_index) (t_mach_state : ThreadPool (Some (S hb))) (t_mem t_mem' : mem) (r2 : option res), machine_semantics.initial_machine (HybConcSem (Some (S hb)) m) r2 t_mem t_mach_state t_mem' main main_args /\ concur_match cd j s_mach_state s_mem' t_mach_state t_mem'.
Lemma compile_one_thread: forall m, HybridMachine_simulation_properties (HybConcSem (Some hb) m) (HybConcSem (Some (S hb)) m) (concur_match).