Section CompileOneThread.
Context (hb: nat).
(*Instantiate definitions in Concur with the current hybridbound*)
Notation concur_match:= (concur_match hb).
Notation match_thread:= (match_thread hb).
Notation match_thread_source:= (match_thread_source hb).
Notation match_thread_target:= (match_thread_target hb).
Notation memcompat2:= (memcompat2 hb).
Notation memcompat1:= (memcompat1 hb).
Notation contains12:= (contains12 hb).
Notation mtch_target:= (mtch_target hb).
Notation mtch_compiled:= (mtch_compiled hb).
Notation mtch_source:= (mtch_source hb).
Notation thread_perms st i cnt:= (fst (@getThreadR _ _ st i cnt)).
Notation lock_perms st i cnt:= (snd (@getThreadR  _ _ st i cnt)).
Definition cast_t {Sem}:
@OrdinalPool.t _ Sem -> @ThreadPool.t _ Sem (@OrdinalThreadPool dryResources _):=
fun X => X.
(* Where to move this:*)
(* ConcurMatch used to be here. *)
(* The following tactics are also in permissions.v but for some reason that one doesn't work... *)
Ltac unfold_getCurPerm:=
repeat rewrite getCurPerm_correct in *;
unfold permission_at in *.
Ltac unfold_getMaxPerm:=
repeat rewrite getMaxPerm_correct in *;
unfold permission_at in *.
Ltac unfold_getPerm:=
try unfold_getMaxPerm; try unfold_getMaxPerm.
(** *Tactics These tactics are here becasue they must be outside a section. they also must be after concur_match definition. *)
(*Do I have to reppeat the LTAC from the section? *)
Inductive opt_rel' {A} (ord: A -> A -> Prop): option A -> option A -> Prop:=
| Some_ord:
forall x y, ord x y -> opt_rel' ord (Some x) (Some y).

Lemma simulation_equivlanence:
forall s3 t s2 cd cd0,
(Smallstep.plus (Asm.step (Genv.globalenv Asm_program))
s3 t s2 \/
Smallstep.star (Asm.step (Genv.globalenv Asm_program))
s3 t s2 /\ InjorderX compiler_sim cd cd0) ->
Smallstep.plus (Asm.step (Genv.globalenv Asm_program))
s3 t s2 \/
t = Events.E0 /\
s2 = s3 /\
InjorderX compiler_sim cd cd0.