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 | |
-/ | |
import analysis.calculus.mean_value | |
/-! | |
# Extending differentiability to the boundary | |
We investigate how differentiable functions inside a set extend to differentiable functions | |
on the boundary. For this, it suffices that the function and its derivative admit limits there. | |
A general version of this statement is given in `has_fderiv_at_boundary_of_tendsto_fderiv`. | |
One-dimensional versions, in which one wants to obtain differentiability at the left endpoint or | |
the right endpoint of an interval, are given in | |
`has_deriv_at_interval_left_endpoint_of_tendsto_deriv` and | |
`has_deriv_at_interval_right_endpoint_of_tendsto_deriv`. These versions are formulated in terms | |
of the one-dimensional derivative `deriv β f`. | |
-/ | |
variables {E : Type*} [normed_add_comm_group E] [normed_space β E] | |
{F : Type*} [normed_add_comm_group F] [normed_space β F] | |
open filter set metric continuous_linear_map | |
open_locale topological_space | |
local attribute [mono] prod_mono | |
/-- If a function `f` is differentiable in a convex open set and continuous on its closure, and its | |
derivative converges to a limit `f'` at a point on the boundary, then `f` is differentiable there | |
with derivative `f'`. -/ | |
theorem has_fderiv_at_boundary_of_tendsto_fderiv {f : E β F} {s : set E} {x : E} {f' : E βL[β] F} | |
(f_diff : differentiable_on β f s) (s_conv : convex β s) (s_open : is_open s) | |
(f_cont : βy β closure s, continuous_within_at f s y) | |
(h : tendsto (Ξ»y, fderiv β f y) (π[s] x) (π f')) : | |
has_fderiv_within_at f f' (closure s) x := | |
begin | |
classical, | |
-- one can assume without loss of generality that `x` belongs to the closure of `s`, as the | |
-- statement is empty otherwise | |
by_cases hx : x β closure s, | |
{ rw β closure_closure at hx, exact has_fderiv_within_at_of_not_mem_closure hx }, | |
push_neg at hx, | |
rw [has_fderiv_within_at, has_fderiv_at_filter, asymptotics.is_o_iff], | |
/- One needs to show that `β₯f y - f x - f' (y - x)β₯ β€ Ξ΅ β₯y - xβ₯` for `y` close to `x` in `closure | |
s`, where `Ξ΅` is an arbitrary positive constant. By continuity of the functions, it suffices to | |
prove this for nearby points inside `s`. In a neighborhood of `x`, the derivative of `f` is | |
arbitrarily close to `f'` by assumption. The mean value inequality completes the proof. -/ | |
assume Ξ΅ Ξ΅_pos, | |
obtain β¨Ξ΄, Ξ΄_pos, hΞ΄β© : β Ξ΄ > 0, β y β s, dist y x < Ξ΄ β β₯fderiv β f y - f'β₯ < Ξ΅, | |
by simpa [dist_zero_right] using tendsto_nhds_within_nhds.1 h Ξ΅ Ξ΅_pos, | |
set B := ball x Ξ΄, | |
suffices : β y β B β© (closure s), β₯f y - f x - (f' y - f' x)β₯ β€ Ξ΅ * β₯y - xβ₯, | |
from mem_nhds_within_iff.2 β¨Ξ΄, Ξ΄_pos, Ξ»y hy, by simpa using this y hyβ©, | |
suffices : β p : E Γ E, p β closure ((B β© s) ΓΛ’ (B β© s)) β β₯f p.2 - f p.1 - (f' p.2 - f' p.1)β₯ | |
β€ Ξ΅ * β₯p.2 - p.1β₯, | |
{ rw closure_prod_eq at this, | |
intros y y_in, | |
apply this β¨x, yβ©, | |
have : B β© closure s β closure (B β© s), from closure_inter_open is_open_ball, | |
exact β¨this β¨mem_ball_self Ξ΄_pos, hxβ©, this y_inβ© }, | |
have key : β p : E Γ E, p β (B β© s) ΓΛ’ (B β© s) β β₯f p.2 - f p.1 - (f' p.2 - f' p.1)β₯ | |
β€ Ξ΅ * β₯p.2 - p.1β₯, | |
{ rintros β¨u, vβ© β¨u_in, v_inβ©, | |
have conv : convex β (B β© s) := (convex_ball _ _).inter s_conv, | |
have diff : differentiable_on β f (B β© s) := f_diff.mono (inter_subset_right _ _), | |
have bound : β z β (B β© s), β₯fderiv_within β f (B β© s) z - f'β₯ β€ Ξ΅, | |
{ intros z z_in, | |
convert le_of_lt (hΞ΄ _ z_in.2 z_in.1), | |
have op : is_open (B β© s) := is_open_ball.inter s_open, | |
rw differentiable_at.fderiv_within _ (op.unique_diff_on z z_in), | |
exact (diff z z_in).differentiable_at (is_open.mem_nhds op z_in) }, | |
simpa using conv.norm_image_sub_le_of_norm_fderiv_within_le' diff bound u_in v_in }, | |
rintros β¨u, vβ© uv_in, | |
refine continuous_within_at.closure_le uv_in _ _ key, | |
have f_cont' : βy β closure s, continuous_within_at (f - f') s y, | |
{ intros y y_in, | |
exact tendsto.sub (f_cont y y_in) (f'.cont.continuous_within_at) }, | |
all_goals { -- common start for both continuity proofs | |
have : (B β© s) ΓΛ’ (B β© s) β s ΓΛ’ s, by mono ; exact inter_subset_right _ _, | |
obtain β¨u_in, v_inβ© : u β closure s β§ v β closure s, | |
by simpa [closure_prod_eq] using closure_mono this uv_in, | |
apply continuous_within_at.mono _ this, | |
simp only [continuous_within_at] }, | |
rw nhds_within_prod_eq, | |
{ have : β u v, f v - f u - (f' v - f' u) = f v - f' v - (f u - f' u) := by { intros, abel }, | |
simp only [this], | |
exact tendsto.comp continuous_norm.continuous_at | |
((tendsto.comp (f_cont' v v_in) tendsto_snd).sub $ | |
tendsto.comp (f_cont' u u_in) tendsto_fst) }, | |
{ apply tendsto_nhds_within_of_tendsto_nhds, | |
rw nhds_prod_eq, | |
exact tendsto_const_nhds.mul | |
(tendsto.comp continuous_norm.continuous_at $ tendsto_snd.sub tendsto_fst) }, | |
end | |
/-- If a function is differentiable on the right of a point `a : β`, continuous at `a`, and | |
its derivative also converges at `a`, then `f` is differentiable on the right at `a`. -/ | |
lemma has_deriv_at_interval_left_endpoint_of_tendsto_deriv {s : set β} {e : E} {a : β} {f : β β E} | |
(f_diff : differentiable_on β f s) (f_lim : continuous_within_at f s a) | |
(hs : s β π[>] a) | |
(f_lim' : tendsto (Ξ»x, deriv f x) (π[>] a) (π e)) : | |
has_deriv_within_at f e (Ici a) a := | |
begin | |
/- This is a specialization of `has_fderiv_at_boundary_of_tendsto_fderiv`. To be in the setting of | |
this theorem, we need to work on an open interval with closure contained in `s βͺ {a}`, that we | |
call `t = (a, b)`. Then, we check all the assumptions of this theorem and we apply it. -/ | |
obtain β¨b, ab : a < b, sab : Ioc a b β sβ© := | |
mem_nhds_within_Ioi_iff_exists_Ioc_subset.1 hs, | |
let t := Ioo a b, | |
have ts : t β s := subset.trans Ioo_subset_Ioc_self sab, | |
have t_diff : differentiable_on β f t := f_diff.mono ts, | |
have t_conv : convex β t := convex_Ioo a b, | |
have t_open : is_open t := is_open_Ioo, | |
have t_closure : closure t = Icc a b := closure_Ioo ab.ne, | |
have t_cont : βy β closure t, continuous_within_at f t y, | |
{ rw t_closure, | |
assume y hy, | |
by_cases h : y = a, | |
{ rw h, exact f_lim.mono ts }, | |
{ have : y β s := sab β¨lt_of_le_of_ne hy.1 (ne.symm h), hy.2β©, | |
exact (f_diff.continuous_on y this).mono ts } }, | |
have t_diff' : tendsto (Ξ»x, fderiv β f x) (π[t] a) (π (smul_right 1 e)), | |
{ simp only [deriv_fderiv.symm], | |
exact tendsto.comp | |
(is_bounded_bilinear_map_smul_right : is_bounded_bilinear_map β _) | |
.continuous_right.continuous_at | |
(tendsto_nhds_within_mono_left Ioo_subset_Ioi_self f_lim'), }, | |
-- now we can apply `has_fderiv_at_boundary_of_differentiable` | |
have : has_deriv_within_at f e (Icc a b) a, | |
{ rw [has_deriv_within_at_iff_has_fderiv_within_at, β t_closure], | |
exact has_fderiv_at_boundary_of_tendsto_fderiv t_diff t_conv t_open t_cont t_diff' }, | |
exact this.nhds_within (mem_nhds_within_Ici_iff_exists_Icc_subset.2 β¨b, ab, subset.refl _β©) | |
end | |
/-- If a function is differentiable on the left of a point `a : β`, continuous at `a`, and | |
its derivative also converges at `a`, then `f` is differentiable on the left at `a`. -/ | |
lemma has_deriv_at_interval_right_endpoint_of_tendsto_deriv {s : set β} {e : E} {a : β} {f : β β E} | |
(f_diff : differentiable_on β f s) (f_lim : continuous_within_at f s a) | |
(hs : s β π[<] a) | |
(f_lim' : tendsto (Ξ»x, deriv f x) (π[<] a) (π e)) : | |
has_deriv_within_at f e (Iic a) a := | |
begin | |
/- This is a specialization of `has_fderiv_at_boundary_of_differentiable`. To be in the setting of | |
this theorem, we need to work on an open interval with closure contained in `s βͺ {a}`, that we | |
call `t = (b, a)`. Then, we check all the assumptions of this theorem and we apply it. -/ | |
obtain β¨b, ba, sabβ© : β b β Iio a, Ico b a β s := | |
mem_nhds_within_Iio_iff_exists_Ico_subset.1 hs, | |
let t := Ioo b a, | |
have ts : t β s := subset.trans Ioo_subset_Ico_self sab, | |
have t_diff : differentiable_on β f t := f_diff.mono ts, | |
have t_conv : convex β t := convex_Ioo b a, | |
have t_open : is_open t := is_open_Ioo, | |
have t_closure : closure t = Icc b a := closure_Ioo (ne_of_lt ba), | |
have t_cont : βy β closure t, continuous_within_at f t y, | |
{ rw t_closure, | |
assume y hy, | |
by_cases h : y = a, | |
{ rw h, exact f_lim.mono ts }, | |
{ have : y β s := sab β¨hy.1, lt_of_le_of_ne hy.2 hβ©, | |
exact (f_diff.continuous_on y this).mono ts } }, | |
have t_diff' : tendsto (Ξ»x, fderiv β f x) (π[t] a) (π (smul_right 1 e)), | |
{ simp only [deriv_fderiv.symm], | |
exact tendsto.comp | |
(is_bounded_bilinear_map_smul_right : is_bounded_bilinear_map β _) | |
.continuous_right.continuous_at | |
(tendsto_nhds_within_mono_left Ioo_subset_Iio_self f_lim'), }, | |
-- now we can apply `has_fderiv_at_boundary_of_differentiable` | |
have : has_deriv_within_at f e (Icc b a) a, | |
{ rw [has_deriv_within_at_iff_has_fderiv_within_at, β t_closure], | |
exact has_fderiv_at_boundary_of_tendsto_fderiv t_diff t_conv t_open t_cont t_diff' }, | |
exact this.nhds_within (mem_nhds_within_Iic_iff_exists_Icc_subset.2 β¨b, ba, subset.refl _β©) | |
end | |
/-- If a real function `f` has a derivative `g` everywhere but at a point, and `f` and `g` are | |
continuous at this point, then `g` is also the derivative of `f` at this point. -/ | |
lemma has_deriv_at_of_has_deriv_at_of_ne {f g : β β E} {x : β} | |
(f_diff : β y β x, has_deriv_at f (g y) y) | |
(hf : continuous_at f x) (hg : continuous_at g x) : | |
has_deriv_at f (g x) x := | |
begin | |
have A : has_deriv_within_at f (g x) (Ici x) x, | |
{ have diff : differentiable_on β f (Ioi x) := | |
Ξ»y hy, (f_diff y (ne_of_gt hy)).differentiable_at.differentiable_within_at, | |
-- next line is the nontrivial bit of this proof, appealing to differentiability | |
-- extension results. | |
apply has_deriv_at_interval_left_endpoint_of_tendsto_deriv diff hf.continuous_within_at | |
self_mem_nhds_within, | |
have : tendsto g (π[>] x) (π (g x)) := tendsto_inf_left hg, | |
apply this.congr' _, | |
apply mem_of_superset self_mem_nhds_within (Ξ»y hy, _), | |
exact (f_diff y (ne_of_gt hy)).deriv.symm }, | |
have B : has_deriv_within_at f (g x) (Iic x) x, | |
{ have diff : differentiable_on β f (Iio x) := | |
Ξ»y hy, (f_diff y (ne_of_lt hy)).differentiable_at.differentiable_within_at, | |
-- next line is the nontrivial bit of this proof, appealing to differentiability | |
-- extension results. | |
apply has_deriv_at_interval_right_endpoint_of_tendsto_deriv diff hf.continuous_within_at | |
self_mem_nhds_within, | |
have : tendsto g (π[<] x) (π (g x)) := tendsto_inf_left hg, | |
apply this.congr' _, | |
apply mem_of_superset self_mem_nhds_within (Ξ»y hy, _), | |
exact (f_diff y (ne_of_lt hy)).deriv.symm }, | |
simpa using B.union A | |
end | |
/-- If a real function `f` has a derivative `g` everywhere but at a point, and `f` and `g` are | |
continuous at this point, then `g` is the derivative of `f` everywhere. -/ | |
lemma has_deriv_at_of_has_deriv_at_of_ne' {f g : β β E} {x : β} | |
(f_diff : β y β x, has_deriv_at f (g y) y) | |
(hf : continuous_at f x) (hg : continuous_at g x) (y : β) : | |
has_deriv_at f (g y) y := | |
begin | |
rcases eq_or_ne y x with rfl|hne, | |
{ exact has_deriv_at_of_has_deriv_at_of_ne f_diff hf hg }, | |
{ exact f_diff y hne } | |
end | |