Documentation

CslibFrontier.Foundations.Data.List.FoldMax

Bounds for list maximum folds #

Main results #

theorem List.le_foldl_max_self {α : Type u_1} [LinearOrder α] (l : List α) (a : α) :
a ≤ foldl max a l

Folding max across l never decreases the initial accumulator a.

theorem List.mem_le_foldl_max {α : Type u_1} [LinearOrder α] {l : List α} {a x : α} (hx : x ∈ l) :
x ≤ foldl max a l

Every element of l is bounded above by l.foldl max a.

theorem List.foldl_max_le {α : Type u_1} [LinearOrder α] {l : List α} {a b : α} (ha : a ≤ b) (hl : ∀ x ∈ l, x ≤ b) :
foldl max a l ≤ b

l.foldl max a ≤ b whenever a ≤ b and every element of l is at most b.

theorem List.foldr_map_max_le_iff {α : Type u_1} {l : List α} {b : ℕ} (f : α → ℕ) :
foldr max 0 (map f l) ≤ b ↔ ∀ x ∈ l, f x ≤ b

The maximum of the natural numbers obtained by mapping f over l, with value zero on the empty list, is at most b exactly when f is at most b on every element of l.