Proof using.
unfold refined_raft_net_invariant_do_generic_server, match_index_all_entries_inv.
simpl. intros. break_and. split.
- unfold match_index_all_entries in *.
simpl in *. intros.
repeat find_higher_order_rewrite.
match goal with
| [ H : nwState ?net ?h = (?x, ?y) |- _ ] =>
replace x with (fst (nwState net h)) in * by (rewrite H; auto);
replace y with (snd (nwState net h)) in * by (rewrite H; auto);
clear H
end.
rewrite update_nop_fst.
update_destruct_simplify_hyp.
+ repeat find_reverse_rewrite.
find_copy_apply_lem_hyp doGenericServer_type. intuition.
find_copy_apply_lem_hyp doGenericServer_matchIndex_preserved.
unfold matchIndex_preserved in *. intuition.
match goal with
| [ H : context [ In _ (allEntries _) ] |- _ ] =>
eapply H; eauto; try congruence
end.
+ repeat find_reverse_rewrite.
match goal with
| [ H : context [ In _ (allEntries _) ] |- _ ] =>
eapply H; eauto; try congruence
end.
- unfold match_index_all_entries_nw in *.
simpl in *.
intros.
find_apply_hyp_hyp.
break_or_hyp.
+ repeat find_higher_order_rewrite.
match goal with
| [ H : nwState ?net ?h = (?x, ?y) |- _ ] =>
replace x with (fst (nwState net h)) in * by (rewrite H; auto);
replace y with (snd (nwState net h)) in * by (rewrite H; auto);
clear H
end.
rewrite update_nop_fst in *.
find_copy_apply_lem_hyp doGenericServer_type. intuition.
update_destruct_simplify_hyp.
* find_copy_apply_lem_hyp doGenericServer_matchIndex_preserved.
unfold matchIndex_preserved in *. intuition.
match goal with
| [ H : context [ In _ (allEntries _) ] |- _ ] =>
eapply H; eauto; try congruence
end.
* match goal with
| [ H : context [ In _ (allEntries _) ] |- _ ] =>
eapply H; eauto; try congruence
end.
+ do_in_map.
find_apply_lem_hyp doGenericServer_packets.
subst. simpl in *. intuition.
Qed.

(* Specifications: *)
Lemma match_index_all_entries_state_same_packet_subset :
refined_raft_net_invariant_state_same_packet_subset match_index_all_entries_inv.