Proof using.
intros.
unfold handleAppendEntries in *.
repeat (break_match; repeat (find_inversion; simpl in *)); auto using advanceCurrentTerm_same_lastApplied.
Qed.
Definition term_of (m : msg) :=
match m with
| RequestVote t _ _ _ => Some t
| RequestVoteReply t _ => Some t
| AppendEntries t _ _ _ _ _ => Some t
| AppendEntriesReply t _ _ => Some t
end.

(* Specifications: *)
Lemma wonElection_length :
forall l1 l2,
wonElection l1 = true ->
length l1 <= length l2 ->
wonElection l2 = true.