Section AppendEntriesRequestReplyCorrespondence.
Context {orig_base_params : BaseParams}.
Context {one_node_params : OneNodeParams orig_base_params}.
Context {raft_params : RaftParams orig_base_params}.
Proof using.
red. unfold append_entries_request_reply_correspondence. intros.
simpl in *. intuition.
Qed.
Proof using.
red. unfold append_entries_request_reply_correspondence. intros.
simpl in *.
find_apply_hyp_hyp. intuition.
- copy_eapply_prop_hyp pBody pBody; auto.
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 p) (pSrc p) (AppendEntries t n pli plt es ci)]) st').
subst.
exists pli,plt,ci,n. simpl in *; intuition.
eapply @RIR_handleInput with (net := net') (inp := Timeout); eauto;
simpl; repeat find_rewrite; eauto.
intros.
do_in_app. intuition.
find_apply_hyp_hyp.
intuition.
- exfalso.
do_in_map. subst. simpl in *.
unfold handleTimeout, tryToBecomeLeader in *.
repeat break_match; find_inversion; intuition; do_in_map; subst; simpl in *; congruence.
Qed.
Proof using.
red. unfold append_entries_request_reply_correspondence. intros.
simpl in *.
find_apply_hyp_hyp. intuition.
- copy_eapply_prop_hyp pBody pBody; auto.
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 p) (pSrc p) (AppendEntries t n pli plt es ci)]) st').
subst.
exists pli,plt,ci,n. simpl in *; intuition.
eapply @RIR_handleInput with (net := net') (inp := ClientRequest client id c); eauto;
simpl; repeat find_rewrite; eauto.
intros.
do_in_app. intuition.
find_apply_hyp_hyp.
intuition.
- exfalso.
do_in_map. subst. simpl in *.
unfold handleClientRequest in *.
repeat break_match; find_inversion; intuition; do_in_map; subst; simpl in *; congruence.
Qed.
Proof using.
red. unfold append_entries_request_reply_correspondence. intros.
simpl in *.
find_apply_hyp_hyp. intuition.
- copy_eapply_prop_hyp pBody pBody; auto.
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 p) (pSrc p) (AppendEntries t n pli plt es ci)]) st').
subst.
exists pli,plt,ci,n. simpl in *; intuition.
eapply @RIR_doLeader with (net := net'); eauto;
simpl; repeat find_rewrite; eauto.
intros.
do_in_app. intuition.
find_apply_hyp_hyp.
intuition.
- exfalso.
do_in_map. subst. simpl in *.
unfold doLeader in *.
repeat break_match; find_inversion; intuition; do_in_map; subst; simpl in *; congruence.
Qed.
Proof using.
red. unfold append_entries_request_reply_correspondence. intros.
simpl in *.
find_apply_hyp_hyp. intuition.
- copy_eapply_prop_hyp pBody pBody; auto.
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 p) (pSrc p) (AppendEntries t n pli plt es ci)]) st').
subst.
exists pli,plt,ci,n. simpl in *; intuition.
eapply @RIR_doGenericServer with (net := net'); eauto;
simpl; repeat find_rewrite; eauto.
intros.
do_in_app. intuition.
find_apply_hyp_hyp.
intuition.
- exfalso.
do_in_map. subst. simpl in *.
unfold doGenericServer in *.
repeat break_match; find_inversion; intuition; do_in_map; subst; simpl in *; congruence.
Qed.
Proof using.
red. unfold append_entries_request_reply_correspondence. intros.
simpl in *.
find_reverse_rewrite.
find_apply_hyp_hyp.
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. subst.
remember mkNetwork as mkN.
remember mkPacket as mkP.
unfold Net.name in *. simpl in *.
exists (mkN ((nwPackets net) ++ [mkP (pDst p) (pSrc p) (AppendEntries t n pli plt es ci)]) (nwState net')).
subst.
exists pli,plt,ci,n. simpl in *; repeat find_rewrite; intuition.
eapply @RIR_step_failure with (net := net''); [|eapply @StepFailure_reboot with (h := h) (failed := [h])]; eauto;
simpl; repeat find_rewrite; eauto.
f_equal.
apply functional_extensionality.
intros. repeat find_higher_order_rewrite.
unfold update. repeat break_if; subst; eauto; congruence.
Qed.
Proof using.
intros.
pose proof dup_drop_reorder _ packet_eq_dec _ _ ltac:(eauto).
match goal with
| [ H : dup_drop_step_star _ _ _ |- _ ] =>
eapply step_failure_dup_drop_step with (f := []) (Sigma := nwState net) in H
end.
eapply step_failure_star_raft_intermediate_reachable_extend with (f := []) (f' := []) (tr := []); [|eauto].
destruct net, net'. simpl in *. subst.
auto.
Qed.

Lemma append_entries_request_reply_correspondence_state_same_packet_subset :
raft_net_invariant_state_same_packet_subset append_entries_request_reply_correspondence.