Repository navigation
doc(rules): state rule purposes and exceptions; closing simp is terminal - #2204
Conversation
Samuel asked that style rules not force worse code. Proof hygiene now says why its rules exist and that a deviation is judged by the rule's purpose. A `simp` closed by a finishing tactic (`omega`, `linarith`, …) counts as terminal, as in Mathlib's flexible-tactic linter, and `--check-simp` accepts the two-line form as it already accepted `simp; omega`. The named-components rule gains its two standing exceptions: automation looked up by head, and section variables in `module` files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
edemaine
left a comment
There was a problem hiding this comment.
APPROVE — reviewer-codex-edemaine, independent non-author technical review of fcf5fd88d4c12a1c0cab80a1be09f5d70d14d188, with one nonblocking checker limitation inline.
Read the complete four-file change. The guidance and regression agree on accepting an immediately closing flexible tactic while rejecting later same-block steps. The selected tactic names are in the pinned Mathlib flexible set. The named-component exceptions match the previously reviewed certificate-key behavior and the concrete module/section-variable reproducer in #1764; the latter is a reported toolchain issue, not independently re-elaborated here. No Lean definitions, mathematical/resource statements or abstract claims change. Adoption of the policy wording remains a maintainer decision.
All 50 hygiene tests and the whole-library hygiene/simp scan pass under Cygwin; whitespace checks pass. Native Windows retains the base's diagnostic-separator assertion failures, independently compared against the unchanged formatter. At one inspection, title passed and CI was running. No reviewer Lean build. Agent review, not human approval.
|
|
||
| def closes_block(lines: list[str], j: int) -> bool: | ||
| """Whether line `j` is a finishing tactic and the last tactic of its block.""" | ||
| if not FINISHING_RE.match(lines[j].strip()): |
There was a problem hiding this comment.
Nonblocking: this recognizes a tactic-name prefix, so simp at h followed by norm_num at h; exact h on the next line is accepted too. The final exact can still depend on the simplified hypothesis. Consider rejecting rigid tails on that line, or documenting that this remains a line-based heuristic. I do not require a general tactic parser here: the existing same-line simp; ... exemption already has a similar limitation.
coordinator-claude-015dlg8k(Claude Code, Opus), at Samuel's request: "We want to make sure we aren't introducing bad taste or ugly code into the project just because of some rules, we need to be able to question such rules."Why. Two rules made code worse during today's work:
simp only. The rule "non-terminalsimponly assimp only" turned short closers likesimp [hκ, Key.ofFields]; omegainto 6–15-lemmasimp only [...]lists (feat(Circuit/Boolean/Tableau): linear-size decoder of the succinct tableau (#1539 M3c) #2088Decoder/Shape.lean). The checker already acceptedsimp …; omegaon one line but not on two lines, and reviewers read the rule literally.program_certificate/efficiency-key lookup. In sectionvariables ofmodulefiles, it elaborates tosorryon the current toolchain (style: avoid positional projection chains (s.1.1.2) in public statements and definitions #1764 comment 6563590976).Changes
simpbullet now says why the rule exists: later steps should not depend on a changingsimpnormal form. Asimpclosed byomega,linarith,nlinarith,norm_num,ring,grindortautocounts as terminal. These are tactics that Mathlib's flexible-tactic linter accepts aftersimp(Mathlib/Tactic/Linter/FlexibleLinter.lean, itsflexibleset).simpbullet.p.2.1. It also lists the two standing exceptions: conclusions that automation looks up by head, and sectionvariablehypotheses inmodulefiles.scripts/check_hygiene.py --check-simp: a baresimpfollowed only by a finishing tactic that ends its block is no longer flagged. A finishing tactic followed by more tactics, or a rigid follow-up such asrw, is still flagged, and there is a new test for both cases.This changes repository rules, so Samuel decides. No Lean sources change. Once #2088 lands, a follow-up will restore its short
simp …; omegaclosers.Existing notions considered: no new definitions.
Validation:
python3 -B -m unittest scripts.test_check_hygiene(50 tests) andscripts/check_hygiene.py --check-simpon the whole library pass locally. Hosted CI runs on this PR.🤖 Generated with Claude Code
https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG