Local Arguments getThreadR {_} {_} {_} _ _ _.
Local Arguments getThreadC {_} {_} {_} _ _ _.
Local Arguments personal_mem : clear implicits.
Local Arguments updThread {_} {_} {_} _ _ _ _ _.
Local Arguments updThreadR {_} {_} {_} _ _ _ _.
Local Arguments updThreadC {_} {_} {_} _ _ _ _.
Local Arguments juicyRestrict : clear implicits.
Set Bullet Behavior "Strict Subproofs".
Open Scope string_scope.
(* Lemma isLK_rewrite r : (forall (sh : Share.t) (rsh : shares.readable_share sh) (z : Z) (P : preds), r <> YES sh rsh (LK z) P) <-> ~ isLK r. *)

Lemma invariant_thread_step
(mem_cohere_step
: forall (c c' : corestate) (jm jm' : juicy_mem) (Phi X : rmap) (ge : genv),
mem_cohere' (m_dry jm) Phi ->
join (m_phi jm) X Phi ->
@corestep corestate juicy_mem (@juicy_core_sem corestate (cl_core_sem ge)) c jm c' jm' ->
exists Phi' : rmap,
join (m_phi jm') (@age_to (@level rmap ag_rmap (m_phi jm')) rmap ag_rmap X) Phi' /\
mem_cohere' (m_dry jm') Phi')
(personal_mem_equiv_spec
: forall (m m' : Mem.mem') (phi : rmap) (pr : mem_cohere' m phi) (pr' : mem_cohere' m' phi),
Mem.nextblock m = Mem.nextblock m' ->
(forall loc : address, max_access_at m loc = max_access_at m' loc) ->
(forall loc : AV.address, isVAL (phi @ loc) -> contents_at m loc = contents_at m' loc) ->
mem_equiv (m_dry (personal_mem m phi pr)) (m_dry (personal_mem m' phi pr')))
(Jspec : juicy_ext_spec unit) Gamma
n m ge i tr sch tp Phi ci ci' jmi'
(Stable : ext_spec_stable age Jspec)
(Stable' : ext_spec_stable juicy_mem_equiv Jspec)
(envcoh : env_coherence Jspec ge Gamma Phi)
(extcompat : joins (ghost_of Phi) (Some (ghost_PCM.ext_ref tt, NoneP) :: nil))
(mwellformed: @mem_wellformed ge m)
(compat : mem_compatible_with tp m Phi)
(En : level Phi = S n)
(lock_bound : lockSet_block_bound (lset tp) (Mem.nextblock m))
(sparse : lock_sparsity (lset tp))
(lock_coh : lock_coherence' tp Phi m compat)
(safety : threads_safety Jspec m tp Phi compat (S n))
(wellformed : threads_wellformed tp)
(unique : unique_Krun tp (i :: sch))
(cnti : containsThread tp i)
(stepi : corestep (juicy_core_sem (cl_core_sem ge)) ci (jm_ cnti compat) ci' jmi')
(safei' : forall ora, jm_bupd ora (jsafeN Jspec ge n ora ci') jmi')
(Eci : getThreadC i tp cnti = Krun ci)
(tp' := age_tp_to (level jmi') tp)
(tp'' := updThread i tp' (cnt_age' cnti) (Krun ci') (m_phi jmi') : jstate ge)
(cm' := (m_dry jmi', (tr, i :: sch, tp''))) :
state_bupd (state_invariant Jspec Gamma n) cm'.