Proof using.
intros.
unfold update_elections_data_client_request.
repeat break_match; repeat find_inversion; auto.
simpl.
find_copy_apply_lem_hyp handleClientRequest_log.
intuition.
- repeat find_rewrite. do_bool. omega.
- right.  break_exists_exists. intuition.
congruence.
Qed.

(* Specifications: *)
Lemma update_elections_data_client_request_allEntries_ind :
forall {h st client id c out st' ps},
handleClientRequest h (snd st) client id c = (out, st', ps) ->
forall (P : list (term * entry) -> Prop),
P (allEntries (fst st)) ->
(forall e,
eIndex e = S (maxIndex (log (snd st))) ->
eTerm e = currentTerm (snd st) ->
eClient e = client -> eInput e = c -> eId e = id -> type (snd st) = Leader ->
P ((currentTerm st', e) :: allEntries (fst st))) ->
P (allEntries (update_elections_data_client_request h st client id c)).
Lemma update_elections_data_client_request_log_allEntries :
forall h st client id c out st' ms,
handleClientRequest h (snd st) client id c = (out, st', ms) ->
(allEntries (update_elections_data_client_request h st client id c) =
allEntries (fst st) /\
log st' = log (snd st)) \/
(type (snd st) = Leader /\
exists e : entry,
eIndex e = S (maxIndex (log (snd st))) /\
eTerm e = currentTerm (snd st) /\
eClient e = client /\ eInput e = c /\ eId e = id /\ type (snd st) = Leader /\
allEntries (update_elections_data_client_request h st client id c) =
(currentTerm st', e) :: allEntries (fst st) /\
log st' = e :: log (snd st)).