Skip to content

compiler: theorem records, kernel/amsthm heads, \newtheoremstyle, \qedhere - #149

Closed
GoKubar wants to merge 1 commit into
mainfrom
agent/kabir-claude/theorem-fidelity-compiler
Closed

GoKubar wants to merge 1 commit into
mainfrom
agent/kabir-claude/theorem-fidelity-compiler

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Compiler half of the theorem-fidelity lane. This PR is based on main and has no dependencies. The render-pipeline layout comes in a separate PR that needs this one pinned into vendor/compiler.

What changes

  • Structured data, non-breaking. Two side tables are added to Parsed. No Block or Inline enum changes.
    • theorems: Vec<TheoremRecord>: kind (kernel / amsthm / proof), \begin[note] and \end spans, name, number, note, swap, fonts (head, note, body), head punctuation, head space, indent, and \thm@preskip/\thm@postskip.
    • qed_marks: Vec<QedMark>: each end-of-proof symbol, placed at the end of a proof, by \qedhere in text, by \qedhere inside a display, or by an explicit \qed.
  • Heads follow the sources.
    • Without amsthm, latex.ltx \@begintheorem: {\bfseries Name Number (Note)} with no period.
    • With amsthm: head font, note in \thm@notefont, and the period in the head font.
  • New commands.
    • \newtheoremstyle (amsthm.sty 236-272). A custom head spec (argument 9) is diagnosed.
    • \swapnumbers.
    • amsmath \numberwithin.
    • [within] on any counter: numbering now uses xref::Counters, with a new set_within.
    • \renewcommand of \proofname and \qedsymbol.
    • \@addpunct for proof headings.
    • \qedhere in text and in math.
  • The supported inventory is regenerated. amsmath commands go from 35 to 36.

Tests

  • tests/amsthm.rs: 26 tests, up from 17. They cover kernel vs amsthm heads, records, \newtheoremstyle, \swapnumbers, \numberwithin, and \qedhere in a list and in a display.
  • cargo test: everything passes except supported_latex::canonical_names_outside_the_inventory_are_diagnosed. It fails the same way on origin/main (built-in \and reaches unsupported), so it predates this PR.
  • clippy -D warnings is clean on the lib and the touched tests. src/main.rs has a clippy error that predates this PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

…dhere

Theorem-like environments now carry the structure a faithful layout needs,
as non-breaking side tables on Parsed:

- Parsed::theorems: one TheoremRecord per instance (kernel \newtheorem,
  amsthm \newtheorem, proof) with kind, \begin[note] and \end spans,
  name/number/note, swap, head/note/body fonts, head punctuation, head
  space (kernel \labelsep, amsthm \thm@headsep glue, { }, \newline),
  indent and \thm@preskip/\thm@postskip.
- Parsed::qed_marks: every end-of-proof symbol (\end{proof}, text
  \qedhere, \qedhere inside a display, \qed) with its placement.

Heads follow the sources: without amsthm, latex.ltx \@BeginTheorem
({\bfseries Name Number (Note)}, no period, italic body); with amsthm,
\thm@headfont Name Number, the note in \thm@notefont, \thm@headpunct in
the head font. New: \newtheoremstyle (amsthm.sty 236-272), \swapnumbers,
amsmath \numberwithin, [within] on any counter (theorem numbering moves
onto xref::Counters, new Counters::set_within), \renewcommand of
\proofname/\qedsymbol, \@addpunct for proof headings, \qedhere (text and
math mode). Supported inventory regenerated.

Tests: tests/amsthm.rs 26 (was 17); compiler cargo test all green except
supported_latex::canonical_names_outside_the_inventory_are_diagnosed,
which fails identically on origin/main (built-in \and reaches
unsupported; pre-existing). clippy --lib and touched tests -D warnings
clean (main.rs has a pre-existing clippy error).

Implementation-Agent: Claude Opus 5 (subagent kabir-claude theorem fidelity, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
Conflicts: lib.rs modules (boxes + color/color_names), parser.rs modules (hyperlinks/boxes/lists + colors) and Inline enum (#137's Box/SetLength/LengthGlue + #150's ColorBox variant, then main's ReferenceForm and #150's ColorBox struct), incremental.rs span shifting (both). Integration fixes: #150's parser/colors.rs box_inlines renamed color_box_inlines (clashed with #137's); #149's theorems.rs ITALIC const gains color: None; set_length records \fboxsep/\fboxrule before #137's set_box_length claims the assignment, so \colorbox sees it (xcolor_parse fboxsep 3.0 vs 5.0).

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
Semantic overlap with #153 resolved to one counter model: equation/figure/table step through xref::Counters (#155); Counters::report() registers them within chapter (#153's numbering), so \chapter's step resets them, and #153's hand-kept equation/figure/table counters and within_chapter are removed. Kept #131's caption/equation hyperref anchors and label_inline. Conflicts: HOST_PRELUDE (amsthm defaults + \counterwithin/\counterwithout pass-through), parser.rs fields/dispatch/captions/bibliography OpenList + subequations begin/end/equation/multirow/labels, supported.rs (counter commands + main's hyperref url/href). Also: Counters::set_within rewritten on #155's Vec reset_by/pieces; #149's \numberwithin arm and fn removed (shadowed #155's counter_numbering with [style]); #155's theorem-counter special case removed (theorem counters are Counters entries since #149); TEXT_EXTRA_ARMS drops numberwithin (now in BUILT_INS); unused HashMap import in parser/boxes.rs.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
…ession handoff)

Stage 1 partly done: #131, #137, #153 (incl. #142), #144, #147, #149, #150,
#155, #159, #163, #164 merged with conflicts and post-expansion fixes recorded
in docs/evidence/integration-2026-09-13b/merge-log.md. Remaining: #166, #169,
#148, #161, then the inventory regeneration and stages 2-4. The helper scripts
under tools/ hard-code the original worktree path.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
…merges

Every stage 1 merge took main's side of the generated inventory and deferred
the regeneration to the end of the stage. Running
crates/compiler/scripts/render_supported_latex.sh picks up #131, #137, #144,
#147, #149, #150, #153, #155, #159, #163, #164, #166 and #169, so
supported_latex::generated_artifacts_are_current passes again.

The TeX Live-derived canonical denominator is deliberately untouched: this
machine has TeX Live 2025, not the MacTeX the committed file was pinned from.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, nixos-pc-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@GoKubar

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing as abandoned (per backlog triage). The theorem lane landed on main through a different architecture while this draft sat: crates/compiler/src/theorems.rs plus merged amsthm PRs #190, #196, #480 and #267. This draft's TheoremRecord side-table model conflicts with that landed design. Its genuinely-unlanded pieces — \newtheoremstyle, \swapnumbers, \qedhere (absent from crates/compiler/src on main) — are worth re-implementing on top of theorems.rs, but that is a new task, not this branch. agent/kabir-claude/theorem-fidelity-compiler is preserved.

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.

1 participant