Module docstring
{"# max and min
This file proves basic properties about maxima and minima on a LinearOrder.
Tags
min, max "}
{"# max and min
This file proves basic properties about maxima and minima on a LinearOrder.
min, max "}
le_min_iff
theorem
: c ≤ min a b ↔ c ≤ a ∧ c ≤ b
theorem le_min_iff : c ≤ min a b ↔ c ≤ a ∧ c ≤ b :=
le_inf_iff
le_max_iff
theorem
: a ≤ max b c ↔ a ≤ b ∨ a ≤ c
theorem le_max_iff : a ≤ max b c ↔ a ≤ b ∨ a ≤ c :=
le_sup_iff
min_le_iff
theorem
: min a b ≤ c ↔ a ≤ c ∨ b ≤ c
theorem min_le_iff : minmin a b ≤ c ↔ a ≤ c ∨ b ≤ c :=
inf_le_iff
max_le_iff
theorem
: max a b ≤ c ↔ a ≤ c ∧ b ≤ c
theorem max_le_iff : maxmax a b ≤ c ↔ a ≤ c ∧ b ≤ c :=
sup_le_iff
lt_min_iff
theorem
: a < min b c ↔ a < b ∧ a < c
theorem lt_min_iff : a < min b c ↔ a < b ∧ a < c :=
lt_inf_iff
lt_max_iff
theorem
: a < max b c ↔ a < b ∨ a < c
theorem lt_max_iff : a < max b c ↔ a < b ∨ a < c :=
lt_sup_iff
min_lt_iff
theorem
: min a b < c ↔ a < c ∨ b < c
theorem min_lt_iff : minmin a b < c ↔ a < c ∨ b < c :=
inf_lt_iff
max_lt_iff
theorem
: max a b < c ↔ a < c ∧ b < c
theorem max_lt_iff : maxmax a b < c ↔ a < c ∧ b < c :=
sup_lt_iff
max_le_max
theorem
: a ≤ c → b ≤ d → max a b ≤ max c d
theorem max_le_max : a ≤ c → b ≤ d → max a b ≤ max c d :=
sup_le_sup
max_le_max_left
theorem
(c) (h : a ≤ b) : max c a ≤ max c b
theorem max_le_max_left (c) (h : a ≤ b) : max c a ≤ max c b := sup_le_sup_left h c
max_le_max_right
theorem
(c) (h : a ≤ b) : max a c ≤ max b c
theorem max_le_max_right (c) (h : a ≤ b) : max a c ≤ max b c := sup_le_sup_right h c
min_le_min
theorem
: a ≤ c → b ≤ d → min a b ≤ min c d
theorem min_le_min : a ≤ c → b ≤ d → min a b ≤ min c d :=
inf_le_inf
min_le_min_left
theorem
(c) (h : a ≤ b) : min c a ≤ min c b
theorem min_le_min_left (c) (h : a ≤ b) : min c a ≤ min c b := inf_le_inf_left c h
min_le_min_right
theorem
(c) (h : a ≤ b) : min a c ≤ min b c
theorem min_le_min_right (c) (h : a ≤ b) : min a c ≤ min b c := inf_le_inf_right c h
le_max_of_le_left
theorem
: a ≤ b → a ≤ max b c
theorem le_max_of_le_left : a ≤ b → a ≤ max b c :=
le_sup_of_le_left
le_max_of_le_right
theorem
: a ≤ c → a ≤ max b c
theorem le_max_of_le_right : a ≤ c → a ≤ max b c :=
le_sup_of_le_right
lt_max_of_lt_left
theorem
(h : a < b) : a < max b c
theorem lt_max_of_lt_left (h : a < b) : a < max b c :=
h.trans_le (le_max_left b c)
lt_max_of_lt_right
theorem
(h : a < c) : a < max b c
theorem lt_max_of_lt_right (h : a < c) : a < max b c :=
h.trans_le (le_max_right b c)
min_le_of_left_le
theorem
: a ≤ c → min a b ≤ c
theorem min_le_of_left_le : a ≤ c → min a b ≤ c :=
inf_le_of_left_le
min_le_of_right_le
theorem
: b ≤ c → min a b ≤ c
theorem min_le_of_right_le : b ≤ c → min a b ≤ c :=
inf_le_of_right_le
min_lt_of_left_lt
theorem
(h : a < c) : min a b < c
theorem min_lt_of_left_lt (h : a < c) : min a b < c :=
(min_le_left a b).trans_lt h
min_lt_of_right_lt
theorem
(h : b < c) : min a b < c
theorem min_lt_of_right_lt (h : b < c) : min a b < c :=
(min_le_right a b).trans_lt h
max_min_distrib_left
theorem
(a b c : α) : max a (min b c) = min (max a b) (max a c)
lemma max_min_distrib_left (a b c : α) : max a (min b c) = min (max a b) (max a c) :=
sup_inf_left _ _ _
max_min_distrib_right
theorem
(a b c : α) : max (min a b) c = min (max a c) (max b c)
lemma max_min_distrib_right (a b c : α) : max (min a b) c = min (max a c) (max b c) :=
sup_inf_right _ _ _
min_max_distrib_left
theorem
(a b c : α) : min a (max b c) = max (min a b) (min a c)
lemma min_max_distrib_left (a b c : α) : min a (max b c) = max (min a b) (min a c) :=
inf_sup_left _ _ _
min_max_distrib_right
theorem
(a b c : α) : min (max a b) c = max (min a c) (min b c)
lemma min_max_distrib_right (a b c : α) : min (max a b) c = max (min a c) (min b c) :=
inf_sup_right _ _ _
min_le_max
theorem
: min a b ≤ max a b
theorem min_le_max : min a b ≤ max a b :=
le_trans (min_le_left a b) (le_max_left a b)
min_eq_left_iff
theorem
: min a b = a ↔ a ≤ b
theorem min_eq_left_iff : minmin a b = a ↔ a ≤ b :=
inf_eq_left
min_eq_right_iff
theorem
: min a b = b ↔ b ≤ a
theorem min_eq_right_iff : minmin a b = b ↔ b ≤ a :=
inf_eq_right
max_eq_left_iff
theorem
: max a b = a ↔ b ≤ a
theorem max_eq_left_iff : maxmax a b = a ↔ b ≤ a :=
sup_eq_left
max_eq_right_iff
theorem
: max a b = b ↔ a ≤ b
theorem max_eq_right_iff : maxmax a b = b ↔ a ≤ b :=
sup_eq_right
min_cases
theorem
(a b : α) : min a b = a ∧ a ≤ b ∨ min a b = b ∧ b < a
/-- For elements `a` and `b` of a linear order, either `min a b = a` and `a ≤ b`,
or `min a b = b` and `b < a`.
Use cases on this lemma to automate linarith in inequalities -/
theorem min_cases (a b : α) : minmin a b = a ∧ a ≤ bmin a b = a ∧ a ≤ b ∨ min a b = b ∧ b < a := by
by_cases h : a ≤ b
· left
exact ⟨min_eq_left h, h⟩
· right
exact ⟨min_eq_right (le_of_lt (not_le.mp h)), not_le.mp h⟩
max_cases
theorem
(a b : α) : max a b = a ∧ b ≤ a ∨ max a b = b ∧ a < b
/-- For elements `a` and `b` of a linear order, either `max a b = a` and `b ≤ a`,
or `max a b = b` and `a < b`.
Use cases on this lemma to automate linarith in inequalities -/
theorem max_cases (a b : α) : maxmax a b = a ∧ b ≤ amax a b = a ∧ b ≤ a ∨ max a b = b ∧ a < b :=
@min_cases αᵒᵈ _ a b
min_eq_iff
theorem
: min a b = c ↔ a = c ∧ a ≤ b ∨ b = c ∧ b ≤ a
theorem min_eq_iff : minmin a b = c ↔ a = c ∧ a ≤ b ∨ b = c ∧ b ≤ a := by
constructor
· intro h
refine Or.imp (fun h' => ?_) (fun h' => ?_) (le_total a b) <;> exact ⟨by simpa [h'] using h, h'⟩
· rintro (⟨rfl, h⟩ | ⟨rfl, h⟩) <;> simp [h]
max_eq_iff
theorem
: max a b = c ↔ a = c ∧ b ≤ a ∨ b = c ∧ a ≤ b
theorem max_eq_iff : maxmax a b = c ↔ a = c ∧ b ≤ a ∨ b = c ∧ a ≤ b :=
@min_eq_iff αᵒᵈ _ a b c
min_lt_min_left_iff
theorem
: min a c < min b c ↔ a < b ∧ a < c
theorem min_lt_min_left_iff : minmin a c < min b c ↔ a < b ∧ a < c := by
simp_rw [lt_min_iff, min_lt_iff, or_iff_left (lt_irrefl _)]
exact and_congr_left fun h => or_iff_left_of_imp h.trans
min_lt_min_right_iff
theorem
: min a b < min a c ↔ b < c ∧ b < a
theorem min_lt_min_right_iff : minmin a b < min a c ↔ b < c ∧ b < a := by
simp_rw [min_comm a, min_lt_min_left_iff]
max_lt_max_left_iff
theorem
: max a c < max b c ↔ a < b ∧ c < b
theorem max_lt_max_left_iff : maxmax a c < max b c ↔ a < b ∧ c < b :=
@min_lt_min_left_iff αᵒᵈ _ _ _ _
max_lt_max_right_iff
theorem
: max a b < max a c ↔ b < c ∧ a < c
theorem max_lt_max_right_iff : maxmax a b < max a c ↔ b < c ∧ a < c :=
@min_lt_min_right_iff αᵒᵈ _ _ _ _
max_idem
instance
: Std.IdempotentOp (α := α) max
/-- An instance asserting that `max a a = a` -/
instance max_idem : Std.IdempotentOp (α := α) max where
idempotent := by simp
min_idem
instance
: Std.IdempotentOp (α := α) min
/-- An instance asserting that `min a a = a` -/
instance min_idem : Std.IdempotentOp (α := α) min where
idempotent := by simp
min_lt_max
theorem
: min a b < max a b ↔ a ≠ b
theorem min_lt_max : minmin a b < max a b ↔ a ≠ b :=
inf_lt_sup
max_lt_max
theorem
(h₁ : a < c) (h₂ : b < d) : max a b < max c d
theorem max_lt_max (h₁ : a < c) (h₂ : b < d) : max a b < max c d :=
max_lt (lt_max_of_lt_left h₁) (lt_max_of_lt_right h₂)
min_lt_min
theorem
(h₁ : a < c) (h₂ : b < d) : min a b < min c d
theorem min_lt_min (h₁ : a < c) (h₂ : b < d) : min a b < min c d :=
@max_lt_max αᵒᵈ _ _ _ _ _ h₁ h₂
min_right_comm
theorem
(a b c : α) : min (min a b) c = min (min a c) b
Max.left_comm
theorem
(a b c : α) : max a (max b c) = max b (max a c)
Max.right_comm
theorem
(a b c : α) : max (max a b) c = max (max a c) b
MonotoneOn.map_max
theorem
(hf : MonotoneOn f s) (ha : a ∈ s) (hb : b ∈ s) : f (max a b) = max (f a) (f b)
theorem MonotoneOn.map_max (hf : MonotoneOn f s) (ha : a ∈ s) (hb : b ∈ s) : f (max a b) =
max (f a) (f b) := by
rcases le_total a b with h | h <;>
simp only [max_eq_right, max_eq_left, hf ha hb, hf hb ha, h]
MonotoneOn.map_min
theorem
(hf : MonotoneOn f s) (ha : a ∈ s) (hb : b ∈ s) : f (min a b) = min (f a) (f b)
theorem MonotoneOn.map_min (hf : MonotoneOn f s) (ha : a ∈ s) (hb : b ∈ s) : f (min a b) =
min (f a) (f b) := hf.dual.map_max ha hb
AntitoneOn.map_max
theorem
(hf : AntitoneOn f s) (ha : a ∈ s) (hb : b ∈ s) : f (max a b) = min (f a) (f b)
theorem AntitoneOn.map_max (hf : AntitoneOn f s) (ha : a ∈ s) (hb : b ∈ s) : f (max a b) =
min (f a) (f b) := hf.dual_right.map_max ha hb
AntitoneOn.map_min
theorem
(hf : AntitoneOn f s) (ha : a ∈ s) (hb : b ∈ s) : f (min a b) = max (f a) (f b)
theorem AntitoneOn.map_min (hf : AntitoneOn f s) (ha : a ∈ s) (hb : b ∈ s) : f (min a b) =
max (f a) (f b) := hf.dual.map_max ha hb
Monotone.map_max
theorem
(hf : Monotone f) : f (max a b) = max (f a) (f b)
theorem Monotone.map_max (hf : Monotone f) : f (max a b) = max (f a) (f b) := by
rcases le_total a b with h | h <;> simp [h, hf h]
Monotone.map_min
theorem
(hf : Monotone f) : f (min a b) = min (f a) (f b)
Antitone.map_max
theorem
(hf : Antitone f) : f (max a b) = min (f a) (f b)
theorem Antitone.map_max (hf : Antitone f) : f (max a b) = min (f a) (f b) := by
rcases le_total a b with h | h <;> simp [h, hf h]
Antitone.map_min
theorem
(hf : Antitone f) : f (min a b) = max (f a) (f b)
min_choice
theorem
(a b : α) : min a b = a ∨ min a b = b
theorem min_choice (a b : α) : minmin a b = a ∨ min a b = b := by cases le_total a b <;> simp [*]
max_choice
theorem
(a b : α) : max a b = a ∨ max a b = b
theorem max_choice (a b : α) : maxmax a b = a ∨ max a b = b :=
@min_choice αᵒᵈ _ a b
le_of_max_le_left
theorem
{a b c : α} (h : max a b ≤ c) : a ≤ c
theorem le_of_max_le_left {a b c : α} (h : max a b ≤ c) : a ≤ c :=
le_trans (le_max_left _ _) h
le_of_max_le_right
theorem
{a b c : α} (h : max a b ≤ c) : b ≤ c
theorem le_of_max_le_right {a b c : α} (h : max a b ≤ c) : b ≤ c :=
le_trans (le_max_right _ _) h
instCommutativeMax
instance
: Std.Commutative (α := α) max
instance instCommutativeMax : Std.Commutative (α := α) max where comm := max_comm
instAssociativeMax
instance
: Std.Associative (α := α) max
instance instAssociativeMax : Std.Associative (α := α) max where assoc := max_assoc
instCommutativeMin
instance
: Std.Commutative (α := α) min
instance instCommutativeMin : Std.Commutative (α := α) min where comm := min_comm
instAssociativeMin
instance
: Std.Associative (α := α) min
instance instAssociativeMin : Std.Associative (α := α) min where assoc := min_assoc
max_left_commutative
theorem
: LeftCommutative (max : α → α → α)
theorem max_left_commutative : LeftCommutative (max : α → α → α) := ⟨max_left_comm⟩
min_left_commutative
theorem
: LeftCommutative (min : α → α → α)
theorem min_left_commutative : LeftCommutative (min : α → α → α) := ⟨min_left_comm⟩