Proof using overlay_map_congr name_map_bijective multi_map_congr fail_msg_map_congr.
move => net net' failed failed' tr H_step.
invcs H_step.
- destruct (pt_map_msg m) eqn:?.
left.
rewrite /pt_map_onet /=.
apply (@StepOrderedFailure_deliver _ _ _ _ _ _ _ _ m0 (filterMap pt_map_msg ms) (filterMap pt_map_output out) (pt_map_data d) (filterMap pt_map_name_msg l) (tot_map_name from) (tot_map_name to)).
* rewrite /= 2!tot_map_name_inv_inverse /=.
find_rewrite.
rewrite /=.
destruct (pt_map_msg _) eqn:?; rewrite Heqo in Heqo0 => //.
by inversion Heqo.
* exact: not_in_failed_not_in.
* rewrite /= -(pt_net_handlers_some _ _ _ _ Heqo)  /pt_mapped_net_handlers /= tot_map_name_inv_inverse.
repeat break_let.
by find_inversion.
* by rewrite /= pt_map_update_eq collate_pt_map_update2_eq.
* by rewrite filterMap_pt_map_trace_ev_outputs_eq.
right.
have [H_eq_d [H_ms H_out]] := pt_net_handlers_none _ _ _ _ Heqo H5.
rewrite filterMap_pt_map_trace_ev_outputs_eq /= H_out /=.
split => //.
rewrite /pt_map_onet /= pt_map_update_eq H_eq_d collate_pt_map_update2_eq H_ms /=.
set nwP1 := update2 _ _ _ _ _.
set nwS1 := update _ _ _ _.
set nwP2 := fun _ _ => _.
set nwS2 := fun _ => _.
have H_eq_s: nwS1 = nwS2.
rewrite /nwS1 /nwS2 {nwS1 nwS2}.
apply functional_extensionality => n.
rewrite /update /=.
case (name_eq_dec _ _) => H_dec //.
by rewrite H_dec tot_map_name_inv_inverse.
have H_eq_p: nwP1 = nwP2.
rewrite /nwP1 /nwP2 /=.
apply functional_extensionality => src.
apply functional_extensionality => dst.
rewrite /update2 /=.
case (sumbool_and _ _ _ _) => H_dec //.
move: H_dec => [H_eq_from H_eq_to].
rewrite -H_eq_from -H_eq_to /= 2!tot_map_name_inv_inverse H3 /=.
case H_m': (pt_map_msg _) => [m'|] //.
by rewrite H_m' in Heqo.
by rewrite H_eq_s H_eq_p.
- case H_i: (pt_map_input _) => [inp'|].
left.
apply (@StepOrderedFailure_input _ _ _ _ (tot_map_name h) _ _ _ _ (filterMap pt_map_output out) inp' (pt_map_data d) (filterMap pt_map_name_msg l)).
* exact: not_in_failed_not_in.
* rewrite /=.
have H_q := pt_input_handlers_some h inp (onwState net h) H_i.
rewrite /pt_mapped_input_handlers /= in H_q.
find_rewrite.
rewrite H_q.
by rewrite tot_map_name_inv_inverse.
* by rewrite /pt_map_onet /= pt_map_update_eq collate_pt_map_eq.
* by rewrite filterMap_pt_map_trace_ev_outputs_eq.
right.
rewrite /= /pt_map_onet /=.
have [H_d [H_l H_o]] := pt_input_handlers_none h inp (onwState net h) H_i H4.
rewrite filterMap_pt_map_trace_ev_outputs_eq H_o /=.
split => //.
rewrite pt_map_update_eq /= H_d.
rewrite collate_pt_map_eq H_l /=.
set nwS1 := update _ _ _ _.
set nwS2 := fun n => pt_map_data _.
have H_eq_n: nwS1 = nwS2.
rewrite /nwS1 /nwS2 /=.
apply functional_extensionality => n.
rewrite /update /=.
case (name_eq_dec _ _) => H_dec //.
by rewrite H_dec tot_map_name_inv_inverse.
by rewrite H_eq_n.
- left.
rewrite /pt_map_onet /=.
set l := map2snd _ _.
have H_nd: NoDup (map fst (filterMap pt_map_name_msg l)).
rewrite /pt_map_name_msg /=.
rewrite /l {l}.
apply NoDup_map_snd_fst.
apply (@nodup_pt_map msg_fail); first exact: in_map2snd_snd.
apply NoDup_map2snd.
apply NoDup_remove_all.
exact: no_dup_nodes.
move => nm nm' H_in H_in'.
by rewrite (pt_map_in_snd  _ _ _ _ pt_fail_msg_fst_snd H_in) (pt_map_in_snd _ _ _ _ pt_fail_msg_fst_snd H_in').
apply: StepOrderedFailure_fail => //.
* exact: not_in_failed_not_in.
* rewrite /= /l collate_pt_map_eq /=.
by rewrite (NoDup_Permutation_collate_eq _ _ name_eq_dec _ _ _ _ H_nd (pt_map_map_pair_eq msg_fail h failed pt_fail_msg_fst_snd)).
Qed.

(* Specifications: *)
Corollary step_ordered_failure_pt_mapped_simulation_star_1 :
forall net failed tr,
@step_ordered_failure_star _ _ overlay_fst fail_msg_fst step_ordered_failure_init (failed, net) tr ->
@step_ordered_failure_star _ _ overlay_snd fail_msg_snd step_ordered_failure_init (map tot_map_name failed, pt_map_onet net) (filterMap pt_map_trace_ev tr).