-
Notifications
You must be signed in to change notification settings - Fork 251
/
Basic.lean
545 lines (430 loc) Β· 26.3 KB
/
Basic.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
/-
Copyright (c) 2023 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 Mathlib.Analysis.Calculus.Deriv.Comp
import Mathlib.Analysis.Calculus.Deriv.Add
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Slope
/-!
# Line derivatives
We define the line derivative of a function `f : E β F`, at a point `x : E` along a vector `v : E`,
as the element `f' : F` such that `f (x + t β’ v) = f x + t β’ f' + o (t)` as `t` tends to `0` in
the scalar field `π`, if it exists. It is denoted by `lineDeriv π f x v`.
This notion is generally less well behaved than the full FrΓ©chet derivative (for instance, the
composition of functions which are line-differentiable is not line-differentiable in general).
The FrΓ©chet derivative should therefore be favored over this one in general, although the line
derivative may sometimes prove handy.
The line derivative in direction `v` is also called the Gateaux derivative in direction `v`,
although the term "Gateaux derivative" is sometimes reserved for the situation where there is
such a derivative in all directions, for the map `v β¦ lineDeriv π f x v` (which doesn't have to be
linear in general).
## Main definition and results
We mimic the definitions and statements for the FrΓ©chet derivative and the one-dimensional
derivative. We define in particular the following objects:
* `LineDifferentiableWithinAt π f s x v`
* `LineDifferentiableAt π f x v`
* `HasLineDerivWithinAt π f f' s x v`
* `HasLineDerivAt π f s x v`
* `lineDerivWithin π f s x v`
* `lineDeriv π f x v`
and develop about them a basic API inspired by the one for the FrΓ©chet derivative.
We depart from the FrΓ©chet derivative in two places, as the dependence of the following predicates
on the direction would make them barely usable:
* We do not define an analogue of the predicate `UniqueDiffOn`;
* We do not define `LineDifferentiableOn` nor `LineDifferentiable`.
-/
noncomputable section
open scoped Topology Filter ENNReal NNReal
open Filter Asymptotics Set
variable {π : Type*} [NontriviallyNormedField π]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace π F]
section Module
/-!
Results that do not rely on a topological structure on `E`
-/
variable (π)
variable {E : Type*} [AddCommGroup E] [Module π E]
/-- `f` has the derivative `f'` at the point `x` along the direction `v` in the set `s`.
That is, `f (x + t v) = f x + t β’ f' + o (t)` when `t` tends to `0` and `x + t v β s`.
Note that this definition is less well behaved than the total FrΓ©chet derivative, which
should generally be favored over this one. -/
def HasLineDerivWithinAt (f : E β F) (f' : F) (s : Set E) (x : E) (v : E) :=
HasDerivWithinAt (fun t β¦ f (x + t β’ v)) f' ((fun t β¦ x + t β’ v) β»ΒΉ' s) (0 : π)
/-- `f` has the derivative `f'` at the point `x` along the direction `v`.
That is, `f (x + t v) = f x + t β’ f' + o (t)` when `t` tends to `0`.
Note that this definition is less well behaved than the total FrΓ©chet derivative, which
should generally be favored over this one. -/
def HasLineDerivAt (f : E β F) (f' : F) (x : E) (v : E) :=
HasDerivAt (fun t β¦ f (x + t β’ v)) f' (0 : π)
/-- `f` is line-differentiable at the point `x` in the direction `v` in the set `s` if there
exists `f'` such that `f (x + t v) = f x + t β’ f' + o (t)` when `t` tends to `0` and `x + t v β s`.
-/
def LineDifferentiableWithinAt (f : E β F) (s : Set E) (x : E) (v : E) : Prop :=
DifferentiableWithinAt π (fun t β¦ f (x + t β’ v)) ((fun t β¦ x + t β’ v) β»ΒΉ' s) (0 : π)
/-- `f` is line-differentiable at the point `x` in the direction `v` if there
exists `f'` such that `f (x + t v) = f x + t β’ f' + o (t)` when `t` tends to `0`. -/
def LineDifferentiableAt (f : E β F) (x : E) (v : E) : Prop :=
DifferentiableAt π (fun t β¦ f (x + t β’ v)) (0 : π)
/-- Line derivative of `f` at the point `x` in the direction `v` within the set `s`, if it exists.
Zero otherwise.
If the line derivative exists (i.e., `β f', HasLineDerivWithinAt π f f' s x v`), then
`f (x + t v) = f x + t lineDerivWithin π f s x v + o (t)` when `t` tends to `0` and `x + t v β s`.
-/
def lineDerivWithin (f : E β F) (s : Set E) (x : E) (v : E) : F :=
derivWithin (fun t β¦ f (x + t β’ v)) ((fun t β¦ x + t β’ v) β»ΒΉ' s) (0 : π)
/-- Line derivative of `f` at the point `x` in the direction `v`, if it exists. Zero otherwise.
If the line derivative exists (i.e., `β f', HasLineDerivAt π f f' x v`), then
`f (x + t v) = f x + t lineDeriv π f x v + o (t)` when `t` tends to `0`.
-/
def lineDeriv (f : E β F) (x : E) (v : E) : F :=
deriv (fun t β¦ f (x + t β’ v)) (0 : π)
variable {π}
variable {f fβ : E β F} {f' fβ' fβ' : F} {s t : Set E} {x v : E}
lemma HasLineDerivWithinAt.mono (hf : HasLineDerivWithinAt π f f' s x v) (hst : t β s) :
HasLineDerivWithinAt π f f' t x v :=
HasDerivWithinAt.mono hf (preimage_mono hst)
lemma HasLineDerivAt.hasLineDerivWithinAt (hf : HasLineDerivAt π f f' x v) (s : Set E) :
HasLineDerivWithinAt π f f' s x v :=
HasDerivAt.hasDerivWithinAt hf
lemma HasLineDerivWithinAt.lineDifferentiableWithinAt (hf : HasLineDerivWithinAt π f f' s x v) :
LineDifferentiableWithinAt π f s x v :=
HasDerivWithinAt.differentiableWithinAt hf
theorem HasLineDerivAt.lineDifferentiableAt (hf : HasLineDerivAt π f f' x v) :
LineDifferentiableAt π f x v :=
HasDerivAt.differentiableAt hf
theorem LineDifferentiableWithinAt.hasLineDerivWithinAt (h : LineDifferentiableWithinAt π f s x v) :
HasLineDerivWithinAt π f (lineDerivWithin π f s x v) s x v :=
DifferentiableWithinAt.hasDerivWithinAt h
theorem LineDifferentiableAt.hasLineDerivAt (h : LineDifferentiableAt π f x v) :
HasLineDerivAt π f (lineDeriv π f x v) x v :=
DifferentiableAt.hasDerivAt h
@[simp] lemma hasLineDerivWithinAt_univ :
HasLineDerivWithinAt π f f' univ x v β HasLineDerivAt π f f' x v := by
simp only [HasLineDerivWithinAt, HasLineDerivAt, preimage_univ, hasDerivWithinAt_univ]
theorem lineDerivWithin_zero_of_not_lineDifferentiableWithinAt
(h : Β¬LineDifferentiableWithinAt π f s x v) :
lineDerivWithin π f s x v = 0 :=
derivWithin_zero_of_not_differentiableWithinAt h
theorem lineDeriv_zero_of_not_lineDifferentiableAt (h : Β¬LineDifferentiableAt π f x v) :
lineDeriv π f x v = 0 :=
deriv_zero_of_not_differentiableAt h
theorem hasLineDerivAt_iff_isLittleO_nhds_zero :
HasLineDerivAt π f f' x v β
(fun t : π => f (x + t β’ v) - f x - t β’ f') =o[π 0] fun t => t := by
simp only [HasLineDerivAt, hasDerivAt_iff_isLittleO_nhds_zero, zero_add, zero_smul, add_zero]
theorem HasLineDerivAt.unique (hβ : HasLineDerivAt π f fβ' x v) (hβ : HasLineDerivAt π f fβ' x v) :
fβ' = fβ' :=
HasDerivAt.unique hβ hβ
protected theorem HasLineDerivAt.lineDeriv (h : HasLineDerivAt π f f' x v) :
lineDeriv π f x v = f' := by
rw [h.unique h.lineDifferentiableAt.hasLineDerivAt]
theorem lineDifferentiableWithinAt_univ :
LineDifferentiableWithinAt π f univ x v β LineDifferentiableAt π f x v := by
simp only [LineDifferentiableWithinAt, LineDifferentiableAt, preimage_univ,
differentiableWithinAt_univ]
theorem LineDifferentiableAt.lineDifferentiableWithinAt (h : LineDifferentiableAt π f x v) :
LineDifferentiableWithinAt π f s x v :=
(differentiableWithinAt_univ.2 h).mono (subset_univ _)
@[simp]
theorem lineDerivWithin_univ : lineDerivWithin π f univ x v = lineDeriv π f x v := by
simp [lineDerivWithin, lineDeriv]
theorem LineDifferentiableWithinAt.mono (h : LineDifferentiableWithinAt π f t x v) (st : s β t) :
LineDifferentiableWithinAt π f s x v :=
(h.hasLineDerivWithinAt.mono st).lineDifferentiableWithinAt
theorem HasLineDerivWithinAt.congr_mono (h : HasLineDerivWithinAt π f f' s x v) (ht : EqOn fβ f t)
(hx : fβ x = f x) (hβ : t β s) : HasLineDerivWithinAt π fβ f' t x v :=
HasDerivWithinAt.congr_mono h (fun y hy β¦ ht hy) (by simpa using hx) (preimage_mono hβ)
theorem HasLineDerivWithinAt.congr (h : HasLineDerivWithinAt π f f' s x v) (hs : EqOn fβ f s)
(hx : fβ x = f x) : HasLineDerivWithinAt π fβ f' s x v :=
h.congr_mono hs hx (Subset.refl _)
theorem HasLineDerivWithinAt.congr' (h : HasLineDerivWithinAt π f f' s x v)
(hs : EqOn fβ f s) (hx : x β s) :
HasLineDerivWithinAt π fβ f' s x v :=
h.congr hs (hs hx)
theorem LineDifferentiableWithinAt.congr_mono (h : LineDifferentiableWithinAt π f s x v)
(ht : EqOn fβ f t) (hx : fβ x = f x) (hβ : t β s) :
LineDifferentiableWithinAt π fβ t x v :=
(HasLineDerivWithinAt.congr_mono h.hasLineDerivWithinAt ht hx hβ).differentiableWithinAt
theorem LineDifferentiableWithinAt.congr (h : LineDifferentiableWithinAt π f s x v)
(ht : β x β s, fβ x = f x) (hx : fβ x = f x) :
LineDifferentiableWithinAt π fβ s x v :=
LineDifferentiableWithinAt.congr_mono h ht hx (Subset.refl _)
theorem lineDerivWithin_congr (hs : EqOn fβ f s) (hx : fβ x = f x) :
lineDerivWithin π fβ s x v = lineDerivWithin π f s x v :=
derivWithin_congr (fun y hy β¦ hs hy) (by simpa using hx)
theorem lineDerivWithin_congr' (hs : EqOn fβ f s) (hx : x β s) :
lineDerivWithin π fβ s x v = lineDerivWithin π f s x v :=
lineDerivWithin_congr hs (hs hx)
theorem hasLineDerivAt_iff_tendsto_slope_zero :
HasLineDerivAt π f f' x v β
Tendsto (fun (t : π) β¦ tβ»ΒΉ β’ (f (x + t β’ v) - f x)) (π[β ] 0) (π f') := by
simp only [HasLineDerivAt, hasDerivAt_iff_tendsto_slope_zero, zero_add,
zero_smul, add_zero]
alias β¨HasLineDerivAt.tendsto_slope_zero, _β© := hasLineDerivAt_iff_tendsto_slope_zero
theorem HasLineDerivAt.tendsto_slope_zero_right [PartialOrder π] (h : HasLineDerivAt π f f' x v) :
Tendsto (fun (t : π) β¦ tβ»ΒΉ β’ (f (x + t β’ v) - f x)) (π[>] 0) (π f') :=
h.tendsto_slope_zero.mono_left (nhds_right'_le_nhds_ne 0)
theorem HasLineDerivAt.tendsto_slope_zero_left [PartialOrder π] (h : HasLineDerivAt π f f' x v) :
Tendsto (fun (t : π) β¦ tβ»ΒΉ β’ (f (x + t β’ v) - f x)) (π[<] 0) (π f') :=
h.tendsto_slope_zero.mono_left (nhds_left'_le_nhds_ne 0)
end Module
section NormedSpace
/-!
Results that need a normed space structure on `E`
-/
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace π E]
{f fβ fβ : E β F} {f' : F} {s t : Set E} {x v : E} {L : E βL[π] F}
theorem HasLineDerivWithinAt.mono_of_mem
(h : HasLineDerivWithinAt π f f' t x v) (hst : t β π[s] x) :
HasLineDerivWithinAt π f f' s x v := by
apply HasDerivWithinAt.mono_of_mem h
apply ContinuousWithinAt.preimage_mem_nhdsWithin'' _ hst (by simp)
apply Continuous.continuousWithinAt; fun_prop
theorem HasLineDerivWithinAt.hasLineDerivAt
(h : HasLineDerivWithinAt π f f' s x v) (hs : s β π x) :
HasLineDerivAt π f f' x v := by
rw [β hasLineDerivWithinAt_univ]
rw [β nhdsWithin_univ] at hs
exact h.mono_of_mem hs
theorem LineDifferentiableWithinAt.lineDifferentiableAt (h : LineDifferentiableWithinAt π f s x v)
(hs : s β π x) : LineDifferentiableAt π f x v :=
(h.hasLineDerivWithinAt.hasLineDerivAt hs).lineDifferentiableAt
lemma HasFDerivWithinAt.hasLineDerivWithinAt (hf : HasFDerivWithinAt f L s x) (v : E) :
HasLineDerivWithinAt π f (L v) s x v := by
let F := fun (t : π) β¦ x + t β’ v
rw [show x = F (0 : π) by simp [F]] at hf
have A : HasDerivWithinAt F (0 + (1 : π) β’ v) (F β»ΒΉ' s) 0 :=
((hasDerivAt_const (0 : π) x).add ((hasDerivAt_id' (0 : π)).smul_const v)).hasDerivWithinAt
simp only [one_smul, zero_add] at A
exact hf.comp_hasDerivWithinAt (x := (0 : π)) A (mapsTo_preimage F s)
lemma HasFDerivAt.hasLineDerivAt (hf : HasFDerivAt f L x) (v : E) :
HasLineDerivAt π f (L v) x v := by
rw [β hasLineDerivWithinAt_univ]
exact hf.hasFDerivWithinAt.hasLineDerivWithinAt v
lemma DifferentiableAt.lineDeriv_eq_fderiv (hf : DifferentiableAt π f x) :
lineDeriv π f x v = fderiv π f x v :=
(hf.hasFDerivAt.hasLineDerivAt v).lineDeriv
theorem LineDifferentiableWithinAt.mono_of_mem (h : LineDifferentiableWithinAt π f s x v)
(hst : s β π[t] x) : LineDifferentiableWithinAt π f t x v :=
(h.hasLineDerivWithinAt.mono_of_mem hst).lineDifferentiableWithinAt
theorem lineDerivWithin_of_mem_nhds (h : s β π x) :
lineDerivWithin π f s x v = lineDeriv π f x v := by
apply derivWithin_of_mem_nhds
apply (Continuous.continuousAt _).preimage_mem_nhds (by simpa using h)
fun_prop
theorem lineDerivWithin_of_isOpen (hs : IsOpen s) (hx : x β s) :
lineDerivWithin π f s x v = lineDeriv π f x v :=
lineDerivWithin_of_mem_nhds (hs.mem_nhds hx)
theorem hasLineDerivWithinAt_congr_set (h : s =αΆ [π x] t) :
HasLineDerivWithinAt π f f' s x v β HasLineDerivWithinAt π f f' t x v := by
apply hasDerivWithinAt_congr_set
let F := fun (t : π) β¦ x + t β’ v
have B : ContinuousAt F 0 := by apply Continuous.continuousAt; fun_prop
have : s =αΆ [π (F 0)] t := by convert h; simp [F]
exact B.preimage_mem_nhds this
theorem lineDifferentiableWithinAt_congr_set (h : s =αΆ [π x] t) :
LineDifferentiableWithinAt π f s x v β LineDifferentiableWithinAt π f t x v :=
β¨fun h' β¦ ((hasLineDerivWithinAt_congr_set h).1
h'.hasLineDerivWithinAt).lineDifferentiableWithinAt,
fun h' β¦ ((hasLineDerivWithinAt_congr_set h.symm).1
h'.hasLineDerivWithinAt).lineDifferentiableWithinAtβ©
theorem lineDerivWithin_congr_set (h : s =αΆ [π x] t) :
lineDerivWithin π f s x v = lineDerivWithin π f t x v := by
apply derivWithin_congr_set
let F := fun (t : π) β¦ x + t β’ v
have B : ContinuousAt F 0 := by apply Continuous.continuousAt; fun_prop
have : s =αΆ [π (F 0)] t := by convert h; simp [F]
exact B.preimage_mem_nhds this
theorem Filter.EventuallyEq.hasLineDerivAt_iff (h : fβ =αΆ [π x] fβ) :
HasLineDerivAt π fβ f' x v β HasLineDerivAt π fβ f' x v := by
apply hasDerivAt_iff
let F := fun (t : π) β¦ x + t β’ v
have B : ContinuousAt F 0 := by apply Continuous.continuousAt; fun_prop
have : fβ =αΆ [π (F 0)] fβ := by convert h; simp [F]
exact B.preimage_mem_nhds this
theorem Filter.EventuallyEq.lineDifferentiableAt_iff (h : fβ =αΆ [π x] fβ) :
LineDifferentiableAt π fβ x v β LineDifferentiableAt π fβ x v :=
β¨fun h' β¦ (h.hasLineDerivAt_iff.1 h'.hasLineDerivAt).lineDifferentiableAt,
fun h' β¦ (h.hasLineDerivAt_iff.2 h'.hasLineDerivAt).lineDifferentiableAtβ©
theorem Filter.EventuallyEq.hasLineDerivWithinAt_iff (h : fβ =αΆ [π[s] x] fβ) (hx : fβ x = fβ x) :
HasLineDerivWithinAt π fβ f' s x v β HasLineDerivWithinAt π fβ f' s x v := by
apply hasDerivWithinAt_iff
Β· have A : Continuous (fun (t : π) β¦ x + t β’ v) := by fun_prop
exact A.continuousWithinAt.preimage_mem_nhdsWithin'' h (by simp)
Β· simpa using hx
theorem Filter.EventuallyEq.hasLineDerivWithinAt_iff_of_mem (h : fβ =αΆ [π[s] x] fβ) (hx : x β s) :
HasLineDerivWithinAt π fβ f' s x v β HasLineDerivWithinAt π fβ f' s x v :=
h.hasLineDerivWithinAt_iff (h.eq_of_nhdsWithin hx)
theorem Filter.EventuallyEq.lineDifferentiableWithinAt_iff
(h : fβ =αΆ [π[s] x] fβ) (hx : fβ x = fβ x) :
LineDifferentiableWithinAt π fβ s x v β LineDifferentiableWithinAt π fβ s x v :=
β¨fun h' β¦ ((h.hasLineDerivWithinAt_iff hx).1 h'.hasLineDerivWithinAt).lineDifferentiableWithinAt,
fun h' β¦ ((h.hasLineDerivWithinAt_iff hx).2 h'.hasLineDerivWithinAt).lineDifferentiableWithinAtβ©
theorem Filter.EventuallyEq.lineDifferentiableWithinAt_iff_of_mem
(h : fβ =αΆ [π[s] x] fβ) (hx : x β s) :
LineDifferentiableWithinAt π fβ s x v β LineDifferentiableWithinAt π fβ s x v :=
h.lineDifferentiableWithinAt_iff (h.eq_of_nhdsWithin hx)
lemma HasLineDerivWithinAt.congr_of_eventuallyEq (hf : HasLineDerivWithinAt π f f' s x v)
(h'f : fβ =αΆ [π[s] x] f) (hx : fβ x = f x) : HasLineDerivWithinAt π fβ f' s x v := by
apply HasDerivWithinAt.congr_of_eventuallyEq hf _ (by simp [hx])
have A : Continuous (fun (t : π) β¦ x + t β’ v) := by fun_prop
exact A.continuousWithinAt.preimage_mem_nhdsWithin'' h'f (by simp)
theorem HasLineDerivAt.congr_of_eventuallyEq (h : HasLineDerivAt π f f' x v) (hβ : fβ =αΆ [π x] f) :
HasLineDerivAt π fβ f' x v := by
apply HasDerivAt.congr_of_eventuallyEq h
let F := fun (t : π) β¦ x + t β’ v
rw [show x = F 0 by simp [F]] at hβ
exact (Continuous.continuousAt (by fun_prop)).preimage_mem_nhds hβ
theorem LineDifferentiableWithinAt.congr_of_eventuallyEq (h : LineDifferentiableWithinAt π f s x v)
(hβ : fβ =αΆ [π[s] x] f) (hx : fβ x = f x) : LineDifferentiableWithinAt π fβ s x v :=
(h.hasLineDerivWithinAt.congr_of_eventuallyEq hβ hx).differentiableWithinAt
theorem LineDifferentiableAt.congr_of_eventuallyEq
(h : LineDifferentiableAt π f x v) (hL : fβ =αΆ [π x] f) :
LineDifferentiableAt π fβ x v := by
apply DifferentiableAt.congr_of_eventuallyEq h
let F := fun (t : π) β¦ x + t β’ v
rw [show x = F 0 by simp [F]] at hL
exact (Continuous.continuousAt (by fun_prop)).preimage_mem_nhds hL
theorem Filter.EventuallyEq.lineDerivWithin_eq (hs : fβ =αΆ [π[s] x] f) (hx : fβ x = f x) :
lineDerivWithin π fβ s x v = lineDerivWithin π f s x v := by
apply derivWithin_eq ?_ (by simpa using hx)
have A : Continuous (fun (t : π) β¦ x + t β’ v) := by fun_prop
exact A.continuousWithinAt.preimage_mem_nhdsWithin'' hs (by simp)
theorem Filter.EventuallyEq.lineDerivWithin_eq_nhds (h : fβ =αΆ [π x] f) :
lineDerivWithin π fβ s x v = lineDerivWithin π f s x v :=
(h.filter_mono nhdsWithin_le_nhds).lineDerivWithin_eq h.self_of_nhds
theorem Filter.EventuallyEq.lineDeriv_eq (h : fβ =αΆ [π x] f) :
lineDeriv π fβ x v = lineDeriv π f x v := by
rw [β lineDerivWithin_univ, β lineDerivWithin_univ, h.lineDerivWithin_eq_nhds]
/-- Converse to the mean value inequality: if `f` is line differentiable at `xβ` and `C`-lipschitz
on a neighborhood of `xβ` then its line derivative at `xβ` in the direction `v` has norm
bounded by `C * βvβ`. This version only assumes that `βf x - f xββ β€ C * βx - xββ` in a
neighborhood of `x`. -/
theorem HasLineDerivAt.le_of_lip' {f : E β F} {f' : F} {xβ : E} (hf : HasLineDerivAt π f f' xβ v)
{C : β} (hCβ : 0 β€ C) (hlip : βαΆ x in π xβ, βf x - f xββ β€ C * βx - xββ) :
βf'β β€ C * βvβ := by
apply HasDerivAt.le_of_lip' hf (by positivity)
have A : Continuous (fun (t : π) β¦ xβ + t β’ v) := by fun_prop
have : βαΆ x in π (xβ + (0 : π) β’ v), βf x - f xββ β€ C * βx - xββ := by simpa using hlip
filter_upwards [(A.continuousAt (x := 0)).preimage_mem_nhds this] with t ht
simp only [preimage_setOf_eq, add_sub_cancel_left, norm_smul, mem_setOf_eq, mul_comm (βtβ)] at ht
simpa [mul_assoc] using ht
/-- Converse to the mean value inequality: if `f` is line differentiable at `xβ` and `C`-lipschitz
on a neighborhood of `xβ` then its line derivative at `xβ` in the direction `v` has norm
bounded by `C * βvβ`. This version only assumes that `βf x - f xββ β€ C * βx - xββ` in a
neighborhood of `x`. -/
theorem HasLineDerivAt.le_of_lipschitzOn
{f : E β F} {f' : F} {xβ : E} (hf : HasLineDerivAt π f f' xβ v)
{s : Set E} (hs : s β π xβ) {C : ββ₯0} (hlip : LipschitzOnWith C f s) :
βf'β β€ C * βvβ := by
refine hf.le_of_lip' C.coe_nonneg ?_
filter_upwards [hs] with x hx using hlip.norm_sub_le hx (mem_of_mem_nhds hs)
/-- Converse to the mean value inequality: if `f` is line differentiable at `xβ` and `C`-lipschitz
then its line derivative at `xβ` in the direction `v` has norm bounded by `C * βvβ`. -/
theorem HasLineDerivAt.le_of_lipschitz
{f : E β F} {f' : F} {xβ : E} (hf : HasLineDerivAt π f f' xβ v)
{C : ββ₯0} (hlip : LipschitzWith C f) : βf'β β€ C * βvβ :=
hf.le_of_lipschitzOn univ_mem (lipschitzOn_univ.2 hlip)
variable (π)
/-- Converse to the mean value inequality: if `f` is `C`-lipschitz
on a neighborhood of `xβ` then its line derivative at `xβ` in the direction `v` has norm
bounded by `C * βvβ`. This version only assumes that `βf x - f xββ β€ C * βx - xββ` in a
neighborhood of `x`.
Version using `lineDeriv`. -/
theorem norm_lineDeriv_le_of_lip' {f : E β F} {xβ : E}
{C : β} (hCβ : 0 β€ C) (hlip : βαΆ x in π xβ, βf x - f xββ β€ C * βx - xββ) :
βlineDeriv π f xβ vβ β€ C * βvβ := by
apply norm_deriv_le_of_lip' (by positivity)
have A : Continuous (fun (t : π) β¦ xβ + t β’ v) := by fun_prop
have : βαΆ x in π (xβ + (0 : π) β’ v), βf x - f xββ β€ C * βx - xββ := by simpa using hlip
filter_upwards [(A.continuousAt (x := 0)).preimage_mem_nhds this] with t ht
simp only [preimage_setOf_eq, add_sub_cancel_left, norm_smul, mem_setOf_eq, mul_comm (βtβ)] at ht
simpa [mul_assoc] using ht
/-- Converse to the mean value inequality: if `f` is `C`-lipschitz on a neighborhood of `xβ`
then its line derivative at `xβ` in the direction `v` has norm bounded by `C * βvβ`.
Version using `lineDeriv`. -/
theorem norm_lineDeriv_le_of_lipschitzOn {f : E β F} {xβ : E} {s : Set E} (hs : s β π xβ)
{C : ββ₯0} (hlip : LipschitzOnWith C f s) : βlineDeriv π f xβ vβ β€ C * βvβ := by
refine norm_lineDeriv_le_of_lip' π C.coe_nonneg ?_
filter_upwards [hs] with x hx using hlip.norm_sub_le hx (mem_of_mem_nhds hs)
/-- Converse to the mean value inequality: if `f` is `C`-lipschitz then
its line derivative at `xβ` in the direction `v` has norm bounded by `C * βvβ`.
Version using `lineDeriv`. -/
theorem norm_lineDeriv_le_of_lipschitz {f : E β F} {xβ : E}
{C : ββ₯0} (hlip : LipschitzWith C f) : βlineDeriv π f xβ vβ β€ C * βvβ :=
norm_lineDeriv_le_of_lipschitzOn π univ_mem (lipschitzOn_univ.2 hlip)
variable {π}
end NormedSpace
section Zero
variable {E : Type*} [AddCommGroup E] [Module π E] {f : E β F} {s : Set E} {x : E}
theorem hasLineDerivWithinAt_zero : HasLineDerivWithinAt π f 0 s x 0 := by
simp [HasLineDerivWithinAt, hasDerivWithinAt_const]
theorem hasLineDerivAt_zero : HasLineDerivAt π f 0 x 0 := by
simp [HasLineDerivAt, hasDerivAt_const]
theorem lineDifferentiableWithinAt_zero : LineDifferentiableWithinAt π f s x 0 :=
hasLineDerivWithinAt_zero.lineDifferentiableWithinAt
theorem lineDifferentiableAt_zero : LineDifferentiableAt π f x 0 :=
hasLineDerivAt_zero.lineDifferentiableAt
theorem lineDeriv_zero : lineDeriv π f x 0 = 0 :=
hasLineDerivAt_zero.lineDeriv
end Zero
section CompRight
variable {E : Type*} [AddCommGroup E] [Module π E]
{E' : Type*} [AddCommGroup E'] [Module π E']
{f : E β F} {f' : F} {x v : E'} {L : E' ββ[π] E}
theorem HasLineDerivAt.of_comp {v : E'} (hf : HasLineDerivAt π (f β L) f' x v) :
HasLineDerivAt π f f' (L x) (L v) := by
simpa [HasLineDerivAt] using hf
theorem LineDifferentiableAt.of_comp {v : E'} (hf : LineDifferentiableAt π (f β L) x v) :
LineDifferentiableAt π f (L x) (L v) :=
hf.hasLineDerivAt.of_comp.lineDifferentiableAt
end CompRight
section SMul
variable {E : Type*} [AddCommGroup E] [Module π E] {f : E β F} {s : Set E} {x v : E} {f' : F}
theorem HasLineDerivWithinAt.smul (h : HasLineDerivWithinAt π f f' s x v) (c : π) :
HasLineDerivWithinAt π f (c β’ f') s x (c β’ v) := by
simp only [HasLineDerivWithinAt] at h β’
let g := fun (t : π) β¦ c β’ t
let s' := (fun (t : π) β¦ x + t β’ v) β»ΒΉ' s
have A : HasDerivAt g c 0 := by simpa using (hasDerivAt_id (0 : π)).const_smul c
have B : HasDerivWithinAt (fun t β¦ f (x + t β’ v)) f' s' (g 0) := by simpa [g] using h
have Z := B.scomp (0 : π) A.hasDerivWithinAt (mapsTo_preimage g s')
simp only [g, s', Function.comp, smul_eq_mul, mul_comm c, β smul_smul] at Z
convert Z
ext t
simp [β smul_smul]
theorem hasLineDerivWithinAt_smul_iff {c : π} (hc : c β 0) :
HasLineDerivWithinAt π f (c β’ f') s x (c β’ v) β HasLineDerivWithinAt π f f' s x v :=
β¨fun h β¦ by simpa [smul_smul, inv_mul_cancel hc] using h.smul (c β»ΒΉ), fun h β¦ h.smul cβ©
theorem HasLineDerivAt.smul (h : HasLineDerivAt π f f' x v) (c : π) :
HasLineDerivAt π f (c β’ f') x (c β’ v) := by
simp only [β hasLineDerivWithinAt_univ] at h β’
exact HasLineDerivWithinAt.smul h c
theorem hasLineDerivAt_smul_iff {c : π} (hc : c β 0) :
HasLineDerivAt π f (c β’ f') x (c β’ v) β HasLineDerivAt π f f' x v :=
β¨fun h β¦ by simpa [smul_smul, inv_mul_cancel hc] using h.smul (c β»ΒΉ), fun h β¦ h.smul cβ©
theorem LineDifferentiableWithinAt.smul (h : LineDifferentiableWithinAt π f s x v) (c : π) :
LineDifferentiableWithinAt π f s x (c β’ v) :=
(h.hasLineDerivWithinAt.smul c).lineDifferentiableWithinAt
theorem lineDifferentiableWithinAt_smul_iff {c : π} (hc : c β 0) :
LineDifferentiableWithinAt π f s x (c β’ v) β LineDifferentiableWithinAt π f s x v :=
β¨fun h β¦ by simpa [smul_smul, inv_mul_cancel hc] using h.smul (c β»ΒΉ), fun h β¦ h.smul cβ©
theorem LineDifferentiableAt.smul (h : LineDifferentiableAt π f x v) (c : π) :
LineDifferentiableAt π f x (c β’ v) :=
(h.hasLineDerivAt.smul c).lineDifferentiableAt
theorem lineDifferentiableAt_smul_iff {c : π} (hc : c β 0) :
LineDifferentiableAt π f x (c β’ v) β LineDifferentiableAt π f x v :=
β¨fun h β¦ by simpa [smul_smul, inv_mul_cancel hc] using h.smul (c β»ΒΉ), fun h β¦ h.smul cβ©
theorem lineDeriv_smul {c : π} : lineDeriv π f x (c β’ v) = c β’ lineDeriv π f x v := by
rcases eq_or_ne c 0 with rfl|hc
Β· simp [lineDeriv_zero]
by_cases H : LineDifferentiableAt π f x v
Β· exact (H.hasLineDerivAt.smul c).lineDeriv
Β· have H' : Β¬ (LineDifferentiableAt π f x (c β’ v)) := by
simpa [lineDifferentiableAt_smul_iff hc] using H
simp [lineDeriv_zero_of_not_lineDifferentiableAt, H, H']
theorem lineDeriv_neg : lineDeriv π f x (-v) = - lineDeriv π f x v := by
rw [β neg_one_smul (R := π) v, lineDeriv_smul, neg_one_smul]
end SMul