intros.
unfold CoreInitial; simpl.
unfold init_machine, JuicyMachineModule.THE_JUICY_MACHINE.JSEM.init_mach.
unfold semantics.initial_core.
unfold ErasureSafety.ErasureProof.JMS.the_sem.
unfold JuicyMachineModule.THE_JUICY_MACHINE.JSEM.ThreadPool.SEM.Sem.
rewrite JuicyMachineModule.THE_JUICY_MACHINE.SEM.CLN_msem.
simpl.
rewrite <- initial_equivalence_trivial.
subst r; simpl.
unfold initial_corestate.
unfold prog in *.
destruct spr as (b' & c' & e & SPR); simpl in *.
change semax_to_juicy_machine.prog with CSL_prog in *.
subst b'.
specialize (SPR n). destruct SPR as [jm [? [? [? _]]]].
unfold juicy_extspec.j_initial_core in H2.
unfold semantics.initial_core in H2. simpl in H2.
rewrite <- H in *.
destruct (Genv.find_funct_ptr g b) eqn:?H; [ | congruence].
inversion H3; clear H3; subst.
f_equal. f_equal. f_equal. f_equal. congruence.
Qed.

(* Specifications: *)
Lemma initial_equivalence': forall U n
(g:JuicyMachineModule.THE_JUICY_MACHINE.JSEM.ThreadPool.SEM.G),
genv_genv g = Genv.globalenv (Ctypes.program_of_program prog) ->
(semantics.initial_core (MachineSemantics U (Some (juicy_mem.m_phi (initial_jm CPROOF n)))))
0 g (proj1_sig (init_mem CPROOF))
(Vptr (projT1 ((spr CPROOF))) Integers.Int.zero) nil =
Some ((U, nil, initial_machine_state CPROOF n), None).
Lemma CoreInitial_juicy_safety:
forall (U : semax_invariant.schedule) (n : nat),
exists init_st,
(semantics.initial_core (MachineSemantics U (init_rmap n)))
0 init_genv (proj1_sig (init_mem CPROOF)) init_point nil =
Some ((U, nil, init_st), None) /\
forall U',
csafe (globalenv prog) (U', nil, init_st)
(proj1_sig (init_mem CPROOF)) n.
(** *Safety for Clight_new*)
Lemma Initial_dry_csafety:
forall (U : semax_invariant.schedule) (n : nat),
exists init_U init_tr init_st,
(semantics.initial_core (MachineSemantics U (Some ( getCurPerm (juicy_mem.m_dry (init_jmem n)), empty_map)))) 0 init_genv (juicy_mem.m_dry (init_jmem n)) init_point nil =
Some ((init_U, init_tr, init_st), None) /\
forall U' ,
csafe (globalenv prog) (U', init_tr, init_st)
(proj1_sig (init_mem CPROOF)) n.
Lemma dry_initial_state_equality:
forall (U : semax_invariant.schedule) (n1 n2 : nat),
(semantics.initial_core (MachineSemantics U (Some ( getCurPerm (juicy_mem.m_dry (init_jmem n1)), empty_map)))) 0 init_genv (juicy_mem.m_dry (init_jmem n1)) init_point nil =
(semantics.initial_core (MachineSemantics U (Some ( getCurPerm (juicy_mem.m_dry (init_jmem n2)), empty_map)))) 0 init_genv (juicy_mem.m_dry (init_jmem n2)) init_point nil.
Lemma Initial_dry_Csafety_stronger:
forall (U : semax_invariant.schedule) (n : nat),
exists init_U init_tr init_st,
(semantics.initial_core (MachineSemantics U (Some ( getCurPerm (juicy_mem.m_dry (init_jmem n)), empty_map)))) 0 init_genv (juicy_mem.m_dry (init_jmem n)) init_point nil =
Some ((init_U, init_tr, init_st), None) /\
forall U' n',
csafe (globalenv prog) (U', init_tr, init_st)
(proj1_sig (init_mem CPROOF)) n'.