Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 5bf92e1

Browse files
committed
chore(analysis/calculus/local_extr): review (#6085)
* golf 2 proofs; * don't use explicit section `variables`; * add 2 docstrings.
1 parent 45f9544 commit 5bf92e1

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

src/analysis/calculus/local_extr.lean

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,13 @@ lemma mem_pos_tangent_cone_at_of_segment_subset {s : set E} {x y : E} (h : segme
8585
y - x ∈ pos_tangent_cone_at s x :=
8686
begin
8787
let c := λn:ℕ, (2:ℝ)^n,
88-
let d := λn:ℕ, (c n)⁻¹ • (y-x),
88+
let d := λn:ℕ, (c n)⁻¹ • (y - x),
8989
refine ⟨c, d, filter.univ_mem_sets' (λn, h _), _, _⟩,
9090
show x + d n ∈ segment x y,
91-
{ rw segment_eq_image,
92-
refine ⟨(c n)⁻¹, ⟨_, _⟩, _⟩,
91+
{ rw segment_eq_image',
92+
refine ⟨(c n)⁻¹, ⟨_, _⟩, rfl⟩,
9393
{ rw inv_nonneg, apply pow_nonneg, norm_num },
94-
{ apply inv_le_one, apply one_le_pow_of_one_le, norm_num },
95-
{ simp only [d, sub_smul, smul_sub, one_smul], abel } },
94+
{ apply inv_le_one, apply one_le_pow_of_one_le, norm_num } },
9695
show tendsto c at_top at_top,
9796
{ exact tendsto_pow_at_top_at_top_of_one_lt one_lt_two },
9897
show filter.tendsto (λ (n : ℕ), c n • d n) filter.at_top (𝓝 (y - x)),
@@ -105,13 +104,12 @@ begin
105104
apply tendsto_const_nhds }
106105
end
107106

107+
lemma mem_pos_tangent_cone_at_of_segment_subset' {s : set E} {x y : E} (h : segment x (x + y) ⊆ s) :
108+
y ∈ pos_tangent_cone_at s x :=
109+
by simpa only [add_sub_cancel'] using mem_pos_tangent_cone_at_of_segment_subset h
110+
108111
lemma pos_tangent_cone_at_univ : pos_tangent_cone_at univ a = univ :=
109-
eq_univ_iff_forall.2
110-
begin
111-
assume x,
112-
rw [← add_sub_cancel x a],
113-
exact mem_pos_tangent_cone_at_of_segment_subset (subset_univ _)
114-
end
112+
eq_univ_of_forall $ λ x, mem_pos_tangent_cone_at_of_segment_subset' (subset_univ _)
115113

116114
/-- If `f` has a local max on `s` at `a`, `f'` is the derivative of `f` at `a` within `s`, and
117115
`y` belongs to the positive tangent cone of `s` at `a`, then `f' y ≤ 0`. -/
@@ -268,13 +266,12 @@ end real
268266

269267
section Rolle
270268

271-
variables (f f' : ℝ → ℝ) {a b : ℝ} (hab : a < b) (hfc : continuous_on f (Icc a b)) (hfI : f a = f b)
272-
273-
include hab hfc hfI
269+
variables (f f' : ℝ → ℝ) {a b : ℝ}
274270

275271
/-- A continuous function on a closed interval with `f a = f b` takes either its maximum
276272
or its minimum value at a point in the interior of the interval. -/
277-
lemma exists_Ioo_extr_on_Icc : ∃ c ∈ Ioo a b, is_extr_on f (Icc a b) c :=
273+
lemma exists_Ioo_extr_on_Icc (hab : a < b) (hfc : continuous_on f (Icc a b)) (hfI : f a = f b) :
274+
∃ c ∈ Ioo a b, is_extr_on f (Icc a b) c :=
278275
begin
279276
have ne : (Icc a b).nonempty, from nonempty_Icc.2 (le_of_lt hab),
280277
-- Consider absolute min and max points
@@ -300,26 +297,30 @@ end
300297

301298
/-- A continuous function on a closed interval with `f a = f b` has a local extremum at some
302299
point of the corresponding open interval. -/
303-
lemma exists_local_extr_Ioo : ∃ c ∈ Ioo a b, is_local_extr f c :=
300+
lemma exists_local_extr_Ioo (hab : a < b) (hfc : continuous_on f (Icc a b)) (hfI : f a = f b) :
301+
∃ c ∈ Ioo a b, is_local_extr f c :=
304302
let ⟨c, cmem, hc⟩ := exists_Ioo_extr_on_Icc f hab hfc hfI
305-
in ⟨c, cmem, hc.is_local_extr $ mem_nhds_sets_iff.2 ⟨Ioo a b, Ioo_subset_Icc_self, is_open_Ioo, cmem
303+
in ⟨c, cmem, hc.is_local_extr $ Icc_mem_nhds cmem.1 cmem.2
306304

307305
/-- Rolle's Theorem `has_deriv_at` version -/
308-
lemma exists_has_deriv_at_eq_zero (hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) :
306+
lemma exists_has_deriv_at_eq_zero (hab : a < b) (hfc : continuous_on f (Icc a b)) (hfI : f a = f b)
307+
(hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) :
309308
∃ c ∈ Ioo a b, f' c = 0 :=
310309
let ⟨c, cmem, hc⟩ := exists_local_extr_Ioo f hab hfc hfI in
311310
⟨c, cmem, hc.has_deriv_at_eq_zero $ hff' c cmem⟩
312311

313312
/-- Rolle's Theorem `deriv` version -/
314-
lemma exists_deriv_eq_zero : ∃ c ∈ Ioo a b, deriv f c = 0 :=
313+
lemma exists_deriv_eq_zero (hab : a < b) (hfc : continuous_on f (Icc a b)) (hfI : f a = f b) :
314+
∃ c ∈ Ioo a b, deriv f c = 0 :=
315315
let ⟨c, cmem, hc⟩ := exists_local_extr_Ioo f hab hfc hfI in
316316
⟨c, cmem, hc.deriv_eq_zero⟩
317317

318-
omit hfc hfI
319-
320-
variables {f f'}
318+
variables {f f'} {l : ℝ}
321319

322-
lemma exists_has_deriv_at_eq_zero' {l : ℝ}
320+
/-- Rolle's Theorem, a version for a function on an open interval: if `f` has derivative `f'`
321+
on `(a, b)` and has the same limit `l` at `𝓝[Ioi a] a` and `𝓝[Iio b] b`, then `f' c = 0`
322+
for some `c ∈ (a, b)`. -/
323+
lemma exists_has_deriv_at_eq_zero' (hab : a < b)
323324
(hfa : tendsto f (𝓝[Ioi a] a) (𝓝 l)) (hfb : tendsto f (𝓝[Iio b] b) (𝓝 l))
324325
(hff' : ∀ x ∈ Ioo a b, has_deriv_at f (f' x) x) :
325326
∃ c ∈ Ioo a b, f' c = 0 :=
@@ -336,7 +337,11 @@ begin
336337
exact ⟨Ioo a b, Ioo_mem_nhds hc.1 hc.2, extend_from_extends this
337338
end
338339

339-
lemma exists_deriv_eq_zero' {l : ℝ}
340+
/-- Rolle's Theorem, a version for a function on an open interval: if `f` has the same limit `l` at
341+
`𝓝[Ioi a] a` and `𝓝[Iio b] b`, then `deriv f c = 0` for some `c ∈ (a, b)`. This version does not
342+
require differentiability of `f` because we define `deriv f c = 0` whenever `f` is not
343+
differentiable at `c`. -/
344+
lemma exists_deriv_eq_zero' (hab : a < b)
340345
(hfa : tendsto f (𝓝[Ioi a] a) (𝓝 l)) (hfb : tendsto f (𝓝[Iio b] b) (𝓝 l)) :
341346
∃ c ∈ Ioo a b, deriv f c = 0 :=
342347
classical.by_cases

0 commit comments

Comments
 (0)