Zulip Chat Archive

Stream: mathlib4

Topic: Unused `Decidable*` instances linter: style?


Thomas Murrills (Nov 04 2025 at 18:42):

I'm currently porting the unused Decidable* instances linter, which checks if there's a Decidable* instance in a theorem's type and suggests removing it in favor of using classical in the proof instead. :)

I'd like to include a Try this: suggestion that removes the binder and also inserts classical in the body. This is easy enough if the body happens to be a by block, but what should the style be if the body is a term?

We could have an instance in before the term, but that seems bulky to me; we could open Classical somewhere, but a different linter seems to discourage this. We could also have a classical% (or classical;, like have ...;) term elaborator.

What's the best style option here? :)

Damiano Testa (Nov 04 2025 at 21:49):

Side question: how are you passing a Try this suggestion from a linter?

Thomas Murrills (Nov 04 2025 at 21:54):

Try this functionality now works in MessageData, since MessageData now supports widgets! :) (There’s still no lightbulb code action, but the suggestion is clickable in the infoview.)

Damiano Testa (Nov 04 2025 at 21:55):

That's great news!

Eric Wieser (Nov 04 2025 at 22:59):

open scoped Classical in term_proof?

Aaron Liu (Nov 04 2025 at 23:01):

by classical exact

Eric Wieser (Nov 04 2025 at 23:05):

That doesn't bind variables (unless I'm forgetting how that works)

Aaron Liu (Nov 04 2025 at 23:07):

what do you mean "bind variables"?

Aaron Liu (Nov 04 2025 at 23:08):

if you're talking about autolambda then I'm pretty sure exact does that

Eric Wieser (Nov 04 2025 at 23:09):

I'm talking about how def and theorem choose which variables to bind, but perhaps my complaint applies only to def

Thomas Murrills (Nov 04 2025 at 23:09):

Eric Wieser said:

open scoped Classical in term_proof?

Is this not the thing that other linter discourages? Or is it only discouraged at the command level or something?

Eric Wieser (Nov 04 2025 at 23:10):

Which linter?

Aaron Liu (Nov 04 2025 at 23:10):

it's discouraged to do it when it could affect the statement of your lemma

Eric Wieser (Nov 04 2025 at 23:11):

It's very discouraged without in, and somewhat discouraged at the command level for the reason that Aaron states

Thomas Murrills (Nov 04 2025 at 23:11):

I think it might be called the “open scoped classical” linter :grinning_face_with_smiling_eyes:

Thomas Murrills (Nov 04 2025 at 23:11):

(on mobile right now)

Eric Wieser (Nov 04 2025 at 23:11):

The term mode classical scope is not discouraged at all

Thomas Murrills (Nov 04 2025 at 23:13):

Ok, great! I think I might prefer open scoped to by classical exact just to avoid introducing any metavariable synthesis timing shenanigans.

Thomas Murrills (Nov 04 2025 at 23:17):

(Unless, of course, we ultimately want a term mode macro for open scoped Classical in for good style, which would be motivated by paralleling the tactic syntax and making source look a bit cleaner. Would obscure things a bit, but might be nice to have a uniform spelling across term and tactic mode.

But that would be a separate discussion which shouldn’t block this one, and the linter could just adapt if that becomes the style. :grinning_face_with_smiling_eyes:)


Last updated: Dec 20 2025 at 21:32 UTC