|
| 1 | +/- |
| 2 | +Copyright (c) 2026 Christoph Spiegel. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Christoph Spiegel |
| 5 | +-/ |
| 6 | +module |
| 7 | + |
| 8 | +public import Mathlib.Analysis.Convex.LineDeriv |
| 9 | +public import Mathlib.Analysis.Calculus.FDeriv.Basic |
| 10 | + |
| 11 | +/-! |
| 12 | +# First-order convexity inequality via the Fréchet derivative |
| 13 | +
|
| 14 | +For `f : E → ℝ` convex on `s ⊆ E` and Fréchet-differentiable at `x ∈ s`, the first-order |
| 15 | +convexity inequality |
| 16 | +
|
| 17 | +`f x + (fderiv ℝ f x) (y - x) ≤ f y` |
| 18 | +
|
| 19 | +holds for `y ∈ s`. This is the Fréchet-derivative restatement of the line-derivative form |
| 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`. |
| 24 | +
|
| 25 | +## Main results |
| 26 | +
|
| 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`. |
| 36 | +* `convexOn_iff_add_fderiv_le` — iff converse: differentiability plus the first-order |
| 37 | + inequality everywhere implies `ConvexOn`. |
| 38 | +-/ |
| 39 | + |
| 40 | +public section |
| 41 | + |
| 42 | +variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 43 | +variable {f : E → ℝ} {s : Set E} {x y : E} |
| 44 | + |
| 45 | +namespace ConvexOn |
| 46 | + |
| 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 | + |
| 54 | +/-- For a convex function `f` Fréchet-differentiable at `x`, the first-order inequality |
| 55 | +`f x + (fderiv ℝ f x) (y - x) ≤ f y` holds. -/ |
| 56 | +theorem add_fderiv_le (hc : ConvexOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s) |
| 57 | + (hf : DifferentiableAt ℝ f x) : |
| 58 | + f x + fderiv ℝ f x (y - x) ≤ f y := |
| 59 | + hc.add_hasFDerivAt_le hx hy hf.hasFDerivAt |
| 60 | + |
| 61 | +/-- Monotonicity of the Fréchet derivative along the chord: for convex `f` differentiable |
| 62 | +at `x` and `y`, `0 ≤ (fderiv ℝ f y - fderiv ℝ f x) (y - x)`. -/ |
| 63 | +theorem fderiv_sub_nonneg (hc : ConvexOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s) |
| 64 | + (hfx : DifferentiableAt ℝ f x) (hfy : DifferentiableAt ℝ f y) : |
| 65 | + 0 ≤ (fderiv ℝ f y - fderiv ℝ f x) (y - x) := by |
| 66 | + rw [ContinuousLinearMap.sub_apply, ← hfx.lineDeriv_eq_fderiv, ← hfy.lineDeriv_eq_fderiv] |
| 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 |
| 75 | + |
| 76 | +end ConvexOn |
| 77 | + |
| 78 | +namespace ConcaveOn |
| 79 | + |
| 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 | + |
| 87 | +/-- For a concave function `f` Fréchet-differentiable at `x`, the reverse first-order |
| 88 | +inequality `f y ≤ f x + (fderiv ℝ f x) (y - x)` holds. -/ |
| 89 | +theorem le_add_fderiv (hc : ConcaveOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s) |
| 90 | + (hf : DifferentiableAt ℝ f x) : |
| 91 | + f y ≤ f x + fderiv ℝ f x (y - x) := |
| 92 | + hc.le_add_hasFDerivAt hx hy hf.hasFDerivAt |
| 93 | + |
| 94 | +end ConcaveOn |
| 95 | + |
| 96 | +namespace StrictConvexOn |
| 97 | + |
| 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 | + |
| 105 | +/-- Strict variant of the first-order inequality for strictly convex `f`: |
| 106 | +when `x ≠ y`, the inequality is strict. -/ |
| 107 | +theorem add_fderiv_lt (hc : StrictConvexOn ℝ s f) (hx : x ∈ s) (hy : y ∈ s) (hxy : x ≠ y) |
| 108 | + (hf : DifferentiableAt ℝ f x) : |
| 109 | + f x + fderiv ℝ f x (y - x) < f y := |
| 110 | + hc.add_hasFDerivAt_lt hx hy hxy hf.hasFDerivAt |
| 111 | + |
| 112 | +end StrictConvexOn |
| 113 | + |
| 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 | + |
| 132 | +/-- A differentiable function is convex iff it satisfies the first-order inequality |
| 133 | +at every pair of points in `s`. -/ |
| 134 | +theorem convexOn_iff_add_fderiv_le (hs : Convex ℝ s) (hf : ∀ x ∈ s, DifferentiableAt ℝ f x) : |
| 135 | + ConvexOn ℝ s f ↔ |
| 136 | + ∀ x ∈ s, ∀ y ∈ s, f x + fderiv ℝ f x (y - x) ≤ f y := by |
| 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) |
0 commit comments