(** ** Proofs about [AsmContext.dryFineMach]*)
Section FineMachineInternal.
Context {initU : seq nat}
{semAx: CoreLanguage.SemAxioms}
{dilMem: DiluteMem}.
Notation fmachine_step := ((corestep (AsmContext.fine_semantics initU))).
(*TODO: maybe move to tactics *)
(** Solves absurd cases from fine-grained internal steps *)
Ltac absurd_internal Hstep :=
inversion Hstep; try inversion Htstep; subst; Tactics.pf_cleanup; simpl in *;
try match goal with
| [H: Some _ = Some _ |- _] => inversion H; subst
end; Tactics.pf_cleanup;
repeat match goal with
| [H: getThreadC ?Pf = _, Hint: ?Pf$_ @ I |- _] =>
unfold getStepType in Hint; simpl in *;
rewrite H in Hint; simpl in Hint
| [H1: match ?Expr with _ => _ end = _,
H2: ?Expr = _ |- _] => rewrite H2 in H1
end; try discriminate; try (exfalso; by auto).
Opaque getThreadC updThreadC containsThread updThread updLockSet addThread remLockSet getThreadR lockSet.

(* Specifications: *)
Lemma fstep_containsThread' :
forall tp tp' m m' i j U tr tr'
(cnti: containsThread tp i)
(cntj: containsThread tp' j)
(Hcomp: mem_compatible tp m),
let mrestr := restrPermMap (((compat_th _ _ Hcomp) cnti).1) in
forall
(Hinternal: cnti$mrestr @ I)
(Hstep: fmachine_step (i :: U, tr, tp) m (U, tr', tp') m'),
containsThread tp j.
Lemma fmachine_step_invariant:
forall (tp tp' : t) m m' (i : nat) (pf : containsThread tp i) U tr tr'
(Hcomp: mem_compatible tp m),
let mrestr := restrPermMap (((compat_th _ _ Hcomp) pf).1) in
forall (Hinternal: pf$mrestr @ I)
(Hstep: fmachine_step (i :: U, tr, tp) m (U, tr', tp') m'),
invariant tp'.
Lemma fmachine_step_compatible:
forall (tp tp' : t) m m' (i : nat) (pf : containsThread tp i) U tr tr'
(Hcomp: mem_compatible tp m),
let mrestr := restrPermMap (((compat_th _ _ Hcomp) pf).1) in
forall (Hinternal: pf$mrestr @ I)
(Hstep: fmachine_step (i :: U,tr, tp) m (U, tr',tp') m'),
mem_compatible tp' m'.
Lemma gsoThreadC_fstepI:
forall tp tp' m m' i j U tr tr'
(pfj: containsThread tp j)
(pfj': containsThread tp' j)
(pfi: containsThread tp i)
(Hcomp: mem_compatible tp m),
let mrestr := restrPermMap (((compat_th _ _ Hcomp) pfi).1) in
forall (Hinternal: pfi$mrestr @ I)
(Hstep: fmachine_step (i :: U, tr, tp) m (U, tr', tp') m')
(Hneq: i <> j),
getThreadC pfj = getThreadC pfj'.
Lemma gsoLockSet_fstepI:
forall tp tp' m m' i U tr tr'
(pfi: containsThread tp i)
(Hcomp: mem_compatible tp m),
let mrestr := restrPermMap (((compat_th _ _ Hcomp) pfi).1) in
forall (Hinternal: pfi$mrestr @ I)
(Hstep: fmachine_step (i :: U, tr, tp) m (U, tr', tp') m'),
lockSet tp = lockSet tp'.