Skip to content

compiler: 50 LaTeX kernel math symbols (\odot, \prec, \sqcup, \bigsqcup, the suits, harpoons and diagonal arrows) - #185

Closed
GoKubar wants to merge 3 commits into
mainfrom
agent/kabir-claude/math-kernel-symbols-compiler
Closed

GoKubar wants to merge 3 commits into
mainfrom
agent/kabir-claude/math-kernel-symbols-compiler

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Compiler half of the LaTeX kernel math-symbol gap #180's sweep found. Layout half is the sibling PR on agent/kabir-claude/math-kernel-symbols-layout (independent, both based on main 89e49fed, no stacking). Neither touches #180's or #181's branches.

#180 closed 10 of the 115 unsupported kernel commands and listed the other 105 tiered by what each needs. This PR + its sibling close 50 more, leaving 55.

What changed

Fifty commands that needed nothing but a COMMAND_GLYPHS row, a symbol_class arm and a decided export outcome. All fifty were diagnosed \… is not supported in math mode on main:

class (from fontmath.ltx) commands
\mathbin \odot \ominus \oslash \sqcap \sqcup \uplus \amalg \star \dagger \ddagger \wr \triangleleft \triangleright \bullet \diamond \bigcirc
\mathrel \prec \preceq \succ \succeq \sqsubseteq \sqsupseteq \asymp \smile \frown \owns \nearrow \nwarrow \searrow \swarrow \leftharpoonup \leftharpoondown \rightharpoonup \rightharpoondown
\mathop \bigsqcup \biguplus
\mathord \clubsuit \diamondsuit \heartsuit \spadesuit \flat \natural \sharp \imath \jmath \varrho \surd \mathdollar \mathsection \mathparagraph

