Section Csafe_KSafe.
(** *Csafe and Ksafe*)
(** Prove of equivalence between Csafe and Ksafe. - Csafe is the safety notion used by top level (Clight) and bottom level (Asm). - Ksafe is the notion of safety used by konig proof. Proofs in this section are for all dry and not diluted Coarse hybrid machines. *)
(* All machine steps are either Core or Angel (according to csafe)*)
Inductive CoreOrAngel: MachState -> MachState -> Prop:=
| IsCore st tr tp':
CoreOrAngel st (fst (fst st), seq.cat (snd (fst st)) tr, tp')
| IsAngel st tr tp':
CoreOrAngel st (schedSkip (fst (fst st)), seq.cat (snd (fst st)) tr, tp').
(* MachStep that doesn't change the schedule, Reduces the set of valid schedules... *)
Inductive has_unique_running tp:Prop :=
| HasUniqueRun i (cnti : ThreadPool.containsThread tp i) q:
ThreadPool.getThreadC cnti = Krun q ->
has_unique_running tp.

Lemma ksafe_csafe_equiv:
forall tp m tr,
(forall U, valid (tr, tp, m) U) ->
(forall n U, ksafe_kstep (U, tr, tp) m n) ->
(forall n U, csafe (U, tr, tp) m n).