Section CommonTheorems.
Context {orig_base_params : BaseParams}.
Context {one_node_params : OneNodeParams orig_base_params}.
Context {raft_params : RaftParams orig_base_params}.
Proof using.
unfold uniqueIndices.
eauto using NoDup_map_elim.
Qed.
Proof using.
intros.
simpl in *. intuition;
find_apply_hyp_hyp; intuition.
Qed.
Proof using.
induction ys; intros; simpl in *.
- break_match; intuition.
- break_match; intuition.
subst. apply sorted_cons; eauto.
intros. eauto using subseq_In.
Qed.
Proof using.
induction l; intros.
- simpl in *. intuition.
- simpl in *. intuition.
+ subst. auto with *.
+ find_apply_hyp_hyp. lia.
Qed.
Proof using.
induction l; intros.
- simpl in *. intuition.
- simpl in *. intuition.
+ subst. auto with *.
+ find_apply_hyp_hyp. lia.
Qed.
Proof using.
intros. intro.
find_apply_lem_hyp maxIndex_is_max; auto.
subst. lia.
Qed.
Proof using.
destruct l; intros; simpl in *; eauto; congruence.
Qed.
Proof using.
induction l; intros; simpl; auto.
repeat break_match; intuition.
- find_inversion. eauto using subseq_refl.
- right. find_reverse_rewrite. auto.
Qed.
Proof using.
intros. eauto using removeAfterIndex_subseq, sorted_subseq.
Qed.
Proof using.
eauto using removeAfterIndex_subseq, subseq_In.
Qed.
Proof using.
induction l; intros; intro.
- intuition.
- simpl in *. break_match; try discriminate. intuition.
+ subst. rewrite <- beq_nat_refl in *. discriminate.
+ find_copy_apply_hyp_hyp. intuition. break_if; do_bool; eauto. lia.
Qed.
Proof using.
induction l; intros.
- discriminate.
- simpl in *. break_match.
+ find_inversion. auto.
+ break_if; eauto; discriminate.
Qed.
Proof using.
induction l; intros.
- discriminate.
- simpl in *. break_match.
+ find_inversion. apply beq_nat_true in Heqb. auto.
+ break_if; eauto; discriminate.
Qed.
Proof using.
eauto using subseq_NoDup, removeAfterIndex_subseq.
Qed.
Notation disjoint xs ys := (forall x, In x xs -> In x ys -> False).
Proof using.
induction xs; intros.
- intuition.
- simpl in *. break_if; simpl in *; intuition.
subst. do_bool. lia.
Qed.
Proof using.
induction xs; intros.
- simpl in *. intuition.
- simpl in *.
break_if; simpl in *; do_bool; intuition; subst; auto.
find_apply_hyp_hyp. lia.
Qed.
Proof using.
induction xs; intros.
- simpl in *. intuition.
- simpl in *.
break_match; simpl in *; intuition;
subst; do_bool;
match goal with
| e : entry, H : forall _, _ = _ \/ _ -> _ |- _ =>
specialize (H e)
end;
intuition.
+ eauto using removeAfterIndex_le_In.
+ find_apply_hyp_hyp. intuition.
match goal with
| _ : eIndex ?e <= ?li, _ : eIndex ?e > eIndex ?e' |- _ =>
assert (eIndex e' <= li) by lia
end.
eauto using removeAfterIndex_le_In.
Qed.

Lemma removeAfterIndex_le :
forall xs i j,
i <= j ->
removeAfterIndex xs i = removeAfterIndex (removeAfterIndex xs j) i.