Skip to content

Reject unexpected primed Lean axiom reports - #3634

Merged
Mister-Meeseeks merged 1 commit into
CrocSwap:mainfrom
roger-sato:fix/lean-axiom-primed-reports
Oct 20, 2026
Merged

Mister-Meeseeks merged 1 commit into
CrocSwap:mainfrom
roger-sato:fix/lean-axiom-primed-reports

Conversation

@roger-sato

Copy link
Copy Markdown
Contributor

Summary

The Lean axiom audit can report PASS 1 declarations while its actual compiler output contains a second theorem depending on a forbidden axiom. Both output regexes excluded apostrophes from names, so a primed name such as bad' was invisible to the report count and axiom checks. A normal audited theorem named actual' also failed with reported 0/1. Lean permits apostrophes in identifiers; see its identifier syntax.

For example, this valid Lean 4.21.0 source compiles successfully and prints both real axiom reports, but the original CLI reports success:

import Init
theorem good : True := True.intro
axiom custom : False
theorem bad' : False := custom
#print axioms good
#print axioms bad' #check Nat

The current source-query reader collects good from this fixture; the extra primed report must still be rejected by the output checker. Match names through the report delimiter, allowing apostrophes while keeping names within one output line. The existing report count, expected-name set, and axiom allowlist then reject the extra bad' report. The corrected CLI exits 1 and reports custom; the original exits 0 with PASS 1 declarations.

This changes only output parsing and adds a separate regression module. Pending #3602 addresses raw strings in the source-query lexer; that lexer and its tests are untouched here. The two fixes cover complementary boundaries. The selected result, theorem sources, frozen inputs, source maps, and certificates are unchanged. This remains a bounded audit helper, not a complete Lean parser or authentication against arbitrary hostile elaborators or loggers.

Test plan

  • Negative control on canonical main 20ecf2891d80b5acf18d980b2164fb44ea7faa90: the new test module produced 7 failures and 7 errors, including the actual Lean false PASS above and rejection of valid primed declarations.
  • LEAN_AUDIT_BIN=/path/to/lean-4.21.0/bin python3.12 -W error -B -m unittest discover -s tests -p 'test_lean_axiom*.py' -v — all 8 tests passed, including both live Lean test groups.
  • The same two modules with python3.12 -I -O -B ... -q — all 8 tests passed.
  • Real Lean positive controls cover an axiom-free primed theorem and a doubly primed theorem using allowed axioms. Real Lean negative controls cover the extra primed report, a custom axiom, and sorryAx. Every fixture compiles successfully before its audit outcome is checked.
  • Parser controls cover ordinary names, namespace/internal/multiple apostrophes, multiline axiom lists, malformed extra primed reports, duplicates, name mismatch, delimiter ambiguity, and CR/LF boundaries.
  • Existing comment/string controls and the three existing audit query inventories pass unchanged; git diff --check passes.
  • Combined this output fix with pending Ignore raw string contents when collecting Lean axiom queries #3602 in a disposable fixture: all 12 parser and live Lean tests passed; the patch also applies cleanly to Ignore raw string contents when collecting Lean axiom queries #3602.
  • Hosted CI, full formal-project builds, and the selected mathematical cold replay were not run for this output-parser change.

Environment: macOS arm64, CPython 3.12.14, Lean 4.21.0 (6741444a63ee). Without LEAN_AUDIT_BIN, the live tests explicitly skip; the parser controls still run.

Attribution and overlap

Retain the helper authors and @ywz65's source-scanner work in #2523. This correction extends the existing output checks independently of @roger-sato's pending #3602 source-lexer fix. Canonical base remains 20ecf2891d80b5acf18d980b2164fb44ea7faa90, priority revision 6. The fresh overlap snapshot covers 344 open PRs, 2,959 closed/merged PRs, and 2,453 Discussions; targeted all-state searches found no equivalent primed-report repair. This is bounded search coverage, not a general novelty claim.

Prepared by roger-sato with substantial OpenAI Codex assistance. Apache-2.0.

@roger-sato
roger-sato marked this pull request as ready for review October 18, 2026 11:44
@Mister-Meeseeks
Mister-Meeseeks merged commit eae5700 into CrocSwap:main Oct 20, 2026
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