Zulip Chat Archive
Stream: lean4
Topic: defLemma and docBlame linters on local instances in sections
Michael Stoll (Apr 17 2024 at 16:03):
If I put a local instance
into a section
, then both the defLemma
and the docBlame
linter complain:
import Std.Tactic.Lint.Misc
import Std.Tactic.Lint.Frontend
/-- some class in Prop -/
class Foo (T : Type) (s t : T) : Prop where
/-- some proof -/
ht : s = t
section foo
local instance bar : Foo Nat 0 0 := ⟨rfl⟩
#lint
/-
-- Found 0 errors in 5 declarations (plus 4 automatically generated ones) in
the current file with 8 linters
-- All linting checks passed!
-/
end foo
#lint
/-
-- Found 2 errors in 1 declarations (plus 0 automatically generated ones) in
the current file with 14 linters
/- The `defLemma` linter reports:
INCORRECT DEF/LEMMA: -/
#check bar /- is a def, should be lemma/theorem -/
/- The `docBlame` linter reports:
DEFINITIONS ARE MISSING DOCUMENTATION STRINGS: -/
#check bar /- definition missing documentation string -/
-/
This occurs only when the #lint
is outside the section with the local defs.
This looks like a bug to me.
Michael Stoll (Apr 17 2024 at 16:04):
Apparently, #lint
uses more linters outside the section than within ?
Mario Carneiro (Apr 17 2024 at 16:05):
the issue is that some linters ignore instances, so local instances confuse them
Mario Carneiro (Apr 17 2024 at 16:06):
it's not really possible to tell whether something "was once" a local instance
Michael Stoll (Apr 17 2024 at 16:06):
So the only way to deal with this is to @[nolint defLemma docBlame]
them?
Mario Carneiro (Apr 17 2024 at 16:07):
you may be able to at least fix the defLemma linter by making it a @[local instance] theorem
Mario Carneiro (Apr 17 2024 at 16:07):
you can also make it private (not sure if the relevant linters are looking for this)
Michael Stoll (Apr 17 2024 at 16:08):
Are private instances visible downstream (not by name, but for inferInstance
etc.)?
Mario Carneiro (Apr 17 2024 at 16:17):
yes
Mario Carneiro (Apr 17 2024 at 16:17):
but private local instances are not
Mario Carneiro (Apr 17 2024 at 16:17):
but making the definition private will at least silence the docBlame linter
Michael Stoll (Apr 17 2024 at 16:30):
If I need to silence one of them anyway, I can as well silence both...
Eric Wieser (Apr 17 2024 at 16:31):
@[local instance] private theorem
and @[local instance] private def
seems like the best approach
Mario Carneiro (Apr 17 2024 at 16:32):
it would be nice if instance
automatically did def
/theorem
properly though
Mario Carneiro (Apr 17 2024 at 16:33):
I'm pretty sure the only reason the defTheorem linter looks for instances is because this is a known bug in instance
Kim Morrison (Apr 18 2024 at 00:48):
Mario Carneiro said:
it would be nice if
instance
automatically diddef
/theorem
properly though
Is there an issue for this? I couldn't find one.
Mario Carneiro (Apr 18 2024 at 04:53):
no, I think it was just a TODO / HACK in the linter code
Jakob von Raumer (Nov 01 2024 at 22:32):
This still hasn't been fixed :confused:
Jakob von Raumer (Nov 01 2024 at 22:33):
So the way forward here is to fix instance
, not the linter, right?
Eric Wieser (Nov 01 2024 at 22:36):
I think there is an open PR that fixes instance
Last updated: May 02 2025 at 03:31 UTC