@@ -9,7 +9,7 @@ public import Mathlib.Topology.Order.OrderClosed
99public import Mathlib.Topology.Order.LocalExtr
1010
1111/-!
12- # Local maxima from monotonicity and antitonicity
12+ # Extrema from monotonicity and antitonicity
1313
1414In this file we prove a lemma that is useful for the First Derivative Test in calculus,
1515and its dual.
@@ -21,16 +21,77 @@ and its dual.
2121
2222* `isLocalMin_of_anti_mono` : the dual statement for minima.
2323
24- * `isLocalMax_of_mono_anti'` : a version of `isLocalMax_of_mono_anti` for filters.
25-
26- * `isLocalMin_of_anti_mono'` : a version of `isLocalMax_of_mono_anti'` for minima.
27-
2824 -/
2925
3026public section
3127
3228open Set Topology Filter
3329
30+ variable {α β : Type *} [Preorder β] {s : Set α} {a b c : α} {f : α → β}
31+
32+ section PartialOrder
33+
34+ variable [PartialOrder α]
35+
36+ /-- If `b ≤ c`, and `f` is antitone on `[b,c)`, then the maximum of
37+ `f` on `[b, c)` is attained at `b`. -/
38+ lemma isMaxOn_of_anti_Ico (g₁ : b ≤ c) (h₁ : AntitoneOn f (Ico b c)) :
39+ IsMaxOn f (Ico b c) b := by
40+ rcases g₁.lt_or_eq with (hp | hq) <;> intro
41+ · aesop
42+ · simp [show Ico b c = ∅ by rw [Ico_eq_empty_iff]; grind]
43+
44+ /-- If `b ≤ c`, and `f` is monotone on `[b,c)`, then the minimum of
45+ `f` on `[b, c)` is attained at `b`. -/
46+ lemma isMinOn_of_mono_Ico (g₁ : b ≤ c) (h₁ : MonotoneOn f (Ico b c)) :
47+ IsMinOn f (Ico b c) b :=
48+ isMaxOn_of_anti_Ico (β := βᵒᵈ) g₁ h₁
49+
50+ /-- If `b ≤ c`, and `f` is antitone on `[b,c]`, then the maximum of
51+ `f` on `[b, c]` is attained at `b`. -/
52+ lemma isMaxOn_of_anti_Icc (g₁ : b ≤ c) (h₁ : AntitoneOn f (Icc b c)) :
53+ IsMaxOn f (Icc b c) b := by
54+ rcases g₁.lt_or_eq with (hp | hq) <;> intro
55+ · aesop
56+ · simp_all
57+
58+ /-- If `b ≤ c`, and `f` is monotone on `[b,c]`, then the minimum of
59+ `f` on `[b, c]` is attained at `b`. -/
60+ lemma isMinOn_of_mono_Icc (g₁ : b ≤ c) (h₁ : MonotoneOn f (Icc b c)) :
61+ IsMinOn f (Icc b c) b :=
62+ isMaxOn_of_anti_Icc (β := βᵒᵈ) g₁ h₁
63+
64+ end PartialOrder
65+
66+ variable [LinearOrder α]
67+
68+ /-- If `a` is an element of a set `s`, and `f` is monotone on `s ∩ (-∞, a]` and antitone on
69+ `s ∩ [a, ∞)`, then the maximum of `f` on `s` is attained at `a`. -/
70+ lemma isMaxOn_of_mono_anti (ha : a ∈ s) (h₀ : MonotoneOn f (s ∩ Set.Iic a))
71+ (h₁ : AntitoneOn f (s ∩ Set.Ici a)) : IsMaxOn f s a :=
72+ fun x _ => by rcases le_total x a <;> aesop
73+
74+ /-- If `a < b < c`, and `f` is monotone on `(a, b]` and antitone on `[b,c)`, then the maximum of
75+ `f` on `(a, c)` is attained at `b`. -/
76+ lemma isMaxOn_of_mono_anti_Ioo (g₀ : a < b) (g₁ : b < c)
77+ (h₀ : MonotoneOn f (Ioc a b))
78+ (h₁ : AntitoneOn f (Ico b c)) : IsMaxOn f (Ioo a c) b :=
79+ fun x _ => by rcases le_total x b <;> aesop
80+
81+ /-- If `a ≤ b < c`, and `f` is monotone on `[a, b]` and antitone on `[b,c)`, then the maximum of
82+ `f` on `[a, c)` is attained at `b`. -/
83+ lemma isMaxOn_of_mono_anti_Ico (g₀ : a ≤ b) (g₁ : b < c)
84+ (h₀ : MonotoneOn f (Icc a b))
85+ (h₁ : AntitoneOn f (Ico b c)) : IsMaxOn f (Ico a c) b :=
86+ fun x _ => by rcases le_total x b <;> aesop
87+
88+ lemma isMinOn_of_anti_mono
89+ {α β : Type *} [LinearOrder α] [Preorder β]
90+ {s : Set α} {a : α} (ha : a ∈ s) {f : α → β}
91+ (h₀ : AntitoneOn f (s ∩ Set.Iic a))
92+ (h₁ : MonotoneOn f (s ∩ Set.Ici a)) : IsMinOn f s a :=
93+ isMaxOn_of_mono_anti (β := βᵒᵈ) ha h₀ h₁
94+
3495/-- If `f` is monotone on `(a,b]` and antitone on `[b,c)` then `f` has
3596a local maximum at `b`. -/
3697lemma isLocalMax_of_mono_anti
0 commit comments