Skip to content

Commit f96e7eb

Browse files
committed
refactor(Analysis/Convex): apply review feedback
Must-fixes (1)–(3): - Add strict 1D additive forms `StrictConvexOn.add_hasDerivAt_mul_lt` and `StrictConcaveOn.lt_add_hasDerivAt_mul` (plus `deriv`-form variants) to `Convex/Deriv.lean`. - Refactor `StrictConvexOn.add_lineDeriv_lt` to use the new strict 1D additive form via `StrictConvexOn.lineRestriction` (drops the brittle midpoint `calc`). - Add `StrictConcaveOn.lt_add_lineDeriv`, `.lt_add_fderiv`, `.lt_add_inner_gradient` (missing concave strict duals across all three layers). - Add `ConvexOn.isMinOn_of_fderiv_eq_zero` (FDeriv-form sibling of the gradient one; needs only `NormedSpace ℝ E`, not Hilbert). - Add `HasLineDerivAt`- and `HasFDerivAt`-flavoured primitive forms for all inequality lemmas; the `lineDeriv` / `fderiv` versions become one-line corollaries via `LineDifferentiableAt.hasLineDerivAt` / `DifferentiableAt.hasFDerivAt`. Should-fixes (4)–(7): - Rename `_sub_apply_nonneg` → `_sub_nonneg` in both LineDeriv and FDeriv; `_apply` was vestigial for the scalar `lineDeriv` and added noise for `fderiv` where the application is visible in the statement. - Drop the LineDeriv-layer iff converse (`convexOn_iff_add_lineDeriv_le`); the FDeriv-layer iff is the canonical statement users want, and its premise `∀ x ∈ s, DifferentiableAt ℝ f x` is easier to instantiate than the pair-quantified line-differentiability of the dropped version. - Reprove `convexOn_iff_add_fderiv_le` directly using `fderiv`-arithmetic (no longer delegating through the dropped LineDeriv iff). - Rewrite Gradient module docstring to lead with "Hilbert space" framing. - Refactor the `▸` chain in `ConvexOn.lineDeriv_sub_nonneg` to a `have` + `rw` block. Bonus: factor out `private lineMap_eq_add_smul_sub` helper.
1 parent c12d5e2 commit f96e7eb

4 files changed

Lines changed: 250 additions & 83 deletions

File tree

