Skip to content

feat(FormalConjecturesUtil): linter for answer(sorry) in solved statements - #5077

Open
theebayuser wants to merge 2 commits into
google-deepmind:mainfrom
theebayuser:feat/solved-answer-sorry-linter
Open

feat(FormalConjecturesUtil): linter for answer(sorry) in solved statements#5077
theebayuser wants to merge 2 commits into
google-deepmind:mainfrom
theebayuser:feat/solved-answer-sorry-linter

Conversation

@theebayuser

@theebayuser theebayuser commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

follow-up pr to #4965: a linter that catches the answer(sorry) placeholders that
PR fixed by hand. Part of #1407.

linter.style.category_answer warns when a declaration tagged @[category research solved]
still writes answer(sorry). The check has to be syntactic: under the default google.answer
setting, answer(sorry) at Prop elaborates to a bare True, so by the time the term exists
the placeholder is gone. It scans the whole declSig, so it also catches value-position
answers such as IsGreatest S answer(sorry), not just answer(sorry) ↔ ….

This is the category-aware complement to #1958's AnswerLinter, which checks quantifier
scoping but does not read the category.

  • The shared toCategorySyntax/toCategories helpers move from CategoryDocstringLinter into
    Attributes/Basic so both linters use them.

  • Eight statements deliberately keep the placeholder and opt out with
    set_option linter.style.category_answer false in, each with a comment giving the reason:
    independence of ZFC (1119, 1175), constants not known explicitly (416, twice, and 975),
    question-form headlines whose answer is recorded in a variant (1007, 1026), and a TODO in
    GraphConjecture34.

  • Off by default; enabled repo-wide through weak.linter.style.category_answer in
    lakefile.toml, matching how the other style linters are switched on.

  • A repo-wide scan found no research solved declaration with a surviving answer(sorry)
    beyond those eight.

  • lake --wfail build FormalConjecturesForMathlib FormalConjecturesUtil — clean (8064 jobs)

  • lake --wfail test — the new FormalConjecturesTest/Util/Linters/CategoryAnswerLinter.lean
    pins both the firing and the silent cases with #guard_msgs

  • Negative control: temporarily removing one opt-out makes the linter fire at the expected
    line, and restoring it silences the warning again

…tatements

Adds `linter.style.category_answer`, which warns when a declaration tagged
`@[category research solved]` still uses `answer(sorry)`. The check is
syntactic: under the default `google.answer` setting `answer(sorry)` at
`Prop` elaborates to a bare `True`, so the placeholder is not visible in
the elaborated term.

The shared `toCategorySyntax`/`toCategories` helpers move from
CategoryDocstringLinter into Attributes/Basic so both linters use them.

Eight statements that deliberately keep the placeholder opt out with
`set_option linter.style.category_answer false in`, each with a comment
saying why: independence of ZFC (1119, 1175), constants that are not known
explicitly (416, twice, and 975), question-form headlines whose answer is
recorded in a variant (1007, 1026), and a TODO in GraphConjecture34.
@github-actions github-actions Bot added documentation Improvements or additions to documentation attributes linter erdos-problems Erdős Problems written-on-the-wall-ii labels Aug 20, 2026

@mo271 mo271 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

left some comments

Comment thread FormalConjectures/ErdosProblems/1007.lean Outdated
Comment thread FormalConjectures/ErdosProblems/1026.lean Outdated
Comment thread FormalConjectures/ErdosProblems/416.lean Outdated
Comment thread FormalConjectures/ErdosProblems/416.lean Outdated
Comment thread FormalConjecturesTest/Util/Linters/CategoryAnswerLinter.lean Outdated
Comment thread FormalConjecturesTest/Util/Linters/CategoryAnswerLinter.lean
Comment thread CONTRIBUTING.md Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

attributes documentation Improvements or additions to documentation erdos-problems Erdős Problems linter written-on-the-wall-ii

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants