Section ThreadPoolErasure.
Context {Sem: Semantics}
{CE: CoreErasure}.
Existing Instance OrdinalPool.OrdinalThreadPool.
Existing Instance DryHybridMachine.dryResources.
Existing Instance BareMachine.resources.
Existing Instance AsmContext.bareMach.
Existing Instance AsmContext.dryFineMach.
Notation containsThreadF := (@containsThread DryHybridMachine.dryResources Sem OrdinalPool.OrdinalThreadPool).
Notation containsThreadE := (@containsThread BareMachine.resources Sem OrdinalPool.OrdinalThreadPool).
Definition ctl_erasure c c' : Prop :=
match c, c' with
| Kinit vf arg, Kinit vf' arg' =>
val_erasure vf vf' /\ val_erasure arg arg'
| Krun c, Krun c' =>
core_erasure c c'
| Kblocked c, Kblocked c' =>
core_erasure c c'
| Kresume c arg, Kresume c' arg' =>
core_erasure c c' /\ arg = arg'
(*we don't use this and our semantics are strange*)
| _, _  => False
end.
Inductive threadPool_erasure tp tp' :=
| ErasedPool :
(forall i, containsThreadF tp i <-> containsThreadE tp' i) ->
(forall i (cnti: containsThreadF tp i)
(cnti': containsThreadE tp' i),
ctl_erasure (getThreadC cnti) (getThreadC cnti')) ->
threadPool_erasure tp tp'.
Proof with eauto with val_erasure erased.
destruct c; simpl...
Qed.
Proof with eauto with val_erasure erased.
intros.
inversion H.
pose proof (erasedPool_num_threads H) as Heq_threads.
constructor.
- unfold addThread; simpl.
unfold OrdinalPool.addThread, OrdinalPool.containsThread; simpl.
intros.
rewrite Heq_threads; auto.
split; now eauto.
- intros.
assert (cnti00 := cntAdd' _ _ _ cnti).
assert (cnti0'0 := cntAdd' _ _ _ cnti').
destruct cnti00 as [[cnti00 ?] | Heq];
destruct cnti0'0 as [[cnti0'0 ?] | ?].
+ erewrite gsoAddCode with (cntj := cnti00) by eauto.
erewrite gsoAddCode with (cntj := cnti0'0) by eauto.
eauto.
+ exfalso; subst; apply H4.
unfold latestThread. simpl.
unfold OrdinalPool.latestThread.
rewrite Heq_threads.
reflexivity.
+ exfalso; subst; apply H4.
unfold latestThread. simpl.
unfold OrdinalPool.latestThread.
rewrite Heq_threads.
reflexivity.
+ subst. erewrite! gssAddCode by eauto.
simpl; split...
Qed.

Lemma erased_remLockSet:
forall tp tp' addr addr',
threadPool_erasure tp tp' ->
threadPool_erasure (remLockSet tp addr)
(remLockSet tp' addr').