Zulip Chat Archive

Stream: mathlib4

Topic: Thank you for the deprecation warnings!


Geoffrey Irving (Feb 06 2024 at 15:54):

This time when I updated mathlib, most of the functions that have been renamed come with deprecation warnings that say what the new function is. This has made this most recent upgrade experience far more pleasant than the last time. Thank you!

One feature request: it would be cool if the deprecation warnings produced clickable things in VSCode that did the substitution, since often just doing the name replace works (and even if it doesn't one can then edit to fix).

Damiano Testa (Feb 06 2024 at 15:59):

I have not really thought about this, but it might be tricky to get the substitution to work automatically, mostly due to dot-notation and what the new name should look like.

Someone else may have a better answer, though!

Damiano Testa (Feb 06 2024 at 16:01):

(I am not saying that it is impossible, but that a simple-minded replacement would not "Just work".)

Richard Copley (Feb 06 2024 at 16:05):

If it's purely a name change In some cases, as in

@[deprecated] alias oldname := newname

there will indeed be a code action (https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/machineApplicableDeprecated.20tag.20attribute).

Damiano Testa (Feb 06 2024 at 16:12):

@Richard Copley the link that you shared highlights that the auto-deprecated script that I used produces the wrong syntax for automatic replacement to work.

@Geoffrey Irving, if your deprecated lemmas were of the op_norm-form, then auto-replacement might have worked better if I had understood how this worked...

Damiano Testa (Feb 06 2024 at 16:39):

Hopefully, #10302 uses the correct syntax and allows auto-replacement of the deprecated op_norm statements.

Geoffrey Irving (Feb 06 2024 at 16:56):

Very cool, thank you! Yep, getting the simple cases right gets nearly all of the value.

Damiano Testa (Feb 06 2024 at 19:15):

In case someone comes here, with the PR, the deprecation code action works with the lemmas that were auto-deprecated. However, even the deprecation does not seem to work if you use a deprecated lemma with dot-notation:

import Std.Tactic.Alias

@[deprecated] alias Nat.sup := Nat.succ_pos

-- code action works
example {m : Nat} : 0 < m.succ := Nat.sup m

open Nat in
-- code action works
example {m : Nat} : 0 < m.succ := sup m

-- no deprecation notice
example {m : Nat} : 0 < m.succ := m.sup

Ruben Van de Velde (Feb 06 2024 at 19:24):

Not even a warning?

Damiano Testa (Feb 06 2024 at 19:24):

No, not even a warning.

Johan Commelin (Feb 07 2024 at 04:57):

Sounds like that should be a bug report for core.

Damiano Testa (Feb 07 2024 at 08:04):

Filed as issue #3270

Josha Dekker (Feb 09 2024 at 10:00):

There was a deprecation warning in Topology/Compactness/Lindelof which I tried to fix by carrying out the suggested change (from subset_trans to embedding_inclusion), but this involved more than just replacing the name of the result, as the result from embedding_inclusion was an Embedding.

My build on #10376 failed when I committed without fixing the deprecation warning, so in order to get my PR to build, I would've been forced to figure out how to do the proof with the intermediate Embedding step, which feels like it adds quite some overhead if you want to quickly add another result which happens to be in the same file as the deprecated step. In this case, aesop quickly gave me a different proof that didn't use embedding.

My question is, is this efficient behaviour, that the build fails when I don't change a deprecated step that doesn't have anything to do with my contribution? Or am I misinterpreting what happened?

Ruben Van de Velde (Feb 09 2024 at 10:25):

I don't think a new warning should come up and block you if you make an unrelated change, if I understand you correctly

Josha Dekker (Feb 09 2024 at 10:27):

Ruben Van de Velde said:

I don't think a new warning should come up and block you if you make an unrelated change, if I understand you correctly

Yes, exactly, that would be what I thought as well. What happened was the following:

The warning was there when I opened the file in VS code. The build failed on my first commit because I forgot to check the lint, but then the build failed on my second commit, due to the presence of a deprecated function in the file, which was unrelated to my change

Ruben Van de Velde (Feb 09 2024 at 10:28):

Ah, I see what happened

Ruben Van de Velde (Feb 09 2024 at 10:29):

The code on master uses _root_.subset_trans which isn't deprecated. You added a new import, which caused subset_trans to resolve to TopologicalSpace.subset_trans instead, and this one is deprecated.

Ruben Van de Velde (Feb 09 2024 at 10:30):

So you could make this change instead:

-  have hiU : ∀ i ∈ s, f i ⊆ ⋃ i, U i := fun _ is ↦ subset_trans (subset_biUnion_of_mem is) hUcover
+  have hiU : ∀ i ∈ s, f i ⊆ ⋃ i, U i := fun _ is ↦
+    _root_.subset_trans (subset_biUnion_of_mem is) hUcover

Josha Dekker (Feb 09 2024 at 10:33):

Okay, that makes sense, I'll fix that line as I think it is more elegant. Would it be good to have something (in general) that avoids that fun resolves to something like A.fun rather than B.fun if the former is deprecated? Or is this horribly complicated to add? I guess it would prevent issues like the one I just ran into.

Damiano Testa (Feb 09 2024 at 10:35):

The systematic use of deprecated in Mathlib is very recent. There are several improvements that would be great, not necessarily hard to implement. There just has not been enough time to really write them, I think.

Ruben Van de Velde (Feb 09 2024 at 11:06):

I'm not convinced that deprecation should affect name resolution. If this particular theorem hadn't been deprecated, you'd also have hit a weird error because the signature no longer matched

Kyle Miller (Feb 09 2024 at 17:44):

In case people aren't aware of it, Mathlib Changelog is a useful tool when you need to figure out what happened to some declaration when you're upgrading.


Last updated: May 02 2025 at 03:31 UTC