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

Commit acf2038

Browse files
urkudsgouezelmergify[bot]
committed
feat(analysis/calculus/mean_value): more corollaries of the MVT (#1819)
* feat(analysis/calculus/mean_value): more corolaries of the MVT * Fix compile, add "strict inequalities" versions of some theorems, add docs * Update src/analysis/calculus/mean_value.lean * Add theorems for `convex_on univ` * Fix comments * @sgouezel adds missing articles Thanks a lot! We don't have them in Russian, so it's hard for me to put them right. Co-Authored-By: sgouezel <sebastien.gouezel@univ-rennes1.fr> * Update src/analysis/calculus/mean_value.lean Co-Authored-By: sgouezel <sebastien.gouezel@univ-rennes1.fr> * Add more `univ` versions Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 64770a8 commit acf2038

File tree

2 files changed

+292
-11
lines changed

2 files changed

+292
-11
lines changed

src/analysis/calculus/mean_value.lean

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ In this file we prove the following facts:
2222
Cauchy's Mean Value Theorem.
2323
2424
* `exists_has_deriv_at_eq_slope` and `exists_deriv_eq_slope` : Lagrange's Mean Value Theorem.
25+
26+
* `convex.image_sub_lt_mul_sub_of_deriv_lt`, `convex.mul_sub_lt_image_sub_of_lt_deriv`,
27+
`convex.image_sub_le_mul_sub_of_deriv_le`, `convex.mul_sub_le_image_sub_of_le_deriv`,
28+
if `∀ x, C (</≤/>/≥) (f' x)`, then `C * (y - x) (</≤/>/≥) (f y - f x)` whenever `x < y`.
29+
30+
* `convex.mono_of_deriv_nonneg`, `convex.antimono_of_deriv_nonpos`,
31+
`convex.strict_mono_of_deriv_pos`, `convex.strict_antimono_of_deriv_neg` :
32+
if the derivative of a function is non-negative/non-positive/positive/negative, then
33+
the function is monotone/monotonically decreasing/strictly monotone/strictly monotonically
34+
decreasing.
35+
36+
* `convex_on_of_deriv_mono`, `convex_on_of_deriv2_nonneg` : if the derivative of a function
37+
is increasing or its second derivative is nonnegative, then the original function is convex.
2538
-/
2639

2740
set_option class.instance_max_depth 120
@@ -162,6 +175,12 @@ have bound : ∀ x ∈ s, ∥fderiv_within ℝ f s x∥ ≤ 0,
162175
by simpa only [(dist_eq_norm _ _).symm, zero_mul, dist_le_zero, eq_comm]
163176
using hs.norm_image_sub_le_of_norm_deriv_le hf bound hx hy
164177

178+
theorem is_const_of_fderiv_eq_zero {f : E → F} (hf : differentiable ℝ f)
179+
(hf' : ∀ x, fderiv ℝ f x = 0) (x y : E) :
180+
f x = f y :=
181+
convex_univ.is_const_of_fderiv_within_eq_zero hf.differentiable_on
182+
(λ x _, by rw fderiv_within_univ; exact hf' x) trivial trivial
183+
165184
/-! ### Functions `[a, b] → ℝ`. -/
166185

167186
section interval
@@ -221,3 +240,229 @@ exists_has_deriv_at_eq_slope f (deriv f) hab hfc
221240
(λ x hx, ((hfd x hx).differentiable_at $ mem_nhds_sets is_open_Ioo hx).has_deriv_at)
222241

223242
end interval
243+
244+
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
245+
of the real line. If `f` is differentiable on the interior of `D` and `C < f'`, then
246+
`f` grows faster than `C * x` on `D`, i.e., `C * (y - x) < f y - f x` whenever `x, y ∈ D`,
247+
`x < y`. -/
248+
theorem convex.mul_sub_lt_image_sub_of_lt_deriv {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
249+
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
250+
{C} (hf'_gt : ∀ x ∈ interior D, C < deriv f x) :
251+
∀ x y ∈ D, x < y → C * (y - x) < f y - f x :=
252+
begin
253+
assume x y hx hy hxy,
254+
have hxyD : Icc x y ⊆ D, from convex_real_iff.1 hD hx hy,
255+
have hxyD' : Ioo x y ⊆ interior D,
256+
from subset_sUnion_of_mem ⟨is_open_Ioo, subset.trans Ioo_subset_Icc_self hxyD⟩,
257+
obtain ⟨a, a_mem, ha⟩ : ∃ a ∈ Ioo x y, deriv f a = (f y - f x) / (y - x),
258+
from exists_deriv_eq_slope f hxy (hf.mono hxyD) (hf'.mono hxyD'),
259+
have : C < (f y - f x) / (y - x), by { rw [← ha], exact hf'_gt _ (hxyD' a_mem) },
260+
exact (lt_div_iff (sub_pos.2 hxy)).1 this
261+
end
262+
263+
/-- Let `f : ℝ → ℝ` be a differentiable function. If `C < f'`, then `f` grows faster than
264+
`C * x`, i.e., `C * (y - x) < f y - f x` whenever `x < y`. -/
265+
theorem mul_sub_lt_image_sub_of_lt_deriv {f : ℝ → ℝ} (hf : differentiable ℝ f)
266+
{C} (hf'_gt : ∀ x, C < deriv f x) ⦃x y⦄ (hxy : x < y) :
267+
C * (y - x) < f y - f x :=
268+
convex_univ.mul_sub_lt_image_sub_of_lt_deriv hf.continuous.continuous_on hf.differentiable_on
269+
(λ x _, hf'_gt x) x y trivial trivial hxy
270+
271+
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
272+
of the real line. If `f` is differentiable on the interior of `D` and `C ≤ f'`, then
273+
`f` grows at least as fast as `C * x` on `D`, i.e., `C * (y - x) ≤ f y - f x` whenever `x, y ∈ D`,
274+
`x ≤ y`. -/
275+
theorem convex.mul_sub_le_image_sub_of_le_deriv {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
276+
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
277+
{C} (hf'_ge : ∀ x ∈ interior D, C ≤ deriv f x) :
278+
∀ x y ∈ D, x ≤ y → C * (y - x) ≤ f y - f x :=
279+
begin
280+
assume x y hx hy hxy,
281+
cases eq_or_lt_of_le hxy with hxy' hxy', by rw [hxy', sub_self, sub_self, mul_zero],
282+
have hxyD : Icc x y ⊆ D, from convex_real_iff.1 hD hx hy,
283+
have hxyD' : Ioo x y ⊆ interior D,
284+
from subset_sUnion_of_mem ⟨is_open_Ioo, subset.trans Ioo_subset_Icc_self hxyD⟩,
285+
obtain ⟨a, a_mem, ha⟩ : ∃ a ∈ Ioo x y, deriv f a = (f y - f x) / (y - x),
286+
from exists_deriv_eq_slope f hxy' (hf.mono hxyD) (hf'.mono hxyD'),
287+
have : C ≤ (f y - f x) / (y - x), by { rw [← ha], exact hf'_ge _ (hxyD' a_mem) },
288+
exact (le_div_iff (sub_pos.2 hxy')).1 this
289+
end
290+
291+
/-- Let `f : ℝ → ℝ` be a differentiable function. If `C ≤ f'`, then `f` grows at least as fast
292+
as `C * x`, i.e., `C * (y - x) ≤ f y - f x` whenever `x ≤ y`. -/
293+
theorem mul_sub_le_image_sub_of_le_deriv {f : ℝ → ℝ} (hf : differentiable ℝ f)
294+
{C} (hf'_ge : ∀ x, C ≤ deriv f x) ⦃x y⦄ (hxy : x ≤ y) :
295+
C * (y - x) ≤ f y - f x :=
296+
convex_univ.mul_sub_le_image_sub_of_le_deriv hf.continuous.continuous_on hf.differentiable_on
297+
(λ x _, hf'_ge x) x y trivial trivial hxy
298+
299+
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
300+
of the real line. If `f` is differentiable on the interior of `D` and `f' < C`, then
301+
`f` grows slower than `C * x` on `D`, i.e., `f y - f x < C * (y - x)` whenever `x, y ∈ D`,
302+
`x < y`. -/
303+
theorem convex.image_sub_lt_mul_sub_of_deriv_lt {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
304+
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
305+
{C} (lt_hf' : ∀ x ∈ interior D, deriv f x < C) :
306+
∀ x y ∈ D, x < y → f y - f x < C * (y - x) :=
307+
begin
308+
assume x y hx hy hxy,
309+
have hf'_gt : ∀ x ∈ interior D, -C < deriv (λ y, -f y) x,
310+
{ assume x hx,
311+
rw [deriv_neg, neg_lt_neg_iff],
312+
exact lt_hf' x hx },
313+
simpa [-neg_lt_neg_iff]
314+
using neg_lt_neg (hD.mul_sub_lt_image_sub_of_lt_deriv hf.neg hf'.neg hf'_gt x y hx hy hxy)
315+
end
316+
317+
/-- Let `f : ℝ → ℝ` be a differentiable function. If `f' < C`, then `f` grows slower than
318+
`C * x` on `D`, i.e., `f y - f x < C * (y - x)` whenever `x < y`. -/
319+
theorem image_sub_lt_mul_sub_of_deriv_lt {f : ℝ → ℝ} (hf : differentiable ℝ f)
320+
{C} (lt_hf' : ∀ x, deriv f x < C) ⦃x y⦄ (hxy : x < y) :
321+
f y - f x < C * (y - x) :=
322+
convex_univ.image_sub_lt_mul_sub_of_deriv_lt hf.continuous.continuous_on hf.differentiable_on
323+
(λ x _, lt_hf' x) x y trivial trivial hxy
324+
325+
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
326+
of the real line. If `f` is differentiable on the interior of `D` and `f' ≤ C`, then
327+
`f` grows at most as fast as `C * x` on `D`, i.e., `f y - f x ≤ C * (y - x)` whenever `x, y ∈ D`,
328+
`x ≤ y`. -/
329+
theorem convex.image_sub_le_mul_sub_of_deriv_le {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
330+
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
331+
{C} (le_hf' : ∀ x ∈ interior D, deriv f x ≤ C) :
332+
∀ x y ∈ D, x ≤ y → f y - f x ≤ C * (y - x) :=
333+
begin
334+
assume x y hx hy hxy,
335+
have hf'_ge : ∀ x ∈ interior D, -C ≤ deriv (λ y, -f y) x,
336+
{ assume x hx,
337+
rw [deriv_neg, neg_le_neg_iff],
338+
exact le_hf' x hx },
339+
simpa [-neg_le_neg_iff]
340+
using neg_le_neg (hD.mul_sub_le_image_sub_of_le_deriv hf.neg hf'.neg hf'_ge x y hx hy hxy)
341+
end
342+
343+
/-- Let `f : ℝ → ℝ` be a differentiable function. If `f' ≤ C`, then `f` grows at most as fast
344+
as `C * x`, i.e., `f y - f x ≤ C * (y - x)` whenever `x ≤ y`. -/
345+
theorem image_sub_le_mul_sub_of_deriv_le {f : ℝ → ℝ} (hf : differentiable ℝ f)
346+
{C} (le_hf' : ∀ x, deriv f x ≤ C) ⦃x y⦄ (hxy : x ≤ y) :
347+
f y - f x ≤ C * (y - x) :=
348+
convex_univ.image_sub_le_mul_sub_of_deriv_le hf.continuous.continuous_on hf.differentiable_on
349+
(λ x _, le_hf' x) x y trivial trivial hxy
350+
351+
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
352+
of the real line. If `f` is differentiable on the interior of `D` and `f'` is positive, then
353+
`f` is a strictly monotonically increasing function on `D`. -/
354+
theorem convex.strict_mono_of_deriv_pos {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
355+
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
356+
(hf'_pos : ∀ x ∈ interior D, 0 < deriv f x) :
357+
∀ x y ∈ D, x < y → f x < f y :=
358+
by simpa only [zero_mul, sub_pos] using hD.mul_sub_lt_image_sub_of_lt_deriv hf hf' hf'_pos
359+
360+
/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is positive, then
361+
`f` is a strictly monotonically increasing function. -/
362+
theorem strict_mono_of_deriv_pos {f : ℝ → ℝ} (hf : differentiable ℝ f)
363+
(hf'_pos : ∀ x, 0 < deriv f x) :
364+
strict_mono f :=
365+
λ x y hxy, convex_univ.strict_mono_of_deriv_pos hf.continuous.continuous_on hf.differentiable_on
366+
(λ x _, hf'_pos x) x y trivial trivial hxy
367+
368+
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
369+
of the real line. If `f` is differentiable on the interior of `D` and `f'` is nonnegative, then
370+
`f` is a monotonically increasing function on `D`. -/
371+
theorem convex.mono_of_deriv_nonneg {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
372+
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
373+
(hf'_nonneg : ∀ x ∈ interior D, 0 ≤ deriv f x) :
374+
∀ x y ∈ D, x ≤ y → f x ≤ f y :=
375+
by simpa only [zero_mul, sub_nonneg] using hD.mul_sub_le_image_sub_of_le_deriv hf hf' hf'_nonneg
376+
377+
/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is nonnegative, then
378+
`f` is a monotonically increasing function. -/
379+
theorem mono_of_deriv_nonneg {f : ℝ → ℝ} (hf : differentiable ℝ f) (hf' : ∀ x, 0 ≤ deriv f x) :
380+
monotone f :=
381+
λ x y hxy, convex_univ.mono_of_deriv_nonneg hf.continuous.continuous_on hf.differentiable_on
382+
(λ x _, hf' x) x y trivial trivial hxy
383+
384+
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
385+
of the real line. If `f` is differentiable on the interior of `D` and `f'` is negative, then
386+
`f` is a strictly monotonically decreasing function on `D`. -/
387+
theorem convex.strict_antimono_of_deriv_neg {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
388+
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
389+
(hf'_neg : ∀ x ∈ interior D, deriv f x < 0) :
390+
∀ x y ∈ D, x < y → f y < f x :=
391+
by simpa only [zero_mul, sub_lt_zero] using hD.image_sub_lt_mul_sub_of_deriv_lt hf hf' hf'_neg
392+
393+
/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is negative, then
394+
`f` is a strictly monotonically decreasing function. -/
395+
theorem strict_antimono_of_deriv_neg {f : ℝ → ℝ} (hf : differentiable ℝ f)
396+
(hf' : ∀ x, deriv f x < 0) :
397+
∀ ⦃x y⦄, x < y → f y < f x :=
398+
λ x y hxy, convex_univ.strict_antimono_of_deriv_neg hf.continuous.continuous_on hf.differentiable_on
399+
(λ x _, hf' x) x y trivial trivial hxy
400+
401+
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D`
402+
of the real line. If `f` is differentiable on the interior of `D` and `f'` is nonpositive, then
403+
`f` is a monotonically decreasing function on `D`. -/
404+
theorem convex.antimono_of_deriv_nonpos {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
405+
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
406+
(hf'_nonpos : ∀ x ∈ interior D, deriv f x ≤ 0) :
407+
∀ x y ∈ D, x ≤ y → f y ≤ f x :=
408+
by simpa only [zero_mul, sub_nonpos] using hD.image_sub_le_mul_sub_of_deriv_le hf hf' hf'_nonpos
409+
410+
/-- Let `f : ℝ → ℝ` be a differentiable function. If `f'` is nonpositive, then
411+
`f` is a monotonically decreasing function. -/
412+
theorem antimono_of_deriv_nonpos {f : ℝ → ℝ} (hf : differentiable ℝ f) (hf' : ∀ x, deriv f x ≤ 0) :
413+
∀ ⦃x y⦄, x ≤ y → f y ≤ f x :=
414+
λ x y hxy, convex_univ.antimono_of_deriv_nonpos hf.continuous.continuous_on hf.differentiable_on
415+
(λ x _, hf' x) x y trivial trivial hxy
416+
417+
/-- If a function `f` is continuous on a convex set `D ⊆ ℝ`, is differentiable on its interior,
418+
and `f'` is monotone on the interior, then `f` is convex on `D`. -/
419+
theorem convex_on_of_deriv_mono {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
420+
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
421+
(hf'_mono : ∀ x y ∈ interior D, x ≤ y → deriv f x ≤ deriv f y) :
422+
convex_on D f :=
423+
convex_on_real_of_slope_mono_adjacent hD
424+
begin
425+
intros x y z hx hz hxy hyz,
426+
-- First we prove some trivial inclusions
427+
have hxzD : Icc x z ⊆ D, from convex_real_iff.1 hD hx hz,
428+
have hxyD : Icc x y ⊆ D, from subset.trans (Icc_subset_Icc_right $ le_of_lt hyz) hxzD,
429+
have hxyD' : Ioo x y ⊆ interior D,
430+
from subset_sUnion_of_mem ⟨is_open_Ioo, subset.trans Ioo_subset_Icc_self hxyD⟩,
431+
have hyzD : Icc y z ⊆ D, from subset.trans (Icc_subset_Icc_left $ le_of_lt hxy) hxzD,
432+
have hyzD' : Ioo y z ⊆ interior D,
433+
from subset_sUnion_of_mem ⟨is_open_Ioo, subset.trans Ioo_subset_Icc_self hyzD⟩,
434+
-- Then we apply MVT to both `[x, y]` and `[y, z]`
435+
obtain ⟨a, ⟨hxa, hay⟩, ha⟩ : ∃ a ∈ Ioo x y, deriv f a = (f y - f x) / (y - x),
436+
from exists_deriv_eq_slope f hxy (hf.mono hxyD) (hf'.mono hxyD'),
437+
obtain ⟨b, ⟨hyb, hbz⟩, hb⟩ : ∃ b ∈ Ioo y z, deriv f b = (f z - f y) / (z - y),
438+
from exists_deriv_eq_slope f hyz (hf.mono hyzD) (hf'.mono hyzD'),
439+
rw [← ha, ← hb],
440+
exact hf'_mono a b (hxyD' ⟨hxa, hay⟩) (hyzD' ⟨hyb, hbz⟩) (le_of_lt $ lt_trans hay hyb)
441+
end
442+
443+
/-- If a function `f` is continuous on a convex set `D ⊆ ℝ`, is differentiable on its interior,
444+
and `f'` is monotone on the interior, then `f` is convex on `ℝ`. -/
445+
theorem convex_on_univ_of_deriv_mono {f : ℝ → ℝ} (hf : differentiable ℝ f)
446+
(hf'_mono : monotone (deriv f)) : convex_on univ f :=
447+
convex_on_of_deriv_mono convex_univ hf.continuous.continuous_on hf.differentiable_on
448+
(λ x y _ _ h, hf'_mono h)
449+
450+
/-- If a function `f` is continuous on a convex set `D ⊆ ℝ`, is twice differentiable on its interior,
451+
and `f''` is nonnegative on the interior, then `f` is convex on `D`. -/
452+
theorem convex_on_of_deriv2_nonneg {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
453+
(hf : continuous_on f D) (hf' : differentiable_on ℝ f (interior D))
454+
(hf'' : differentiable_on ℝ (deriv f) (interior D))
455+
(hf''_nonneg : ∀ x ∈ interior D, 0 ≤ (deriv^[2] f x)) :
456+
convex_on D f :=
457+
convex_on_of_deriv_mono hD hf hf' $
458+
assume x y hx hy hxy,
459+
hD.interior.mono_of_deriv_nonneg hf''.continuous_on (by rwa [interior_interior])
460+
(by rwa [interior_interior]) _ _ hx hy hxy
461+
462+
/-- If a function `f` is twice differentiable on `ℝ`, and `f''` is nonnegative on `ℝ`,
463+
then `f` is convex on `ℝ`. -/
464+
theorem convex_on_univ_of_deriv2_nonneg {f : ℝ → ℝ} (hf' : differentiable ℝ f)
465+
(hf'' : differentiable ℝ (deriv f)) (hf''_nonneg : ∀ x, 0 ≤ (deriv^[2] f x)) :
466+
convex_on univ f :=
467+
convex_on_of_deriv2_nonneg convex_univ hf'.continuous.continuous_on hf'.differentiable_on
468+
hf''.differentiable_on (λ x _, hf''_nonneg x)

src/analysis/convex.lean

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -412,18 +412,54 @@ begin
412412
simpa [hab, zero_lt_one] using h hx hy ha hb,
413413
end
414414

415-
lemma convex_on_linorder [linear_order α] {f : α → ℝ} : convex_on D f ↔
416-
convex D ∧ ∀ {x y : α} {a b : ℝ}, x ∈ D → y ∈ D → x < y → 0 ≤ a → 0 ≤ b → a + b = 1
417-
f (a • x + b • y) ≤ a * f x + b * f y :=
415+
/-- For a function on a convex set in a linear ordered space, in order to prove that it is convex
416+
it suffices to verify the inequality `f (a • x + b • y) ≤ a * f x + b * f y` only for `x < y`
417+
and positive `a`, `b`. The main use case is `α = ℝ` however one can apply it, e.g., to `ℝ^n` with
418+
lexicographic order. -/
419+
lemma linear_order.convex_on_of_lt [linear_order α] {f : α → ℝ} (hD : convex D)
420+
(hf : ∀ {x y : α} {a b : ℝ}, x ∈ D → y ∈ D → x < y → 0 < a → 0 < b → a + b = 1
421+
f (a • x + b • y) ≤ a * f x + b * f y) : convex_on D f :=
418422
begin
419-
refine and_congr iff.rfl ⟨_, _⟩; intros h x y a b hx hy,
420-
{ intro hxy, exact h hx hy },
421-
{ intros ha hb hab,
422-
wlog hxy : x<=y using [x y a b, y x b a],
423-
exact le_total _ _,
424-
apply or.elim (lt_or_eq_of_le hxy),
425-
{ intros hxy, exact h hx hy hxy ha hb hab },
426-
{ intros hxy, rw [hxy, ←add_smul, hab, one_smul, ←add_mul,hab,one_mul] } }
423+
use hD,
424+
intros x y a b hx hy ha hb hab,
425+
wlog hxy : x<=y using [x y a b, y x b a],
426+
{ exact le_total _ _ },
427+
{ cases eq_or_lt_of_le hxy with hxy hxy,
428+
by { subst y, rw [← add_smul, ← add_mul, hab, one_smul, one_mul] },
429+
cases eq_or_lt_of_le ha with ha ha,
430+
by { subst a, rw [zero_add] at hab, subst b, simp },
431+
cases eq_or_lt_of_le hb with hb hb,
432+
by { subst b, rw [add_zero] at hab, subst a, simp },
433+
exact hf hx hy hxy ha hb hab }
434+
end
435+
436+
/-- For a function `f` defined on a convex subset `D` of `ℝ`, if for any three points `x<y<z`
437+
the slope of the secant line of `f` on `[x, y]` is less than or equal to the slope
438+
of the secant line of `f` on `[x, z]`, then `f` is convex on `D`. This way of proving convexity
439+
of a function is used in the proof of convexity of a function with a monotone derivative. -/
440+
lemma convex_on_real_of_slope_mono_adjacent {D : set ℝ} (hD : convex D) {f : ℝ → ℝ}
441+
(hf : ∀ {x y z : ℝ}, x ∈ D → z ∈ D → x < y → y < z →
442+
(f y - f x) / (y - x) ≤ (f z - f y) / (z - y)) :
443+
convex_on D f :=
444+
linear_order.convex_on_of_lt hD
445+
begin
446+
assume x z a b hx hz hxz ha hb hab,
447+
let y := a * x + b * z,
448+
have hxy : x < y,
449+
{ rw [← one_mul x, ← hab, add_mul],
450+
exact add_lt_add_left ((mul_lt_mul_left hb).2 hxz) _ },
451+
have hyz : y < z,
452+
{ rw [← one_mul z, ← hab, add_mul],
453+
exact add_lt_add_right ((mul_lt_mul_left ha).2 hxz) _ },
454+
have : (f y - f x) * (z - y) ≤ (f z - f y) * (y - x),
455+
from (div_le_div_iff (sub_pos.2 hxy) (sub_pos.2 hyz)).1 (hf hx hz hxy hyz),
456+
have A : z - y + (y - x) = z - x, by abel,
457+
have B : 0 < z - x, from sub_pos.2 (lt_trans hxy hyz),
458+
rw [sub_mul, sub_mul, sub_le_iff_le_add', ← add_sub_assoc, le_sub_iff_add_le, ← mul_add, A,
459+
← le_div_iff B, add_div, mul_div_assoc, mul_div_assoc,
460+
mul_comm (f x), mul_comm (f z)] at this,
461+
rw [eq_comm, ← sub_eq_iff_eq_add] at hab; subst a,
462+
convert this; symmetry; simp only [div_eq_iff (ne_of_gt B), y]; ring
427463
end
428464

429465
lemma convex_on.subset (h_convex_on : convex_on D f) (h_subset : A ⊆ D) (h_convex : convex A) :

0 commit comments

Comments
 (0)