Proof using.
unfold raft_net_invariant_do_generic_server.
intros. subst.
unfold doGenericServer in *.
break_let.
repeat find_inversion;
eapply log_matching_state_same_packet_subset; eauto; intros;
use_applyEntries_spec; subst;
simpl in *.
- find_higher_order_rewrite. rewrite if_sum_bool_fun_comm.
simpl. break_if; subst; auto.
- find_apply_hyp_hyp. intuition.
Qed.
Ltac use_entries_match :=
match goal with
| [ _ : eIndex ?e1 = eIndex ?e2,
H : context [entries_match]
|- _ ] =>
first [ solve [eapply H with (e:=e2)(e':=e1); eauto; congruence] |
solve [eapply H with (e:=e1)(e':=e2); eauto; congruence]]
end.
Ltac contradict_maxIndex :=
match goal with
| [ _ : S (maxIndex ?l) <= eIndex ?e,
He : In ?e ?l |- _ ] =>
exfalso; apply maxIndex_is_max in He; intuition; omega
end.

Lemma handleClientRequest_log_matching_hosts_entries_match :
forall h h' net client id c,
h' <> h ->
log_matching_hosts net ->
leader_sublog_host_invariant net ->
logs_sorted_host net ->
type (nwState net h) = Leader ->
entries_match
((mkEntry h client id (S (maxIndex (log (nwState net h)))) (currentTerm (nwState net h)) c)
:: (log (nwState net h)))
(log (nwState net h')).