Class comes from fontmath.ltx, never from the glyph's looks: \bullet and \diamond are \mathbin (283, 282), \preceq/\succeq \mathrel (324, 323), \bigsqcup/\biguplus \mathop with \displaylimits (262, 250). \surd is plain TeX's {\mathchar"1270} — class 1, but braced, so the atom is Ord, which the measurement confirms. \owns is \ni's own second name (331/332): same glyph, same class, one row.

Six of the 105 (\bullet, \diamond, \bigcirc, \owns, \varrho, \surd) were in #180's "macros, delimiters or package constructs, needs its own arm" tier. Reading fontmath.ltx shows five of them are plain \DeclareMathSymbols and \surd a one-line \mathchar, so they are table rows after all.

Measured against pdfTeX, not assumed

TeX Live 2025 pdflatex at 10pt. For each symbol, \showthe\wd0 of \hbox{$\sym$} is the declared slot's TFM width, and of \hbox{$a\sym b$} that width plus the glue the class adds, read against the $ab$ control of 9.57755pt — 0 for Ord, 2×3mu Op, 2×4mu Bin, 2×5mu Rel. A wrong family or slot moves the first; a wrong class moves only the second. All 50 agree, first run, no adjustment. Examples:

$\sym$ $a\sym b$ − control − glyph class
\amalg 7.50002 21.52190 4.44433 = 2×4mu Bin ✓
\asymp 7.77780 22.91077 5.55542 = 2×5mu Rel ✓
\bigsqcup 8.33336 21.24416 3.33325 = 2×3mu Op ✓
\clubsuit 7.77780 17.35535 0.00000 Ord ✓
\surd 8.33336 17.91090 −0.00001 Ord ✓ (the braces win)

tests/kernel_math_symbols.rs re-measures the same difference through the compiler — $a\sym b$ minus $a\mathord{\sym}b$, so the glyph width cancels — against a same-class symbol the compiler already carried (\ast Bin, \equiv Rel, \sum Op), plus an end-to-end glyph/diagnostic check and a display-limits check on the two operators.

Two code points corrected against the repo's own table

crates/compiler/tests/amsmath_corpus/oracle.py's OMS_TEXT already states what each cmsy slot carries — it is how the oracle names reference glyphs so words can align. 29 of my 31 symbols-family rows agreed with it; the two that did not were the ones I had taken from unicode-math's command aliases, and OMS_TEXT is right in both:

  • cmsy "0D \bigcirc is ◯ U+25EF (1013 in Latin Modern Math, cmsy's slot is exactly 1 em), not U+25CB (796) — a 20% narrow glyph.
  • cmsy "0F \bullet is ∙ U+2219, not U+2022. Same width, but U+2022 is also WinAnsi's bullet, so emitting it from math left the glyph on the text face.

\imath/\jmath moved the same way, caught by the real-world corpus rather than by reading: they are U+1D6A4/U+1D6A5 (322/384 — cmmi10's own 0.322456 em / 0.384030 em), not the text dotless pair U+0131/U+0237 (278/306).

Export

42 glyphs are bound to the pinned Latin Modern Math resource, advances read from the exact bundled font program (lm_math::ADVANCES 75 → 118 rows; tests/lm_math_binding.rs re-reads the file and fails on drift). \surd is Adobe Symbol's own radical.

Five are deliberately not in lm_math::ADVANCES: \dagger, \ddagger, \mathsection, \mathparagraph, \mathdollar. export::map_char consults that table before WinAnsi, so a row there takes the glyph over in ordinary prose too — a dagger in a footnote would start coming from the math face. They export as the real WinAnsi text glyphs instead. export's "every math symbol has a decided outcome" guard now states that exception explicitly (TEXT_FACE_MATH_SYMBOLS) rather than requiring the Symbol face for everything, and a test pins each one's WinAnsi code.

That exact hazard is what the real-world corpus caught: with \imath on U+0131, the unicode-accents fixture silently lost an export_limitation for a literal ı in prose. After the U+1D6A4 fix the corpus is identical again.

Gates

Font setup: a symlink-free flat directory of the repo's own apps/mac/Fonts/*.otf plus every .tfm under apps/mac/Fonts/texmf, and a real copy of that texmf tree next to the binary — the rooted required-metrics reader only looks at <exe>/../Resources/texmf, <exe>/texmf and <exe>/../share/flashtex/texmf, never at FLASHTEX_TFM_DIRS. Without it every run reports required_metrics_unavailable, silently falls back to OpenType MATH metrics, and both corpora score 0/59 and 0/39 on unmodified main. Every number below was taken only after asserting zero font_unavailable / required_metrics_unavailable / ec_metrics_unavailable.

gate main this branch
crates/compiler cargo test --release --no-fail-fast 395 passed 399 passed, 0 failed, 4 ignored (4 new tests)
crates/render-pipeline cargo test --release --no-fail-fast 170 passed, 1 ignored 170 passed, 0 failed, 1 ignored (unchanged; run with no FLASHTEX_* exports)
amsmath corpus 59/59 59/59, per-fixture identical
amssymb corpus 38/39 38/39, same single failure (32-braces-narrow)
real-world corpus (10 fixtures × 2 producers, --no-oracle) — 20/20 pairs identical: status, pages and exact diagnostic set
HW1 / HW2 (flashtex-render --tex) 3 / 3 pages 3 / 3 pages, 0 errors, 0 overfull

End-to-end, this is the point of the PR. A 12pt fixture holding $a\sym b$ for all 50 symbols with ASCII text anchors between them, measured against TeX Live 2025 pdflatex with the repo's own oracle machinery (pdftext.py, oracle.ref_pages/cand_pages) and vendor/compiler + vendor/math-layout locally swapped to this branch and its sibling (uncommitted, as the vendoring rules require):

anchors within 0.5 bp worst not supported diagnostics
pinned vendor (main) 4 / 60 236.853 bp 50
both branches vendored 60 / 60 0.006 bp 0

Anchors, not the math words: pdftext has no glyph-name table for cmmi/OMI, so the letters-family symbols read as ? on the reference side and cannot be paired by text. Each anchor's x is the cumulative width of every formula before it, so a wrong slot or class still moves it — which is exactly what the 236.853 bp control shows.

Follow-ups this PR does not take

  • supported/coverage.md does not move, and that is not a sign these did not land: its canonical denominator carries no math symbols at all — odot, alpha and every other symbol are absent from canonical-latex.tsv, whose 410 "kernel" commands come from the reference-manual index. The sweep found 509 math commands; the coverage metric can see none of them. Regenerating needs canonical_latex.py against TeX Live, and this box is TL2025 where the committed file came from TL2026, so I have not touched it.
  • The 55 kernel commands still unsupported are compiler: \colon as math punctuation, \mathbb as a real msbm alphabet, the largesymbols operators and \neg #180's list minus these 50: the 12 delimiters (\Vert \vert \backslash \Updownarrow \updownarrow \lgroup \rgroup \lmoustache \rmoustache \arrowvert \Arrowvert \bracevert), the 9 latexsym symbols (\Box \Diamond \Join \leadsto \lhd \rhd \unlhd \unrhd \mho, which need a whole new lasy symbol font the bundle does not ship), and the ~34 macros/accents/operators (\not, \hookleftarrow, \longmapsto, \smallint, \intop, \ointop, \mathring, \dddot, \pmb, \mathscr, \iiiint, \injlim, …).

Resume notes

  • Branch agent/kabir-claude/math-kernel-symbols-compiler, head 6fb5cb03, based on main 89e49fed. Three commits.
  • Sibling: agent/kabir-claude/math-kernel-symbols-layout, head c1702353.
  • Files: crates/compiler/src/{math,lm_math,export,vocabulary}.rs, crates/compiler/tests/kernel_math_symbols.rs, regenerated supported-latex.json ×2 and docs/user/compiler.md. No crates/render-pipeline/vendor/* file is committed (git diff origin/main -- crates/render-pipeline/vendor/ is empty).
  • To reproduce the end-to-end table: copy crates/compiler/src/{export,lm_math,math,supported,vocabulary}.rs over crates/render-pipeline/vendor/compiler/src/ and crates/math-layout/src/{cm,mathlist}.rs from the sibling branch over crates/render-pipeline/vendor/math-layout/src/ (all seven are byte-identical to main before these branches — verified), rebuild flashtex-render, put a real copy of apps/mac/Fonts/texmf next to the binary, and point --fonts at the flat OTF+TFM directory. Do not commit the vendor swap.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

GoKubar and others added 3 commits September 13, 2026 13:11
…ng class

A sweep of all 509 kernel/plain/latexsym/amssymb/amsmath math commands through
this compiler found amssymb essentially complete and the LaTeX *kernel* symbol
set the real gap. These are the 50 rows that needed nothing but a
`COMMAND_GLYPHS` entry, a `symbol_class` arm and a decided export outcome:
`\odot`, `\ominus`, `\oslash`, `\sqcap`, `\sqcup`, `\sqsubseteq`,
`\sqsupseteq`, `\uplus`, `\amalg`, `\star`, `\dagger`, `\ddagger`, `\wr`,
`\triangleleft`, `\triangleright`, `\bullet`, `\diamond`, `\bigcirc`, `\prec`,
`\preceq`, `\succ`, `\succeq`, `\asymp`, `\smile`, `\frown`, the four diagonal
arrows, the four harpoons, the four card suits, `\flat`/`\natural`/`\sharp`,
`\imath`, `\jmath`, `\varrho`, `\surd`, `\mathdollar`, `\mathsection`,
`\mathparagraph`, `\owns`, and the two `largesymbols` operators `\bigsqcup`
and `\biguplus`. All 50 were diagnosed "is not supported in math mode" before.

Class comes from `fontmath.ltx`, never from the glyph's looks: `\bullet` and
`\diamond` are `\mathbin` (283, 282), `\preceq`/`\succeq` `\mathrel` (324, 323),
`\bigsqcup`/`\biguplus` `\mathop` with `\displaylimits` (262, 250), and `\surd`
is plain TeX's `{\mathchar"1270}` -- braced, so Ord despite its class-1 code.
`\owns` is `\ni`'s own second name (331/332), so it is the same glyph and class.

Verified against pdfTeX (TeX Live 2025) at 10pt rather than assumed. For each
symbol `\showthe\wd0` of `\hbox{$\sym$}` gives the slot's TFM width and of
`\hbox{$a\sym b$}` that width plus the glue the class adds, read against the
`$ab$` control of 9.57755pt: 0 for Ord, 2x3mu Op, 2x4mu Bin, 2x5mu Rel. Every
one of the 50 agrees. `tests/kernel_math_symbols.rs` re-measures the same
difference through the compiler (`$a\sym b$` minus `$a\mathord{\sym}b$`, so the
glyph width cancels) against a same-class symbol the compiler already carried.

Export: 42 of the glyphs are bound to the pinned Latin Modern Math resource,
with advances read from the exact bundled font program (`lm_math::ADVANCES`,
75 -> 117 rows; `tests/lm_math_binding.rs` re-reads the file and fails on drift).
`\surd` is Adobe Symbol's own `radical`. `\dagger`, `\ddagger`, `\bullet`,
`\mathsection`, `\mathparagraph` and `\mathdollar` are deliberately NOT in
`lm_math::ADVANCES`: `export::map_char` consults that table before WinAnsi, so
a row there would take over the *text* face's own dagger, bullet and section
sign in ordinary prose. They export as the real WinAnsi text glyphs instead, and
`export`'s "every math symbol has a decided outcome" guard now states that
exception explicitly rather than requiring the Symbol face for everything.

The 14 of these names that sat in `vocabulary::KNOWN_UNIMPLEMENTED_COMMANDS`
moved out of it. Generated artefacts regenerated
(`crates/compiler/scripts/render_supported_latex.sh`,
`apps/mac/scripts/sync-supported-latex.sh`); `supported_latex.rs::
generated_artifacts_are_current` passes. `supported/coverage.md` does not move:
its canonical denominator carries no math symbols at all (`odot`, `alpha` and
the rest are absent from `canonical-latex.tsv`), which is a separate gap in the
metric, not a sign these did not land.

`crates/compiler` `cargo test --release --no-fail-fast`: 399 passed, 0 failed,
4 ignored (was 395 on main; 4 new tests).

Implementation-Agent: engine-engineer (kabir-claude lane, NixOS linux-primary)
Commit-Executor: claude-code (direct Git fallback, Cursor usage limit)

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
…rries

Cross-checked the 31 `symbols`-family rows of the previous commit against the
mapping this repo already states for family 2 -- `OMS_TEXT` in
`crates/compiler/tests/amsmath_corpus/oracle.py`, which names cmsy glyphs so the
oracle's reference words can align with FlashTeX's. 29 of 31 agree. The two that
did not were the two I had taken from `unicode-math`'s aliases instead:

* cmsy `"0D` `\bigcirc` -- `unicode-math` maps it to U+25CB, whose Latin Modern
  Math advance is 796; cmsy's own width is 1 em (`\hbox{$\bigcirc$}` is
  10.00002pt at 10pt), and U+25EF, which `OMS_TEXT` names, is 1013. U+25CB was
  the wrong glyph and would have set the symbol 20% narrow.
* cmsy `"0F` `\bullet` -- U+2219 (`OMS_TEXT`) and U+2022 (`unicode-math`) are
  both 500 in Latin Modern Math, so nothing moves, but U+2022 is also WinAnsi's
  bullet: emitting it from math left the glyph on the *text* face, and a row in
  `lm_math::ADVANCES` to fix that would have taken the text face's own bullet
  away from ordinary prose. U+2219 has neither problem.

So `\bullet` leaves the text-face exception list, which is now the five symbols
that genuinely have no Symbol-face glyph and a real WinAnsi one: `\dagger`,
`\ddagger`, `\mathsection`, `\mathparagraph`, `\mathdollar`.
`lm_math::ADVANCES` 117 -> 118 rows.

`crates/compiler` `cargo test --release --no-fail-fast`: 399 passed, 0 failed,
4 ignored. Generated artefacts regenerated.

Implementation-Agent: engine-engineer (kabir-claude lane, NixOS linux-primary)
Commit-Executor: claude-code (direct Git fallback, Cursor usage limit)

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
Found by the real-world corpus, which was otherwise byte-identical between main
and this branch: the `unicode-accents` fixture lost an `export_limitation` for a
literal `ı` (U+0131) in *prose*. That was the previous commit's `\imath` row
reaching into text -- the same failure mode the dagger and bullet rows avoid --
and the width was wrong besides. cmmi10 sets `\imath` 0.322456 em and `\jmath`
0.384030 em wide (pdfTeX `\showthe\wd0`: 3.22456pt and 3.84030pt at 10pt); in
the bundled Latin Modern Math that is U+1D6A4 (322) and U+1D6A5 (384), the
Mathematical Alphanumeric dotless letters `unicode-math` names for these two
commands. The text dotless pair U+0131/U+0237 is 278 and 306 -- 14% and 20%
narrow. Switched both, so prose keeps its own U+0131 and the compiler's layout
gets cmmi's width.

The render pipeline's geometry was already right either way: it sets the atom at
cmmi `"7B`/`"7C` from the TFM, and the character is only the key. This moves the
compiler's own approximate layout (the Mac preview) and the export decision.

`crates/compiler` `cargo test --release --no-fail-fast`: 399 passed, 0 failed,
4 ignored. Generated artefacts regenerated.

Implementation-Agent: engine-engineer (kabir-claude lane, NixOS linux-primary)
Commit-Executor: claude-code (direct Git fallback, Cursor usage limit)

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 superseded — the work is already on main.

Replacement: suits/\odot/\sqcup are on main; sibling #186 merged as 9bdcd5c

Closed by the integration lane while clearing a 219-PR backlog (112 of them drafts). If this is wrong, reopen it and tell me — I would rather be corrected than leave stale work buried.

— orchestrator-astra (Commander)

@GoKubar GoKubar closed this Sep 15, 2026
@GoKubar
GoKubar deleted the agent/kabir-claude/math-kernel-symbols-compiler branch September 16, 2026 04:18
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