Skip to content

Commit 5b5db12

Browse files
committed
feat(Analysis/Calculus/DerivativeTest): add continuousOn_*, isMaxOn_of_deriv_*, isMinOn_of_deriv_*
1 parent 392e177 commit 5b5db12

1 file changed

Lines changed: 225 additions & 0 deletions

File tree

Mathlib/Analysis/Calculus/DerivativeTest.lean

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ private lemma continuousOn_Icc {f : ℝ → ℝ} {a b : ℝ} (g₀ : a ≤ b)
7070
(hd₀ : DifferentiableOn ℝ f (Ioo a b)) : ContinuousOn f (Icc a b) :=
7171
Ioo_union_both g₀ ▸ hd₀.continuousOn.union_continuousAt isOpen_Ioo (by simp_all)
7272

73+
/-- If `f` is continuous at `b` and differentiable on `(-∞, b)`, then `f` is continuous on
74+
`(-∞, b]`. -/
75+
private lemma continuousOn_Iic {f : ℝ → ℝ} {b : ℝ} (h : ContinuousAt f b)
76+
(hd₀ : DifferentiableOn ℝ f (Iio b)) : ContinuousOn f (Iic b) := by
77+
simp_rw [← Iio_union_right]
78+
apply hd₀.continuousOn.union_continuousAt isOpen_Iio (by simp [h])
79+
80+
/-- If `f` is continuous at `a` and differentiable on `(a, ∞)`, then `f` is continuous on
81+
`[a, ∞)`. -/
82+
private lemma continuousOn_Ici {f : ℝ → ℝ} {a : ℝ} (h : ContinuousAt f a)
83+
(hd₀ : DifferentiableOn ℝ f (Ioi a)) : ContinuousOn f (Ici a) := by
84+
rw [← Ioi_union_left]
85+
exact hd₀.continuousOn.union_continuousAt isOpen_Ioi (by simp [h])
86+
7387
/-- Suppose `a < b < c`, `f : ℝ → ℝ` is continuous at `b`, the derivative `f'` is nonnegative on
7488
`(a, b)`, and the derivative `f'` is nonpositive on `(b, c)`. Then `f` attains its maximum on
7589
`(a, c)` at `b`. -/
@@ -115,6 +129,142 @@ lemma isMaxOn_of_deriv_Ico {f : ℝ → ℝ} {a b c : ℝ} (g₀ : a ≤ b) (g
115129
(antitoneOn_of_deriv_nonpos (convex_Ico b c) (continuousOn_Ico g₁ hb hd₁) (by simp_all)
116130
(by simp_all))
117131

132+
/-- Suppose `a ≤ b ≤ c`, `f : ℝ → ℝ` is continuous at `a`, `b`, and `c`, the derivative `f'` is
133+
nonnegative on `(a, b)`, and the derivative `f'` is nonpositive on `(b, c)`. Then `f` attains its
134+
maximum on `[a, c]` at `b`. -/
135+
lemma isMaxOn_of_deriv_Icc {f : ℝ → ℝ} {a b c : ℝ} (g₀ : a ≤ b) (g₁ : b ≤ c)
136+
(ha : ContinuousAt f a) (hb : ContinuousAt f b) (hc : ContinuousAt f c)
137+
(hd₀ : DifferentiableOn ℝ f (Ioo a b)) (hd₁ : DifferentiableOn ℝ f (Ioo b c))
138+
(h₀ : ∀ x ∈ Ioo a b, 0 ≤ deriv f x)
139+
(h₁ : ∀ x ∈ Ioo b c, deriv f x ≤ 0) : IsMaxOn f (Icc a c) b :=
140+
isMaxOn_of_mono_anti_Icc g₀ g₁
141+
(monotoneOn_of_deriv_nonneg (convex_Icc a b) (continuousOn_Icc g₀ ha hb hd₀) (by simp_all)
142+
(by simp_all))
143+
(antitoneOn_of_deriv_nonpos (convex_Icc b c) (continuousOn_Icc g₁ hb hc hd₁) (by simp_all)
144+
(by simp_all))
145+
146+
/-- Suppose `a < b`, `f : ℝ → ℝ` is continuous at `b`, the derivative `f'` is nonnegative on
147+
`(a, b)`, and the derivative `f'` is nonpositive on `(b, ∞)`. Then `f` attains its maximum on
148+
`(a, ∞)` at `b`. -/
149+
lemma isMaxOn_of_deriv_Ioi {f : ℝ → ℝ} {a b : ℝ} (g₀ : a < b)
150+
(hb : ContinuousAt f b)
151+
(hd₀ : DifferentiableOn ℝ f (Ioo a b))
152+
(hd₁ : DifferentiableOn ℝ f (Ioi b))
153+
(h₀ : ∀ x ∈ Ioo a b, 0 ≤ deriv f x)
154+
(h₁ : ∀ x ∈ Ioi b, deriv f x ≤ 0) : IsMaxOn f (Ioi a) b :=
155+
isMaxOn_of_mono_anti_Ioi g₀
156+
(monotoneOn_of_deriv_nonneg (convex_Ioc a b) (continuousOn_Ioc g₀ hb hd₀) (by simp_all)
157+
(by simp_all))
158+
(antitoneOn_of_deriv_nonpos (convex_Ici b) (continuousOn_Ici hb hd₁) (by simp_all)
159+
(by simp_all))
160+
161+
/-- Suppose `a ≤ b`, `f : ℝ → ℝ` is continuous at `a` and `b`, the derivative `f'` is nonnegative
162+
on `(a, b)`, and the derivative `f'` is nonpositive on `(b, ∞)`. Then `f` attains its maximum on
163+
`[a, ∞)` at `b`. -/
164+
lemma isMaxOn_of_deriv_Ici {f : ℝ → ℝ} {a b : ℝ} (g₀ : a ≤ b)
165+
(ha : ContinuousAt f a) (hb : ContinuousAt f b)
166+
(hd₀ : DifferentiableOn ℝ f (Ioo a b))
167+
(hd₁ : DifferentiableOn ℝ f (Ioi b))
168+
(h₀ : ∀ x ∈ Ioo a b, 0 ≤ deriv f x)
169+
(h₁ : ∀ x ∈ Ioi b, deriv f x ≤ 0) : IsMaxOn f (Ici a) b :=
170+
isMaxOn_of_mono_anti_Ici g₀
171+
(monotoneOn_of_deriv_nonneg (convex_Icc a b) (continuousOn_Icc g₀ ha hb hd₀) (by simp_all)
172+
(by simp_all))
173+
(antitoneOn_of_deriv_nonpos (convex_Ici b) (continuousOn_Ici hb hd₁) (by simp_all)
174+
(by simp_all))
175+
176+
/-- Suppose `b < c`, `f : ℝ → ℝ` is continuous at `b`, the derivative `f'` is nonnegative on
177+
`(-∞, b)`, and the derivative `f'` is nonpositive on `(b, c)`. Then `f` attains its maximum on
178+
`(-∞, c)` at `b`. -/
179+
lemma isMaxOn_of_deriv_Iio {f : ℝ → ℝ} {b c : ℝ} (g₁ : b < c)
180+
(hb : ContinuousAt f b)
181+
(hd₀ : DifferentiableOn ℝ f (Iio b))
182+
(hd₁ : DifferentiableOn ℝ f (Ioo b c))
183+
(h₀ : ∀ x ∈ Iio b, 0 ≤ deriv f x)
184+
(h₁ : ∀ x ∈ Ioo b c, deriv f x ≤ 0) : IsMaxOn f (Iio c) b :=
185+
isMaxOn_of_mono_anti_Iio g₁
186+
(monotoneOn_of_deriv_nonneg (convex_Iic b) (continuousOn_Iic hb hd₀) (by simp_all)
187+
(by simp_all))
188+
(antitoneOn_of_deriv_nonpos (convex_Ico b c) (continuousOn_Ico g₁ hb hd₁) (by simp_all)
189+
(by simp_all))
190+
191+
/-- Suppose `b ≤ c`, `f : ℝ → ℝ` is continuous at `b` and `c`, the derivative `f'` is nonnegative
192+
on `(-∞, b)`, and the derivative `f'` is nonpositive on `(b, c)`. Then `f` attains its maximum on
193+
`(-∞, c]` at `b`. -/
194+
lemma isMaxOn_of_deriv_Iic {f : ℝ → ℝ} {b c : ℝ} (g₁ : b ≤ c)
195+
(hb : ContinuousAt f b) (hc : ContinuousAt f c)
196+
(hd₀ : DifferentiableOn ℝ f (Iio b))
197+
(hd₁ : DifferentiableOn ℝ f (Ioo b c))
198+
(h₀ : ∀ x ∈ Iio b, 0 ≤ deriv f x)
199+
(h₁ : ∀ x ∈ Ioo b c, deriv f x ≤ 0) : IsMaxOn f (Iic c) b :=
200+
isMaxOn_of_mono_anti_Iic g₁
201+
(monotoneOn_of_deriv_nonneg (convex_Iic b) (continuousOn_Iic hb hd₀) (by simp_all)
202+
(by simp_all))
203+
(antitoneOn_of_deriv_nonpos (convex_Icc b c) (continuousOn_Icc g₁ hb hc hd₁) (by simp_all)
204+
(by simp_all))
205+
206+
/-- Suppose `f : ℝ → ℝ` is continuous at `b`, the derivative `f'` is nonnegative on `(-∞, b)`,
207+
and the derivative `f'` is nonpositive on `(b, ∞)`. Then `f` attains its maximum on `ℝ`
208+
at `b`. -/
209+
lemma isMaxOn_of_deriv_univ {f : ℝ → ℝ} {b : ℝ}
210+
(hb : ContinuousAt f b)
211+
(hd₀ : DifferentiableOn ℝ f (Iio b))
212+
(hd₁ : DifferentiableOn ℝ f (Ioi b))
213+
(h₀ : ∀ x ∈ Iio b, 0 ≤ deriv f x)
214+
(h₁ : ∀ x ∈ Ioi b, deriv f x ≤ 0) : IsMaxOn f univ b :=
215+
isMaxOn_of_mono_anti_univ
216+
(monotoneOn_of_deriv_nonneg (convex_Iic b) (continuousOn_Iic hb hd₀) (by simp_all)
217+
(by simp_all))
218+
(antitoneOn_of_deriv_nonpos (convex_Ici b) (continuousOn_Ici hb hd₁) (by simp_all)
219+
(by simp_all))
220+
221+
-- After isMinOn_of_deriv_Ici, before isLocalMin_of_deriv_Ioo
222+
223+
/-- Suppose `b < c`, `f : ℝ → ℝ` is continuous at `b`, the derivative `f'` is nonpositive on
224+
`(-∞, b)`, and the derivative `f'` is nonnegative on `(b, c)`. Then `f` attains its minimum on
225+
`(-∞, c)` at `b`. -/
226+
lemma isMinOn_of_deriv_Iio {f : ℝ → ℝ} {b c : ℝ} (g₁ : b < c)
227+
(hb : ContinuousAt f b)
228+
(hd₀ : DifferentiableOn ℝ f (Iio b))
229+
(hd₁ : DifferentiableOn ℝ f (Ioo b c))
230+
(h₀ : ∀ x ∈ Iio b, deriv f x ≤ 0)
231+
(h₁ : ∀ x ∈ Ioo b c, 0 ≤ deriv f x) : IsMinOn f (Iio c) b :=
232+
isMinOn_of_anti_mono_Iio g₁
233+
(antitoneOn_of_deriv_nonpos (convex_Iic b) (continuousOn_Iic hb hd₀) (by simp_all)
234+
(by simp_all))
235+
(monotoneOn_of_deriv_nonneg (convex_Ico b c) (continuousOn_Ico g₁ hb hd₁) (by simp_all)
236+
(by simp_all))
237+
238+
/-- Suppose `b ≤ c`, `f : ℝ → ℝ` is continuous at `b` and `c`, the derivative `f'` is nonpositive
239+
on `(-∞, b)`, and the derivative `f'` is nonnegative on `(b, c)`. Then `f` attains its minimum on
240+
`(-∞, c]` at `b`. -/
241+
lemma isMinOn_of_deriv_Iic {f : ℝ → ℝ} {b c : ℝ} (g₁ : b ≤ c)
242+
(hb : ContinuousAt f b) (hc : ContinuousAt f c)
243+
(hd₀ : DifferentiableOn ℝ f (Iio b))
244+
(hd₁ : DifferentiableOn ℝ f (Ioo b c))
245+
(h₀ : ∀ x ∈ Iio b, deriv f x ≤ 0)
246+
(h₁ : ∀ x ∈ Ioo b c, 0 ≤ deriv f x) : IsMinOn f (Iic c) b :=
247+
isMinOn_of_anti_mono_Iic g₁
248+
(antitoneOn_of_deriv_nonpos (convex_Iic b) (continuousOn_Iic hb hd₀) (by simp_all)
249+
(by simp_all))
250+
(monotoneOn_of_deriv_nonneg (convex_Icc b c) (continuousOn_Icc g₁ hb hc hd₁) (by simp_all)
251+
(by simp_all))
252+
253+
/-- Suppose `f : ℝ → ℝ` is continuous at `b`, the derivative `f'` is nonpositive on `(-∞, b)`,
254+
and the derivative `f'` is nonnegative on `(b, ∞)`. Then `f` attains its minimum on `ℝ`
255+
at `b`. -/
256+
lemma isMinOn_of_deriv_univ {f : ℝ → ℝ} {b : ℝ}
257+
(hb : ContinuousAt f b)
258+
(hd₀ : DifferentiableOn ℝ f (Iio b))
259+
(hd₁ : DifferentiableOn ℝ f (Ioi b))
260+
(h₀ : ∀ x ∈ Iio b, deriv f x ≤ 0)
261+
(h₁ : ∀ x ∈ Ioi b, 0 ≤ deriv f x) : IsMinOn f univ b :=
262+
isMinOn_of_anti_mono_univ
263+
(antitoneOn_of_deriv_nonpos (convex_Iic b) (continuousOn_Iic hb hd₀) (by simp_all)
264+
(by simp_all))
265+
(monotoneOn_of_deriv_nonneg (convex_Ici b) (continuousOn_Ici hb hd₁) (by simp_all)
266+
(by simp_all))
267+
118268
/-- The First-Derivative Test from calculus, maxima version.
119269
Suppose `a < b < c`, `f : ℝ → ℝ` is continuous at `b`,
120270
the derivative `f'` is nonnegative on `(a,b)`, and
@@ -144,6 +294,81 @@ lemma isMinOn_of_deriv_Ioo {f : ℝ → ℝ} {a b c : ℝ} (g₀ : a < b) (g₁
144294
(antitoneOn_of_deriv_nonpos (convex_Ioc a b) hIoc (by simp_all) (by simp_all))
145295
(monotoneOn_of_deriv_nonneg (convex_Ico b c) hIco (by simp_all) (by simp_all))
146296

297+
/-- Suppose `a < b ≤ c`, `f : ℝ → ℝ` is continuous at `b` and `c`, the derivative `f'` is
298+
nonpositive on `(a, b)`, and the derivative `f'` is nonnegative on `(b, c)`. Then `f` attains its
299+
minimum on `(a, c]` at `b`. -/
300+
lemma isMinOn_of_deriv_Ioc {f : ℝ → ℝ} {a b c : ℝ} (g₀ : a < b) (g₁ : b ≤ c)
301+
(hb : ContinuousAt f b) (hc : ContinuousAt f c)
302+
(hd₀ : DifferentiableOn ℝ f (Ioo a b))
303+
(hd₁ : DifferentiableOn ℝ f (Ioo b c))
304+
(h₀ : ∀ x ∈ Ioo a b, deriv f x ≤ 0)
305+
(h₁ : ∀ x ∈ Ioo b c, 0 ≤ deriv f x) : IsMinOn f (Ioc a c) b :=
306+
isMinOn_of_anti_mono_Ioc g₀ g₁
307+
(antitoneOn_of_deriv_nonpos (convex_Ioc a b) (continuousOn_Ioc g₀ hb hd₀) (by simp_all)
308+
(by simp_all))
309+
(monotoneOn_of_deriv_nonneg (convex_Icc b c) (continuousOn_Icc g₁ hb hc hd₁) (by simp_all)
310+
(by simp_all))
311+
312+
/-- Suppose `a ≤ b < c`, `f : ℝ → ℝ` is continuous at `a` and `b`, the derivative `f'` is
313+
nonpositive on `(a, b)`, and the derivative `f'` is nonnegative on `(b, c)`. Then `f` attains its
314+
minimum on `[a, c)` at `b`. -/
315+
lemma isMinOn_of_deriv_Ico {f : ℝ → ℝ} {a b c : ℝ} (g₀ : a ≤ b) (g₁ : b < c)
316+
(ha : ContinuousAt f a) (hb : ContinuousAt f b)
317+
(hd₀ : DifferentiableOn ℝ f (Ioo a b))
318+
(hd₁ : DifferentiableOn ℝ f (Ioo b c))
319+
(h₀ : ∀ x ∈ Ioo a b, deriv f x ≤ 0)
320+
(h₁ : ∀ x ∈ Ioo b c, 0 ≤ deriv f x) : IsMinOn f (Ico a c) b :=
321+
isMinOn_of_anti_mono_Ico g₀ g₁
322+
(antitoneOn_of_deriv_nonpos (convex_Icc a b) (continuousOn_Icc g₀ ha hb hd₀) (by simp_all)
323+
(by simp_all))
324+
(monotoneOn_of_deriv_nonneg (convex_Ico b c) (continuousOn_Ico g₁ hb hd₁) (by simp_all)
325+
(by simp_all))
326+
327+
/-- Suppose `a ≤ b ≤ c`, `f : ℝ → ℝ` is continuous at `a`, `b`, and `c`, the derivative `f'` is
328+
nonpositive on `(a, b)`, and the derivative `f'` is nonnegative on `(b, c)`. Then `f` attains its
329+
minimum on `[a, c]` at `b`. -/
330+
lemma isMinOn_of_deriv_Icc {f : ℝ → ℝ} {a b c : ℝ} (g₀ : a ≤ b) (g₁ : b ≤ c)
331+
(ha : ContinuousAt f a) (hb : ContinuousAt f b) (hc : ContinuousAt f c)
332+
(hd₀ : DifferentiableOn ℝ f (Ioo a b))
333+
(hd₁ : DifferentiableOn ℝ f (Ioo b c))
334+
(h₀ : ∀ x ∈ Ioo a b, deriv f x ≤ 0)
335+
(h₁ : ∀ x ∈ Ioo b c, 0 ≤ deriv f x) : IsMinOn f (Icc a c) b :=
336+
isMinOn_of_anti_mono_Icc g₀ g₁
337+
(antitoneOn_of_deriv_nonpos (convex_Icc a b) (continuousOn_Icc g₀ ha hb hd₀) (by simp_all)
338+
(by simp_all))
339+
(monotoneOn_of_deriv_nonneg (convex_Icc b c) (continuousOn_Icc g₁ hb hc hd₁) (by simp_all)
340+
(by simp_all))
341+
342+
/-- Suppose `a < b`, `f : ℝ → ℝ` is continuous at `b`, the derivative `f'` is nonpositive on
343+
`(a, b)`, and the derivative `f'` is nonnegative on `(b, ∞)`. Then `f` attains its minimum on
344+
`(a, ∞)` at `b`. -/
345+
lemma isMinOn_of_deriv_Ioi {f : ℝ → ℝ} {a b : ℝ} (g₀ : a < b)
346+
(hb : ContinuousAt f b)
347+
(hd₀ : DifferentiableOn ℝ f (Ioo a b))
348+
(hd₁ : DifferentiableOn ℝ f (Ioi b))
349+
(h₀ : ∀ x ∈ Ioo a b, deriv f x ≤ 0)
350+
(h₁ : ∀ x ∈ Ioi b, 0 ≤ deriv f x) : IsMinOn f (Ioi a) b :=
351+
isMinOn_of_anti_mono_Ioi g₀
352+
(antitoneOn_of_deriv_nonpos (convex_Ioc a b) (continuousOn_Ioc g₀ hb hd₀) (by simp_all)
353+
(by simp_all))
354+
(monotoneOn_of_deriv_nonneg (convex_Ici b) (continuousOn_Ici hb hd₁) (by simp_all)
355+
(by simp_all))
356+
357+
/-- Suppose `a ≤ b`, `f : ℝ → ℝ` is continuous at `a` and `b`, the derivative `f'` is nonpositive
358+
on `(a, b)`, and the derivative `f'` is nonnegative on `(b, ∞)`. Then `f` attains its minimum on
359+
`[a, ∞)` at `b`. -/
360+
lemma isMinOn_of_deriv_Ici {f : ℝ → ℝ} {a b : ℝ} (g₀ : a ≤ b)
361+
(ha : ContinuousAt f a) (hb : ContinuousAt f b)
362+
(hd₀ : DifferentiableOn ℝ f (Ioo a b))
363+
(hd₁ : DifferentiableOn ℝ f (Ioi b))
364+
(h₀ : ∀ x ∈ Ioo a b, deriv f x ≤ 0)
365+
(h₁ : ∀ x ∈ Ioi b, 0 ≤ deriv f x) : IsMinOn f (Ici a) b :=
366+
isMinOn_of_anti_mono_Ici g₀
367+
(antitoneOn_of_deriv_nonpos (convex_Icc a b) (continuousOn_Icc g₀ ha hb hd₀) (by simp_all)
368+
(by simp_all))
369+
(monotoneOn_of_deriv_nonneg (convex_Ici b) (continuousOn_Ici hb hd₁) (by simp_all)
370+
(by simp_all))
371+
147372
/-- The First-Derivative Test from calculus, minima version. -/
148373
lemma isLocalMin_of_deriv_Ioo {f : ℝ → ℝ} {a b c : ℝ}
149374
(g₀ : a < b) (g₁ : b < c) (h : ContinuousAt f b)

0 commit comments

Comments
 (0)