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.

Lemma Asm_preserves_invariant:
forall g i (st: @t dryResources (HybridSem (@Some nat (S hb))))
cnt st' (th_st: Smallstep.state (Asm.part_semantics g)) c2 m Hlt t0,
invariant (cast_t st) ->
@getThreadC _ (HybridSem _) _ _ cnt =
(Krun (TST c2)) ->
let th_perm:= @getThreadR _ _ i st cnt in
let th_m:= @restrPermMap (fst th_perm) m Hlt in
Asm.step Asm_g (Asm.set_mem c2 th_m) t0 th_st ->
st' = updThread cnt (Krun (TST th_st))
(getCurPerm (Smallstep.get_mem th_st),
snd (getThreadR cnt)) ->
invariant (cast_t st').