End juicy.
(*+ Final instantiation *)
Record CSL_proof := {
CSL_prog : Clight.program;
CSL_CS: compspecs;
CSL_V : varspecs;
CSL_G : funspecs;
CSL_ext_link : string -> ident;
CSL_ext_link_inj : forall s1 s2, CSL_ext_link s1 = CSL_ext_link s2 -> s1 = s2;
CSL_all_safe : semax_prog.semax_prog (Concurrent_Espec unit CSL_CS CSL_ext_link)
CSL_prog CSL_V CSL_G;
CSL_init_mem_not_none : Genv.init_mem CSL_prog <> None;
}.
Section Safety.
Variable CPROOF: CSL_proof.
Definition CS :=   CPROOF.(CSL_CS).
Definition V :=   CPROOF.(CSL_V).
Definition G :=   CPROOF.(CSL_G).
Definition ext_link :=   CPROOF.(CSL_ext_link).
Definition ext_link_inj :=   CPROOF.(CSL_ext_link_inj).
Definition prog :=   CPROOF.(CSL_prog).
Definition all_safe :=   CPROOF.(CSL_all_safe).
Definition init_mem_not_none :=   CPROOF.(CSL_init_mem_not_none).
Definition Jspec' := (@OK_spec (Concurrent_Espec unit CS ext_link)).
(* another, looser invariant to have more standard preservation statement *)
Definition inv Gamma n state :=
exists m, (n <= m)%nat /\ state_invariant(ge := globalenv prog) Jspec' Gamma m state.

Lemma invariant_safe Gamma n state :
inv Gamma n state -> jmsafe (globalenv prog) n state.