Section Preservation.
Variables
(CS : compspecs)
(ext_link : string -> ident)
(ext_link_inj : forall s1 s2, ext_link s1 = ext_link s2 -> s1 = s2).
Definition Jspec' := (@OK_spec (Concurrent_Espec unit CS ext_link)).
Open Scope string_scope.
(* ============================ *)

(* We prove preservation for most states of the machine, including Kblocked at acquire, but preservation does not hold for makelock or release, so, we make an exception and will use safety induction in the safety theorem.  Because it's faster to prove safety induction, we don't prove preservation for freelock and spawn, either, because we did those two last. *)
Theorem preservation ge Gamma n state state' :
~ blocked_at_external state CREATE ->
~ blocked_at_external state MKLOCK ->
~ blocked_at_external state FREE_LOCK ->
~ blocked_at_external state UNLOCK ->
state_step state state' ->
state_invariant Jspec' Gamma (S n) state ->
state_bupd(ge := ge) (state_invariant Jspec' Gamma n) state' \/
state_bupd(ge := ge) (state_invariant Jspec' Gamma (S n)) state'.