Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
/- | |
Copyright (c) 2019 SΓ©bastien GouΓ«zel. All rights reserved. | |
Released under Apache 2.0 license as described in the file LICENSE. | |
Authors: SΓ©bastien GouΓ«zel, Yury Kudryashov | |
-/ | |
import analysis.calculus.local_extr | |
import analysis.convex.slope | |
import analysis.convex.topology | |
import data.complex.is_R_or_C | |
/-! | |
# The mean value inequality and equalities | |
In this file we prove the following facts: | |
* `convex.norm_image_sub_le_of_norm_deriv_le` : if `f` is differentiable on a convex set `s` | |
and the norm of its derivative is bounded by `C`, then `f` is Lipschitz continuous on `s` with | |
constant `C`; also a variant in which what is bounded by `C` is the norm of the difference of the | |
derivative from a fixed linear map. This lemma and its versions are formulated using `is_R_or_C`, | |
so they work both for real and complex derivatives. | |
* `image_le_of*`, `image_norm_le_of_*` : several similar lemmas deducing `f x β€ B x` or | |
`β₯f xβ₯ β€ B x` from upper estimates on `f'` or `β₯f'β₯`, respectively. These lemmas differ by | |
their assumptions: | |
* `of_liminf_*` lemmas assume that limit inferior of some ratio is less than `B' x`; | |
* `of_deriv_right_*`, `of_norm_deriv_right_*` lemmas assume that the right derivative | |
or its norm is less than `B' x`; | |
* `of_*_lt_*` lemmas assume a strict inequality whenever `f x = B x` or `β₯f xβ₯ = B x`; | |
* `of_*_le_*` lemmas assume a non-strict inequality everywhere on `[a, b)`; | |
* name of a lemma ends with `'` if (1) it assumes that `B` is continuous on `[a, b]` | |
and has a right derivative at every point of `[a, b)`, and (2) the lemma has | |
a counterpart assuming that `B` is differentiable everywhere on `β` | |
* `norm_image_sub_le_*_segment` : if derivative of `f` on `[a, b]` is bounded above | |
by a constant `C`, then `β₯f x - f aβ₯ β€ C * β₯x - aβ₯`; several versions deal with | |
right derivative and derivative within `[a, b]` (`has_deriv_within_at` or `deriv_within`). | |
* `convex.is_const_of_fderiv_within_eq_zero` : if a function has derivative `0` on a convex set `s`, | |
then it is a constant on `s`. | |
* `exists_ratio_has_deriv_at_eq_ratio_slope` and `exists_ratio_deriv_eq_ratio_slope` : | |
Cauchy's Mean Value Theorem. | |
* `exists_has_deriv_at_eq_slope` and `exists_deriv_eq_slope` : Lagrange's Mean Value Theorem. | |
* `domain_mvt` : Lagrange's Mean Value Theorem, applied to a segment in a convex domain. | |
* `convex.image_sub_lt_mul_sub_of_deriv_lt`, `convex.mul_sub_lt_image_sub_of_lt_deriv`, | |
`convex.image_sub_le_mul_sub_of_deriv_le`, `convex.mul_sub_le_image_sub_of_le_deriv`, | |
if `β x, C (</β€/>/β₯) (f' x)`, then `C * (y - x) (</β€/>/β₯) (f y - f x)` whenever `x < y`. | |
* `convex.monotone_on_of_deriv_nonneg`, `convex.antitone_on_of_deriv_nonpos`, | |
`convex.strict_mono_of_deriv_pos`, `convex.strict_anti_of_deriv_neg` : | |
if the derivative of a function is non-negative/non-positive/positive/negative, then | |
the function is monotone/antitone/strictly monotone/strictly monotonically | |
decreasing. | |
* `convex_on_of_deriv_monotone_on`, `convex_on_of_deriv2_nonneg` : if the derivative of a function | |
is increasing or its second derivative is nonnegative, then the original function is convex. | |
* `strict_fderiv_of_cont_diff` : a C^1 function over the reals is strictly differentiable. (This | |
is a corollary of the mean value inequality.) | |
-/ | |
variables {E : Type*} [normed_add_comm_group E] [normed_space β E] | |
{F : Type*} [normed_add_comm_group F] [normed_space β F] | |
open metric set asymptotics continuous_linear_map filter | |
open_locale classical topological_space nnreal | |
/-! ### One-dimensional fencing inequalities -/ | |
/-- General fencing theorem for continuous functions with an estimate on the derivative. | |
Let `f` and `B` be continuous functions on `[a, b]` such that | |
* `f a β€ B a`; | |
* `B` has right derivative `B'` at every point of `[a, b)`; | |
* for each `x β [a, b)` the right-side limit inferior of `(f z - f x) / (z - x)` | |
is bounded above by a function `f'`; | |
* we have `f' x < B' x` whenever `f x = B x`. | |
Then `f x β€ B x` everywhere on `[a, b]`. -/ | |
lemma image_le_of_liminf_slope_right_lt_deriv_boundary' {f f' : β β β} {a b : β} | |
(hf : continuous_on f (Icc a b)) | |
-- `hf'` actually says `liminf (f z - f x) / (z - x) β€ f' x` | |
(hf' : β x β Ico a b, β r, f' x < r β βαΆ z in π[>] x, slope f x z < r) | |
{B B' : β β β} (ha : f a β€ B a) (hB : continuous_on B (Icc a b)) | |
(hB' : β x β Ico a b, has_deriv_within_at B (B' x) (Ici x) x) | |
(bound : β x β Ico a b, f x = B x β f' x < B' x) : | |
β β¦xβ¦, x β Icc a b β f x β€ B x := | |
begin | |
change Icc a b β {x | f x β€ B x}, | |
set s := {x | f x β€ B x} β© Icc a b, | |
have A : continuous_on (Ξ» x, (f x, B x)) (Icc a b), from hf.prod hB, | |
have : is_closed s, | |
{ simp only [s, inter_comm], | |
exact A.preimage_closed_of_closed is_closed_Icc order_closed_topology.is_closed_le' }, | |
apply this.Icc_subset_of_forall_exists_gt ha, | |
rintros x β¨hxB : f x β€ B x, xabβ© y hy, | |
cases hxB.lt_or_eq with hxB hxB, | |
{ -- If `f x < B x`, then all we need is continuity of both sides | |
refine nonempty_of_mem (inter_mem _ (Ioc_mem_nhds_within_Ioi β¨le_rfl, hyβ©)), | |
have : βαΆ x in π[Icc a b] x, f x < B x, | |
from A x (Ico_subset_Icc_self xab) | |
(is_open.mem_nhds (is_open_lt continuous_fst continuous_snd) hxB), | |
have : βαΆ x in π[>] x, f x < B x, | |
from nhds_within_le_of_mem (Icc_mem_nhds_within_Ioi xab) this, | |
exact this.mono (Ξ» y, le_of_lt) }, | |
{ rcases exists_between (bound x xab hxB) with β¨r, hfr, hrBβ©, | |
specialize hf' x xab r hfr, | |
have HB : βαΆ z in π[>] x, r < slope B x z, | |
from (has_deriv_within_at_iff_tendsto_slope' $ lt_irrefl x).1 | |
(hB' x xab).Ioi_of_Ici (Ioi_mem_nhds hrB), | |
obtain β¨z, hfz, hzB, hzβ© : | |
β z, slope f x z < r β§ r < slope B x z β§ z β Ioc x y, | |
from (hf'.and_eventually (HB.and (Ioc_mem_nhds_within_Ioi β¨le_rfl, hyβ©))).exists, | |
refine β¨z, _, hzβ©, | |
have := (hfz.trans hzB).le, | |
rwa [slope_def_field, slope_def_field, div_le_div_right (sub_pos.2 hz.1), hxB, | |
sub_le_sub_iff_right] at this } | |
end | |
/-- General fencing theorem for continuous functions with an estimate on the derivative. | |
Let `f` and `B` be continuous functions on `[a, b]` such that | |
* `f a β€ B a`; | |
* `B` has derivative `B'` everywhere on `β`; | |
* for each `x β [a, b)` the right-side limit inferior of `(f z - f x) / (z - x)` | |
is bounded above by a function `f'`; | |
* we have `f' x < B' x` whenever `f x = B x`. | |
Then `f x β€ B x` everywhere on `[a, b]`. -/ | |
lemma image_le_of_liminf_slope_right_lt_deriv_boundary {f f' : β β β} {a b : β} | |
(hf : continuous_on f (Icc a b)) | |
-- `hf'` actually says `liminf (f z - f x) / (z - x) β€ f' x` | |
(hf' : β x β Ico a b, β r, f' x < r β βαΆ z in π[>] x, slope f x z < r) | |
{B B' : β β β} (ha : f a β€ B a) (hB : β x, has_deriv_at B (B' x) x) | |
(bound : β x β Ico a b, f x = B x β f' x < B' x) : | |
β β¦xβ¦, x β Icc a b β f x β€ B x := | |
image_le_of_liminf_slope_right_lt_deriv_boundary' hf hf' ha | |
(Ξ» x hx, (hB x).continuous_at.continuous_within_at) | |
(Ξ» x hx, (hB x).has_deriv_within_at) bound | |
/-- General fencing theorem for continuous functions with an estimate on the derivative. | |
Let `f` and `B` be continuous functions on `[a, b]` such that | |
* `f a β€ B a`; | |
* `B` has right derivative `B'` at every point of `[a, b)`; | |
* for each `x β [a, b)` the right-side limit inferior of `(f z - f x) / (z - x)` | |
is bounded above by `B'`. | |
Then `f x β€ B x` everywhere on `[a, b]`. -/ | |
lemma image_le_of_liminf_slope_right_le_deriv_boundary {f : β β β} {a b : β} | |
(hf : continuous_on f (Icc a b)) | |
{B B' : β β β} (ha : f a β€ B a) (hB : continuous_on B (Icc a b)) | |
(hB' : β x β Ico a b, has_deriv_within_at B (B' x) (Ici x) x) | |
-- `bound` actually says `liminf (f z - f x) / (z - x) β€ B' x` | |
(bound : β x β Ico a b, β r, B' x < r β βαΆ z in π[>] x, slope f x z < r) : | |
β β¦xβ¦, x β Icc a b β f x β€ B x := | |
begin | |
have Hr : β x β Icc a b, β r > 0, f x β€ B x + r * (x - a), | |
{ intros x hx r hr, | |
apply image_le_of_liminf_slope_right_lt_deriv_boundary' hf bound, | |
{ rwa [sub_self, mul_zero, add_zero] }, | |
{ exact hB.add (continuous_on_const.mul | |
(continuous_id.continuous_on.sub continuous_on_const)) }, | |
{ assume x hx, | |
exact (hB' x hx).add (((has_deriv_within_at_id x (Ici x)).sub_const a).const_mul r) }, | |
{ assume x hx _, | |
rw [mul_one], | |
exact (lt_add_iff_pos_right _).2 hr }, | |
exact hx }, | |
assume x hx, | |
have : continuous_within_at (Ξ» r, B x + r * (x - a)) (Ioi 0) 0, | |
from continuous_within_at_const.add (continuous_within_at_id.mul continuous_within_at_const), | |
convert continuous_within_at_const.closure_le _ this (Hr x hx); simp | |
end | |
/-- General fencing theorem for continuous functions with an estimate on the derivative. | |
Let `f` and `B` be continuous functions on `[a, b]` such that | |
* `f a β€ B a`; | |
* `B` has right derivative `B'` at every point of `[a, b)`; | |
* `f` has right derivative `f'` at every point of `[a, b)`; | |
* we have `f' x < B' x` whenever `f x = B x`. | |
Then `f x β€ B x` everywhere on `[a, b]`. -/ | |
lemma image_le_of_deriv_right_lt_deriv_boundary' {f f' : β β β} {a b : β} | |
(hf : continuous_on f (Icc a b)) | |
(hf' : β x β Ico a b, has_deriv_within_at f (f' x) (Ici x) x) | |
{B B' : β β β} (ha : f a β€ B a) (hB : continuous_on B (Icc a b)) | |
(hB' : β x β Ico a b, has_deriv_within_at B (B' x) (Ici x) x) | |
(bound : β x β Ico a b, f x = B x β f' x < B' x) : | |
β β¦xβ¦, x β Icc a b β f x β€ B x := | |
image_le_of_liminf_slope_right_lt_deriv_boundary' hf | |
(Ξ» x hx r hr, (hf' x hx).liminf_right_slope_le hr) ha hB hB' bound | |
/-- General fencing theorem for continuous functions with an estimate on the derivative. | |
Let `f` and `B` be continuous functions on `[a, b]` such that | |
* `f a β€ B a`; | |
* `B` has derivative `B'` everywhere on `β`; | |
* `f` has right derivative `f'` at every point of `[a, b)`; | |
* we have `f' x < B' x` whenever `f x = B x`. | |
Then `f x β€ B x` everywhere on `[a, b]`. -/ | |
lemma image_le_of_deriv_right_lt_deriv_boundary {f f' : β β β} {a b : β} | |
(hf : continuous_on f (Icc a b)) | |
(hf' : β x β Ico a b, has_deriv_within_at f (f' x) (Ici x) x) | |
{B B' : β β β} (ha : f a β€ B a) (hB : β x, has_deriv_at B (B' x) x) | |
(bound : β x β Ico a b, f x = B x β f' x < B' x) : | |
β β¦xβ¦, x β Icc a b β f x β€ B x := | |
image_le_of_deriv_right_lt_deriv_boundary' hf hf' ha | |
(Ξ» x hx, (hB x).continuous_at.continuous_within_at) | |
(Ξ» x hx, (hB x).has_deriv_within_at) bound | |
/-- General fencing theorem for continuous functions with an estimate on the derivative. | |
Let `f` and `B` be continuous functions on `[a, b]` such that | |
* `f a β€ B a`; | |
* `B` has derivative `B'` everywhere on `β`; | |
* `f` has right derivative `f'` at every point of `[a, b)`; | |
* we have `f' x β€ B' x` on `[a, b)`. | |
Then `f x β€ B x` everywhere on `[a, b]`. -/ | |
lemma image_le_of_deriv_right_le_deriv_boundary {f f' : β β β} {a b : β} | |
(hf : continuous_on f (Icc a b)) | |
(hf' : β x β Ico a b, has_deriv_within_at f (f' x) (Ici x) x) | |
{B B' : β β β} (ha : f a β€ B a) (hB : continuous_on B (Icc a b)) | |
(hB' : β x β Ico a b, has_deriv_within_at B (B' x) (Ici x) x) | |
(bound : β x β Ico a b, f' x β€ B' x) : | |
β β¦xβ¦, x β Icc a b β f x β€ B x := | |
image_le_of_liminf_slope_right_le_deriv_boundary hf ha hB hB' $ | |
assume x hx r hr, (hf' x hx).liminf_right_slope_le (lt_of_le_of_lt (bound x hx) hr) | |
/-! ### Vector-valued functions `f : β β E` -/ | |
section | |
variables {f : β β E} {a b : β} | |
/-- General fencing theorem for continuous functions with an estimate on the derivative. | |
Let `f` and `B` be continuous functions on `[a, b]` such that | |
* `β₯f aβ₯ β€ B a`; | |
* `B` has right derivative at every point of `[a, b)`; | |
* for each `x β [a, b)` the right-side limit inferior of `(β₯f zβ₯ - β₯f xβ₯) / (z - x)` | |
is bounded above by a function `f'`; | |
* we have `f' x < B' x` whenever `β₯f xβ₯ = B x`. | |
Then `β₯f xβ₯ β€ B x` everywhere on `[a, b]`. -/ | |
lemma image_norm_le_of_liminf_right_slope_norm_lt_deriv_boundary {E : Type*} | |
[normed_add_comm_group E] {f : β β E} {f' : β β β} (hf : continuous_on f (Icc a b)) | |
-- `hf'` actually says `liminf (β₯f zβ₯ - β₯f xβ₯) / (z - x) β€ f' x` | |
(hf' : β x β Ico a b, β r, f' x < r β | |
βαΆ z in π[>] x, slope (norm β f) x z < r) | |
{B B' : β β β} (ha : β₯f aβ₯ β€ B a) (hB : continuous_on B (Icc a b)) | |
(hB' : β x β Ico a b, has_deriv_within_at B (B' x) (Ici x) x) | |
(bound : β x β Ico a b, β₯f xβ₯ = B x β f' x < B' x) : | |
β β¦xβ¦, x β Icc a b β β₯f xβ₯ β€ B x := | |
image_le_of_liminf_slope_right_lt_deriv_boundary' (continuous_norm.comp_continuous_on hf) hf' | |
ha hB hB' bound | |
/-- General fencing theorem for continuous functions with an estimate on the norm of the derivative. | |
Let `f` and `B` be continuous functions on `[a, b]` such that | |
* `β₯f aβ₯ β€ B a`; | |
* `f` and `B` have right derivatives `f'` and `B'` respectively at every point of `[a, b)`; | |
* the norm of `f'` is strictly less than `B'` whenever `β₯f xβ₯ = B x`. | |
Then `β₯f xβ₯ β€ B x` everywhere on `[a, b]`. We use one-sided derivatives in the assumptions | |
to make this theorem work for piecewise differentiable functions. | |
-/ | |
lemma image_norm_le_of_norm_deriv_right_lt_deriv_boundary' {f' : β β E} | |
(hf : continuous_on f (Icc a b)) | |
(hf' : β x β Ico a b, has_deriv_within_at f (f' x) (Ici x) x) | |
{B B' : β β β} (ha : β₯f aβ₯ β€ B a) (hB : continuous_on B (Icc a b)) | |
(hB' : β x β Ico a b, has_deriv_within_at B (B' x) (Ici x) x) | |
(bound : β x β Ico a b, β₯f xβ₯ = B x β β₯f' xβ₯ < B' x) : | |
β β¦xβ¦, x β Icc a b β β₯f xβ₯ β€ B x := | |
image_norm_le_of_liminf_right_slope_norm_lt_deriv_boundary hf | |
(Ξ» x hx r hr, (hf' x hx).liminf_right_slope_norm_le hr) ha hB hB' bound | |
/-- General fencing theorem for continuous functions with an estimate on the norm of the derivative. | |
Let `f` and `B` be continuous functions on `[a, b]` such that | |
* `β₯f aβ₯ β€ B a`; | |
* `f` has right derivative `f'` at every point of `[a, b)`; | |
* `B` has derivative `B'` everywhere on `β`; | |
* the norm of `f'` is strictly less than `B'` whenever `β₯f xβ₯ = B x`. | |
Then `β₯f xβ₯ β€ B x` everywhere on `[a, b]`. We use one-sided derivatives in the assumptions | |
to make this theorem work for piecewise differentiable functions. | |
-/ | |
lemma image_norm_le_of_norm_deriv_right_lt_deriv_boundary {f' : β β E} | |
(hf : continuous_on f (Icc a b)) | |
(hf' : β x β Ico a b, has_deriv_within_at f (f' x) (Ici x) x) | |
{B B' : β β β} (ha : β₯f aβ₯ β€ B a) (hB : β x, has_deriv_at B (B' x) x) | |
(bound : β x β Ico a b, β₯f xβ₯ = B x β β₯f' xβ₯ < B' x) : | |
β β¦xβ¦, x β Icc a b β β₯f xβ₯ β€ B x := | |
image_norm_le_of_norm_deriv_right_lt_deriv_boundary' hf hf' ha | |
(Ξ» x hx, (hB x).continuous_at.continuous_within_at) | |
(Ξ» x hx, (hB x).has_deriv_within_at) bound | |
/-- General fencing theorem for continuous functions with an estimate on the norm of the derivative. | |
Let `f` and `B` be continuous functions on `[a, b]` such that | |
* `β₯f aβ₯ β€ B a`; | |
* `f` and `B` have right derivatives `f'` and `B'` respectively at every point of `[a, b)`; | |
* we have `β₯f' xβ₯ β€ B x` everywhere on `[a, b)`. | |
Then `β₯f xβ₯ β€ B x` everywhere on `[a, b]`. We use one-sided derivatives in the assumptions | |
to make this theorem work for piecewise differentiable functions. | |
-/ | |
lemma image_norm_le_of_norm_deriv_right_le_deriv_boundary' {f' : β β E} | |
(hf : continuous_on f (Icc a b)) | |
(hf' : β x β Ico a b, has_deriv_within_at f (f' x) (Ici x) x) | |
{B B' : β β β} (ha : β₯f aβ₯ β€ B a) (hB : continuous_on B (Icc a b)) | |
(hB' : β x β Ico a b, has_deriv_within_at B (B' x) (Ici x) x) | |
(bound : β x β Ico a b, β₯f' xβ₯ β€ B' x) : | |
β β¦xβ¦, x β Icc a b β β₯f xβ₯ β€ B x := | |
image_le_of_liminf_slope_right_le_deriv_boundary (continuous_norm.comp_continuous_on hf) ha hB hB' $ | |
(Ξ» x hx r hr, (hf' x hx).liminf_right_slope_norm_le (lt_of_le_of_lt (bound x hx) hr)) | |
/-- General fencing theorem for continuous functions with an estimate on the norm of the derivative. | |
Let `f` and `B` be continuous functions on `[a, b]` such that | |
* `β₯f aβ₯ β€ B a`; | |
* `f` has right derivative `f'` at every point of `[a, b)`; | |
* `B` has derivative `B'` everywhere on `β`; | |
* we have `β₯f' xβ₯ β€ B x` everywhere on `[a, b)`. | |
Then `β₯f xβ₯ β€ B x` everywhere on `[a, b]`. We use one-sided derivatives in the assumptions | |
to make this theorem work for piecewise differentiable functions. | |
-/ | |
lemma image_norm_le_of_norm_deriv_right_le_deriv_boundary {f' : β β E} | |
(hf : continuous_on f (Icc a b)) | |
(hf' : β x β Ico a b, has_deriv_within_at f (f' x) (Ici x) x) | |
{B B' : β β β} (ha : β₯f aβ₯ β€ B a) (hB : β x, has_deriv_at B (B' x) x) | |
(bound : β x β Ico a b, β₯f' xβ₯ β€ B' x) : | |
β β¦xβ¦, x β Icc a b β β₯f xβ₯ β€ B x := | |
image_norm_le_of_norm_deriv_right_le_deriv_boundary' hf hf' ha | |
(Ξ» x hx, (hB x).continuous_at.continuous_within_at) | |
(Ξ» x hx, (hB x).has_deriv_within_at) bound | |
/-- A function on `[a, b]` with the norm of the right derivative bounded by `C` | |
satisfies `β₯f x - f aβ₯ β€ C * (x - a)`. -/ | |
theorem norm_image_sub_le_of_norm_deriv_right_le_segment {f' : β β E} {C : β} | |
(hf : continuous_on f (Icc a b)) | |
(hf' : β x β Ico a b, has_deriv_within_at f (f' x) (Ici x) x) | |
(bound : βx β Ico a b, β₯f' xβ₯ β€ C) : | |
β x β Icc a b, β₯f x - f aβ₯ β€ C * (x - a) := | |
begin | |
let g := Ξ» x, f x - f a, | |
have hg : continuous_on g (Icc a b), from hf.sub continuous_on_const, | |
have hg' : β x β Ico a b, has_deriv_within_at g (f' x) (Ici x) x, | |
{ assume x hx, | |
simpa using (hf' x hx).sub (has_deriv_within_at_const _ _ _) }, | |
let B := Ξ» x, C * (x - a), | |
have hB : β x, has_deriv_at B C x, | |
{ assume x, | |
simpa using (has_deriv_at_const x C).mul ((has_deriv_at_id x).sub (has_deriv_at_const x a)) }, | |
convert image_norm_le_of_norm_deriv_right_le_deriv_boundary hg hg' _ hB bound, | |
simp only [g, B], rw [sub_self, norm_zero, sub_self, mul_zero] | |
end | |
/-- A function on `[a, b]` with the norm of the derivative within `[a, b]` | |
bounded by `C` satisfies `β₯f x - f aβ₯ β€ C * (x - a)`, `has_deriv_within_at` | |
version. -/ | |
theorem norm_image_sub_le_of_norm_deriv_le_segment' {f' : β β E} {C : β} | |
(hf : β x β Icc a b, has_deriv_within_at f (f' x) (Icc a b) x) | |
(bound : βx β Ico a b, β₯f' xβ₯ β€ C) : | |
β x β Icc a b, β₯f x - f aβ₯ β€ C * (x - a) := | |
begin | |
refine norm_image_sub_le_of_norm_deriv_right_le_segment | |
(Ξ» x hx, (hf x hx).continuous_within_at) (Ξ» x hx, _) bound, | |
exact (hf x $ Ico_subset_Icc_self hx).nhds_within (Icc_mem_nhds_within_Ici hx) | |
end | |
/-- A function on `[a, b]` with the norm of the derivative within `[a, b]` | |
bounded by `C` satisfies `β₯f x - f aβ₯ β€ C * (x - a)`, `deriv_within` | |
version. -/ | |
theorem norm_image_sub_le_of_norm_deriv_le_segment {C : β} (hf : differentiable_on β f (Icc a b)) | |
(bound : βx β Ico a b, β₯deriv_within f (Icc a b) xβ₯ β€ C) : | |
β x β Icc a b, β₯f x - f aβ₯ β€ C * (x - a) := | |
begin | |
refine norm_image_sub_le_of_norm_deriv_le_segment' _ bound, | |
exact Ξ» x hx, (hf x hx).has_deriv_within_at | |
end | |
/-- A function on `[0, 1]` with the norm of the derivative within `[0, 1]` | |
bounded by `C` satisfies `β₯f 1 - f 0β₯ β€ C`, `has_deriv_within_at` | |
version. -/ | |
theorem norm_image_sub_le_of_norm_deriv_le_segment_01' {f' : β β E} {C : β} | |
(hf : β x β Icc (0:β) 1, has_deriv_within_at f (f' x) (Icc (0:β) 1) x) | |
(bound : βx β Ico (0:β) 1, β₯f' xβ₯ β€ C) : | |
β₯f 1 - f 0β₯ β€ C := | |
by simpa only [sub_zero, mul_one] | |
using norm_image_sub_le_of_norm_deriv_le_segment' hf bound 1 (right_mem_Icc.2 zero_le_one) | |
/-- A function on `[0, 1]` with the norm of the derivative within `[0, 1]` | |
bounded by `C` satisfies `β₯f 1 - f 0β₯ β€ C`, `deriv_within` version. -/ | |
theorem norm_image_sub_le_of_norm_deriv_le_segment_01 {C : β} | |
(hf : differentiable_on β f (Icc (0:β) 1)) | |
(bound : βx β Ico (0:β) 1, β₯deriv_within f (Icc (0:β) 1) xβ₯ β€ C) : | |
β₯f 1 - f 0β₯ β€ C := | |
by simpa only [sub_zero, mul_one] | |
using norm_image_sub_le_of_norm_deriv_le_segment hf bound 1 (right_mem_Icc.2 zero_le_one) | |
theorem constant_of_has_deriv_right_zero (hcont : continuous_on f (Icc a b)) | |
(hderiv : β x β Ico a b, has_deriv_within_at f 0 (Ici x) x) : | |
β x β Icc a b, f x = f a := | |
by simpa only [zero_mul, norm_le_zero_iff, sub_eq_zero] using | |
Ξ» x hx, norm_image_sub_le_of_norm_deriv_right_le_segment | |
hcont hderiv (Ξ» y hy, by rw norm_le_zero_iff) x hx | |
theorem constant_of_deriv_within_zero (hdiff : differentiable_on β f (Icc a b)) | |
(hderiv : β x β Ico a b, deriv_within f (Icc a b) x = 0) : | |
β x β Icc a b, f x = f a := | |
begin | |
have H : β x β Ico a b, β₯deriv_within f (Icc a b) xβ₯ β€ 0 := | |
by simpa only [norm_le_zero_iff] using Ξ» x hx, hderiv x hx, | |
simpa only [zero_mul, norm_le_zero_iff, sub_eq_zero] using | |
Ξ» x hx, norm_image_sub_le_of_norm_deriv_le_segment hdiff H x hx, | |
end | |
variables {f' g : β β E} | |
/-- If two continuous functions on `[a, b]` have the same right derivative and are equal at `a`, | |
then they are equal everywhere on `[a, b]`. -/ | |
theorem eq_of_has_deriv_right_eq | |
(derivf : β x β Ico a b, has_deriv_within_at f (f' x) (Ici x) x) | |
(derivg : β x β Ico a b, has_deriv_within_at g (f' x) (Ici x) x) | |
(fcont : continuous_on f (Icc a b)) (gcont : continuous_on g (Icc a b)) | |
(hi : f a = g a) : | |
β y β Icc a b, f y = g y := | |
begin | |
simp only [β @sub_eq_zero _ _ (f _)] at hi β’, | |
exact hi βΈ constant_of_has_deriv_right_zero (fcont.sub gcont) | |
(Ξ» y hy, by simpa only [sub_self] using (derivf y hy).sub (derivg y hy)), | |
end | |
/-- If two differentiable functions on `[a, b]` have the same derivative within `[a, b]` everywhere | |
on `[a, b)` and are equal at `a`, then they are equal everywhere on `[a, b]`. -/ | |
theorem eq_of_deriv_within_eq (fdiff : differentiable_on β f (Icc a b)) | |
(gdiff : differentiable_on β g (Icc a b)) | |
(hderiv : eq_on (deriv_within f (Icc a b)) (deriv_within g (Icc a b)) (Ico a b)) | |
(hi : f a = g a) : | |
β y β Icc a b, f y = g y := | |
begin | |
have A : β y β Ico a b, has_deriv_within_at f (deriv_within f (Icc a b) y) (Ici y) y := | |
Ξ» y hy, (fdiff y (mem_Icc_of_Ico hy)).has_deriv_within_at.nhds_within | |
(Icc_mem_nhds_within_Ici hy), | |
have B : β y β Ico a b, has_deriv_within_at g (deriv_within g (Icc a b) y) (Ici y) y := | |
Ξ» y hy, (gdiff y (mem_Icc_of_Ico hy)).has_deriv_within_at.nhds_within | |
(Icc_mem_nhds_within_Ici hy), | |
exact eq_of_has_deriv_right_eq A (Ξ» y hy, (hderiv hy).symm βΈ B y hy) fdiff.continuous_on | |
gdiff.continuous_on hi | |
end | |
end | |
/-! | |
### Vector-valued functions `f : E β G` | |
Theorems in this section work both for real and complex differentiable functions. We use assumptions | |
`[is_R_or_C π] [normed_space π E] [normed_space π G]` to achieve this result. For the domain `E` we | |
also assume `[normed_space β E]` to have a notion of a `convex` set. -/ | |
section | |
variables {π G : Type*} [is_R_or_C π] [normed_space π E] [normed_add_comm_group G] | |
[normed_space π G] | |
namespace convex | |
variables {f : E β G} {C : β} {s : set E} {x y : E} {f' : E β E βL[π] G} {Ο : E βL[π] G} | |
/-- The mean value theorem on a convex set: if the derivative of a function is bounded by `C`, then | |
the function is `C`-Lipschitz. Version with `has_fderiv_within`. -/ | |
theorem norm_image_sub_le_of_norm_has_fderiv_within_le | |
(hf : β x β s, has_fderiv_within_at f (f' x) s x) (bound : βxβs, β₯f' xβ₯ β€ C) | |
(hs : convex β s) (xs : x β s) (ys : y β s) : β₯f y - f xβ₯ β€ C * β₯y - xβ₯ := | |
begin | |
letI : normed_space β G := restrict_scalars.normed_space β π G, | |
/- By composition with `t β¦ x + t β’ (y-x)`, we reduce to a statement for functions defined | |
on `[0,1]`, for which it is proved in `norm_image_sub_le_of_norm_deriv_le_segment`. | |
We just have to check the differentiability of the composition and bounds on its derivative, | |
which is straightforward but tedious for lack of automation. -/ | |
have C0 : 0 β€ C := le_trans (norm_nonneg _) (bound x xs), | |
set g : β β E := Ξ» t, x + t β’ (y - x), | |
have Dg : β t, has_deriv_at g (y-x) t, | |
{ assume t, | |
simpa only [one_smul] using ((has_deriv_at_id t).smul_const (y - x)).const_add x }, | |
have segm : Icc 0 1 β g β»ΒΉ' s, | |
{ rw [β image_subset_iff, β segment_eq_image'], | |
apply hs.segment_subset xs ys }, | |
have : f x = f (g 0), by { simp only [g], rw [zero_smul, add_zero] }, | |
rw this, | |
have : f y = f (g 1), by { simp only [g], rw [one_smul, add_sub_cancel'_right] }, | |
rw this, | |
have D2: β t β Icc (0:β) 1, has_deriv_within_at (f β g) (f' (g t) (y - x)) (Icc 0 1) t, | |
{ intros t ht, | |
have : has_fderiv_within_at f ((f' (g t)).restrict_scalars β) s (g t), | |
from hf (g t) (segm ht), | |
exact this.comp_has_deriv_within_at _ (Dg t).has_deriv_within_at segm }, | |
apply norm_image_sub_le_of_norm_deriv_le_segment_01' D2, | |
refine Ξ» t ht, le_of_op_norm_le _ _ _, | |
exact bound (g t) (segm $ Ico_subset_Icc_self ht) | |
end | |
/-- The mean value theorem on a convex set: if the derivative of a function is bounded by `C` on | |
`s`, then the function is `C`-Lipschitz on `s`. Version with `has_fderiv_within` and | |
`lipschitz_on_with`. -/ | |
theorem lipschitz_on_with_of_nnnorm_has_fderiv_within_le {C : ββ₯0} | |
(hf : β x β s, has_fderiv_within_at f (f' x) s x) (bound : βxβs, β₯f' xβ₯β β€ C) | |
(hs : convex β s) : lipschitz_on_with C f s := | |
begin | |
rw lipschitz_on_with_iff_norm_sub_le, | |
intros x x_in y y_in, | |
exact hs.norm_image_sub_le_of_norm_has_fderiv_within_le hf bound y_in x_in | |
end | |
/-- Let `s` be a convex set in a real normed vector space `E`, let `f : E β G` be a function | |
differentiable within `s` in a neighborhood of `x : E` with derivative `f'`. Suppose that `f'` is | |
continuous within `s` at `x`. Then for any number `K : ββ₯0` larger than `β₯f' xβ₯β`, `f` is | |
`K`-Lipschitz on some neighborhood of `x` within `s`. See also | |
`convex.exists_nhds_within_lipschitz_on_with_of_has_fderiv_within_at` for a version that claims | |
existence of `K` instead of an explicit estimate. -/ | |
lemma exists_nhds_within_lipschitz_on_with_of_has_fderiv_within_at_of_nnnorm_lt | |
(hs : convex β s) {f : E β G} (hder : βαΆ y in π[s] x, has_fderiv_within_at f (f' y) s y) | |
(hcont : continuous_within_at f' s x) (K : ββ₯0) (hK : β₯f' xβ₯β < K) : | |
β t β π[s] x, lipschitz_on_with K f t := | |
begin | |
obtain β¨Ξ΅, Ξ΅0, hΞ΅β© : | |
β Ξ΅ > 0, ball x Ξ΅ β© s β {y | has_fderiv_within_at f (f' y) s y β§ β₯f' yβ₯β < K}, | |
from mem_nhds_within_iff.1 (hder.and $ hcont.nnnorm.eventually (gt_mem_nhds hK)), | |
rw inter_comm at hΞ΅, | |
refine β¨s β© ball x Ξ΅, inter_mem_nhds_within _ (ball_mem_nhds _ Ξ΅0), _β©, | |
exact (hs.inter (convex_ball _ _)).lipschitz_on_with_of_nnnorm_has_fderiv_within_le | |
(Ξ» y hy, (hΞ΅ hy).1.mono (inter_subset_left _ _)) (Ξ» y hy, (hΞ΅ hy).2.le) | |
end | |
/-- Let `s` be a convex set in a real normed vector space `E`, let `f : E β G` be a function | |
differentiable within `s` in a neighborhood of `x : E` with derivative `f'`. Suppose that `f'` is | |
continuous within `s` at `x`. Then for any number `K : ββ₯0` larger than `β₯f' xβ₯β`, `f` is Lipschitz | |
on some neighborhood of `x` within `s`. See also | |
`convex.exists_nhds_within_lipschitz_on_with_of_has_fderiv_within_at_of_nnnorm_lt` for a version | |
with an explicit estimate on the Lipschitz constant. -/ | |
lemma exists_nhds_within_lipschitz_on_with_of_has_fderiv_within_at | |
(hs : convex β s) {f : E β G} (hder : βαΆ y in π[s] x, has_fderiv_within_at f (f' y) s y) | |
(hcont : continuous_within_at f' s x) : | |
β K (t β π[s] x), lipschitz_on_with K f t := | |
(exists_gt _).imp $ | |
hs.exists_nhds_within_lipschitz_on_with_of_has_fderiv_within_at_of_nnnorm_lt hder hcont | |
/-- The mean value theorem on a convex set: if the derivative of a function within this set is | |
bounded by `C`, then the function is `C`-Lipschitz. Version with `fderiv_within`. -/ | |
theorem norm_image_sub_le_of_norm_fderiv_within_le | |
(hf : differentiable_on π f s) (bound : βxβs, β₯fderiv_within π f s xβ₯ β€ C) | |
(hs : convex β s) (xs : x β s) (ys : y β s) : β₯f y - f xβ₯ β€ C * β₯y - xβ₯ := | |
hs.norm_image_sub_le_of_norm_has_fderiv_within_le (Ξ» x hx, (hf x hx).has_fderiv_within_at) | |
bound xs ys | |
/-- The mean value theorem on a convex set: if the derivative of a function is bounded by `C` on | |
`s`, then the function is `C`-Lipschitz on `s`. Version with `fderiv_within` and | |
`lipschitz_on_with`. -/ | |
theorem lipschitz_on_with_of_nnnorm_fderiv_within_le {C : ββ₯0} | |
(hf : differentiable_on π f s) (bound : β x β s, β₯fderiv_within π f s xβ₯β β€ C) | |
(hs : convex β s) : lipschitz_on_with C f s:= | |
hs.lipschitz_on_with_of_nnnorm_has_fderiv_within_le (Ξ» x hx, (hf x hx).has_fderiv_within_at) bound | |
/-- The mean value theorem on a convex set: if the derivative of a function is bounded by `C`, | |
then the function is `C`-Lipschitz. Version with `fderiv`. -/ | |
theorem norm_image_sub_le_of_norm_fderiv_le | |
(hf : β x β s, differentiable_at π f x) (bound : βxβs, β₯fderiv π f xβ₯ β€ C) | |
(hs : convex β s) (xs : x β s) (ys : y β s) : β₯f y - f xβ₯ β€ C * β₯y - xβ₯ := | |
hs.norm_image_sub_le_of_norm_has_fderiv_within_le | |
(Ξ» x hx, (hf x hx).has_fderiv_at.has_fderiv_within_at) bound xs ys | |
/-- The mean value theorem on a convex set: if the derivative of a function is bounded by `C` on | |
`s`, then the function is `C`-Lipschitz on `s`. Version with `fderiv` and `lipschitz_on_with`. -/ | |
theorem lipschitz_on_with_of_nnnorm_fderiv_le {C : ββ₯0} | |
(hf : β x β s, differentiable_at π f x) (bound : βxβs, β₯fderiv π f xβ₯β β€ C) | |
(hs : convex β s) : lipschitz_on_with C f s := | |
hs.lipschitz_on_with_of_nnnorm_has_fderiv_within_le | |
(Ξ» x hx, (hf x hx).has_fderiv_at.has_fderiv_within_at) bound | |
/-- Variant of the mean value inequality on a convex set, using a bound on the difference between | |
the derivative and a fixed linear map, rather than a bound on the derivative itself. Version with | |
`has_fderiv_within`. -/ | |
theorem norm_image_sub_le_of_norm_has_fderiv_within_le' | |
(hf : β x β s, has_fderiv_within_at f (f' x) s x) (bound : βxβs, β₯f' x - Οβ₯ β€ C) | |
(hs : convex β s) (xs : x β s) (ys : y β s) : β₯f y - f x - Ο (y - x)β₯ β€ C * β₯y - xβ₯ := | |
begin | |
/- We subtract `Ο` to define a new function `g` for which `g' = 0`, for which the previous theorem | |
applies, `convex.norm_image_sub_le_of_norm_has_fderiv_within_le`. Then, we just need to glue | |
together the pieces, expressing back `f` in terms of `g`. -/ | |
let g := Ξ»y, f y - Ο y, | |
have hg : β x β s, has_fderiv_within_at g (f' x - Ο) s x := | |
Ξ» x xs, (hf x xs).sub Ο.has_fderiv_within_at, | |
calc β₯f y - f x - Ο (y - x)β₯ = β₯f y - f x - (Ο y - Ο x)β₯ : by simp | |
... = β₯(f y - Ο y) - (f x - Ο x)β₯ : by abel | |
... = β₯g y - g xβ₯ : by simp | |
... β€ C * β₯y - xβ₯ : convex.norm_image_sub_le_of_norm_has_fderiv_within_le hg bound hs xs ys, | |
end | |
/-- Variant of the mean value inequality on a convex set. Version with `fderiv_within`. -/ | |
theorem norm_image_sub_le_of_norm_fderiv_within_le' | |
(hf : differentiable_on π f s) (bound : βxβs, β₯fderiv_within π f s x - Οβ₯ β€ C) | |
(hs : convex β s) (xs : x β s) (ys : y β s) : β₯f y - f x - Ο (y - x)β₯ β€ C * β₯y - xβ₯ := | |
hs.norm_image_sub_le_of_norm_has_fderiv_within_le' (Ξ» x hx, (hf x hx).has_fderiv_within_at) | |
bound xs ys | |
/-- Variant of the mean value inequality on a convex set. Version with `fderiv`. -/ | |
theorem norm_image_sub_le_of_norm_fderiv_le' | |
(hf : β x β s, differentiable_at π f x) (bound : βxβs, β₯fderiv π f x - Οβ₯ β€ C) | |
(hs : convex β s) (xs : x β s) (ys : y β s) : β₯f y - f x - Ο (y - x)β₯ β€ C * β₯y - xβ₯ := | |
hs.norm_image_sub_le_of_norm_has_fderiv_within_le' | |
(Ξ» x hx, (hf x hx).has_fderiv_at.has_fderiv_within_at) bound xs ys | |
/-- If a function has zero FrΓ©chet derivative at every point of a convex set, | |
then it is a constant on this set. -/ | |
theorem is_const_of_fderiv_within_eq_zero (hs : convex β s) (hf : differentiable_on π f s) | |
(hf' : β x β s, fderiv_within π f s x = 0) (hx : x β s) (hy : y β s) : | |
f x = f y := | |
have bound : β x β s, β₯fderiv_within π f s xβ₯ β€ 0, | |
from Ξ» x hx, by simp only [hf' x hx, norm_zero], | |
by simpa only [(dist_eq_norm _ _).symm, zero_mul, dist_le_zero, eq_comm] | |
using hs.norm_image_sub_le_of_norm_fderiv_within_le hf bound hx hy | |
theorem _root_.is_const_of_fderiv_eq_zero (hf : differentiable π f) (hf' : β x, fderiv π f x = 0) | |
(x y : E) : | |
f x = f y := | |
convex_univ.is_const_of_fderiv_within_eq_zero hf.differentiable_on | |
(Ξ» x _, by rw fderiv_within_univ; exact hf' x) trivial trivial | |
end convex | |
namespace convex | |
variables {f f' : π β G} {s : set π} {x y : π} | |
/-- The mean value theorem on a convex set in dimension 1: if the derivative of a function is | |
bounded by `C`, then the function is `C`-Lipschitz. Version with `has_deriv_within`. -/ | |
theorem norm_image_sub_le_of_norm_has_deriv_within_le {C : β} | |
(hf : β x β s, has_deriv_within_at f (f' x) s x) (bound : βxβs, β₯f' xβ₯ β€ C) | |
(hs : convex β s) (xs : x β s) (ys : y β s) : β₯f y - f xβ₯ β€ C * β₯y - xβ₯ := | |
convex.norm_image_sub_le_of_norm_has_fderiv_within_le (Ξ» x hx, (hf x hx).has_fderiv_within_at) | |
(Ξ» x hx, le_trans (by simp) (bound x hx)) hs xs ys | |
/-- The mean value theorem on a convex set in dimension 1: if the derivative of a function is | |
bounded by `C` on `s`, then the function is `C`-Lipschitz on `s`. | |
Version with `has_deriv_within` and `lipschitz_on_with`. -/ | |
theorem lipschitz_on_with_of_nnnorm_has_deriv_within_le {C : ββ₯0} (hs : convex β s) | |
(hf : β x β s, has_deriv_within_at f (f' x) s x) (bound : βxβs, β₯f' xβ₯β β€ C) : | |
lipschitz_on_with C f s := | |
convex.lipschitz_on_with_of_nnnorm_has_fderiv_within_le (Ξ» x hx, (hf x hx).has_fderiv_within_at) | |
(Ξ» x hx, le_trans (by simp) (bound x hx)) hs | |
/-- The mean value theorem on a convex set in dimension 1: if the derivative of a function within | |
this set is bounded by `C`, then the function is `C`-Lipschitz. Version with `deriv_within` -/ | |
theorem norm_image_sub_le_of_norm_deriv_within_le {C : β} | |
(hf : differentiable_on π f s) (bound : βxβs, β₯deriv_within f s xβ₯ β€ C) | |
(hs : convex β s) (xs : x β s) (ys : y β s) : β₯f y - f xβ₯ β€ C * β₯y - xβ₯ := | |
hs.norm_image_sub_le_of_norm_has_deriv_within_le (Ξ» x hx, (hf x hx).has_deriv_within_at) | |
bound xs ys | |
/-- The mean value theorem on a convex set in dimension 1: if the derivative of a function is | |
bounded by `C` on `s`, then the function is `C`-Lipschitz on `s`. | |
Version with `deriv_within` and `lipschitz_on_with`. -/ | |
theorem lipschitz_on_with_of_nnnorm_deriv_within_le {C : ββ₯0} (hs : convex β s) | |
(hf : differentiable_on π f s) (bound : βxβs, β₯deriv_within f s xβ₯β β€ C) : | |
lipschitz_on_with C f s := | |
hs.lipschitz_on_with_of_nnnorm_has_deriv_within_le (Ξ» x hx, (hf x hx).has_deriv_within_at) bound | |
/-- The mean value theorem on a convex set in dimension 1: if the derivative of a function is | |
bounded by `C`, then the function is `C`-Lipschitz. Version with `deriv`. -/ | |
theorem norm_image_sub_le_of_norm_deriv_le {C : β} | |
(hf : β x β s, differentiable_at π f x) (bound : βxβs, β₯deriv f xβ₯ β€ C) | |
(hs : convex β s) (xs : x β s) (ys : y β s) : β₯f y - f xβ₯ β€ C * β₯y - xβ₯ := | |
hs.norm_image_sub_le_of_norm_has_deriv_within_le | |
(Ξ» x hx, (hf x hx).has_deriv_at.has_deriv_within_at) bound xs ys | |
/-- The mean value theorem on a convex set in dimension 1: if the derivative of a function is | |
bounded by `C` on `s`, then the function is `C`-Lipschitz on `s`. | |
Version with `deriv` and `lipschitz_on_with`. -/ | |
theorem lipschitz_on_with_of_nnnorm_deriv_le {C : ββ₯0} | |
(hf : β x β s, differentiable_at π f x) (bound : βxβs, β₯deriv f xβ₯β β€ C) | |
(hs : convex β s) : lipschitz_on_with C f s := | |
hs.lipschitz_on_with_of_nnnorm_has_deriv_within_le | |
(Ξ» x hx, (hf x hx).has_deriv_at.has_deriv_within_at) bound | |
/-- The mean value theorem set in dimension 1: if the derivative of a function is bounded by `C`, | |
then the function is `C`-Lipschitz. Version with `deriv` and `lipschitz_with`. -/ | |
theorem _root_.lipschitz_with_of_nnnorm_deriv_le {C : ββ₯0} (hf : differentiable π f) | |
(bound : β x, β₯deriv f xβ₯β β€ C) : lipschitz_with C f := | |
lipschitz_on_univ.1 $ convex_univ.lipschitz_on_with_of_nnnorm_deriv_le (Ξ» x hx, hf x) | |
(Ξ» x hx, bound x) | |
/-- If `f : π β G`, `π = R` or `π = β`, is differentiable everywhere and its derivative equal zero, | |
then it is a constant function. -/ | |
theorem _root_.is_const_of_deriv_eq_zero (hf : differentiable π f) (hf' : β x, deriv f x = 0) | |
(x y : π) : | |
f x = f y := | |
is_const_of_fderiv_eq_zero hf (Ξ» z, by { ext, simp [β deriv_fderiv, hf'] }) _ _ | |
end convex | |
end | |
/-! ### Functions `[a, b] β β`. -/ | |
section interval | |
-- Declare all variables here to make sure they come in a correct order | |
variables (f f' : β β β) {a b : β} (hab : a < b) (hfc : continuous_on f (Icc a b)) | |
(hff' : β x β Ioo a b, has_deriv_at f (f' x) x) (hfd : differentiable_on β f (Ioo a b)) | |
(g g' : β β β) (hgc : continuous_on g (Icc a b)) (hgg' : β x β Ioo a b, has_deriv_at g (g' x) x) | |
(hgd : differentiable_on β g (Ioo a b)) | |
include hab hfc hff' hgc hgg' | |
/-- Cauchy's **Mean Value Theorem**, `has_deriv_at` version. -/ | |
lemma exists_ratio_has_deriv_at_eq_ratio_slope : | |
β c β Ioo a b, (g b - g a) * f' c = (f b - f a) * g' c := | |
begin | |
let h := Ξ» x, (g b - g a) * f x - (f b - f a) * g x, | |
have hI : h a = h b, | |
{ simp only [h], ring }, | |
let h' := Ξ» x, (g b - g a) * f' x - (f b - f a) * g' x, | |
have hhh' : β x β Ioo a b, has_deriv_at h (h' x) x, | |
from Ξ» x hx, ((hff' x hx).const_mul (g b - g a)).sub ((hgg' x hx).const_mul (f b - f a)), | |
have hhc : continuous_on h (Icc a b), | |
from (continuous_on_const.mul hfc).sub (continuous_on_const.mul hgc), | |
rcases exists_has_deriv_at_eq_zero h h' hab hhc hI hhh' with β¨c, cmem, hcβ©, | |
exact β¨c, cmem, sub_eq_zero.1 hcβ© | |
end | |
omit hfc hgc | |
/-- Cauchy's **Mean Value Theorem**, extended `has_deriv_at` version. -/ | |
lemma exists_ratio_has_deriv_at_eq_ratio_slope' {lfa lga lfb lgb : β} | |
(hff' : β x β Ioo a b, has_deriv_at f (f' x) x) (hgg' : β x β Ioo a b, has_deriv_at g (g' x) x) | |
(hfa : tendsto f (π[>] a) (π lfa)) (hga : tendsto g (π[>] a) (π lga)) | |
(hfb : tendsto f (π[<] b) (π lfb)) (hgb : tendsto g (π[<] b) (π lgb)) : | |
β c β Ioo a b, (lgb - lga) * (f' c) = (lfb - lfa) * (g' c) := | |
begin | |
let h := Ξ» x, (lgb - lga) * f x - (lfb - lfa) * g x, | |
have hha : tendsto h (π[>] a) (π $ lgb * lfa - lfb * lga), | |
{ have : tendsto h (π[>] a)(π $ (lgb - lga) * lfa - (lfb - lfa) * lga) := | |
(tendsto_const_nhds.mul hfa).sub (tendsto_const_nhds.mul hga), | |
convert this using 2, | |
ring }, | |
have hhb : tendsto h (π[<] b) (π $ lgb * lfa - lfb * lga), | |
{ have : tendsto h (π[<] b)(π $ (lgb - lga) * lfb - (lfb - lfa) * lgb) := | |
(tendsto_const_nhds.mul hfb).sub (tendsto_const_nhds.mul hgb), | |
convert this using 2, | |
ring }, | |
let h' := Ξ» x, (lgb - lga) * f' x - (lfb - lfa) * g' x, | |
have hhh' : β x β Ioo a b, has_deriv_at h (h' x) x, | |
{ intros x hx, | |
exact ((hff' x hx).const_mul _ ).sub (((hgg' x hx)).const_mul _) }, | |
rcases exists_has_deriv_at_eq_zero' hab hha hhb hhh' with β¨c, cmem, hcβ©, | |
exact β¨c, cmem, sub_eq_zero.1 hcβ© | |
end | |
include hfc | |
omit hgg' | |
/-- Lagrange's Mean Value Theorem, `has_deriv_at` version -/ | |
lemma exists_has_deriv_at_eq_slope : β c β Ioo a b, f' c = (f b - f a) / (b - a) := | |
begin | |
rcases exists_ratio_has_deriv_at_eq_ratio_slope f f' hab hfc hff' | |
id 1 continuous_id.continuous_on (Ξ» x hx, has_deriv_at_id x) with β¨c, cmem, hcβ©, | |
use [c, cmem], | |
simp only [_root_.id, pi.one_apply, mul_one] at hc, | |
rw [β hc, mul_div_cancel_left], | |
exact ne_of_gt (sub_pos.2 hab) | |
end | |
omit hff' | |
/-- Cauchy's Mean Value Theorem, `deriv` version. -/ | |
lemma exists_ratio_deriv_eq_ratio_slope : | |
β c β Ioo a b, (g b - g a) * (deriv f c) = (f b - f a) * (deriv g c) := | |
exists_ratio_has_deriv_at_eq_ratio_slope f (deriv f) hab hfc | |
(Ξ» x hx, ((hfd x hx).differentiable_at $ is_open.mem_nhds is_open_Ioo hx).has_deriv_at) | |
g (deriv g) hgc $ | |
Ξ» x hx, ((hgd x hx).differentiable_at $ is_open.mem_nhds is_open_Ioo hx).has_deriv_at | |
omit hfc | |
/-- Cauchy's Mean Value Theorem, extended `deriv` version. -/ | |
lemma exists_ratio_deriv_eq_ratio_slope' {lfa lga lfb lgb : β} | |
(hdf : differentiable_on β f $ Ioo a b) (hdg : differentiable_on β g $ Ioo a b) | |
(hfa : tendsto f (π[>] a) (π lfa)) (hga : tendsto g (π[>] a) (π lga)) | |
(hfb : tendsto f (π[<] b) (π lfb)) (hgb : tendsto g (π[<] b) (π lgb)) : | |
β c β Ioo a b, (lgb - lga) * (deriv f c) = (lfb - lfa) * (deriv g c) := | |
exists_ratio_has_deriv_at_eq_ratio_slope' _ _ hab _ _ | |
(Ξ» x hx, ((hdf x hx).differentiable_at $ Ioo_mem_nhds hx.1 hx.2).has_deriv_at) | |
(Ξ» x hx, ((hdg x hx).differentiable_at $ Ioo_mem_nhds hx.1 hx.2).has_deriv_at) | |
hfa hga hfb hgb | |
/-- Lagrange's **Mean Value Theorem**, `deriv` version. -/ | |
lemma exists_deriv_eq_slope : β c β Ioo a b, deriv f c = (f b - f a) / (b - a) := | |
exists_has_deriv_at_eq_slope f (deriv f) hab hfc | |
(Ξ» x hx, ((hfd x hx).differentiable_at $ is_open.mem_nhds is_open_Ioo hx).has_deriv_at) | |
end interval | |
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` | |
of the real line. If `f` is differentiable on the interior of `D` and `C < f'`, then | |
`f` grows faster than `C * x` on `D`, i.e., `C * (y - x) < f y - f x` whenever `x, y β D`, | |
`x < y`. -/ | |
theorem convex.mul_sub_lt_image_sub_of_lt_deriv {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf' : differentiable_on β f (interior D)) | |
{C} (hf'_gt : β x β interior D, C < deriv f x) : | |
β x y β D, x < y β C * (y - x) < f y - f x := | |
begin | |
assume x hx y hy hxy, | |
have hxyD : Icc x y β D, from hD.ord_connected.out hx hy, | |
have hxyD' : Ioo x y β interior D, | |
from subset_sUnion_of_mem β¨is_open_Ioo, subset.trans Ioo_subset_Icc_self hxyDβ©, | |
obtain β¨a, a_mem, haβ© : β a β Ioo x y, deriv f a = (f y - f x) / (y - x), | |
from exists_deriv_eq_slope f hxy (hf.mono hxyD) (hf'.mono hxyD'), | |
have : C < (f y - f x) / (y - x), by { rw [β ha], exact hf'_gt _ (hxyD' a_mem) }, | |
exact (lt_div_iff (sub_pos.2 hxy)).1 this | |
end | |
/-- Let `f : β β β` be a differentiable function. If `C < f'`, then `f` grows faster than | |
`C * x`, i.e., `C * (y - x) < f y - f x` whenever `x < y`. -/ | |
theorem mul_sub_lt_image_sub_of_lt_deriv {f : β β β} (hf : differentiable β f) | |
{C} (hf'_gt : β x, C < deriv f x) β¦x yβ¦ (hxy : x < y) : | |
C * (y - x) < f y - f x := | |
convex_univ.mul_sub_lt_image_sub_of_lt_deriv hf.continuous.continuous_on hf.differentiable_on | |
(Ξ» x _, hf'_gt x) x trivial y trivial hxy | |
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` | |
of the real line. If `f` is differentiable on the interior of `D` and `C β€ f'`, then | |
`f` grows at least as fast as `C * x` on `D`, i.e., `C * (y - x) β€ f y - f x` whenever `x, y β D`, | |
`x β€ y`. -/ | |
theorem convex.mul_sub_le_image_sub_of_le_deriv {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf' : differentiable_on β f (interior D)) | |
{C} (hf'_ge : β x β interior D, C β€ deriv f x) : | |
β x y β D, x β€ y β C * (y - x) β€ f y - f x := | |
begin | |
assume x hx y hy hxy, | |
cases eq_or_lt_of_le hxy with hxy' hxy', by rw [hxy', sub_self, sub_self, mul_zero], | |
have hxyD : Icc x y β D, from hD.ord_connected.out hx hy, | |
have hxyD' : Ioo x y β interior D, | |
from subset_sUnion_of_mem β¨is_open_Ioo, subset.trans Ioo_subset_Icc_self hxyDβ©, | |
obtain β¨a, a_mem, haβ© : β a β Ioo x y, deriv f a = (f y - f x) / (y - x), | |
from exists_deriv_eq_slope f hxy' (hf.mono hxyD) (hf'.mono hxyD'), | |
have : C β€ (f y - f x) / (y - x), by { rw [β ha], exact hf'_ge _ (hxyD' a_mem) }, | |
exact (le_div_iff (sub_pos.2 hxy')).1 this | |
end | |
/-- Let `f : β β β` be a differentiable function. If `C β€ f'`, then `f` grows at least as fast | |
as `C * x`, i.e., `C * (y - x) β€ f y - f x` whenever `x β€ y`. -/ | |
theorem mul_sub_le_image_sub_of_le_deriv {f : β β β} (hf : differentiable β f) | |
{C} (hf'_ge : β x, C β€ deriv f x) β¦x yβ¦ (hxy : x β€ y) : | |
C * (y - x) β€ f y - f x := | |
convex_univ.mul_sub_le_image_sub_of_le_deriv hf.continuous.continuous_on hf.differentiable_on | |
(Ξ» x _, hf'_ge x) x trivial y trivial hxy | |
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` | |
of the real line. If `f` is differentiable on the interior of `D` and `f' < C`, then | |
`f` grows slower than `C * x` on `D`, i.e., `f y - f x < C * (y - x)` whenever `x, y β D`, | |
`x < y`. -/ | |
theorem convex.image_sub_lt_mul_sub_of_deriv_lt {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf' : differentiable_on β f (interior D)) | |
{C} (lt_hf' : β x β interior D, deriv f x < C) : | |
β x y β D, x < y β f y - f x < C * (y - x) := | |
begin | |
assume x hx y hy hxy, | |
have hf'_gt : β x β interior D, -C < deriv (Ξ» y, -f y) x, | |
{ assume x hx, | |
rw [deriv.neg, neg_lt_neg_iff], | |
exact lt_hf' x hx }, | |
simpa [-neg_lt_neg_iff] | |
using neg_lt_neg (hD.mul_sub_lt_image_sub_of_lt_deriv hf.neg hf'.neg hf'_gt x hx y hy hxy) | |
end | |
/-- Let `f : β β β` be a differentiable function. If `f' < C`, then `f` grows slower than | |
`C * x` on `D`, i.e., `f y - f x < C * (y - x)` whenever `x < y`. -/ | |
theorem image_sub_lt_mul_sub_of_deriv_lt {f : β β β} (hf : differentiable β f) | |
{C} (lt_hf' : β x, deriv f x < C) β¦x yβ¦ (hxy : x < y) : | |
f y - f x < C * (y - x) := | |
convex_univ.image_sub_lt_mul_sub_of_deriv_lt hf.continuous.continuous_on hf.differentiable_on | |
(Ξ» x _, lt_hf' x) x trivial y trivial hxy | |
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` | |
of the real line. If `f` is differentiable on the interior of `D` and `f' β€ C`, then | |
`f` grows at most as fast as `C * x` on `D`, i.e., `f y - f x β€ C * (y - x)` whenever `x, y β D`, | |
`x β€ y`. -/ | |
theorem convex.image_sub_le_mul_sub_of_deriv_le {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf' : differentiable_on β f (interior D)) | |
{C} (le_hf' : β x β interior D, deriv f x β€ C) : | |
β x y β D, x β€ y β f y - f x β€ C * (y - x) := | |
begin | |
assume x hx y hy hxy, | |
have hf'_ge : β x β interior D, -C β€ deriv (Ξ» y, -f y) x, | |
{ assume x hx, | |
rw [deriv.neg, neg_le_neg_iff], | |
exact le_hf' x hx }, | |
simpa [-neg_le_neg_iff] | |
using neg_le_neg (hD.mul_sub_le_image_sub_of_le_deriv hf.neg hf'.neg hf'_ge x hx y hy hxy) | |
end | |
/-- Let `f : β β β` be a differentiable function. If `f' β€ C`, then `f` grows at most as fast | |
as `C * x`, i.e., `f y - f x β€ C * (y - x)` whenever `x β€ y`. -/ | |
theorem image_sub_le_mul_sub_of_deriv_le {f : β β β} (hf : differentiable β f) | |
{C} (le_hf' : β x, deriv f x β€ C) β¦x yβ¦ (hxy : x β€ y) : | |
f y - f x β€ C * (y - x) := | |
convex_univ.image_sub_le_mul_sub_of_deriv_le hf.continuous.continuous_on hf.differentiable_on | |
(Ξ» x _, le_hf' x) x trivial y trivial hxy | |
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` | |
of the real line. If `f` is differentiable on the interior of `D` and `f'` is positive, then | |
`f` is a strictly monotone function on `D`. | |
Note that we don't require differentiability explicitly as it already implied by the derivative | |
being strictly positive. -/ | |
theorem convex.strict_mono_on_of_deriv_pos {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf' : β x β interior D, 0 < deriv f x) : | |
strict_mono_on f D := | |
begin | |
rintro x hx y hy, | |
simpa only [zero_mul, sub_pos] using hD.mul_sub_lt_image_sub_of_lt_deriv hf _ hf' x hx y hy, | |
exact Ξ» z hz, (differentiable_at_of_deriv_ne_zero (hf' z hz).ne').differentiable_within_at, | |
end | |
/-- Let `f : β β β` be a differentiable function. If `f'` is positive, then | |
`f` is a strictly monotone function. | |
Note that we don't require differentiability explicitly as it already implied by the derivative | |
being strictly positive. -/ | |
theorem strict_mono_of_deriv_pos {f : β β β} (hf' : β x, 0 < deriv f x) : strict_mono f := | |
strict_mono_on_univ.1 $ convex_univ.strict_mono_on_of_deriv_pos | |
(Ξ» z _, (differentiable_at_of_deriv_ne_zero (hf' z).ne').differentiable_within_at | |
.continuous_within_at) | |
(Ξ» x _, hf' x) | |
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` | |
of the real line. If `f` is differentiable on the interior of `D` and `f'` is nonnegative, then | |
`f` is a monotone function on `D`. -/ | |
theorem convex.monotone_on_of_deriv_nonneg {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf' : differentiable_on β f (interior D)) | |
(hf'_nonneg : β x β interior D, 0 β€ deriv f x) : | |
monotone_on f D := | |
Ξ» x hx y hy hxy, by simpa only [zero_mul, sub_nonneg] | |
using hD.mul_sub_le_image_sub_of_le_deriv hf hf' hf'_nonneg x hx y hy hxy | |
/-- Let `f : β β β` be a differentiable function. If `f'` is nonnegative, then | |
`f` is a monotone function. -/ | |
theorem monotone_of_deriv_nonneg {f : β β β} (hf : differentiable β f) (hf' : β x, 0 β€ deriv f x) : | |
monotone f := | |
monotone_on_univ.1 $ convex_univ.monotone_on_of_deriv_nonneg hf.continuous.continuous_on | |
hf.differentiable_on (Ξ» x _, hf' x) | |
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` | |
of the real line. If `f` is differentiable on the interior of `D` and `f'` is negative, then | |
`f` is a strictly antitone function on `D`. -/ | |
theorem convex.strict_anti_on_of_deriv_neg {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf' : β x β interior D, deriv f x < 0) : | |
strict_anti_on f D := | |
Ξ» x hx y, by simpa only [zero_mul, sub_lt_zero] | |
using hD.image_sub_lt_mul_sub_of_deriv_lt hf | |
(Ξ» z hz, (differentiable_at_of_deriv_ne_zero (hf' z hz).ne).differentiable_within_at) hf' x hx y | |
/-- Let `f : β β β` be a differentiable function. If `f'` is negative, then | |
`f` is a strictly antitone function. | |
Note that we don't require differentiability explicitly as it already implied by the derivative | |
being strictly negative. -/ | |
theorem strict_anti_of_deriv_neg {f : β β β} (hf' : β x, deriv f x < 0) : | |
strict_anti f := | |
strict_anti_on_univ.1 $ convex_univ.strict_anti_on_of_deriv_neg | |
(Ξ» z _, (differentiable_at_of_deriv_ne_zero (hf' z).ne).differentiable_within_at | |
.continuous_within_at) | |
(Ξ» x _, hf' x) | |
/-- Let `f` be a function continuous on a convex (or, equivalently, connected) subset `D` | |
of the real line. If `f` is differentiable on the interior of `D` and `f'` is nonpositive, then | |
`f` is an antitone function on `D`. -/ | |
theorem convex.antitone_on_of_deriv_nonpos {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf' : differentiable_on β f (interior D)) | |
(hf'_nonpos : β x β interior D, deriv f x β€ 0) : | |
antitone_on f D := | |
Ξ» x hx y hy hxy, by simpa only [zero_mul, sub_nonpos] | |
using hD.image_sub_le_mul_sub_of_deriv_le hf hf' hf'_nonpos x hx y hy hxy | |
/-- Let `f : β β β` be a differentiable function. If `f'` is nonpositive, then | |
`f` is an antitone function. -/ | |
theorem antitone_of_deriv_nonpos {f : β β β} (hf : differentiable β f) (hf' : β x, deriv f x β€ 0) : | |
antitone f := | |
antitone_on_univ.1 $ convex_univ.antitone_on_of_deriv_nonpos hf.continuous.continuous_on | |
hf.differentiable_on (Ξ» x _, hf' x) | |
/-- If a function `f` is continuous on a convex set `D β β`, is differentiable on its interior, | |
and `f'` is monotone on the interior, then `f` is convex on `D`. -/ | |
theorem monotone_on.convex_on_of_deriv {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf' : differentiable_on β f (interior D)) | |
(hf'_mono : monotone_on (deriv f) (interior D)) : | |
convex_on β D f := | |
convex_on_of_slope_mono_adjacent hD | |
begin | |
intros x y z hx hz hxy hyz, | |
-- First we prove some trivial inclusions | |
have hxzD : Icc x z β D, from hD.ord_connected.out hx hz, | |
have hxyD : Icc x y β D, from subset.trans (Icc_subset_Icc_right $ le_of_lt hyz) hxzD, | |
have hxyD' : Ioo x y β interior D, | |
from subset_sUnion_of_mem β¨is_open_Ioo, subset.trans Ioo_subset_Icc_self hxyDβ©, | |
have hyzD : Icc y z β D, from subset.trans (Icc_subset_Icc_left $ le_of_lt hxy) hxzD, | |
have hyzD' : Ioo y z β interior D, | |
from subset_sUnion_of_mem β¨is_open_Ioo, subset.trans Ioo_subset_Icc_self hyzDβ©, | |
-- Then we apply MVT to both `[x, y]` and `[y, z]` | |
obtain β¨a, β¨hxa, hayβ©, haβ© : β a β Ioo x y, deriv f a = (f y - f x) / (y - x), | |
from exists_deriv_eq_slope f hxy (hf.mono hxyD) (hf'.mono hxyD'), | |
obtain β¨b, β¨hyb, hbzβ©, hbβ© : β b β Ioo y z, deriv f b = (f z - f y) / (z - y), | |
from exists_deriv_eq_slope f hyz (hf.mono hyzD) (hf'.mono hyzD'), | |
rw [β ha, β hb], | |
exact hf'_mono (hxyD' β¨hxa, hayβ©) (hyzD' β¨hyb, hbzβ©) (hay.trans hyb).le | |
end | |
/-- If a function `f` is continuous on a convex set `D β β`, is differentiable on its interior, | |
and `f'` is antitone on the interior, then `f` is concave on `D`. -/ | |
theorem antitone_on.concave_on_of_deriv {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf' : differentiable_on β f (interior D)) | |
(h_anti : antitone_on (deriv f) (interior D)) : | |
concave_on β D f := | |
begin | |
have : monotone_on (deriv (-f)) (interior D), | |
{ intros x hx y hy hxy, | |
convert neg_le_neg (h_anti hx hy hxy); | |
convert deriv.neg }, | |
exact neg_convex_on_iff.mp (this.convex_on_of_deriv hD hf.neg hf'.neg), | |
end | |
lemma strict_mono_on.exists_slope_lt_deriv_aux {x y : β} {f : β β β} | |
(hf : continuous_on f (Icc x y)) (hxy : x < y) | |
(hf'_mono : strict_mono_on (deriv f) (Ioo x y)) (h : β w β Ioo x y, deriv f w β 0) : | |
β a β Ioo x y, (f y - f x) / (y - x) < deriv f a := | |
begin | |
have A : differentiable_on β f (Ioo x y), | |
from Ξ» w wmem, (differentiable_at_of_deriv_ne_zero (h w wmem)).differentiable_within_at, | |
obtain β¨a, β¨hxa, hayβ©, haβ© : β a β Ioo x y, deriv f a = (f y - f x) / (y - x), | |
from exists_deriv_eq_slope f hxy hf A, | |
rcases nonempty_Ioo.2 hay with β¨b, β¨hab, hbyβ©β©, | |
refine β¨b, β¨hxa.trans hab, hbyβ©, _β©, | |
rw β ha, | |
exact hf'_mono β¨hxa, hayβ© β¨hxa.trans hab, hbyβ© hab | |
end | |
lemma strict_mono_on.exists_slope_lt_deriv {x y : β} {f : β β β} | |
(hf : continuous_on f (Icc x y)) (hxy : x < y) | |
(hf'_mono : strict_mono_on (deriv f) (Ioo x y)) : | |
β a β Ioo x y, (f y - f x) / (y - x) < deriv f a := | |
begin | |
by_cases h : β w β Ioo x y, deriv f w β 0, | |
{ apply strict_mono_on.exists_slope_lt_deriv_aux hf hxy hf'_mono h }, | |
{ push_neg at h, | |
rcases h with β¨w, β¨hxw, hwyβ©, hwβ©, | |
obtain β¨a, β¨hxa, hawβ©, haβ© : β (a : β) (H : a β Ioo x w), (f w - f x) / (w - x) < deriv f a, | |
{ apply strict_mono_on.exists_slope_lt_deriv_aux _ hxw _ _, | |
{ exact hf.mono (Icc_subset_Icc le_rfl hwy.le) }, | |
{ exact hf'_mono.mono (Ioo_subset_Ioo le_rfl hwy.le) }, | |
{ assume z hz, | |
rw β hw, | |
apply ne_of_lt, | |
exact hf'_mono β¨hz.1, hz.2.trans hwyβ© β¨hxw, hwyβ© hz.2 } }, | |
obtain β¨b, β¨hwb, hbyβ©, hbβ© : β (b : β) (H : b β Ioo w y), (f y - f w) / (y - w) < deriv f b, | |
{ apply strict_mono_on.exists_slope_lt_deriv_aux _ hwy _ _, | |
{ refine hf.mono (Icc_subset_Icc hxw.le le_rfl), }, | |
{ exact hf'_mono.mono (Ioo_subset_Ioo hxw.le le_rfl) }, | |
{ assume z hz, | |
rw β hw, | |
apply ne_of_gt, | |
exact hf'_mono β¨hxw, hwyβ© β¨hxw.trans hz.1, hz.2β© hz.1, } }, | |
refine β¨b, β¨hxw.trans hwb, hbyβ©, _β©, | |
simp only [div_lt_iff, hxy, hxw, hwy, sub_pos] at β’ ha hb, | |
have : deriv f a * (w - x) < deriv f b * (w - x), | |
{ apply mul_lt_mul _ le_rfl (sub_pos.2 hxw) _, | |
{ exact hf'_mono β¨hxa, haw.trans hwyβ© β¨hxw.trans hwb, hbyβ© (haw.trans hwb) }, | |
{ rw β hw, | |
exact (hf'_mono β¨hxw, hwyβ© β¨hxw.trans hwb, hbyβ© hwb).le } }, | |
linarith } | |
end | |
lemma strict_mono_on.exists_deriv_lt_slope_aux {x y : β} {f : β β β} | |
(hf : continuous_on f (Icc x y)) (hxy : x < y) | |
(hf'_mono : strict_mono_on (deriv f) (Ioo x y)) (h : β w β Ioo x y, deriv f w β 0) : | |
β a β Ioo x y, deriv f a < (f y - f x) / (y - x) := | |
begin | |
have A : differentiable_on β f (Ioo x y), | |
from Ξ» w wmem, (differentiable_at_of_deriv_ne_zero (h w wmem)).differentiable_within_at, | |
obtain β¨a, β¨hxa, hayβ©, haβ© : β a β Ioo x y, deriv f a = (f y - f x) / (y - x), | |
from exists_deriv_eq_slope f hxy hf A, | |
rcases nonempty_Ioo.2 hxa with β¨b, β¨hxb, hbaβ©β©, | |
refine β¨b, β¨hxb, hba.trans hayβ©, _β©, | |
rw β ha, | |
exact hf'_mono β¨hxb, hba.trans hayβ© β¨hxa, hayβ© hba | |
end | |
lemma strict_mono_on.exists_deriv_lt_slope {x y : β} {f : β β β} | |
(hf : continuous_on f (Icc x y)) (hxy : x < y) | |
(hf'_mono : strict_mono_on (deriv f) (Ioo x y)) : | |
β a β Ioo x y, deriv f a < (f y - f x) / (y - x) := | |
begin | |
by_cases h : β w β Ioo x y, deriv f w β 0, | |
{ apply strict_mono_on.exists_deriv_lt_slope_aux hf hxy hf'_mono h }, | |
{ push_neg at h, | |
rcases h with β¨w, β¨hxw, hwyβ©, hwβ©, | |
obtain β¨a, β¨hxa, hawβ©, haβ© : β (a : β) (H : a β Ioo x w), deriv f a < (f w - f x) / (w - x), | |
{ apply strict_mono_on.exists_deriv_lt_slope_aux _ hxw _ _, | |
{ exact hf.mono (Icc_subset_Icc le_rfl hwy.le) }, | |
{ exact hf'_mono.mono (Ioo_subset_Ioo le_rfl hwy.le) }, | |
{ assume z hz, | |
rw β hw, | |
apply ne_of_lt, | |
exact hf'_mono β¨hz.1, hz.2.trans hwyβ© β¨hxw, hwyβ© hz.2 } }, | |
obtain β¨b, β¨hwb, hbyβ©, hbβ© : β (b : β) (H : b β Ioo w y), deriv f b < (f y - f w) / (y - w), | |
{ apply strict_mono_on.exists_deriv_lt_slope_aux _ hwy _ _, | |
{ refine hf.mono (Icc_subset_Icc hxw.le le_rfl), }, | |
{ exact hf'_mono.mono (Ioo_subset_Ioo hxw.le le_rfl) }, | |
{ assume z hz, | |
rw β hw, | |
apply ne_of_gt, | |
exact hf'_mono β¨hxw, hwyβ© β¨hxw.trans hz.1, hz.2β© hz.1, } }, | |
refine β¨a, β¨hxa, haw.trans hwyβ©, _β©, | |
simp only [lt_div_iff, hxy, hxw, hwy, sub_pos] at β’ ha hb, | |
have : deriv f a * (y - w) < deriv f b * (y - w), | |
{ apply mul_lt_mul _ le_rfl (sub_pos.2 hwy) _, | |
{ exact hf'_mono β¨hxa, haw.trans hwyβ© β¨hxw.trans hwb, hbyβ© (haw.trans hwb) }, | |
{ rw β hw, | |
exact (hf'_mono β¨hxw, hwyβ© β¨hxw.trans hwb, hbyβ© hwb).le } }, | |
linarith } | |
end | |
/-- If a function `f` is continuous on a convex set `D β β`, and `f'` is strictly monotone on the | |
interior, then `f` is strictly convex on `D`. | |
Note that we don't require differentiability, since it is guaranteed at all but at most | |
one point by the strict monotonicity of `f'`. -/ | |
lemma strict_mono_on.strict_convex_on_of_deriv {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf' : strict_mono_on (deriv f) (interior D)) : | |
strict_convex_on β D f := | |
strict_convex_on_of_slope_strict_mono_adjacent hD | |
begin | |
intros x y z hx hz hxy hyz, | |
-- First we prove some trivial inclusions | |
have hxzD : Icc x z β D, from hD.ord_connected.out hx hz, | |
have hxyD : Icc x y β D, from subset.trans (Icc_subset_Icc_right $ le_of_lt hyz) hxzD, | |
have hxyD' : Ioo x y β interior D, | |
from subset_sUnion_of_mem β¨is_open_Ioo, subset.trans Ioo_subset_Icc_self hxyDβ©, | |
have hyzD : Icc y z β D, from subset.trans (Icc_subset_Icc_left $ le_of_lt hxy) hxzD, | |
have hyzD' : Ioo y z β interior D, | |
from subset_sUnion_of_mem β¨is_open_Ioo, subset.trans Ioo_subset_Icc_self hyzDβ©, | |
-- Then we get points `a` and `b` in each interval `[x, y]` and `[y, z]` where the derivatives | |
-- can be compared to the slopes between `x, y` and `y, z` respectively. | |
obtain β¨a, β¨hxa, hayβ©, haβ© : β a β Ioo x y, (f y - f x) / (y - x) < deriv f a, | |
from strict_mono_on.exists_slope_lt_deriv (hf.mono hxyD) hxy (hf'.mono hxyD'), | |
obtain β¨b, β¨hyb, hbzβ©, hbβ© : β b β Ioo y z, deriv f b < (f z - f y) / (z - y), | |
from strict_mono_on.exists_deriv_lt_slope (hf.mono hyzD) hyz (hf'.mono hyzD'), | |
apply ha.trans (lt_trans _ hb), | |
exact hf' (hxyD' β¨hxa, hayβ©) (hyzD' β¨hyb, hbzβ©) (hay.trans hyb), | |
end | |
/-- If a function `f` is continuous on a convex set `D β β` and `f'` is strictly antitone on the | |
interior, then `f` is strictly concave on `D`. | |
Note that we don't require differentiability, since it is guaranteed at all but at most | |
one point by the strict antitonicity of `f'`. -/ | |
lemma strict_anti_on.strict_concave_on_of_deriv {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (h_anti : strict_anti_on (deriv f) (interior D)) : | |
strict_concave_on β D f := | |
begin | |
have : strict_mono_on (deriv (-f)) (interior D), | |
{ intros x hx y hy hxy, | |
convert neg_lt_neg (h_anti hx hy hxy); | |
convert deriv.neg }, | |
exact neg_strict_convex_on_iff.mp (this.strict_convex_on_of_deriv hD hf.neg), | |
end | |
/-- If a function `f` is differentiable and `f'` is monotone on `β` then `f` is convex. -/ | |
theorem monotone.convex_on_univ_of_deriv {f : β β β} (hf : differentiable β f) | |
(hf'_mono : monotone (deriv f)) : convex_on β univ f := | |
(hf'_mono.monotone_on _).convex_on_of_deriv convex_univ hf.continuous.continuous_on | |
hf.differentiable_on | |
/-- If a function `f` is differentiable and `f'` is antitone on `β` then `f` is concave. -/ | |
theorem antitone.concave_on_univ_of_deriv {f : β β β} (hf : differentiable β f) | |
(hf'_anti : antitone (deriv f)) : concave_on β univ f := | |
(hf'_anti.antitone_on _).concave_on_of_deriv convex_univ hf.continuous.continuous_on | |
hf.differentiable_on | |
/-- If a function `f` is continuous and `f'` is strictly monotone on `β` then `f` is strictly | |
convex. Note that we don't require differentiability, since it is guaranteed at all but at most | |
one point by the strict monotonicity of `f'`. -/ | |
lemma strict_mono.strict_convex_on_univ_of_deriv {f : β β β} (hf : continuous f) | |
(hf'_mono : strict_mono (deriv f)) : strict_convex_on β univ f := | |
(hf'_mono.strict_mono_on _).strict_convex_on_of_deriv convex_univ hf.continuous_on | |
/-- If a function `f` is continuous and `f'` is strictly antitone on `β` then `f` is strictly | |
concave. Note that we don't require differentiability, since it is guaranteed at all but at most | |
one point by the strict antitonicity of `f'`. -/ | |
lemma strict_anti.strict_concave_on_univ_of_deriv {f : β β β} (hf : continuous f) | |
(hf'_anti : strict_anti (deriv f)) : strict_concave_on β univ f := | |
(hf'_anti.strict_anti_on _).strict_concave_on_of_deriv convex_univ hf.continuous_on | |
/-- If a function `f` is continuous on a convex set `D β β`, is twice differentiable on its | |
interior, and `f''` is nonnegative on the interior, then `f` is convex on `D`. -/ | |
theorem convex_on_of_deriv2_nonneg {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf' : differentiable_on β f (interior D)) | |
(hf'' : differentiable_on β (deriv f) (interior D)) | |
(hf''_nonneg : β x β interior D, 0 β€ (deriv^[2] f x)) : | |
convex_on β D f := | |
(hD.interior.monotone_on_of_deriv_nonneg hf''.continuous_on (by rwa interior_interior) | |
$ by rwa interior_interior).convex_on_of_deriv hD hf hf' | |
/-- If a function `f` is continuous on a convex set `D β β`, is twice differentiable on its | |
interior, and `f''` is nonpositive on the interior, then `f` is concave on `D`. -/ | |
theorem concave_on_of_deriv2_nonpos {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf' : differentiable_on β f (interior D)) | |
(hf'' : differentiable_on β (deriv f) (interior D)) | |
(hf''_nonpos : β x β interior D, deriv^[2] f x β€ 0) : | |
concave_on β D f := | |
(hD.interior.antitone_on_of_deriv_nonpos hf''.continuous_on (by rwa interior_interior) | |
$ by rwa interior_interior).concave_on_of_deriv hD hf hf' | |
/-- If a function `f` is continuous on a convex set `D β β` and `f''` is strictly positive on the | |
interior, then `f` is strictly convex on `D`. | |
Note that we don't require twice differentiability explicitly as it is already implied by the second | |
derivative being strictly positive, except at at most one point. -/ | |
lemma strict_convex_on_of_deriv2_pos {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf'' : β x β interior D, 0 < (deriv^[2] f) x) : | |
strict_convex_on β D f := | |
(hD.interior.strict_mono_on_of_deriv_pos (Ξ» z hz, | |
(differentiable_at_of_deriv_ne_zero (hf'' z hz).ne').differentiable_within_at | |
.continuous_within_at) $ by rwa interior_interior).strict_convex_on_of_deriv hD hf | |
/-- If a function `f` is continuous on a convex set `D β β` and `f''` is strictly negative on the | |
interior, then `f` is strictly concave on `D`. | |
Note that we don't require twice differentiability explicitly as it already implied by the second | |
derivative being strictly negative, except at at most one point. -/ | |
lemma strict_concave_on_of_deriv2_neg {D : set β} (hD : convex β D) {f : β β β} | |
(hf : continuous_on f D) (hf'' : β x β interior D, deriv^[2] f x < 0) : | |
strict_concave_on β D f := | |
(hD.interior.strict_anti_on_of_deriv_neg (Ξ» z hz, | |
(differentiable_at_of_deriv_ne_zero (hf'' z hz).ne).differentiable_within_at | |
.continuous_within_at) $ by rwa interior_interior).strict_concave_on_of_deriv hD hf | |
/-- If a function `f` is twice differentiable on a open convex set `D β β` and | |
`f''` is nonnegative on `D`, then `f` is convex on `D`. -/ | |
theorem convex_on_of_deriv2_nonneg' {D : set β} (hD : convex β D) {f : β β β} | |
(hf' : differentiable_on β f D) (hf'' : differentiable_on β (deriv f) D) | |
(hf''_nonneg : β x β D, 0 β€ (deriv^[2] f) x) : convex_on β D f := | |
convex_on_of_deriv2_nonneg hD hf'.continuous_on (hf'.mono interior_subset) | |
(hf''.mono interior_subset) (Ξ» x hx, hf''_nonneg x (interior_subset hx)) | |
/-- If a function `f` is twice differentiable on an open convex set `D β β` and | |
`f''` is nonpositive on `D`, then `f` is concave on `D`. -/ | |
theorem concave_on_of_deriv2_nonpos' {D : set β} (hD : convex β D) {f : β β β} | |
(hf' : differentiable_on β f D) (hf'' : differentiable_on β (deriv f) D) | |
(hf''_nonpos : β x β D, deriv^[2] f x β€ 0) : concave_on β D f := | |
concave_on_of_deriv2_nonpos hD hf'.continuous_on (hf'.mono interior_subset) | |
(hf''.mono interior_subset) (Ξ» x hx, hf''_nonpos x (interior_subset hx)) | |
/-- If a function `f` is continuous on a convex set `D β β` and `f''` is strictly positive on `D`, | |
then `f` is strictly convex on `D`. | |
Note that we don't require twice differentiability explicitly as it is already implied by the second | |
derivative being strictly positive, except at at most one point. -/ | |
lemma strict_convex_on_of_deriv2_pos' {D : set β} (hD : convex β D) | |
{f : β β β} (hf : continuous_on f D) (hf'' : β x β D, 0 < (deriv^[2] f) x) : | |
strict_convex_on β D f := | |
strict_convex_on_of_deriv2_pos hD hf $ Ξ» x hx, hf'' x (interior_subset hx) | |
/-- If a function `f` is continuous on a convex set `D β β` and `f''` is strictly negative on `D`, | |
then `f` is strictly concave on `D`. | |
Note that we don't require twice differentiability explicitly as it is already implied by the second | |
derivative being strictly negative, except at at most one point. -/ | |
lemma strict_concave_on_of_deriv2_neg' {D : set β} (hD : convex β D) | |
{f : β β β} (hf : continuous_on f D) (hf'' : β x β D, deriv^[2] f x < 0) : | |
strict_concave_on β D f := | |
strict_concave_on_of_deriv2_neg hD hf $ Ξ» x hx, hf'' x (interior_subset hx) | |
/-- If a function `f` is twice differentiable on `β`, and `f''` is nonnegative on `β`, | |
then `f` is convex on `β`. -/ | |
theorem convex_on_univ_of_deriv2_nonneg {f : β β β} (hf' : differentiable β f) | |
(hf'' : differentiable β (deriv f)) (hf''_nonneg : β x, 0 β€ (deriv^[2] f) x) : | |
convex_on β univ f := | |
convex_on_of_deriv2_nonneg' convex_univ hf'.differentiable_on | |
hf''.differentiable_on (Ξ» x _, hf''_nonneg x) | |
/-- If a function `f` is twice differentiable on `β`, and `f''` is nonpositive on `β`, | |
then `f` is concave on `β`. -/ | |
theorem concave_on_univ_of_deriv2_nonpos {f : β β β} (hf' : differentiable β f) | |
(hf'' : differentiable β (deriv f)) (hf''_nonpos : β x, deriv^[2] f x β€ 0) : | |
concave_on β univ f := | |
concave_on_of_deriv2_nonpos' convex_univ hf'.differentiable_on | |
hf''.differentiable_on (Ξ» x _, hf''_nonpos x) | |
/-- If a function `f` is continuous on `β`, and `f''` is strictly positive on `β`, | |
then `f` is strictly convex on `β`. | |
Note that we don't require twice differentiability explicitly as it is already implied by the second | |
derivative being strictly positive, except at at most one point. -/ | |
lemma strict_convex_on_univ_of_deriv2_pos {f : β β β} (hf : continuous f) | |
(hf'' : β x, 0 < (deriv^[2] f) x) : | |
strict_convex_on β univ f := | |
strict_convex_on_of_deriv2_pos' convex_univ hf.continuous_on $ Ξ» x _, hf'' x | |
/-- If a function `f` is continuous on `β`, and `f''` is strictly negative on `β`, | |
then `f` is strictly concave on `β`. | |
Note that we don't require twice differentiability explicitly as it is already implied by the second | |
derivative being strictly negative, except at at most one point. -/ | |
lemma strict_concave_on_univ_of_deriv2_neg {f : β β β} (hf : continuous f) | |
(hf'' : β x, deriv^[2] f x < 0) : | |
strict_concave_on β univ f := | |
strict_concave_on_of_deriv2_neg' convex_univ hf.continuous_on $ Ξ» x _, hf'' x | |
/-! ### Functions `f : E β β` -/ | |
/-- Lagrange's Mean Value Theorem, applied to convex domains. -/ | |
theorem domain_mvt | |
{f : E β β} {s : set E} {x y : E} {f' : E β (E βL[β] β)} | |
(hf : β x β s, has_fderiv_within_at f (f' x) s x) (hs : convex β s) (xs : x β s) (ys : y β s) : | |
β z β segment β x y, f y - f x = f' z (y - x) := | |
begin | |
have hIccIoo := @Ioo_subset_Icc_self β _ 0 1, | |
-- parametrize segment | |
set g : β β E := Ξ» t, x + t β’ (y - x), | |
have hseg : β t β Icc (0:β) 1, g t β segment β x y, | |
{ rw segment_eq_image', | |
simp only [mem_image, and_imp, add_right_inj], | |
intros t ht, exact β¨t, ht, rflβ© }, | |
have hseg' : Icc 0 1 β g β»ΒΉ' s, | |
{ rw β image_subset_iff, unfold image, change β _, _, | |
intros z Hz, rw mem_set_of_eq at Hz, rcases Hz with β¨t, Ht, hgtβ©, | |
rw β hgt, exact hs.segment_subset xs ys (hseg t Ht) }, | |
-- derivative of pullback of f under parametrization | |
have hfg: β t β Icc (0:β) 1, has_deriv_within_at (f β g) | |
((f' (g t) : E β β) (y-x)) (Icc (0:β) 1) t, | |
{ intros t Ht, | |
have hg : has_deriv_at g (y-x) t, | |
{ have := ((has_deriv_at_id t).smul_const (y - x)).const_add x, | |
rwa one_smul at this }, | |
exact (hf (g t) $ hseg' Ht).comp_has_deriv_within_at _ hg.has_deriv_within_at hseg' }, | |
-- apply 1-variable mean value theorem to pullback | |
have hMVT : β (t β Ioo (0:β) 1), ((f' (g t) : E β β) (y-x)) = (f (g 1) - f (g 0)) / (1 - 0), | |
{ refine exists_has_deriv_at_eq_slope (f β g) _ (by norm_num) _ _, | |
{ exact Ξ» t Ht, (hfg t Ht).continuous_within_at }, | |
{ exact Ξ» t Ht, (hfg t $ hIccIoo Ht).has_deriv_at (Icc_mem_nhds Ht.1 Ht.2) } }, | |
-- reinterpret on domain | |
rcases hMVT with β¨t, Ht, hMVT'β©, | |
use g t, refine β¨hseg t $ hIccIoo Ht, _β©, | |
simp [g, hMVT'], | |
end | |
section is_R_or_C | |
/-! | |
### Vector-valued functions `f : E β F`. Strict differentiability. | |
A `C^1` function is strictly differentiable, when the field is `β` or `β`. This follows from the | |
mean value inequality on balls, which is a particular case of the above results after restricting | |
the scalars to `β`. Note that it does not make sense to talk of a convex set over `β`, but balls | |
make sense and are enough. Many formulations of the mean value inequality could be generalized to | |
balls over `β` or `β`. For now, we only include the ones that we need. | |
-/ | |
variables {π : Type*} [is_R_or_C π] {G : Type*} [normed_add_comm_group G] [normed_space π G] | |
{H : Type*} [normed_add_comm_group H] [normed_space π H] {f : G β H} {f' : G β G βL[π] H} {x : G} | |
/-- Over the reals or the complexes, a continuously differentiable function is strictly | |
differentiable. -/ | |
lemma has_strict_fderiv_at_of_has_fderiv_at_of_continuous_at | |
(hder : βαΆ y in π x, has_fderiv_at f (f' y) y) (hcont : continuous_at f' x) : | |
has_strict_fderiv_at f (f' x) x := | |
begin | |
-- turn little-o definition of strict_fderiv into an epsilon-delta statement | |
refine is_o_iff.mpr (Ξ» c hc, metric.eventually_nhds_iff_ball.mpr _), | |
-- the correct Ξ΅ is the modulus of continuity of f' | |
rcases metric.mem_nhds_iff.mp (inter_mem hder (hcont $ ball_mem_nhds _ hc)) with β¨Ξ΅, Ξ΅0, hΞ΅β©, | |
refine β¨Ξ΅, Ξ΅0, _β©, | |
-- simplify formulas involving the product E Γ E | |
rintros β¨a, bβ© h, | |
rw [β ball_prod_same, prod_mk_mem_set_prod_eq] at h, | |
-- exploit the choice of Ξ΅ as the modulus of continuity of f' | |
have hf' : β x' β ball x Ξ΅, β₯f' x' - f' xβ₯ β€ c, | |
{ intros x' H', rw β dist_eq_norm, exact le_of_lt (hΞ΅ H').2 }, | |
-- apply mean value theorem | |
letI : normed_space β G := restrict_scalars.normed_space β π G, | |
refine (convex_ball _ _).norm_image_sub_le_of_norm_has_fderiv_within_le' _ hf' h.2 h.1, | |
exact Ξ» y hy, (hΞ΅ hy).1.has_fderiv_within_at | |
end | |
/-- Over the reals or the complexes, a continuously differentiable function is strictly | |
differentiable. -/ | |
lemma has_strict_deriv_at_of_has_deriv_at_of_continuous_at {f f' : π β G} {x : π} | |
(hder : βαΆ y in π x, has_deriv_at f (f' y) y) (hcont : continuous_at f' x) : | |
has_strict_deriv_at f (f' x) x := | |
has_strict_fderiv_at_of_has_fderiv_at_of_continuous_at (hder.mono (Ξ» y hy, hy.has_fderiv_at)) $ | |
(smul_rightL π π G 1).continuous.continuous_at.comp hcont | |
end is_R_or_C | |