(* Main File putting all together. *)
From mathcomp.ssreflect Require Import ssreflect ssrbool ssrnat ssrfun eqtype seq fintype finfun.
Set Implicit Arguments.
Set Bullet Behavior "Strict Subproofs".
Module Main (CC_correct: CompCert_correctness).
(*Import the *)
(*Import the safety of the compiler for concurrent programs*)
(* Module ConcurCC_safe:= (SafetyStatement CC_correct). *)
Module ConcurCC_safe := (Concurrent_Safety CC_correct).
(*Importing the definition for ASM semantics and machines*)
(*Use a section to contain the parameters.*)
Section MainTheorem.
(*Assumptions *)
Context (CPROOF : semax_to_juicy_machine.CSL_proof).
Definition Clight_prog:= semax_to_juicy_machine.CSL_prog CPROOF.
Definition Main_ptr:=Values.Vptr (Ctypes.prog_main Clight_prog) Integers.Ptrofs.zero.
Context (Asm_prog: Asm.program).
Context (compilation : CC_correct.CompCert_compiler Clight_prog = Some Asm_prog).
Context (asm_genv_safe: Asm_core.safe_genv (@x86_context.X86Context.the_ge Asm_prog)).
Instance SemTarget : Semantics:= @x86_context.X86Context.X86Sem Asm_prog asm_genv_safe.
Existing Instance X86Inj.X86Inj.
Variable init_mem_wd:
forall m,
Genv.init_mem Asm_prog = Some m ->
mem_obs_eq.MemoryWD.valid_mem m /\
mem_obs_eq.CoreInjections.ge_wd (Renamings.id_ren m) the_ge.
(* This should be instantiated: it says initial_Clight_state taken from CPROOF, is an initial state of CompCert. *)
Context (CPROOF_initial:
Clight.start_stack (Clight.globalenv Clight_prog)
(init_mem CPROOF)
(Clight_safety.initial_Clight_state CPROOF)
Main_ptr nil).

(* MOVE THIS TO ANOTHER FILE *)
Lemma CPROOF_initial_mem:  Genv.init_mem (Ctypes.program_of_program Clight_prog) = Some (init_mem CPROOF).
Definition SemSource p:= (ClightSemanticsForMachines.ClightSem (Clight.globalenv p)).