Proof using lsi si.
unfold raft_net_invariant_client_request.
intros.
unfold handleClientRequest in *.
break_match; try solve [do_state_same_packet_subset].
find_inversion.
unfold log_matching in *. intuition.
- unfold log_matching_hosts. simpl in *.
intuition; repeat find_higher_order_rewrite; repeat rewrite if_sum_bool_fun_comm; simpl in *.
+ repeat break_if.
* auto using entries_match_refl.
* subst. find_copy_apply_lem_hyp leader_sublog_invariant_invariant.
find_copy_apply_lem_hyp logs_sorted_invariant.
auto using
entries_match_sym,
leader_sublog_weaken_host,
logs_sorted_weaken_host,
handleClientRequest_log_matching_hosts_entries_match.
* subst.
find_copy_apply_lem_hyp leader_sublog_invariant_invariant.
find_copy_apply_lem_hyp logs_sorted_invariant.
auto using
entries_match_sym,
leader_sublog_weaken_host,
logs_sorted_weaken_host,
handleClientRequest_log_matching_hosts_entries_match.
* unfold log_matching_hosts in *. intuition.
+ break_if; subst; simpl in *.
* find_apply_lem_hyp le_lt_eq_dec.
intuition; [|eexists; intuition eauto]; simpl; auto.
unfold log_matching_hosts in *. intuition.
assert (i <= maxIndex (log (nwState net h))) by omega.
cut (exists e : entry,
eIndex e = i /\ In e (log (nwState net h)));
[intros; break_exists; eexists; intuition eauto|].
eauto.
* unfold log_matching_hosts in *. intuition.
+ unfold log_matching_hosts in *.
break_if; simpl in *; try do_in_app; simpl in *;
intuition eauto; subst; simpl; auto with *.
- unfold log_matching_nw.
intuition; simpl in *; repeat find_higher_order_rewrite;
repeat rewrite if_sum_bool_fun_comm in *; simpl in *.
+ break_if; subst.
* { intuition.
- subst. simpl in *. find_copy_apply_lem_hyp leader_sublog_invariant_invariant.
find_copy_apply_lem_hyp logs_sorted_invariant.
unfold leader_sublog_invariant, leader_sublog_nw_invariant, logs_sorted in *.
intuition.
contradict_leader_sublog.
unfold log_matching_nw in *.
use_leader_sublog.
find_apply_hyp_hyp. intuition.
- right. unfold log_matching_nw in *. intuition.
find_apply_hyp_hyp. intuition.
use_nw_invariant.
use_log_matching_nw_host. intuition.
}
* unfold log_matching_nw in *.
find_apply_hyp_hyp. intuition.
use_nw_invariant.
use_log_matching_nw_host. intuition.
+ break_if; subst.
* { intuition.
- subst. simpl in *. find_copy_apply_lem_hyp leader_sublog_invariant_invariant.
find_copy_apply_lem_hyp logs_sorted_invariant.
unfold leader_sublog_invariant, leader_sublog_nw_invariant, logs_sorted in *.
intuition.
contradict_leader_sublog.
unfold log_matching_nw in *.
use_leader_sublog.
find_apply_hyp_hyp. intuition.
- simpl.
unfold log_matching_nw in *. intuition.
find_apply_hyp_hyp. intuition.
use_nw_invariant.
use_log_matching_nw_host. intuition.
break_exists; eexists; intuition eauto.
}
* unfold log_matching_nw in *.
find_apply_hyp_hyp. intuition.
use_nw_invariant.
use_log_matching_nw_host. intuition.
+ unfold log_matching_nw in *.
find_apply_hyp_hyp. intuition.
use_nw_invariant.
+ unfold log_matching_nw in *.
find_apply_hyp_hyp. intuition.
use_nw_invariant.
+ unfold log_matching_nw in *.
do 2 (find_apply_hyp_hyp; intuition). subst.
use_log_matching_nw_nw.
+ unfold log_matching_nw in *.
do 2 (find_apply_hyp_hyp; intuition). subst.
use_log_matching_nw_nw.
+ unfold log_matching_nw in *.
do 2 (find_apply_hyp_hyp; intuition). subst.
use_log_matching_nw_nw.
Qed.

(* Specifications: *)
Lemma tryToBecomeLeader_spec :
forall h d out d' l,
tryToBecomeLeader h d = (out, d', l) ->
log d' = log d /\
(forall m, In m l -> ~ is_append_entries (snd m)).