Section EveryEntryWasCreated.
Context {orig_base_params : BaseParams}.
Context {one_node_params : OneNodeParams orig_base_params}.
Context {raft_params : RaftParams orig_base_params}.
Context {rri : raft_refinement_interface}.
Context {lhlli : leaders_have_leaderLogs_interface}.
Hint Constructors in_any_log : core.
(* proof sketch: prove for in_any_log. the only time new entries come into the system is on a leader, and leaders have leaderLogs in their term.  *)
Definition in_any_log_term_was_created net :=
forall e,
in_any_log net e ->
term_was_created net (eTerm e).
Ltac iae_case :=
match goal with
| [ H : in_any_log _ _ |- _ ] => invcs H
end.
Proof using.
intros. unfold term_was_created in *.
break_exists_exists. eauto.
Qed.
Ltac in_aer :=
repeat find_rewrite; eapply in_aer; eauto; repeat find_rewrite; reflexivity.
Proof using.
red. intros. unfold in_any_log_term_was_created. intros.
eapply term_was_created_preserved; [eapply_prop in_any_log_term_was_created|];
[|
intros; simpl in *;
repeat find_higher_order_rewrite;
destruct_update; simpl in *; eauto;
rewrite update_elections_data_appendEntries_leaderLogs; eauto].
iae_case.
- repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_apply_lem_hyp handleAppendEntries_log. intuition; try in_aer.
+ repeat find_rewrite. eauto.
+ repeat find_rewrite. do_in_app. intuition; try in_aer.
eauto using removeAfterIndex_in.
- find_eapply_lem_hyp handleAppendEntries_not_append_entries.
find_apply_hyp_hyp. intuition.
+ match goal with
| _ : In ?p' (_ ++ _) |- _ => eapply @in_aer with (p := p'); eauto
end.
+ subst. simpl in *.
find_false. unfold mEntries in *.
break_match; try congruence. subst.
repeat eexists; eauto.
- repeat find_higher_order_rewrite.
destruct_update; simpl in *; eauto.
find_rewrite_lem update_elections_data_appendEntries_leaderLogs.
eauto.
Qed.

Lemma in_any_log_term_was_created_request_vote :
refined_raft_net_invariant_request_vote in_any_log_term_was_created.