AFTD Auto-Formalizing Theoretical Domains

HasDerivAt.comp_hasGradientAt

theoremverifiedformalizationimported Lean

The gradient of y ↦ φ (f y) is φ' times the gradient of f, for φ' the derivative of φ at f x.

Statement

set_option autoImplicit true in
set_option relaxedAutoImplicit true in
open InnerProductSpace in
variable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F] [CompleteSpace F]
  {f g : F → ℝ} {f' g' : F} {x : F} in
lemma HasDerivAt.comp_hasGradientAt {φ : ℝ → ℝ} {φ' : ℝ} (hf : HasGradientAt f f' x)
    (hφ : HasDerivAt φ φ' (f x)) : HasGradientAt (fun y => φ (f y)) (φ' • f') x
Formalizes
Physlib, `HasDerivAt.comp_hasGradientAt`
Lean proof
By Aadarsh Agarwal, Rithwik Ranganathan, from github.com/leanprover-community/physlib at e411c6e89692 (Copyright (c) 2026 Aadarsh Agarwal. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.34.1.
Verified
09 Oct 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 2
  • hasGradientAt_normAway from the origin, the gradient of the norm is the unit vector ‖x‖⁻¹ • x.
  • gradient_comp_coordChain rule for a function of one coordinate: the gradient of y ↦ f (y i) at x is f' • EuclideanSpace.single i 1, where f' is the…

Lean source view module on GitHub

set_option autoImplicit true inset_option relaxedAutoImplicit true inopen InnerProductSpace invariable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F] [CompleteSpace F]  {f g : F → ℝ} {f' g' : F} {x : F} in/-- The gradient of `y ↦ φ (f y)` is `φ'` times the gradient of `f`, for `φ'` the derivative of `φ` at `f x`. -/lemma HasDerivAt.comp_hasGradientAt {φ : ℝ → ℝ} {φ' : ℝ} (hf : HasGradientAt f f' x)    (hφ : HasDerivAt φ φ' (f x)) : HasGradientAt (fun y => φ (f y)) (φ' • f') x := by  rw [hasGradientAt_iff_hasFDerivAt] at *  simp only [map_smul]  exact hφ.comp_hasFDerivAt x hf
See it in the graphDiscuss this resultChallenge it