Section SerializedMsgCorrect.
Context {orig_base_params : BaseParams}.
Context {orig_multi_params : MultiParams orig_base_params}.
Context {orig_failure_params : FailureParams orig_multi_params}.
Context {orig_name_overlay_params : NameOverlayParams orig_multi_params}.
Context {orig_fail_msg_params : FailMsgParams orig_multi_params}.
Context {orig_new_msg_params : NewMsgParams orig_multi_params}.
Context {orig_msg_serializer : Serializer msg}.
Definition serialize_packet p :=
@mkPacket _ serialized_multi_params
(@pSrc _ orig_multi_params p)
(pDst p)
(serialize_top (serialize (pBody p))).
Definition serialize_net (net : @network _ orig_multi_params) : (@network _ serialized_multi_params) :=
@mkNetwork _ serialized_multi_params (map serialize_packet (nwPackets net)) net.(nwState).
Definition serialize_onet (net : @ordered_network _ orig_multi_params) : (@ordered_network _ serialized_multi_params) :=
@mkONetwork _ serialized_multi_params (fun src dst => map (fun v => serialize_top (serialize v)) (net.(onwPackets) src dst)) net.(onwState).
Definition serialize_odnet (net : @ordered_dynamic_network _ orig_multi_params) : (@ordered_dynamic_network _ serialized_multi_params) :=
@mkODNetwork _ serialized_multi_params net.(odnwNodes) (fun src dst => map (fun v => serialize_top (serialize v)) (net.(odnwPackets) src dst)) net.(odnwState).
Instance orig_multi_params_name_tot_map :
MultiParamsNameTotalMap orig_multi_params serialized_multi_params :=
{
tot_map_name := id ;
tot_map_name_inv := id
}.
Instance orig_multi_params_name_tot_map_bijective :
MultiParamsNameTotalMapBijective orig_multi_params_name_tot_map :=
{
tot_map_name_inv_inverse := fun _ => eq_refl ;
tot_map_name_inverse_inv := fun _ => eq_refl
}.
Instance orig_base_params_tot_map :
BaseParamsTotalMap orig_base_params serialized_base_params :=
{
tot_map_data := id;
tot_map_input := id;
tot_map_output := id
}.
Instance orig_multi_params_tot_msg_map :
MultiParamsMsgTotalMap orig_multi_params serialized_multi_params :=
{
tot_map_msg := fun v => serialize_top (serialize v)
}.
Instance orig_failure_params_tot_map_congruency : FailureParamsTotalMapCongruency orig_failure_params serialized_failure_params orig_base_params_tot_map :=
{
tot_reboot_eq := fun _ => eq_refl
}.
Instance orig_multi_name_overlay_params_tot_map_congruency : NameOverlayParamsTotalMapCongruency orig_name_overlay_params serialized_name_overlay_params orig_multi_params_name_tot_map :=
{
tot_adjacent_to_fst_snd := fun _ _ => conj (fun H => H) (fun H => H)
}.
Instance orig_multi_fail_msg_params_tot_map_congruency : FailMsgParamsTotalMapCongruency orig_fail_msg_params serialized_fail_msg_params orig_multi_params_tot_msg_map :=
{
tot_fail_msg_fst_snd := eq_refl
}.
Instance orig_multi_new_msg_params_tot_map_congruency : NewMsgParamsTotalMapCongruency orig_new_msg_params serialized_new_msg_params orig_multi_params_tot_msg_map :=
{
tot_new_msg_fst_snd := eq_refl
}.
Program Instance orig_multi_params_map_congruency :
MultiParamsTotalMapCongruency orig_base_params_tot_map
orig_multi_params_name_tot_map orig_multi_params_tot_msg_map :=
{
tot_init_handlers_eq := fun _ => eq_refl ;
tot_net_handlers_eq := _ ;
tot_input_handlers_eq := _
}.
Next Obligation.
rewrite /tot_mapped_net_handlers /= /tot_map_name_msgs /= /id /=.
repeat break_let.
rewrite /serialized_net_handlers.
rewrite serialize_deserialize_top_id.
rewrite /serialize_handler_result.
repeat break_let.
find_injection.
rewrite map_id.
set l1 := map _ l.
set l2 := map _ l.
suff H_suff: l1 = l2 by rewrite H_suff.
rewrite /l1 /l2.
clear.
elim: l => //=.
move => p l IH.
rewrite IH /= /serialize_name_msg_tuple /=.
by break_let.
Qed.
Next Obligation.
rewrite /tot_mapped_input_handlers /=.
repeat break_let.
unfold serialized_input_handlers in *.
rewrite /serialize_handler_result /id /tot_map_name_msgs /tot_map_name /= /id /=.
repeat break_let.
find_injection.
rewrite map_id.
set l1 := map _ l.
set l2 := map _ l.
suff H_suff: l1 = l2 by rewrite H_suff.
rewrite /l1 /l2.
clear.
elim: l => //=.
move => p l IH.
rewrite IH /= /serialize_name_msg_tuple /=.
by break_let.
Qed.

(* Specifications: *)
Lemma serialize_odnet_tot_map_odnet :
forall net, serialize_odnet net = tot_map_odnet net.