Section inner.
Variable client : clientId.
Variable id : nat.
Variable client' : clientId.
Variable id' : nat.
Proof using.
intros. find_eapply_lem_hyp before_func_app_necessary; eauto.
intuition.
break_exists. unfold in_input_trace in *.
break_exists. do_in_app. intuition;
[find_apply_hyp_hyp; simpl in *; break_if; repeat (do_bool; intuition)|].
invcs H0; intuition.
- break_if; congruence.
- find_inversion; try congruence.
repeat (do_bool; intuition).
break_if; try congruence.
- find_inversion.
Qed.
Proof using.
intros. unfold output_before_input in *.
induction tr; simpl in *; intuition.
- unfold key_in_output_trace.
unfold is_output_with_key in *. repeat break_match; try congruence.
subst. do 2 eexists. intuition; eauto.
- unfold key_in_output_trace in *.
break_exists_exists. simpl; intuition.
Qed.
Proof using.
intros. unfold in_applied_entries, entries_ordered in *.
induction (applied_entries (nwState net)); simpl in *; break_exists; intuition.
- subst. left. unfold has_key. break_match.
simpl. break_if; repeat (do_bool; intuition).
- right. intuition.
+ apply Bool.not_true_iff_false. intuition.
find_false.
unfold has_key in *. break_match; simpl in *; break_if; repeat (do_bool; intuition); try congruence.
subst. eexists; intuition; eauto.
+ eapply IHl.
* eexists; intuition; eauto.
* intuition. find_false. break_exists_exists. intuition.
Qed.

Lemma in_applied_entries_applied_implies_input_state :
forall net,
in_applied_entries client' id' net ->
exists e,
eClient e = client' /\
eId e = id' /\
applied_implies_input_state client' id' (eInput e) net.