Mathlib/Analysis/Convex/Deriv.lean

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,22 @@ lemma deriv_lt_slope (hfc : StrictConvexOn ℝ S f) (hx : x ∈ S) (hy : y ∈ S
790790
deriv f x < slope f x y :=
791791
hfc.lt_slope_of_hasDerivAt hx hy hxy hfd.hasDerivAt
792792

793+
/-- Strict additive form of the 1D first-order convexity inequality: for `f : ℝ → ℝ` strictly
794+
convex on `S`, `x, y ∈ S` with `x < y`, and `f` differentiable at `x`, we have
795+
`f x + f' * (y - x) < f y` where `f' = deriv f x`. -/
796+
lemma add_hasDerivAt_mul_lt (hfc : StrictConvexOn ℝ S f) (hx : x ∈ S) (hy : y ∈ S) (hxy : x < y)
797+
(ha : HasDerivAt f f' x) :
798+
f x + f' * (y - x) < f y := by
799+
have h := hfc.lt_slope_of_hasDerivAt hx hy hxy ha
800+
rw [slope_def_field, lt_div_iff₀ (sub_pos.mpr hxy)] at h
801+
linarith
802+
803+
/-- Reformulation of `StrictConvexOn.add_hasDerivAt_mul_lt` using `deriv`. -/
804+
lemma add_deriv_mul_lt (hfc : StrictConvexOn ℝ S f) (hx : x ∈ S) (hy : y ∈ S) (hxy : x < y)
805+
(hfd : DifferentiableAt ℝ f x) :
806+
f x + deriv f x * (y - x) < f y :=
807+
hfc.add_hasDerivAt_mul_lt hx hy hxy hfd.hasDerivAt
808+
793809
end left
794810

795811
section right
@@ -1024,6 +1040,22 @@ lemma slope_lt_deriv (hfc : StrictConcaveOn ℝ S f) (hx : x ∈ S) (hy : y ∈
10241040
slope f x y < deriv f x :=
10251041
hfc.slope_lt_of_hasDerivAt hx hy hxy hfd.hasDerivAt
10261042

1043+
/-- Strict additive form of the 1D first-order concavity inequality: for `f : ℝ → ℝ` strictly
1044+
concave on `S`, `x, y ∈ S` with `x < y`, and `f` differentiable at `x`, we have
1045+
`f y < f x + f' * (y - x)` where `f' = deriv f x`. -/
1046+
lemma lt_add_hasDerivAt_mul (hfc : StrictConcaveOn ℝ S f) (hx : x ∈ S) (hy : y ∈ S) (hxy : x < y)
1047+
(ha : HasDerivAt f f' x) :
1048+
f y < f x + f' * (y - x) := by
1049+
have h := hfc.slope_lt_of_hasDerivAt hx hy hxy ha
1050+
rw [slope_def_field, div_lt_iff₀ (sub_pos.mpr hxy)] at h
1051+
linarith
1052+
1053+
/-- Reformulation of `StrictConcaveOn.lt_add_hasDerivAt_mul` using `deriv`. -/
1054+
lemma lt_add_deriv_mul (hfc : StrictConcaveOn ℝ S f) (hx : x ∈ S) (hy : y ∈ S) (hxy : x < y)
1055+
(hfd : DifferentiableAt ℝ f x) :
1056+
f y < f x + deriv f x * (y - x) :=
1057+
hfc.lt_add_hasDerivAt_mul hx hy hxy hfd.hasDerivAt
1058+
10271059
end left
10281060

10291061
section right

Mathlib/Analysis/Convex/FDeriv.lean

Lines changed: 85 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@ convexity inequality
1717
`f x + (fderiv ℝ f x) (y - x) ≤ f y`
1818
1919
holds for `y ∈ s`. This is the Fréchet-derivative restatement of the line-derivative form
20-
in `Mathlib.Analysis.Convex.LineDeriv`, lifted via `DifferentiableAt.lineDeriv_eq_fderiv`.
20+
in `Mathlib.Analysis.Convex.LineDeriv`, lifted via `HasFDerivAt.hasLineDerivAt`.
21+
22+
The `HasFDerivAt`-flavoured statements are the primitives; the `fderiv`-flavoured ones are
23+
corollaries under `DifferentiableAt`.
2124
2225
## Main results
2326
24-
* `ConvexOn.add_fderiv_le` — the first-order convexity inequality (Fréchet form).
25-
* `ConcaveOn.le_add_fderiv` — the concave dual.
26-
* `ConvexOn.fderiv_sub_apply_nonneg` — monotonicity: `0 ≤ (fderiv ℝ f y - fderiv ℝ f x) (y - x)`.
27-
* `StrictConvexOn.add_fderiv_lt` — strict variant.
27+
* `ConvexOn.add_hasFDerivAt_le` / `ConvexOn.add_fderiv_le` — the first-order convexity
28+
inequality (Fréchet form).
29+
* `ConcaveOn.le_add_hasFDerivAt` / `ConcaveOn.le_add_fderiv` — the concave dual.
30+
* `ConvexOn.fderiv_sub_nonneg` — monotonicity along the chord:
31+
`0 ≤ (fderiv ℝ f y - fderiv ℝ f x) (y - x)`.
32+
* `StrictConvexOn.add_hasFDerivAt_lt` / `StrictConvexOn.add_fderiv_lt` — strict variant.
33+
* `StrictConcaveOn.lt_add_hasFDerivAt` / `StrictConcaveOn.lt_add_fderiv` — strict concave dual.
34+
* `ConvexOn.isMinOn_of_fderiv_eq_zero` — convex + zero Fréchet derivative at `x` ⟹ `x`
35+
minimises `f`.
2836
* `convexOn_iff_add_fderiv_le` — iff converse: differentiability plus the first-order
2937
inequality everywhere implies `ConvexOn`.
3038
-/
@@ -36,51 +44,114 @@ variable {f : E → ℝ} {s : Set E} {x y : E}
3644

3745
namespace ConvexOn
3846

47+
/-- For a convex function `f` with Fréchet derivative `f'` at `x`, the first-order inequality
48+
`f x + f' (y - x) ≤ f y` holds. -/
49+
theorem add_hasFDerivAt_le (hc : ConvexOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s)
50+
{f' : E →L[ℝ] ℝ} (hf : HasFDerivAt f f' x) :
51+
f x + f' (y - x) ≤ f y :=
52+
hc.add_hasLineDerivAt_le hx hy (hf.hasLineDerivAt _)
53+
3954
/-- For a convex function `f` Fréchet-differentiable at `x`, the first-order inequality
4055
`f x + (fderiv ℝ f x) (y - x) ≤ f y` holds. -/
4156
theorem add_fderiv_le (hc : ConvexOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s)
4257
(hf : DifferentiableAt ℝ f x) :
4358
f x + fderiv ℝ f x (y - x) ≤ f y :=
44-
hf.lineDeriv_eq_fderiv ▸ hc.add_lineDeriv_le hx hy hf.lineDifferentiableAt
59+
hc.add_hasFDerivAt_le hx hy hf.hasFDerivAt
4560

4661
/-- Monotonicity of the Fréchet derivative along the chord: for convex `f` differentiable
4762
at `x` and `y`, `0 ≤ (fderiv ℝ f y - fderiv ℝ f x) (y - x)`. -/
48-
theorem fderiv_sub_apply_nonneg (hc : ConvexOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s)
63+
theorem fderiv_sub_nonneg (hc : ConvexOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s)
4964
(hfx : DifferentiableAt ℝ f x) (hfy : DifferentiableAt ℝ f y) :
5065
0 ≤ (fderiv ℝ f y - fderiv ℝ f x) (y - x) := by
5166
rw [ContinuousLinearMap.sub_apply, ← hfx.lineDeriv_eq_fderiv, ← hfy.lineDeriv_eq_fderiv]
52-
exact hc.lineDeriv_sub_apply_nonneg hx hy hfx.lineDifferentiableAt hfy.lineDifferentiableAt
67+
exact hc.lineDeriv_sub_nonneg hx hy hfx.lineDifferentiableAt hfy.lineDifferentiableAt
68+
69+
/-- A convex function with a vanishing Fréchet derivative at an interior point of differentiability
70+
attains its minimum there. -/
71+
theorem isMinOn_of_fderiv_eq_zero (hc : ConvexOn ℝ s f) (hx : x ∈ s)
72+
(hf : DifferentiableAt ℝ f x) (hgrad : fderiv ℝ f x = 0) :
73+
IsMinOn f s x :=
74+
fun y hy => by simpa [hgrad] using hc.add_fderiv_le hx hy hf
5375

5476
end ConvexOn
5577

5678
namespace ConcaveOn
5779

80+
/-- For a concave function `f` with Fréchet derivative `f'` at `x`, the reverse first-order
81+
inequality `f y ≤ f x + f' (y - x)` holds. -/
82+
theorem le_add_hasFDerivAt (hc : ConcaveOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s)
83+
{f' : E →L[ℝ] ℝ} (hf : HasFDerivAt f f' x) :
84+
f y ≤ f x + f' (y - x) :=
85+
hc.le_add_hasLineDerivAt hx hy (hf.hasLineDerivAt _)
86+
5887
/-- For a concave function `f` Fréchet-differentiable at `x`, the reverse first-order
5988
inequality `f y ≤ f x + (fderiv ℝ f x) (y - x)` holds. -/
6089
theorem le_add_fderiv (hc : ConcaveOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s)
6190
(hf : DifferentiableAt ℝ f x) :
6291
f y ≤ f x + fderiv ℝ f x (y - x) :=
63-
hf.lineDeriv_eq_fderiv ▸ hc.le_add_lineDeriv hx hy hf.lineDifferentiableAt
92+
hc.le_add_hasFDerivAt hx hy hf.hasFDerivAt
6493

6594
end ConcaveOn
6695

6796
namespace StrictConvexOn
6897

98+
/-- Strict variant of the first-order inequality for strictly convex `f` with Fréchet derivative
99+
`f'` at `x`, assuming `x ≠ y`: `f x + f' (y - x) < f y`. -/
100+
theorem add_hasFDerivAt_lt (hc : StrictConvexOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s) (hxy : x ≠ y)
101+
{f' : E →L[ℝ] ℝ} (hf : HasFDerivAt f f' x) :
102+
f x + f' (y - x) < f y :=
103+
hc.add_hasLineDerivAt_lt hx hy hxy (hf.hasLineDerivAt _)
104+
69105
/-- Strict variant of the first-order inequality for strictly convex `f`:
70106
when `x ≠ y`, the inequality is strict. -/
71107
theorem add_fderiv_lt (hc : StrictConvexOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s) (hxy : x ≠ y)
72108
(hf : DifferentiableAt ℝ f x) :
73109
f x + fderiv ℝ f x (y - x) < f y :=
74-
hf.lineDeriv_eq_fderiv ▸ hc.add_lineDeriv_lt hx hy hxy hf.lineDifferentiableAt
110+
hc.add_hasFDerivAt_lt hx hy hxy hf.hasFDerivAt
75111

76112
end StrictConvexOn
77113

114+
namespace StrictConcaveOn
115+
116+
/-- Strict variant of the reverse first-order inequality for strictly concave `f` with Fréchet
117+
derivative `f'` at `x`, assuming `x ≠ y`: `f y < f x + f' (y - x)`. -/
118+
theorem lt_add_hasFDerivAt (hc : StrictConcaveOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s) (hxy : x ≠ y)
119+
{f' : E →L[ℝ] ℝ} (hf : HasFDerivAt f f' x) :
120+
f y < f x + f' (y - x) :=
121+
hc.lt_add_hasLineDerivAt hx hy hxy (hf.hasLineDerivAt _)
122+
123+
/-- Strict variant of the reverse first-order inequality for strictly concave `f`: when `x ≠ y`,
124+
the inequality is strict. -/
125+
theorem lt_add_fderiv (hc : StrictConcaveOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s) (hxy : x ≠ y)
126+
(hf : DifferentiableAt ℝ f x) :
127+
f y < f x + fderiv ℝ f x (y - x) :=
128+
hc.lt_add_hasFDerivAt hx hy hxy hf.hasFDerivAt
129+
130+
end StrictConcaveOn
131+
78132
/-- A differentiable function is convex iff it satisfies the first-order inequality
79133
at every pair of points in `s`. -/
80134
theorem convexOn_iff_add_fderiv_le (hs : Convex ℝ s) (hf : ∀ x ∈ s, DifferentiableAt ℝ f x) :
81135
ConvexOn ℝ s f ↔
82136
∀ x ∈ s, ∀ y ∈ s, f x + fderiv ℝ f x (y - x) ≤ f y := by
83-
rw [convexOn_iff_add_lineDeriv_le hs fun x hx _ _ => (hf x hx).lineDifferentiableAt]
84-
refine forall_congr' fun x => imp_congr_right fun hx => forall_congr' fun _ =>
85-
imp_congr_right fun _ => ?_
86-
rw [(hf x hx).lineDeriv_eq_fderiv]
137+
refine ⟨fun hc x hx y hy => hc.add_fderiv_le hx hy (hf x hx), fun H => ⟨hs, ?_⟩⟩
138+
intro x hx y hy a b ha hb hab
139+
set z := a • x + b • y with hz
140+
set L := fderiv ℝ f z (x - y) with hL
141+
change f z ≤ a • f x + b • f y
142+
simp only [smul_eq_mul]
143+
have hzs : z ∈ s := hs hx hy ha hb hab
144+
have hb_eq : b = 1 - a := by linarith
145+
have hxz : x - z = b • (x - y) := by rw [hz, hb_eq]; module
146+
have hyz : y - z = -(a • (x - y)) := by rw [hz, hb_eq]; module
147+
have hzx : f z + b * L ≤ f x := by
148+
have h := H z hzs x hx
149+
rwa [hxz, (fderiv ℝ f z).map_smul, smul_eq_mul] at h
150+
have hzy : f z - a * L ≤ f y := by
151+
have h := H z hzs y hy
152+
rw [hyz, map_neg, (fderiv ℝ f z).map_smul, smul_eq_mul] at h
153+
linarith
154+
calc f z
155+
= a * (f z + b * L) + b * (f z - a * L) := by linear_combination (f z) * hab.symm
156+
_ ≤ a * f x + b * f y :=
157+
add_le_add (mul_le_mul_of_nonneg_left hzx ha) (mul_le_mul_of_nonneg_left hzy hb)

Mathlib/Analysis/Convex/Gradient.lean

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,24 @@ public import Mathlib.Analysis.Calculus.Gradient.Basic
1111
/-!
1212
# First-order convexity inequality via the gradient
1313
14-
For `f : F → ℝ` convex on `s ⊆ F` on a Hilbert space and differentiable at `x ∈ s`,
14+
On a Hilbert space `F`, for `f : F → ℝ` convex on `s ⊆ F` and differentiable at `x ∈ s`,
1515
the first-order convexity inequality
1616
1717
`f x + ⟪∇ f x, y - x⟫ ≤ f y`
1818
1919
holds for `y ∈ s`. This is the gradient/inner-product restatement of the Fréchet form
20-
in `Mathlib.Analysis.Convex.FDeriv`, lifted via `inner_gradient_left`.
20+
in `Mathlib.Analysis.Convex.FDeriv`, lifted via Riesz representation
21+
(`inner_gradient_left`).
2122
2223
## Main results
2324
2425
* `ConvexOn.add_inner_gradient_le` — the first-order convexity inequality (gradient form).
2526
* `ConcaveOn.le_add_inner_gradient` — the concave dual.
26-
* `ConvexOn.inner_gradient_sub_nonneg` — monotonicity: `0 ≤ ⟪∇ f y - ∇ f x, y - x⟫`.
27-
* `ConvexOn.isMinOn_of_gradient_eq_zero` — convex + zero gradient at `x` ⟹ `x` minimizes `f`.
27+
* `ConvexOn.inner_gradient_sub_nonneg` — monotonicity along the chord:
28+
`0 ≤ ⟪∇ f y - ∇ f x, y - x⟫`.
29+
* `ConvexOn.isMinOn_of_gradient_eq_zero` — convex + zero gradient at `x` ⟹ `x` minimises `f`.
2830
* `StrictConvexOn.add_inner_gradient_lt` — strict variant.
31+
* `StrictConcaveOn.lt_add_inner_gradient` — strict concave dual.
2932
* `convexOn_iff_add_inner_gradient_le` — iff converse.
3033
-/
3134

@@ -54,7 +57,7 @@ theorem inner_gradient_sub_nonneg (hc : ConvexOn ℝ s f) (hx : x ∈ s) (hy : y
5457
0 ≤ ⟪∇ f y - ∇ f x, y - x⟫ := by
5558
rw [inner_sub_left, inner_gradient_left, inner_gradient_left,
5659
← ContinuousLinearMap.sub_apply]
57-
exact hc.fderiv_sub_apply_nonneg hx hy hfx hfy
60+
exact hc.fderiv_sub_nonneg hx hy hfx hfy
5861

5962
/-- A convex function attains its minimum on `s` at any critical point: if `f` is convex on
6063
`s`, Fréchet-differentiable at `x ∈ s`, and `∇ f x = 0`, then `x` minimizes `f` on `s`.
@@ -89,6 +92,17 @@ theorem add_inner_gradient_lt (hc : StrictConvexOn ℝ s f) (hx : x ∈ s) (hy :
8992

9093
end StrictConvexOn
9194

95+
namespace StrictConcaveOn
96+
97+
/-- Strict variant of the reverse first-order gradient inequality for strictly concave `f`. -/
98+
theorem lt_add_inner_gradient (hc : StrictConcaveOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s)
99+
(hxy : x ≠ y) (hf : DifferentiableAt ℝ f x) :
100+
f y < f x + ⟪∇ f x, y - x⟫ := by
101+
rw [inner_gradient_left]
102+
exact hc.lt_add_fderiv hx hy hxy hf
103+
104+
end StrictConcaveOn
105+
92106
/-- A differentiable function on a Hilbert space is convex iff it satisfies the first-order
93107
gradient inequality at every pair of points in `s`. -/
94108
theorem convexOn_iff_add_inner_gradient_le (hs : Convex ℝ s)

0 commit comments

Comments
 (0)