Hint Constructors context contextlist.
Hint Resolve context_compose contextlist_compose.
(** * Safe executions. *)
(** A state is safe according to the nondeterministic semantics if it cannot get stuck by doing silent transitions only. *)
Definition safe (s: Csem.state) : Prop :=
forall s', star Csem.step ge s E0 s' ->
(exists r, final_state s' r) \/ (exists t, exists s'', Csem.step ge s' t s'').

(* Specifications: *)
Lemma safe_steps:
forall s s',
safe s -> star Csem.step ge s E0 s' -> safe s'.
Lemma star_safe:
forall s1 s2 t s3,
safe s1 -> star Csem.step ge s1 E0 s2 -> (safe s2 -> star Csem.step ge s2 t s3) ->
star Csem.step ge s1 t s3.
Lemma plus_safe:
forall s1 s2 t s3,
safe s1 -> star Csem.step ge s1 E0 s2 -> (safe s2 -> plus Csem.step ge s2 t s3) ->
plus Csem.step ge s1 t s3.
Lemma safe_imm_safe:
forall f C a k e m K,
safe (ExprState f (C a) k e m) ->
context K RV C ->
imm_safe ge e K a m.