Zulip Chat Archive

Stream: new members

Topic: Is there a way to simplify the proof of differentiable?


Yicheng Tao (Oct 06 2024 at 14:44):

import Mathlib
open BigOperators

open Nat
example :  i :  , DifferentiableAt  (fun y => i * Real.sin (i * y) *  j  (Finset.range (n + 1)).erase i, Real.cos (j * y)) 0 := by
  intro i
  apply Differentiable.mul
  apply Differentiable.mul
  apply differentiable_const
  apply Differentiable.sin
  apply Differentiable.mul
  apply differentiable_const
  apply differentiable_id
  apply Differentiable.finset_prod
  intro j _
  apply Differentiable.cos
  apply Differentiable.mul
  apply differentiable_const
  apply differentiable_id

Here is a small mwe extracted from my proof. As you can see, it looks awful. I think there should be some tactic to simplify the proof. Maybe some tactic that can automatically solve these common differentiable problems.

By the way, I was using version 4.10.0. simp made little progress most of the time in this kind of problem.

Daniel Weber (Oct 06 2024 at 14:47):

I think that tactic is fun_prop

Sébastien Gouëzel (Oct 06 2024 at 14:48):

import Mathlib
open BigOperators

attribute [fun_prop] Real.differentiable_sin Differentiable.finset_prod Real.differentiable_cos

open Nat
example :  i :  , DifferentiableAt  (fun y => i * Real.sin (i * y) *  j  (Finset.range (n + 1)).erase i, Real.cos (j * y)) 0 := by
  fun_prop

Sébastien Gouëzel (Oct 06 2024 at 14:49):

As you can see, there as some missing fun_prop attributes, which is why the tactic does not work out of the box. Thanks to your report, I'm gonna PR them right away to mathlib!

Yicheng Tao (Oct 06 2024 at 14:51):

I was just trying the tactic and saw the following errors:

Issues:
  No theorems found for `Real.sin` in order to prove `Differentiable  fun y0 => Real.sin y0`
  No theorems found for `Real.sin` in order to prove `Differentiable  fun y => Real.sin (i * y)`

I was just about to report it.

Yicheng Tao (Oct 06 2024 at 14:52):

Sébastien Gouëzel said:

import Mathlib
open BigOperators

attribute [fun_prop] Real.differentiable_sin Differentiable.finset_prod Real.differentiable_cos

open Nat
example :  i :  , DifferentiableAt  (fun y => i * Real.sin (i * y) *  j  (Finset.range (n + 1)).erase i, Real.cos (j * y)) 0 := by
  fun_prop

Thanks! That's really helpful.

Yicheng Tao (Oct 06 2024 at 14:58):

By the way, DifferentiableAt theorems should also be added. @Sébastien Gouëzel
In my case, these theorems solve my problem.

attribute [fun_prop] Real.differentiable_sin Differentiable.finset_prod Real.differentiable_cos DifferentiableAt.finset_prod DifferentiableAt.cos DifferentiableAt.sin

Sébastien Gouëzel (Oct 06 2024 at 15:01):

Normally, the ones I have added should be enough -- the snippet I have posted works for me. But in the PR I will also add the DifferentiableAt versions, for sure.

Yicheng Tao (Oct 06 2024 at 15:05):

You are right for the mwe. But my whole proof needs DifferentiableAt. These two often come together in the proof. That's why I mentioned it.


Last updated: May 02 2025 at 03:31 UTC