Proof using cci vci cei laei taifoli rri.
unfold refined_raft_net_invariant_request_vote_reply, match_index_all_entries_inv.
simpl. intros. split.
- unfold match_index_all_entries in *. simpl. intros. break_and.
find_apply_lem_hyp handleRequestVoteReply_spec.
repeat find_higher_order_rewrite.
update_destruct_simplify_hyp.
+ intuition; try congruence.
* subst.
{ update_destruct_simplify_hyp.
- rewrite update_elections_data_requestVoteReply_allEntries.
repeat find_reverse_rewrite. eauto.
- repeat find_reverse_rewrite. eauto.
}
* repeat find_rewrite.
unfold assoc_default in *.
{ break_match.
- simpl in *. break_if; try discriminate.
match goal with
| [ H : Some _ = Some _ |- _ ] => invc H
end.
rewrite_update.
simpl.
rewrite update_elections_data_requestVoteReply_allEntries.
match goal with
| [ |- In (?t, _) _ ] => replace t with (eTerm e) by congruence
end.
eapply log_all_entries_invariant; auto.
- find_apply_lem_hyp lifted_terms_and_indices_from_one_log; auto.
intuition. omega.
}
+ update_destruct_simplify_hyp.
* rewrite update_elections_data_requestVoteReply_allEntries.
repeat find_reverse_rewrite. eauto.
* repeat find_reverse_rewrite. eauto.
- unfold match_index_all_entries_nw in *.
simpl in *.
intros.
find_apply_lem_hyp handleRequestVoteReply_spec'.
repeat find_higher_order_rewrite.
find_apply_hyp_hyp.
update_destruct_simplify_hyp.
+ intuition; try congruence.
* subst.
{ update_destruct_simplify_hyp.
- rewrite update_elections_data_requestVoteReply_allEntries.
repeat find_rewrite.
match goal with
| [ H : context [ In _ (allEntries _) ] |- _ ] =>
eapply H; eauto; congruence
end.
- repeat find_rewrite.
match goal with
| [ H : context [ In _ (allEntries _) ] |- _ ] =>
eapply H; eauto; congruence
end.
}
* subst.
intro_refined_invariant candidate_entries_invariant.
match goal with
| [ H : candidateEntries_host_invariant _ |- _ ] =>
pose proof H (pDst p) e
end.
unfold raft_data in *.
conclude_using congruence.
{ find_eapply_lem_hyp wonElection_candidateEntries_rvr; eauto.
- intuition.
- eauto using votes_correct_invariant.
- eauto using cronies_correct_invariant.
- unfold raft_refined_base_params, raft_refined_multi_params in *. congruence.
- unfold raft_refined_multi_params, raft_refined_base_params in *.
simpl in *.
unfold raft_data in *.
congruence.
}
+ { update_destruct_simplify_hyp.
- rewrite update_elections_data_requestVoteReply_allEntries.
repeat find_rewrite.
match goal with
| [ H : context [ In _ (allEntries _) ] |- _ ] =>
eapply H; eauto; congruence
end.
- repeat find_rewrite.
match goal with
| [ H : context [ In _ (allEntries _) ] |- _ ] =>
eapply H; eauto; congruence
end.
}
Qed.

Lemma doLeader_sends_AE :
forall st h os st' ms m,
doLeader st h = (os, st', ms) ->
In m ms ->
is_append_entries (snd m).