Section section_for_maxs.
#[local] Notation In := List.In.
Definition maxs : list nat -> nat := fold_right max 0.
Proof with (lia || eauto).
unfold maxs. revert n H_IN. induction ns as [ | n' ns IH]; simpl...
intros n [H_eq | H_in]... enough (ENOUGH: fold_right max 0 ns >= n)...
Qed.
Proof with (lia || eauto).
unfold maxs. revert ns2.
induction ns1 as [ | n1 ns1 IH]; simpl...
intros n; rewrite IH...
Qed.
Proof with try now (lia || firstorder; eauto).
unfold maxs. induction ns as [ | n1 ns1 IH]; simpl... intros n phi_n.
destruct (le_gt_dec n n1) as [H_le | H_gt]... enough (claim1 : fold_right max 0 ns1 >= n)...
destruct (phi_dec n) as [H_yes | H_no]... destruct (phi_in n H_yes)...
enough (claim2 : forall ks : list nat, forall k : nat, In k ks -> fold_right max 0 ks >= k)...
induction ks; simpl... intros k [H_eq | H_in]... enough (claim3: fold_right Init.Nat.max 0 ks >= k)...
Qed.

Lemma maxs_lt_iff (ns : list nat)
: forall z, maxs ns > z <-> exists i, In i ns /\ i > z.