Skip to content

doc(rules): state rule purposes and exceptions; closing simp is terminal - #2204

Merged
SamuelSchlesinger merged 1 commit into
mainfrom
claude/rules-purpose
Nov 2, 2026
Merged

SamuelSchlesinger merged 1 commit into
mainfrom
claude/rules-purpose

Conversation

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator

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:

Changes

  • AGENTS.md, Proof hygiene:
    • A short preamble: the rules serve readability and robustness. When one makes a specific proof or statement worse, deviate, say why, and propose an amendment. Reviewers judge by purpose, not letter.
    • The simp bullet now says why the rule exists: later steps should not depend on a changing simp normal form. A simp closed by omega, linarith, nlinarith, norm_num, ring, grind or tauto counts as terminal. These are tactics that Mathlib's flexible-tactic linter accepts after simp (Mathlib/Tactic/Linter/FlexibleLinter.lean, its flexible set).
  • CONTRIBUTING.md:
  • scripts/check_hygiene.py --check-simp: a bare simp followed 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 as rw, 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 …; omega closers.

Existing notions considered: no new definitions.

Validation: python3 -B -m unittest scripts.test_check_hygiene (50 tests) and scripts/check_hygiene.py --check-simp on the whole library pass locally. Hosted CI runs on this PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

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 edemaine 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.

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.

Comment thread scripts/check_hygiene.py

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()):

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.

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.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit 66a6a0c Nov 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants