Section MainTheorem.
(*Assumptions *)
Context (CPROOF : semax_to_juicy_machine.CSL_proof).
Context (program_proof : CSL_prog CPROOF = C_program).
Definition Main_ptr:=Values.Vptr (Ctypes.prog_main C_program) Integers.Ptrofs.zero.
Context (compilation : CC_correct.CompCert_compiler C_program = Some Asm_program).
Context (asm_genv_safe: Asm_core.safe_genv (@x86_context.X86Context.the_ge Asm_program)).
Instance SemTarget : Semantics:= @x86_context.X86Context.X86Sem Asm_program asm_genv_safe.
Existing Instance X86Inj.X86Inj.
Variable init_mem_wd:
forall m,
Genv.init_mem Asm_program = Some m ->
mem_obs_eq.MemoryWD.valid_mem m /\
mem_obs_eq.CoreInjections.ge_wd (Renamings.id_ren m) semantics.the_ge.
(* This should be instantiated: it says initial_Clight_state taken from CPROOF, is an initial state of CompCert. *)
Context (CPROOF_initial:
entry_point (Clight.globalenv C_program)
(erasure_safety.init_mem CPROOF)
(Clight_safety.initial_Clight_state CPROOF)
Main_ptr nil).
(*Safety from CSL to Coarse Asm*)
Definition SemSource p:= (ClightSemanticsForMachines.ClightSem (Clight.globalenv p)).
Definition asm_concursem m:=
(HybridMachineSig.HybridMachineSig.ConcurMachineSemantics
(Sem:=SemTarget)
(ThreadPool:= threadPool.OrdinalPool.OrdinalThreadPool(Sem:=SemTarget))
(HybridMachine:=concurrent_compiler_safety.TargetHybridMachine)
(machineSig:= HybridMachine.DryHybridMachine.DryHybridMachineSig) m).
Definition asm_init_machine:=
machine_semantics.initial_machine (asm_concursem (Genv.init_mem Asm_program)).
Context {SW : Clight_safety.spawn_wrapper CPROOF}.
Notation sc_execution := (@Executions.fine_execution _ BareDilMem BareMachine.resources
BareMachine.BareMachineSig).

Theorem CSL2FineBareAsm_safety:
forall U,
exists (init_mem_target init_mem_target':Memory.mem) init_thread_target,
let init_tp_target :=
threadPool.ThreadPool.mkPool
(Sem:=SemTarget)
(resources:=BareMachine.resources)
(Krun init_thread_target) tt in
permissionless_init_machine Asm_program _
init_mem_target
init_tp_target
init_mem_target'
Main_ptr nil /\
(forall n,
HybridMachineSig.HybridMachineSig.HybridFineMachine.fsafe
(dilMem:= BareDilMem)
(ThreadPool:=threadPool.OrdinalPool.OrdinalThreadPool
(resources:=BareMachine.resources)
(Sem:=SemTarget))
(machineSig:= BareMachine.BareMachineSig)
init_tp_target (@HybridMachineSig.diluteMem BareDilMem init_mem_target') U n) /\
(forall final_state final_mem tr,
sc_execution (U, [::], init_tp_target)
(@HybridMachineSig.diluteMem BareDilMem init_mem_target')
([::], tr, final_state) final_mem ->
SpinLocks.spinlock_synchronized tr).