Proof using.
case => ns ps s.
rewrite /deserialize_odnet /serialize_odnet /=.
set ps' := fun _ _ => filterMap _ _.
have H_p: ps' = ps.
rewrite /ps'.
clear.
apply functional_extensionality => src.
apply functional_extensionality => dst.
elim: (ps src dst) => [|m ms IH] //=.
by rewrite serialize_deserialize_top_id IH.
by rewrite H_p.
Qed.
Instance multi_params_orig_name_tot_map :
MultiParamsNameTotalMap serialized_multi_params orig_multi_params :=
{
tot_map_name := id ;
tot_map_name_inv := id
}.
Instance multi_params_orig_name_tot_map_bijective :
MultiParamsNameTotalMapBijective multi_params_orig_name_tot_map :=
{
tot_map_name_inv_inverse := fun _ => eq_refl _;
tot_map_name_inverse_inv := fun _ => eq_refl _
}.
Instance multi_orig_params_pt_msg_map : MultiParamsMsgPartialMap serialized_multi_params orig_multi_params :=
{
pt_map_msg := fun m =>
match deserialize_top deserialize m with
| Some data => Some data
| None => None
end
}.
Instance multi_orig_base_params_pt_map : BaseParamsPartialMap serialized_base_params orig_base_params :=
{
pt_map_data := id;
pt_map_input := fun i => Some i;
pt_map_output := fun o => Some o
}.
Instance multi_orig_failure_params_pt_map_congruency : FailureParamsPartialMapCongruency serialized_failure_params orig_failure_params multi_orig_base_params_pt_map :=
{
pt_reboot_eq := fun _ => eq_refl _
}.
Instance multi_orig_name_overlay_params_tot_map_congruency : NameOverlayParamsTotalMapCongruency serialized_name_overlay_params orig_name_overlay_params multi_params_orig_name_tot_map :=
{
tot_adjacent_to_fst_snd := fun _ _ => conj (fun H => H) (fun H => H)
}.
Program Instance multi_orig_fail_msg_params_pt_map_congruency : FailMsgParamsPartialMapCongruency serialized_fail_msg_params orig_fail_msg_params multi_orig_params_pt_msg_map :=
{
pt_fail_msg_fst_snd := _
}.
Next Obligation.
by rewrite serialize_deserialize_top_id.
Qed.
Program Instance multi_orig_new_msg_params_pt_map_congruency : NewMsgParamsPartialMapCongruency serialized_new_msg_params orig_new_msg_params multi_orig_params_pt_msg_map :=
{
pt_new_msg_fst_snd := _
}.
Next Obligation.
by rewrite serialize_deserialize_top_id.
Qed.
Program Instance multi_orig_params_pt_map_congruency : MultiParamsPartialMapCongruency multi_orig_base_params_pt_map multi_params_orig_name_tot_map multi_orig_params_pt_msg_map :=
{
pt_init_handlers_eq := fun _ => eq_refl ;
pt_net_handlers_some := _ ;
pt_net_handlers_none := _ ;
pt_input_handlers_some := _ ;
pt_input_handlers_none := _;
}.
Next Obligation.
rewrite /pt_mapped_net_handlers.
repeat break_let.
rewrite /tot_map_name /= /id.
rewrite /pt_map_msg /= in H.
rewrite /net_handlers /= /serialized_net_handlers in Heqp.
move: H Heqp.
case H_m: (deserialize_top deserialize m) => [m0|] => H_eq //.
find_injection.
rewrite /serialize_handler_result in Heqp.
repeat break_let.
find_injection.
set sl2 := filterMap (fun _ => _) _.
set sl1 := filterMap _ _.
have H_eq: sl2 = l0.
rewrite /sl2.
clear.
elim: l0 => //=.
move => o l IH.
by rewrite IH.
have H_eq': sl1 = l1.
rewrite /sl1 /pt_map_name_msg /tot_map_name /id /= /id /serialize_name_msg_tuple.
clear.
elim: l1 => //=.
case => [n m] => /=.
move => l IH.
by rewrite serialize_deserialize_top_id IH.
by rewrite H_eq H_eq'.
Qed.
Next Obligation.
rewrite /net_handlers /= /serialized_net_handlers /= in H0.
rewrite /pt_map_msg /= in H.
move: H H0.
case H_eq_m: (deserialize_top deserialize m) => [m'|] H_eq H_eq'; first by repeat break_let.
by find_injection.
Qed.
Next Obligation.
rewrite /pt_mapped_input_handlers.
repeat break_let.
destruct p.
rewrite /tot_map_name /= /id.
rewrite /input_handlers /= /serialized_input_handlers in Heqp.
find_injection.
rewrite /serialize_handler_result in Heqp.
repeat break_let.
find_injection.
set sl2 := filterMap (fun _ => _) _.
set sl1 := filterMap _ _.
have H_eq: sl2 = l0.
rewrite /sl2.
clear.
elim: l0 => //=.
move => o l IH.
by rewrite IH.
have H_eq': sl1 = l1.
rewrite /sl1 /pt_map_name_msg /tot_map_name /id /= /id /serialize_name_msg_tuple.
clear.
elim: l1 => //=.
case => [n m] => /=.
move => l IH.
by rewrite serialize_deserialize_top_id IH.
by rewrite H_eq H_eq'.
Qed.

(* Specifications: *)
Lemma pt_map_net_deserialize_net :
forall net, pt_map_net net = deserialize_net net.