Zulip Chat Archive

Stream: mathlib4

Topic: Elementary `HasDerivAt` results


Paul Lezeau (Mar 25 2025 at 15:16):

Would the following two results be worth adding to Mathlib?

theorem hasDerivAtFilter_zero {𝕜 : Type u}
    [NontriviallyNormedField 𝕜] {F : Type v} [NormedAddCommGroup F]
    [NormedSpace 𝕜 F] (x : 𝕜) (L : Filter 𝕜) :
    HasDerivAtFilter (0 : 𝕜  F) 0 x L where
  isLittleOTVS := by
    simp [Asymptotics.isLittleOTVS_iff_isLittleO]

theorem hasDerivAt_zero {𝕜 : Type u}
    [NontriviallyNormedField 𝕜] {F : Type v} [NormedAddCommGroup F]
    [NormedSpace 𝕜 F] (x : 𝕜) :
    HasDerivAt (0 : 𝕜  F) 0 x := by
  apply hasDerivAtFilter_zero

These have come up relatively naturally in what I'm doing, but I'm not sure how useful they would be given that there are already very similar results, e.g. docs#hasDerivWithinAt_const

Eric Wieser (Mar 25 2025 at 15:29):

I think this comes down to the same thing as whether to write Continuous (f * g) or Continuous (fun x => f x * g x), and what to name them if we have both

Eric Wieser (Mar 25 2025 at 15:30):

Indeed, if we decide we only want the one with fun, then there is no need for your lemma as it's a syntactic specialization of the const one you mention

Paul Lezeau (Mar 25 2025 at 15:53):

Both conventions seem to be used here, since there is also docs#derivWithin_zero

Eric Wieser (Mar 25 2025 at 16:03):

I guess following every _const result with _zero, _one, and _ofNat would be reasonable then

Paul Lezeau (Mar 25 2025 at 16:42):

#23310

Eric Wieser (Mar 29 2025 at 15:40):

Turns out this adds a lot of lemmas. Would we prefer to just write them all manually as

theorem hasDerivAtFilter_zero : HasDerivAtFilter (0 : 𝕜  F) 0 x L :=
  hasDerivAtFilter_const _ _ _

theorem hasDerivAtFilter_one [One F] : HasDerivAtFilter (1 : 𝕜  F) 0 x L :=
  hasDerivAtFilter_const _ _ _

theorem hasDerivAtFilter_natCast [NatCast F] (n : ) : HasDerivAtFilter (n : 𝕜  F) 0 x L :=
  hasDerivAtFilter_const _ _ _

theorem hasDerivAtFilter_intCast [IntCast F] (z : ) : HasDerivAtFilter (z : 𝕜  F) 0 x L :=
  hasDerivAtFilter_const _ _ _

theorem hasDerivAtFilter_ofNat (n : ) [OfNat F n] : HasDerivAtFilter (ofNat(n) : 𝕜  F) 0 x L :=
  hasDerivAtFilter_const _ _ _

or have something more mechanical like

run_cmd do
  for (name, args, val) in [
    (`hasDerivAtFilter_zero,
      #[],  `(0)),
    (`hasDerivAtFilter_one,
      #[ `(bracketedBinderF| [One F])],  `(1)),
    (`hasDerivAtFilter_natCast,
      #[ `(bracketedBinderF| [NatCast F]),  `(bracketedBinderF| (n : ))],  `(n)),
    (`hasDerivAtFilter_intCast,
      #[ `(bracketedBinderF| [IntCast F]),  `(bracketedBinderF| (z : ))],  `(z)),
    (`hasDerivAtFilter_ofNat,
      #[ `(bracketedBinderF| (n : )),  `(bracketedBinderF| [OfNat F n])],  `(ofNat(n)))
  ] do
    Lean.Elab.Command.elabCommandTopLevel <|
       `(command|
      theorem $(Lean.mkIdent name) $args* :
        HasDerivAtFilter ($(val) : 𝕜  F) 0 x L :=
          hasDerivAtFilter_const _ _ _)

Ruben Van de Velde (Mar 29 2025 at 17:13):

If the mechanical code is longer than the copy/pasted code... :)

Yury G. Kudryashov (Mar 29 2025 at 19:19):

I think that we should have a tactic that specializes "const" results to

  • OfNat.ofNat;
  • zero and one
  • Nat.cast;
  • Int.cast.

Yury G. Kudryashov (Mar 29 2025 at 19:19):

This appears in many contexts, not only HasDerivAt.

Paul Lezeau (Mar 29 2025 at 19:25):

I can have a go at writing that:)

Eric Wieser (Mar 29 2025 at 23:46):

Not a tactic, but an attribute / command, right?

Yury G. Kudryashov (Mar 30 2025 at 01:10):

Yes, I meant "meta program".

Eric Wieser (Mar 30 2025 at 09:38):

Is the proposal that we write this before merging #23310, or that we attempt it as a follow up?

Paul Lezeau (Mar 30 2025 at 10:35):

I was thinking of doing this as a follow up

Yury G. Kudryashov (Mar 30 2025 at 18:57):

Another related proposal is to have an attribute and/or command that turns a Nat.cast lemma into zero, one, and ofNat lemmas.

Eric Wieser (Mar 30 2025 at 21:35):

I think that for zero and one that probably ends up discarding generality

Eric Wieser (Mar 30 2025 at 21:36):

For ofNat we could certainly make lots use of that, but I wouldn't work for the PR mentioned above.


Last updated: May 02 2025 at 03:31 UTC