Zulip Chat Archive

Stream: new members

Topic: fderivWithin Confusion


Dominic Steinitz (Dec 27 2024 at 12:05):

This typechecks on https://live.lean-lang.org/ so apparently the derivative of f x = x and g x = -x at 0 are equal.

import Mathlib

theorem fderivWithin_congr_of_eq_on_open
  {m n : }
  (f g : EuclideanSpace  (Fin m)  EuclideanSpace  (Fin n)) (s : Set (EuclideanSpace  (Fin m)))
  (he :  x  s, f x = g x) :
   x  s, fderivWithin  f s x = fderivWithin  g s x := by
    intro z hz
    exact fderivWithin_congr he (he z hz)

def f : EuclideanSpace  (Fin 1) -> EuclideanSpace  (Fin 1) := λ x => x
def g : EuclideanSpace  (Fin 1)  EuclideanSpace  (Fin 1) := λ x => -x
def s : Set (EuclideanSpace  (Fin 1)) := {λ _ : Fin 1 => (0 : )}

example : ( x  s, f x = g x)   x  s, fderivWithin  f s x = fderivWithin  g s x  := by
  intro h_eq
  apply fderivWithin_congr_of_eq_on_open f g {0} h_eq

Dominic Steinitz (Dec 27 2024 at 12:59):

(deleted)

Eric Wieser (Dec 27 2024 at 16:08):

Your example reduces to

import Mathlib

example :
    fderivWithin  (fun x :  => x) {0} 0 = fderivWithin  (fun x => -x) {0} 0  := by
  refine fderivWithin_congr (by simp) (by simp)

right?

Eric Wieser (Dec 27 2024 at 16:08):

Maybe docs#hasFDerivWithinAt_singleton is of interest here

Dominic Steinitz (Dec 28 2024 at 15:41):

Maybe - I would say the derivative of a function on singleton is not defined but maybe when I start thinking about connections I will revise my view.

Kevin Buzzard (Dec 28 2024 at 20:15):

You would probably also say that 1/0 is not defined but in lean it's also 0

Kevin Buzzard (Dec 28 2024 at 20:16):

We don't have runtime errors in proofs so we have junk values in proofs instead

Eric Wieser (Dec 28 2024 at 20:56):

Is this one a junk value? Usually the rule is that fderivWithin is junk if HasFDerivWithinAt is false, but that doesn't apply here

Winston Yin (尹維晨) (Jan 16 2025 at 07:27):

I think it's important to clarify this. The derivative f' of a function f : E → F at a point x : E is defined as any linear map E → F that makes f x - f y - f' (x - y) = o(x - y) hold as y approaches x from every direction. When you use HasFDerivWithinAt, you're saying that this expression holds as y approaches x while remaining in the given set s, which is weaker. For a set s that doesn't include enough of the tangent directions around x, the FDerivWithinAt is still well defined but may not be unique. You can imagine, for example, that x = 0 in ℝ^2, and s is just the axis-1, so the derivative at 0 within s is only specified along axis-1 but is completely arbitrary along axis-2. The predicate UniqueDiffWithinAt guarantees that the derivative at x within s is unique by requiring that s cover enough of the tangent directions. If you now consider the singleton s = {x}, for a function f, the little-o expression holds trivially when you restrict y to approach x while remaining in {x}, for any choice of f'. In particular, f' = 0 is a valid derivative.

@Kevin Buzzard That the derivative of a function within a singleton is well defined is not a case of junk value, but the choice of f' = 0 in docs#hasFDerivWithinAt_singleton is.


Last updated: May 02 2025 at 03:31 UTC