Zulip Chat Archive
Stream: mathlib4
Topic: fun_prop unfolding behaviour
Michael Rothgang (Jan 15 2026 at 12:56):
I just learned (via #33998) about fun_prop [c] --- according to the documentation there, it will unfold c and then apply fun_prop. However, there are cases in mathlib where replacing unfold foo; fun_prop by fun_prop [foo] does not work. Is this expected/can it be described when this holds? If not, I'm happy to debug further.
Michael Rothgang (Jan 15 2026 at 13:00):
#34000 has a few working golfs, and comments on the failing golfs.
Michael Rothgang (Jan 15 2026 at 13:01):
Here is one example that fails, in Mathlib.Data.Real.Sqrt, line 123:
@[continuity, fun_prop]
theorem continuous_sqrt : Continuous (√· : ℝ → ℝ) := by
-- TODO: why does this fail? fun_prop [sqrt]
unfold sqrt; fun_prop
(This is not an MWE, as importing mathlib makes it harder to make one.)
Replacing the local notation \sqrt by Real.sqrt does not make a difference.
Michael Rothgang (Jan 15 2026 at 13:01):
CC @Tomas Skrivan perhaps you can help me investigate this.
Tomas Skrivan (Jan 15 2026 at 13:11):
Ohh that feature was never really used and tested. Might make sense to remove it, or do you want to keep it and debug it?
Tomas Skrivan (Jan 15 2026 at 13:16):
My suspicion is that: If sqrt is typeclass field(like other arithmetic operations like +) then fun_prop is likely doing some naive unfolding which just results in structure projection like instSqrtReal.1 which then confuses fun_prop.
Tomas Skrivan (Jan 15 2026 at 13:16):
Unfortunately, I don't have the time right now to look into the code more deeply
Jakub Nowak (Jan 15 2026 at 13:21):
Tomas Skrivan said:
My suspicion is that: If
sqrtis typeclass field(like other arithmetic operations like+) [...]
It's not.
Aaron Liu (Jan 15 2026 at 21:41):
aha
Aaron Liu (Jan 15 2026 at 21:41):
if I make Real.sqrt not irreducible then it works
Aaron Liu (Jan 15 2026 at 21:42):
oh and I also need to use the full name Real.sqrt instead of just sqrt
Aaron Liu (Jan 15 2026 at 21:42):
so that's two things
Michael Stoll (Jan 15 2026 at 21:48):
(Note that Real.sqrt was made irreducible for performance reasons not so long ago.)
Last updated: Feb 28 2026 at 14:05 UTC