Documentation

CslibFrontier.Foundations.Data.List.ArgMin

The first minimizer of a nonempty list #

Mathlib's List.argmin f l is none exactly on the empty list. Algorithms that select a cheapest candidate usually need the positive form, and often read the choice off with a default through Option.getD. This file provides those forms.

Main results #

theorem List.exists_argmin_eq_some {α : Type u_1} {β : Type u_2} [LinearOrder β] {f : α → β} {l : List α} (hl : l ≠ []) :
∃ (m : α), argmin f l = some m

A nonempty list has a first minimizer.

theorem List.getD_argmin_mem {α : Type u_1} {β : Type u_2} [LinearOrder β] {f : α → β} {l : List α} (hl : l ≠ []) (d : α) :
(argmin f l).getD d ∈ l

On a nonempty list, the first minimizer read with any default is a member of the list.

theorem List.getD_argmin_le {α : Type u_1} {β : Type u_2} [LinearOrder β] {f : α → β} {l : List α} {x : α} (hx : x ∈ l) (d : α) :
f ((argmin f l).getD d) ≤ f x

The first minimizer read with any default is at most every member of the list.

theorem List.argmin_map_equiv {α : Type u_3} {γ : Type u_4} {δ : Type u_5} [LinearOrder δ] (e : α → γ) (l : List α) (f : γ → δ) :
Option.map e (argmin (f ∘ e) l) = argmin f (map e l)
theorem List.argmin_congr_mem {α : Type u_3} {δ : Type u_4} [LinearOrder δ] (all l : List α) {f g : α → δ} (hl : ∀ x ∈ l, x ∈ all) (hfg : ∀ x ∈ all, f x = g x) :
argmin f l = argmin g l
theorem List.isSome_argmin_filter {α : Type u_3} {δ : Type u_4} [LinearOrder δ] (l : List α) (p : α → Bool) (f : α → δ) :
(argmin f (filter p l)).isSome = l.any p