Proof using.
intros.
unfold entries_match. intros. split; intros.
- in_crush_start.
+ match goal with
| [ H : _ |- _ ] => solve [eapply H; eauto]
end.
+ exfalso.
find_apply_lem_hyp removeAfterIndex_In_le; intuition.
find_apply_hyp_hyp. omega.
+ find_apply_lem_hyp findAtIndex_elim.
intuition subst.
match goal with
| [ H : forall _ _, _, H' : eIndex ?e1 = eIndex ?e2 |- _ ] =>
specialize (H e1 e2); do 4 concludes
end.
intuition. break_exists.
intuition.
find_copy_apply_lem_hyp removeAfterIndex_In_le; intuition.
find_apply_lem_hyp removeAfterIndex_in.
use_entries_match.
+ repeat find_apply_lem_hyp removeAfterIndex_in. use_entries_match.
- in_crush_start.
+ match goal with
| [ H : forall _ _, _, H' : eIndex ?e1 = eIndex ?e2 |- _ ] =>
specialize (H e1 e2); do 4 concludes
end.
intuition. break_exists. intuition.
destruct (le_lt_dec (eIndex e'') pli).
* apply in_or_app. right.
apply removeAfterIndex_le_In; auto.
find_apply_lem_hyp findAtIndex_elim. intuition.
subst. use_entries_match.
* apply in_or_app. left.
match goal with
| H : forall _, _ < _ <= _ -> _ |- In ?e _ =>
specialize (H (eIndex e))
end.
intuition.
conclude_using ltac:(eapply le_trans; eauto; apply maxIndex_is_max; eauto).
break_exists. intuition.
match goal with
| _: eIndex ?e1 = eIndex ?e2 |- context [ ?e2 ] =>
eapply rachet with (x' := e1); eauto using sorted_uniqueIndices with *
end.
+ apply in_or_app. right.
find_copy_apply_lem_hyp removeAfterIndex_In_le; eauto.
apply removeAfterIndex_le_In; [omega|].
find_apply_lem_hyp removeAfterIndex_in.
use_entries_match.
Qed.

(* Specifications: *)
Lemma doLeader_appliedEntries :
forall sigma h os st' ms,
doLeader (sigma h) h = (os, st', ms) ->
applied_entries (update name_eq_dec sigma h st') = applied_entries sigma.