Documentation

Tdaf.Analysis.Convex.Subgradient.Gradient

Gradients and the subdifferential #

Where a convex function is differentiable its gradient is its only subgradient, and the directional derivative is the corresponding linear function. Conversely, for a convex function finite at x, differentiability at x is equivalent to linearity of f'(x; ·), and in finite dimensions the two-sided derivatives along the vectors of a basis already suffice.

Dually, a point of epi f* is exposed exactly when it is (y, f* y) for a y that is the only subgradient of f somewhere, and the same holds for the set cut out by a positively homogeneous function. Both are phrased in terms of unique subgradients rather than of differentiability: the converse passage needs x interior to dom f and is in Subgradient/Uniqueness.lean.

Main results #

Implementation notes #

Differentiability of an EReal-valued function is carried by a local real representative: HasFDerivAt needs a normed target, so a convex f : E → EReal is differentiable at x when some real g has f =ᶠ[𝓝 x] fun z => (g z : EReal) and HasFDerivAt g f' x. This forces x ∈ int (dom f), the standing assumption that f x is finite. Restricting to f : E → ℝ instead would lose the Legendre theory, where the interesting functions are +∞ outside an open set.

The directional-derivative statements hold over an arbitrary pairing B, with uniqueness needing B separating in its second variable. In place of [FiniteDimensional ℝ E] the exposed point results assume [IsCompatiblePairing B.flip] — every continuous linear functional on F is ⟨x, ·⟩ — which holds for finite-dimensional E paired with StrongDual ℝ E.

References #

[^1]: R. T. Rockafellar, Convex Analysis, Princeton University Press, 1970, §25.

The algebraic core: a linear directional derivative #

theorem Tdaf.ConvexAnalysis.subgradient_eq_singleton_of_dirDeriv_eq {E : Type u_1} {F : Type u_2} [AddCommGroup E] [Module ℝ E] [AddCommGroup F] [Module ℝ F] {B : E →ₗ[ℝ] F →ₗ[ℝ] ℝ} {f : E → EReal} {x : E} (hsep : Function.Injective ⇑B.flip) (ht : f x ≠ ⊤) (hb : f x ≠ ⊥) {y₀ : F} (h : ∀ (v : E), dirDeriv f x v = ↑((B v) y₀)) :
subgradient B f x = {y₀}

Algebraically: if the directional derivative f'(x; ·) is the linear function ⟨·, y₀⟩, then y₀ is the unique subgradient of f at x. This is the description of ∂f x by ⟨·, y⟩ ≤ f'(x; ·) plus the observation that ⟨v, y⟩ ≤ ⟨v, y₀⟩ for every v, -v included, forces ⟨·, y⟩ = ⟨·, y₀⟩; the pairing must therefore separate the points of F.

theorem Tdaf.ConvexAnalysis.clFn_dirDeriv_eq_of_subgradient_eq_singleton {E : Type u_1} {F : Type u_2} [AddCommGroup E] [Module ℝ E] [AddCommGroup F] [Module ℝ F] {B : E →ₗ[ℝ] F →ₗ[ℝ] ℝ} {f : E → EReal} {x : E} [TopologicalSpace E] [ContinuousSMul ℝ E] [IsTopologicalAddGroup E] [LocallyConvexSpace ℝ E] [IsCompatiblePairing B] (hf : ConvexFn f) (ht : f x ≠ ⊤) (hb : f x ≠ ⊥) {y₀ : F} (h : subgradient B f x = {y₀}) :
clFn (dirDeriv f x) = fun (v : E) => ↑((B v) y₀)

The converse at the level of closures: if ∂f x is a single point y₀, then cl f'(x; ·) is the linear function ⟨·, y₀⟩. It is cl f'(x; ·) = δ*(· | ∂f x), the support function of a singleton being linear.

Rays and difference quotients #

