Section OutputGreatestId.
Context {orig_base_params : BaseParams}.
Context {one_node_params : OneNodeParams orig_base_params}.
Context {raft_params : RaftParams orig_base_params}.
Context {lmi : log_matching_interface}.
Context {si : sorted_interface}.
Context {aemi : applied_entries_monotonic_interface}.
Context {smsi : state_machine_safety_interface}.
Context {misi : max_index_sanity_interface}.
Context {smci : state_machine_correct_interface}.
Context {lacimi : lastApplied_commitIndex_match_interface}.
Proof using.
intros. unfold key_in_output_trace in *.
break_exists_exists.
intuition. do_in_app; intuition.
exfalso. eauto.
Qed.
Proof using.
intros.
unfold key_in_output_list in *.
break_exists; do_in_app; intuition eauto.
Qed.
Proof using.
intuition.
unfold key_in_output_list in *.
break_exists; intuition.
Qed.
Proof using.
intros. unfold doLeader, advanceCommitIndex in *.
repeat break_match; find_inversion; intuition;
find_apply_lem_hyp key_in_output_list_empty; auto.
Qed.
Proof using.
intros. unfold handleInput, handleTimeout, handleClientRequest, tryToBecomeLeader in *.
repeat break_match; find_inversion; intuition eauto using key_in_output_list_empty;
unfold key_in_output_list in *; break_exists; simpl in *; intuition; congruence.
Qed.
Proof using.
intros. unfold has_key. break_match; subst; simpl in *.
break_if; repeat (do_bool; intuition).
Qed.
Proof using.
intros. unfold has_key in *. break_match.
simpl in *. subst.
break_if; repeat (do_bool; intuition); try congruence.
Qed.
Proof using.
induction l; intros; simpl in *; intuition.
- find_inversion. simpl in *. intuition.
- unfold cacheApplyEntry, applyEntry in *.
repeat break_match; repeat find_inversion; simpl in *; intuition; eauto;
try solve
[find_inversion; find_rewrite; find_inversion; do_bool; lia];
try solve [find_inversion; repeat find_rewrite; congruence].
+ do_bool. destruct (clientId_eq_dec (eClient a) client).
* subst. find_rewrite. find_inversion.
eapply IHl; [eapply lt_le_trans; eauto|idtac|idtac|]; eauto.
unfold getLastId.
simpl. eauto using get_set_same.
* eapply IHl; eauto.
unfold getLastId in *.
simpl. rewrite get_set_diff; eauto.
+ do_bool. destruct (clientId_eq_dec (eClient a) client).
* repeat find_rewrite. congruence.
* eapply IHl; eauto.
unfold getLastId in *.
simpl. rewrite get_set_diff; eauto.
+ do_bool. destruct (clientId_eq_dec (eClient a) client).
* repeat find_rewrite. find_inversion.
eapply IHl; [eapply lt_le_trans; eauto|idtac|idtac|]; eauto.
unfold getLastId.
simpl. eauto using get_set_same.
* eapply IHl; eauto.
unfold getLastId in *.
simpl. rewrite get_set_diff; eauto.
+ do_bool. destruct (clientId_eq_dec (eClient a) client).
* repeat find_rewrite. congruence.
* eapply IHl; eauto.
unfold getLastId in *.
simpl. rewrite get_set_diff; eauto.
Qed.
Proof using.
induction l; intros; simpl in *; intuition.
- find_inversion. simpl in *. intuition.
- repeat break_match.
+ subst.
find_inversion. do_in_app. intuition.
* do_in_map. find_inversion. eauto using has_key_own_key.
* { destruct (has_key client id' a) eqn:?; eauto.
exfalso.
unfold cacheApplyEntry, applyEntry in *.
find_apply_lem_hyp has_key_true_necessary. intuition.
repeat break_match; repeat find_rewrite; find_inversion; do_bool; subst_max.
- find_eapply_lem_hyp applyEntries_cache; eauto; lia.
- find_eapply_lem_hyp applyEntries_cache; eauto; lia.
- find_eapply_lem_hyp applyEntries_cache; eauto;
unfold getLastId in *; simpl in *; eauto using get_set_same.
- find_eapply_lem_hyp applyEntries_cache; eauto;
unfold getLastId in *; simpl in *; eauto using get_set_same.
}
+ simpl in *. find_inversion.
{ destruct (has_key client id' a) eqn:?; eauto.
exfalso.
unfold cacheApplyEntry, applyEntry in *.
find_apply_lem_hyp has_key_true_necessary. intuition.
repeat break_match; repeat find_rewrite; find_inversion; do_bool; subst.
- find_eapply_lem_hyp applyEntries_cache; eauto; lia.
- find_eapply_lem_hyp applyEntries_cache; eauto; lia.
- eapply applyEntries_cache in Heqp0; eauto;
unfold getLastId in *; simpl in *; eauto using get_set_same.
- eapply applyEntries_cache in Heqp0; eauto;
unfold getLastId in *; simpl in *; eauto using get_set_same.
}
Qed.

Lemma entries_contiguous :
forall net,
raft_intermediate_reachable net ->
(forall h, contiguous_range_exact_lo (log (nwState net h)) 0).