Section LabeledStepOrderFailure.
Context `{labeled_multi_params : LabeledMultiParams}.
Inductive lb_step_ordered_failure : lb_step_relation (list name * ordered_network) label (name * (input + output)) :=
| LabeledStepOrderedFailure_deliver : forall net net' failed tr m ms out d l from to lb,
onwPackets net from to = m :: ms ->
~ In to failed ->
lb_net_handlers to from m (onwState net to) = (lb, out, d, l) ->
net' = mkONetwork (collate name_eq_dec to (update2 name_eq_dec (onwPackets net) from to ms) l)
(update name_eq_dec (onwState net) to d) ->
tr = map2fst to (map inr out) ->
lb_step_ordered_failure (failed, net) lb (failed, net') tr
| LabeledStepOrderedFailure_input : forall h net net' failed tr out inp d l lb,
~ In h failed ->
lb_input_handlers h inp (onwState net h) = (lb, out, d, l) ->
net' = mkONetwork (collate name_eq_dec h (onwPackets net) l)
(update name_eq_dec (onwState net) h d) ->
tr = (h, inl inp) :: map2fst h (map inr out) ->
lb_step_ordered_failure (failed, net) lb (failed, net') tr
| LabeledStepOrderedFailure_stutter : forall net failed, lb_step_ordered_failure (failed, net) label_silent (failed, net) [].
Context {overlay_params : NameOverlayParams unlabeled_multi_params}.
Context {fail_msg_params : FailMsgParams unlabeled_multi_params}.
Proof using.
rewrite /step_star_lb_step_reachable.
case => failed net l.
case => failed' net' tr tr' H_star H_st.
invcs H_st.
- set net' := {| onwPackets := _ ; onwState := _ |}.
apply (@refl_trans_1n_trace_trans _ _ _ _ (failed', net)) => //.
rewrite (app_nil_end (map2fst _ _)).
apply: (@RT1nTStep _ _ _ _ (failed', net')); last exact: RT1nTBase.
apply: (StepOrderedFailure_deliver _ _ _ H3) => //.
rewrite /net_handlers /= /unlabeled_net_handlers /=.
repeat break_let.
by tuple_inversion.
- set net' := {| onwPackets := _ ; onwState := _ |}.
apply (@refl_trans_1n_trace_trans _ _ _ _ (failed', net)) => //.
rewrite (app_nil_end (_ :: _)).
apply: (@RT1nTStep _ _ _ _ (failed', net')); last exact: RT1nTBase.
apply: StepOrderedFailure_input => //; first by [].
rewrite /input_handlers /= /unlabeled_input_handlers /=.
repeat break_let.
by tuple_inversion.
- by have ->: tr' ++ [] = tr' by auto with datatypes.
Qed.

Lemma step_ordered_failure_star_lb_step_execution :
forall s, event_step_star step_ordered_failure step_ordered_failure_init (hd s) ->
lb_step_execution lb_step_ordered_failure s ->
always (now (event_step_star step_ordered_failure step_ordered_failure_init)) s.