Section AllEntriesIndicesGt0.
Context {orig_base_params : BaseParams}.
Context {one_node_params : OneNodeParams orig_base_params}.
Context {raft_params : RaftParams orig_base_params}.
Context {rri : raft_refinement_interface}.
Context {taifoli : terms_and_indices_from_one_log_interface}.
Proof using.
unfold refined_raft_net_invariant_init, allEntries_indices_gt_0.
simpl. intuition.
Qed.
Proof using.
unfold refined_raft_net_invariant_client_request, allEntries_indices_gt_0.
intros. simpl in *.
repeat find_higher_order_rewrite.
update_destruct_max_simplify; eauto.
find_apply_lem_hyp update_elections_data_client_request_allEntries.
intuition.
- find_rewrite. eauto.
- break_exists. break_and. find_rewrite. simpl in *.
intuition eauto.
subst. lia.
Qed.
Proof using.
unfold refined_raft_net_invariant_timeout, allEntries_indices_gt_0.
intros. simpl in *.
repeat find_higher_order_rewrite.
update_destruct_max_simplify; eauto.
find_rewrite_lem update_elections_data_timeout_allEntries.
eauto.
Qed.
Proof using.
unfold deghost.
simpl. intuition.
apply in_map_iff.
eexists; eauto.
Qed.
Proof using taifoli rri.
intros.
pose proof (lift_prop _ terms_and_indices_from_one_log_nw_invariant).
match goal with
| [ H : _ |- _ ] => eapply H; eauto using ghost_packet
end.
Qed.
Proof using taifoli rri.
unfold refined_raft_net_invariant_append_entries, allEntries_indices_gt_0.
intros. simpl in *.
repeat find_higher_order_rewrite.
update_destruct_max_simplify; eauto.
find_apply_lem_hyp update_elections_data_appendEntries_allEntries.
intuition eauto.
eapply lifted_taifol_nw; eauto.
Qed.
Proof using.
unfold refined_raft_net_invariant_append_entries_reply, allEntries_indices_gt_0.
intros. simpl in *.
repeat find_higher_order_rewrite.
update_destruct_max_simplify; eauto.
Qed.
Proof using.
unfold refined_raft_net_invariant_request_vote, allEntries_indices_gt_0.
intros. simpl in *.
repeat find_higher_order_rewrite.
update_destruct_max_simplify; eauto.
find_rewrite_lem update_elections_data_requestVote_allEntries.
eauto.
Qed.
Proof using.
unfold refined_raft_net_invariant_request_vote_reply, allEntries_indices_gt_0.
intros. simpl in *.
repeat find_higher_order_rewrite.
update_destruct_max_simplify; eauto.
find_rewrite_lem update_elections_data_requestVoteReply_allEntries.
eauto.
Qed.
Proof using.
unfold refined_raft_net_invariant_do_leader, allEntries_indices_gt_0.
intros. simpl in *.
repeat find_higher_order_rewrite.
update_destruct_max_simplify; eauto.
match goal with
| [ H : nwState ?net ?h = (?x, _) |- _ ] =>
replace (x) with (fst (nwState net h)) in * by (rewrite H; auto)
end.
eauto.
Qed.
Proof using.
unfold refined_raft_net_invariant_do_generic_server, allEntries_indices_gt_0.
intros. simpl in *.
repeat find_higher_order_rewrite.
update_destruct_max_simplify; eauto.
match goal with
| [ H : nwState ?net ?h = (?x, _) |- _ ] =>
replace (x) with (fst (nwState net h)) in * by (rewrite H; auto)
end.
eauto.
Qed.
Proof using.
unfold refined_raft_net_invariant_state_same_packet_subset, allEntries_indices_gt_0.
intros.
repeat find_reverse_higher_order_rewrite.
eauto.
Qed.
Proof using.
unfold refined_raft_net_invariant_reboot, allEntries_indices_gt_0.
intros.
repeat find_higher_order_rewrite.
update_destruct_max_simplify; eauto.
match goal with
| [ H : nwState ?net ?h = (?x, _) |- _ ] =>
replace (x) with (fst (nwState net h)) in * by (rewrite H; auto)
end.
eauto.
Qed.

Lemma allEntries_indices_gt_0_invariant :
forall net,
refined_raft_intermediate_reachable net ->
allEntries_indices_gt_0 net.