theorem Tdaf.ConvexAnalysis.tendsto_ray_nhdsGT {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] (x v : E) :
Filter.Tendsto (fun (t : ℝ) => x + t • v) (nhdsWithin 0 (Set.Ioi 0)) (nhds x)

The ray t ↦ x + t • v tends to x as t ↓ 0.

theorem Tdaf.ConvexAnalysis.tendsto_slope_ray_of_hasFDerivAt {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {g : E → ℝ} {x : E} {f' : E →L[ℝ] ℝ} (hd : HasFDerivAt g f' x) (v : E) :
Filter.Tendsto (fun (t : ℝ) => (g (x + t • v) - g x) / t) (nhdsWithin 0 (Set.Ioi 0)) (nhds (f' v))

The difference quotient along a ray converges to the derivative in that direction. This is the only piece of calculus the section uses.

Local finiteness and properness #

theorem Tdaf.ConvexAnalysis.mem_interior_dom_of_eventuallyEq_coe {E : Type u_1} [NormedAddCommGroup E] {f : E → EReal} {g : E → ℝ} {x : E} (hfg : f =ᶠ[nhds x] fun (z : E) => ↑(g z)) :

A function that agrees with a real-valued function near x has x in the interior of its effective domain. Neither convexity nor differentiability plays any role — only local finiteness.

theorem Tdaf.ConvexAnalysis.proper_of_eventuallyEq_coe {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {g : E → ℝ} {x : E} (hf : ConvexFn f) (hfg : f =ᶠ[nhds x] fun (z : E) => ↑(g z)) :

A convex function that is finite near a point is proper. Unlike the general statement that a convex function taking −∞ takes it throughout the relative interior of its domain, this holds in any topological vector space: if f u = ⊥ then f is ⊥ on the half-open segment [u, x), whose points approach x, where f is finite.

The gradient is the unique subgradient #

theorem Tdaf.ConvexAnalysis.le_of_hasFDerivAt {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {g : E → ℝ} {x : E} {f' : E →L[ℝ] ℝ} (hf : ConvexFn f) (hp : Proper f) (hfg : f =ᶠ[nhds x] fun (z : E) => ↑(g z)) (hd : HasFDerivAt g f' x) (z : E) :
f x + ↑(f' (z - x)) ≤ f z

The gradient inequality: a convex function lies above its tangent affine function at every point of differentiability.

theorem Tdaf.ConvexAnalysis.eq_of_mem_subgradient_of_hasFDerivAt {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {g : E → ℝ} {x : E} {f' : E →L[ℝ] ℝ} (hfg : f =ᶠ[nhds x] fun (z : E) => ↑(g z)) (hd : HasFDerivAt g f' x) {y : StrongDual ℝ E} (hy : y ∈ subgradient (topDualPairing ℝ E).flip f x) :
y = f'

Uniqueness: any subgradient at a point of differentiability is the derivative. Neither convexity nor properness is used — only the limit of the difference quotient along the two opposite rays.

theorem Tdaf.ConvexAnalysis.subgradient_eq_singleton_of_hasFDerivAt {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {g : E → ℝ} {x : E} {f' : E →L[ℝ] ℝ} (hf : ConvexFn f) (hp : Proper f) (hfg : f =ᶠ[nhds x] fun (z : E) => ↑(g z)) (hd : HasFDerivAt g f' x) :

At a point where a convex function is differentiable, the gradient is the unique subgradient.

theorem Tdaf.ConvexAnalysis.dirDeriv_eq_of_hasFDerivAt {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {g : E → ℝ} {x : E} {f' : E →L[ℝ] ℝ} (hf : ConvexFn f) (hp : Proper f) (hfg : f =ᶠ[nhds x] fun (z : E) => ↑(g z)) (hd : HasFDerivAt g f' x) (v : E) :
dirDeriv f x v = ↑(f' v)

Necessity: at a point of differentiability the directional derivative is the linear function v ↦ ⟨v, ∇f x⟩. Both halves come from the defining infimum: the lower bound is the gradient inequality at x + a • v, the upper bound the limit a ↓ 0, extracted through EReal.lt_iff_exists_real_btwn so that no EReal division has to be computed.

Packaging: ∇f for an EReal-valued function #

f has gradient f' at x: near x, f agrees with a real-valued function that is Fréchet differentiable at x with derivative f'. This is ∇f x = f'. An EReal-valued function cannot satisfy HasFDerivAt directly — that needs a normed target — and the local real representative carries exactly what the classical definition presupposes: f finite near x.

Equations
Instances For

    f is differentiable at x: it has a gradient there.

    Equations
    Instances For
      theorem Tdaf.ConvexAnalysis.hasGradientAt_coe {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {g : E → ℝ} {x : E} {f' : E →L[ℝ] ℝ} (hd : HasFDerivAt g f' x) :
      HasGradientAt (fun (z : E) => ↑(g z)) f' x

      Packaged: a gradient at x puts x in the interior of dom f.

      theorem Tdaf.ConvexAnalysis.HasGradientAt.proper {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {x : E} {f' : E →L[ℝ] ℝ} (hf : ConvexFn f) (h : HasGradientAt f f' x) :

      Packaged: a convex function with a gradient somewhere is proper.

      theorem Tdaf.ConvexAnalysis.HasGradientAt.le {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {x : E} {f' : E →L[ℝ] ℝ} (hf : ConvexFn f) (h : HasGradientAt f f' x) (z : E) :
      f x + ↑(f' (z - x)) ≤ f z

      The gradient inequality, packaged.

      Packaged: the gradient is the only subgradient.

      theorem Tdaf.ConvexAnalysis.HasGradientAt.dirDeriv_eq {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {x : E} {f' : E →L[ℝ] ℝ} (hf : ConvexFn f) (h : HasGradientAt f f' x) (v : E) :
      dirDeriv f x v = ↑(f' v)

      Packaged: f'(x; v) = ⟨v, ∇f x⟩ at a point of differentiability.

      theorem Tdaf.ConvexAnalysis.HasGradientAt.unique {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {x : E} {f₁' f₂' : StrongDual ℝ E} (h₁ : HasGradientAt f f₁' x) (h₂ : HasGradientAt f f₂' x) :
      f₁' = f₂'

      The gradient is unique where it exists. This is the uniqueness of HasFDerivAt for the local real representative, and it needs no convexity.

      From directional derivatives back to the gradient #

      theorem Tdaf.ConvexAnalysis.exists_forall_abs_le_of_dirDeriv_eq {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {x : E} (hf : ConvexFn f) {r : ℝ} (hr : f x = ↑r) {v : E} {c η : ℝ} (hη : 0 < η) (hpos : dirDeriv f x v = ↑c) (hneg : dirDeriv f x (-v) = ↑(-c)) :
      ∃ (a₀ : ℝ), 0 < a₀ ∧ ∀ (t : ℝ), |t| ≤ a₀ → f (x + t • v) ≤ ↑(r + t * c + |t| * η)

      The two-sided one-dimensional estimate behind sufficiency. If the directional derivatives of f at x along v and -v are c and -c, then for every η > 0 there is a step a₀ > 0 with

      f (x + t • v) ≤ f x + t * c + |t| * η        whenever |t| ≤ a₀,
      

      for t of either sign. On the negative side the one-sided estimate is applied in the direction -v; the linear term survives unchanged because (-t) * (-c) = t * c, while the error term picks up |t| = -t.

      theorem Tdaf.ConvexAnalysis.exists_le_of_forall_basis_dirDeriv_eq {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {x : E} {ι : Type u_2} [Finite ι] [FiniteDimensional ℝ E] (b : Module.Basis ι ℝ E) (hf : ConvexFn f) {r : ℝ} (hr : f x = ↑r) {y₀ : StrongDual ℝ E} (hpos : ∀ (j : ι), dirDeriv f x (b j) = ↑(y₀ (b j))) (hneg : ∀ (j : ι), dirDeriv f x (-b j) = ↑(-y₀ (b j))) {ε : ℝ} (hε : 0 < ε) :
      ∃ (δ : ℝ), 0 < δ ∧ ∀ (z : E), ‖z - x‖ ≤ δ → f z ≤ ↑(r + y₀ (z - x) + ε * ‖z - x‖)

      Sufficiency, quantitatively: two-sided directional derivatives along a basis already force the tangent affine estimate

      f z ≤ f x + ⟨z - x, y₀⟩ + ε ‖z - x‖
      

      on a ball whose radius depends only on ε.

      Finite-dimensionality enters through a cross-polytope decomposition rather than through compactness of the unit sphere, which keeps the argument quantitative. Writing z - x = ∑ ξ j • b j and S = ∑ |ξ j|, the point z is the convex combination with weights |ξ j| / S of the points x + (S * sign (ξ j)) • b j, each at distance S from x along a basis direction, where the one-sided estimate applies. The linear terms recombine into ⟨z - x, y₀⟩ exactly and the error is S * η, at most ε ‖z - x‖ once η is scaled by the constant relating ∑ |ξ j| to ‖z - x‖.

      theorem Tdaf.ConvexAnalysis.dirDeriv_eq_of_forall_basis_dirDeriv_eq {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {x : E} {ι : Type u_2} [Finite ι] [FiniteDimensional ℝ E] (b : Module.Basis ι ℝ E) (hf : ConvexFn f) (ht : f x ≠ ⊤) (hb : f x ≠ ⊥) {y₀ : StrongDual ℝ E} (hpos : ∀ (j : ι), dirDeriv f x (b j) = ↑(y₀ (b j))) (hneg : ∀ (j : ι), dirDeriv f x (-b j) = ↑(-y₀ (b j))) (v : E) :
      dirDeriv f x v = ↑(y₀ v)

      The estimate of exists_le_of_forall_basis_dirDeriv_eq recovers f'(x; ·) in every direction, not only along the basis: it bounds f'(x; v) above by ⟨v, y₀⟩, and the general inequality -f'(x; -v) ≤ f'(x; v) supplies the matching lower bound. This turns n two-sided partial derivatives into linearity of f'(x; ·) without a detour that would need f'(x; ·) to be proper first.

      theorem Tdaf.ConvexAnalysis.hasGradientAt_of_forall_basis_dirDeriv_eq {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {x : E} {ι : Type u_2} [Finite ι] [FiniteDimensional ℝ E] (b : Module.Basis ι ℝ E) (hf : ConvexFn f) (ht : f x ≠ ⊤) (hb : f x ≠ ⊥) {y₀ : StrongDual ℝ E} (hpos : ∀ (j : ι), dirDeriv f x (b j) = ↑(y₀ (b j))) (hneg : ∀ (j : ι), dirDeriv f x (-b j) = ↑(-y₀ (b j))) :
      HasGradientAt f y₀ x

      Sufficiency, from two-sided derivatives along a basis: f is Fréchet differentiable at x, with gradient the functional y₀ whose values along the basis are the given one-sided derivatives. The two-sided estimate f x + ⟨z - x, y₀⟩ ≤ f z ≤ f x + ⟨z - x, y₀⟩ + ε ‖z - x‖ does all three jobs at once: it makes f finite near x, so that the local real representative exists, and exhibits the little-o estimate defining HasFDerivAt.

      theorem Tdaf.ConvexAnalysis.hasGradientAt_of_dirDeriv_eq {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {x : E} [FiniteDimensional ℝ E] (hf : ConvexFn f) (ht : f x ≠ ⊤) (hb : f x ≠ ⊥) {y₀ : StrongDual ℝ E} (h : ∀ (v : E), dirDeriv f x v = ↑(y₀ v)) :
      HasGradientAt f y₀ x

      Sufficiency: if the directional derivative f'(x; ·) is the linear function ⟨·, y₀⟩, then f is differentiable at x with ∇f x = y₀. This is the previous theorem read at any basis; the hypothesis in every direction is more than the proof consumes.

      theorem Tdaf.ConvexAnalysis.differentiableAtFn_iff_exists_dirDeriv_eq {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {x : E} [FiniteDimensional ℝ E] (hf : ConvexFn f) (ht : f x ≠ ⊤) (hb : f x ≠ ⊥) :
      DifferentiableAtFn f x ↔ ∃ (y₀ : StrongDual ℝ E), ∀ (v : E), dirDeriv f x v = ↑(y₀ v)

      In full: for a convex function finite at x, differentiability at x is equivalent to linearity of f'(x; ·). Necessity is HasGradientAt.dirDeriv_eq and sufficiency is hasGradientAt_of_dirDeriv_eq.

      theorem Tdaf.ConvexAnalysis.differentiableAtFn_of_forall_basis_dirDeriv_eq {E : Type u_1} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : E → EReal} {x : E} {ι : Type u_2} [Finite ι] [FiniteDimensional ℝ E] (b : Module.Basis ι ℝ E) (hf : ConvexFn f) (ht : f x ≠ ⊤) (hb : f x ≠ ⊥) (c : ι → ℝ) (hpos : ∀ (j : ι), dirDeriv f x (b j) = ↑(c j)) (hneg : ∀ (j : ι), dirDeriv f x (-b j) = ↑(-c j)) :

      It is already enough that the n two-sided partial derivatives exist and are finite. Here "the n partial derivatives" is the pair of one-sided derivatives along the vectors of a basis, and "two-sided and finite" is the requirement that they be the negatives of each other and real. The gradient is then b.constr of those numbers.

      Exposed points of a half-cylinder #

      The exposed points of a half-cylinder C ×ˢ [0, ∞) are the points (z, 0) with z an exposed point of C. A functional exposing a point of the cylinder must be strictly decreasing in the vertical direction, since otherwise the whole vertical ray attains the maximum; that forces the height to be 0 and reduces the functional to one on C. The cylinder is the epigraph of an indicator function, so this is how a statement about epi f* becomes one about a convex set.

      Exposed points of the epigraph of a conjugate #

      theorem Tdaf.ConvexAnalysis.Proper.eq_sub_of_mem_subgradient {E : Type u_1} {F : Type u_2} [AddCommGroup E] [Module ℝ E] [AddCommGroup F] [Module ℝ F] {B : E →ₗ[ℝ] F →ₗ[ℝ] ℝ} {f : E → EReal} (hp : Proper f) {x : E} {y : F} {μ : ℝ} (hy : y ∈ subgradient B f x) (hμ : conj B f y = ↑μ) :
      f x = ↑((B x) y - μ)

      A subgradient pins down the value: if y ∈ ∂f x and f* y = μ is finite, then f x = ⟨x, y⟩ - μ. This is Fenchel's equality solved for f x, and in particular f x is finite.

      In subgradient form: (y, μ) is an exposed point of epi f* exactly when μ = f* y and y is the only subgradient of f at some point x.

      Geometrically, a supporting hyperplane to epi f* touching it in a single point is necessarily non-vertical, hence the graph of an affine function ⟨x, ·⟩ - α; supporting epi f* at (y, μ) says x ∈ ∂f*(y), i.e. y ∈ ∂f x, and touching nowhere else says ∂f x is no larger than {y}. Only the forward direction uses closedness, through ∂f* = (∂f)⁻¹.

      Exposed points of a set cut out by a positively homogeneous function #

      The exposed points of a set are the values of the subdifferential of any positively homogeneous function that cuts it out. If g is closed proper convex and positively homogeneous and C = {x | ⟨x, y⟩ ≤ g y for all y} — for instance g the support function of C — then z is an exposed point of C exactly when z is the only subgradient of g at some y. The conjugate of g is the indicator of C, so epi g* is the half-cylinder C ×ˢ [0, ∞) and this is the previous result read at height 0.