Zulip Chat Archive

Stream: mathlib4

Topic: Unused Fact in type linter


Bhavik Mehta (Dec 03 2025 at 20:36):

Can we also have a version of the "Unused fintype in type" linter for Fact instances? The general consensus for Fintype vs Finite (use Fintype only if the statement's type requires it, otherwise use Finite) seems generally similar for Fact instances, eg Fact p.Prime or Fact (1 <= p); ie only have it as an (instance) assumption if the statement's type requires it. (Apologies if this is the wrong thread for that, I couldn't find an existing thread about this linter)

Notification Bot (Dec 04 2025 at 18:58):

A message was moved here from #mathlib4 > Unused fintype in type linter by Thomas Murrills.

Thomas Murrills (Dec 04 2025 at 18:59):

Hmm, I'm guessing instances of Prop classes should be permitted to use [Fact _], right? :thinking: ( :working_on_it: #32436)

Thomas Murrills (Dec 04 2025 at 19:01):

(A potential false positive of this form that I have in mind is expChar_prime in Mathlib.Algebra.CharP.Defs.)

Thomas Murrills (Dec 04 2025 at 19:03):

Also, to be clear: I suppose the linter's suggestion ought to be to simply replace it with an ordinary hypothesis of the form (h : p.Prime), right? Are there any weird but systematic cases where this is not what we want? :eyes:

Thomas Murrills (Dec 04 2025 at 19:38):

Wow, quite a few violations! :dizzy: If i'm counting correctly, 110 files violated this linter (but this does include linting against instances, which we might not want to do).

Bhavik Mehta (Dec 04 2025 at 20:17):

We definitely want to allow data-carrying instances to have this assumption. I'm not certain but it seems reasonable to me to allow propositional instances to have it too; and it also seems okay to be more permissive in the first version.

Thomas Murrills (Dec 04 2025 at 20:35):

Data-carrying instances are already excluded by the linter—however, by exempting propositional instances too, we've reduced the number of files with violations by 22 (to 88). :)


Last updated: Dec 20 2025 at 21:32 UTC