Proof using.
red. unfold append_entries_request_reply_correspondence. intros.
simpl in *.
find_apply_hyp_hyp. intuition.
- copy_eapply_prop_hyp pBody pBody; auto; [|repeat find_rewrite; in_crush].
unfold exists_equivalent_network_with_aer in *.
break_exists_name net'.
break_exists_name pli'.
break_exists_name plt'.
break_exists_name ci'.
break_exists_name n'.
intuition.
remember mkNetwork as mkN.
remember mkPacket as mkP.
unfold Net.name in *. simpl in *.
exists (mkN (ps' ++ [mkP (pDst p0) (pSrc p0) (AppendEntries t0 n' pli' plt' es0 ci')]) st').
subst.
exists pli',plt',ci',n'. simpl in *; intuition.
repeat find_rewrite.
match goal with
| H : nwPackets net' = (?xs ++ ?p :: ?ys) ++ ?l |- _ =>
assert (nwPackets net' = xs ++ p :: (ys ++ l))
by (find_rewrite_lem app_ass; rewrite app_comm_cons; auto);
clear H
end.
eapply RIR_handleMessage with (net0 := net') (p1 := p);
simpl; repeat find_rewrite; eauto;
simpl; repeat break_let; eauto; try find_inversion; eauto.
intros. do_in_app. simpl in *.
intuition; try find_apply_hyp_hyp; intuition; in_crush.
- subst. simpl in *. subst. unfold exists_equivalent_network_with_aer.
find_eapply_lem_hyp RIR_step_failure; [|eapply StepFailure_dup with (failed := [])]; eauto.
remember mkNetwork as mkN.
remember mkPacket as mkP.
unfold Net.name in *. simpl in *.
match goal with
| _ : raft_intermediate_reachable (mkN (?p :: _) _ ) |- _ =>
(exists (mkN (ps' ++ [p]) st'))
end.
subst.
(exists pli, plt, ci, n).
simpl in *. intuition.
+ match goal with
| _ : raft_intermediate_reachable (mkNetwork ?ps ?st) |- _ =>
eapply RIR_handleMessage with (net0 := (mkNetwork ps st)) (p0 := p)
(xs0 := (p :: xs))
end; eauto;
simpl in *; repeat find_rewrite; simpl in *; repeat break_let; eauto;
repeat find_inversion; eauto.
intros.
do_in_app. simpl in *. intuition.
find_apply_hyp_hyp. intuition; subst; auto.
+ f_equal. f_equal.
destruct p; simpl in *; f_equal; intuition.
subst.
find_apply_lem_hyp handleAppendEntries_reply_spec; auto.
intuition. subst. auto.
Qed.

(* Specifications: *)
Lemma append_entries_request_reply_correspondence_append_entries_reply :
raft_net_invariant_append_entries_reply append_entries_request_reply_correspondence.