Definition init_mem : { m | Genv.init_mem prog = Some m } := init_m prog init_mem_not_none.Definition spr :=
    semax_prog_rule'
      (Concurrent_Espec unit CS ext_link) V G prog
      (proj1_sig init_mem) 0 all_safe (proj2_sig init_mem).Definition initial_corestate : corestate := projT1 (projT2 spr).Definition initial_jm (n : nat) : juicy_mem := proj1_sig (snd (projT2 (projT2 spr)) n tt).Definition initial_machine_state (n : nat) :=
    @OrdinalPool.mk LocksAndResources (@JSem (globalenv prog))
      (pos.mkPos (le_n 1))
      (fun _ => Krun initial_corestate)
      (fun _ => m_phi (initial_jm n))
      (addressFiniteMap.AMap.empty _).Definition NoExternal_Espec : external_specification mem external_function unit :=
    Build_external_specification
      _ _ _
      (* no external calls from the machine *)
      (fun _ => False)
      (fun _ _ _ _ _ _ _ => False)
      (fun _ _ _ _ _ _ _ => False)
      (* when the machine is halted, it means no more schedule, there
      is nothing to check: *)
      (fun _ _ _ => Logic.True).Definition NoExternal_Hrel : nat -> mem -> mem -> Prop := fun _ _ _ => False.

Theorem safety_initial_state (sch : schedule) (n : nat) : jm_csafe (sch, nil, initial_machine_state n) (proj1_sig init_mem) n.