Skip to content

math: the four kernel cmsy square relations (\sqcup, \sqcap, \sqsubseteq, \sqsupseteq) - #210

Merged
GoKubar merged 1 commit into
mainfrom
engine/math-square-relations
Sep 13, 2026
Merged

GoKubar merged 1 commit into
mainfrom
engine/math-square-relations

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Adds \sqcup, \sqcap, \sqsubseteq and \sqsupseteq, which the compiler had no rows for at all.

These are base LaTeX2e kernel symbols, not amssymb — a point worth stating because the neighbouring amssymb work suggested otherwise. fontmath.ltx:

279: \DeclareMathSymbol{\sqcup}{\mathbin}{symbols}{"74}
278: \DeclareMathSymbol{\sqcap}{\mathbin}{symbols}{"75}
301: \DeclareMathSymbol{\sqsubseteq}{\mathrel}{symbols}{"76}
302: \DeclareMathSymbol{\sqsupseteq}{\mathrel}{symbols}{"77}

Oracle evidence

pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025). \show gives \mathchar"2274, "2275, "3276, "3277 both with and without amssymb loaded — family 2 (cmsy), slots "74–"77, and amsfonts does not touch them (it adds only the strict \sqsubset/\sqsupset, from msam — a separate gap, fixed in #PR3).

Atom classes measured at 10pt against the $ab$ control (9.57755pt):

probe measured decomposition class
$a\sqcup b$ 20.68857pt 9.57755 + 6.66669 + 8mu Bin
$a\sqcap b$ 20.68857pt same Bin
$a\sqsubseteq b$ 22.91077pt 9.57755 + 7.7778 + 10mu Rel
$a\sqsupseteq b$ 22.91077pt same Rel

1mu = 10/18pt, so 8mu = 4.44444pt and 10mu = 5.55556pt; measured residuals are 4.44433pt and 5.55542pt. $\subseteq$ measures identically to $\sqsubseteq$ — a cross-check that both are cmsy relations of the same design width.

Export

The base-14 Symbol face has no square cup/cap or square subset, so the four glyphs are bound to the pinned Latin Modern Math resource like the other symbols in lm_math. That is what keeps export's every_math_symbol_has_a_decided_export_outcome guard satisfied. Their advances (667 and 778 per 1000 em) are read from the pinned font program and agree with the pdfLaTeX measurements above.

Scope

Compiler-side only (the non-TFM layout). Two companions, all three based on main, none stacked:

  • math-layout cm::symbol_slot gets cmsy "74–"77 so the TFM path boxes them as pdfLaTeX does.
  • the generator PR fixes a separate, false SKIP premise.

End-to-end output needs all three plus a render-pipeline vendor re-pin (done locally, left uncommitted per instruction).

Gates

cargo test on crates/compiler: 439 passed, 1 failed vs a control checkout of the same base at 438 passed, 1 failed. The +1 is this PR's new test; the single failure is the pre-existing canonical_names_outside_the_inventory_are_diagnosed (assertion failed: !BUILT_INS.contains(&name), parser.rs:5227), which fails identically on main. tests/robustness.rs's deeply_nested_input_does_not_blow_the_stack overflows its stack on this NixOS host on main too — environment, not this change.

No fixture in the real-world, amsmath or amssymb corpora uses any of these four commands, so those gates are untouched by construction (verified by grep with word boundaries).

docs/user/compiler.md and supported/supported-latex.json regenerated with scripts/render_supported_latex.sh (537 → 541 math command entries). supported/coverage.md is unchanged: the canonical denominator does not list these names.

Draft — not for merge while main is in the release sequence.

…teq, \sqsupseteq)

These are base LaTeX2e kernel symbols, not amssymb, and the compiler had
none of them. `fontmath.ltx` declares them from the `symbols` (cmsy)
family:

    279: \DeclareMathSymbol{\sqcup}{\mathbin}{symbols}{"74}
    278: \DeclareMathSymbol{\sqcap}{\mathbin}{symbols}{"75}
    301: \DeclareMathSymbol{\sqsubseteq}{\mathrel}{symbols}{"76}
    302: \DeclareMathSymbol{\sqsupseteq}{\mathrel}{symbols}{"77}

Verified against pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025). `\show`
gives \mathchar"2274, "2275, "3276 and "3277 both with and without
amssymb loaded, confirming family 2 (cmsy) and the slots above, and that
amsfonts does not touch them -- it adds only the strict `\sqsubset` and
`\sqsupset`, which come from msam and are a separate gap.

Classes measured at 10pt against the 9.57755pt `$ab$` control:

    $a\sqcup b$       20.68857pt = 9.57755 + 6.66669 + 8mu   -> Bin
    $a\sqcap b$       20.68857pt                             -> Bin
    $a\sqsubseteq b$  22.91077pt = 9.57755 + 7.7778  + 10mu  -> Rel
    $a\sqsupseteq b$  22.91077pt                             -> Rel

(1mu = 10/18pt here, so 8mu = 4.44444pt and 10mu = 5.55556pt; the
measured residuals are 4.44433pt and 5.55542pt.) `$\subseteq$` measures
identically to `$\sqsubseteq$`, a useful cross-check that both are cmsy
relations of the same design width.

The base-14 Symbol face has no square cup/cap or square subset, so the
glyphs are bound to the pinned Latin Modern Math resource like the other
symbols in `lm_math`, which is what keeps `export`'s
`every_math_symbol_has_a_decided_export_outcome` guard satisfied. Their
advances (667 and 778 per 1000 em) are read from the pinned font program
and agree with the pdfLaTeX measurements above.

This is the compiler's own (non-TFM) layout only. The matching
math-layout change that boxes them from the cmsy TFM at "74-"77 is a
separate PR against `cm::symbol_slot`; end-to-end output needs both plus
a render-pipeline vendor re-pin.

docs/user/compiler.md and supported/supported-latex.json are regenerated
with scripts/render_supported_latex.sh (537 -> 541 math command entries);
supported/coverage.md is unchanged because the canonical denominator does
not list these names.

Implementation-Agent: engine-engineer (Claude Opus 5), linux-primary
Commit-Executor: engine-engineer (Claude Opus 5), direct git

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

GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

End-to-end gate results

Verified locally with all three PRs of this set applied together (#210 compiler kernel relations, #211 math-layout slots, #212 generator) plus a local, uncommitted render-pipeline vendor re-pin — the four vendored files (vendor/compiler/src/{math,lm_math,amssymb}.rs, vendor/math-layout/src/cm.rs) were byte-identical to main beforehand, so the re-pin is a straight file copy and no vendor change is committed anywhere.

Environment: bundled fonts only (FLASHTEX_FONT_DIRS=apps/mac/Fonts, FLASHTEX_TFM_DIRS = bundled lm + ec + amsfonts/symbols). The system TeX Live is used as an oracle only, never in the product path. CARGO_BUILD_JOBS=8.

gate control (same base, 08f49796) with these PRs
crates/compiler 438 passed, 1 failed 440 passed, 1 failed
crates/math-layout 56 passed, 0 failed 57 passed, 0 failed
crates/render-pipeline 186 passed, 3 failed 186 passed, 3 failed
amsmath corpus 59/59 59/59
amssymb corpus 38/39 38/39
HW1 3 pages, 0 overfull, 0 errors 3 pages, 0 overfull, 0 errors
HW2 3 pages, 0 overfull, 0 errors 3 pages, 0 overfull, 0 errors
real-world corpus 10 fixtures identical pages and diagnostic counts in every fixture

Failing sets are identical to the control, not just the counts:

  • compiler: canonical_names_outside_the_inventory_are_diagnosed (assertion failed: !BUILT_INS.contains(&name), parser.rs:5227), plus tests/robustness.rs's deeply_nested_input_does_not_blow_the_stack, which overflows its stack on this NixOS host. Both fail identically on main.
  • render-pipeline: font_family_fixtures_match_pdflatex, footnotes_against_pdflatex, page_frame_against_pdflatex — the env-contaminated controls.
  • amssymb: the single failure is 32-braces-narrow, worst 1.012 bp, identical on the control.

Note cargo test stops at the first failing test binary, so every run above used --no-fail-fast; without it the compiler crate reports only ~399 of its tests.

Corpus references are MacTeX 2026 and were not regenerated (--no-oracle); the amsmath/amssymb oracle checks ran against the committed refs.

Font diagnostics on the gates: HW1, HW2 and the amsmath/amssymb corpora report zero. The corpus-wide run shows 3 pre-existing ec_metrics_unavailable diagnostics (missing ectt1000/ectt1200 T1 typewriter TFMs) in article-twocolumn and input-bibliography only — identical on the control, unrelated to this work.

Before/after on the actual commands

A probe document ($a\sqcup b$ … $\angle$ $\hbar$ $\mho$) through the control compiler binary built from 08f49796:

unknown_command | \sqcup is not supported in math mode
unknown_command | \sqcap is not supported in math mode
unknown_command | \sqsubseteq is not supported in math mode
unknown_command | \sqsupseteq is not supported in math mode
unknown_command | \sqsubset is not supported in math mode
unknown_command | \sqsupset is not supported in math mode
unknown_command | \rightleftharpoons is not supported in math mode
unknown_command | \mho is not supported in math mode

With these PRs: zero unknown_command diagnostics, and the render reports msam10/msbm10 resource profiles, confirming the amsfonts symbols take the msam/msbm path rather than a fallback.

So eight commands move from hard-unsupported to rendering; \angle and \hbar rendered before but from a generic Latin Modern glyph matching neither of pdfLaTeX's two answers, and now take their declared msam/msbm slots.

Coverage gap worth a follow-up

No fixture in the real-world, amsmath or amssymb corpora uses any of these ten commands (checked by word-boundary grep). That is why the gates are unmoved — but it also means the 39-fixture amssymb corpus never exercised the symbols the generator was dropping, and there is no position-level oracle fixture for them yet. Adding one is the natural next step, and would give these symbols the same 0.5 bp treatment the rest of the corpus gets.

@GoKubar
GoKubar marked this pull request as ready for review September 13, 2026 21:43
@GoKubar
GoKubar merged commit fd385a3 into main Sep 13, 2026
19 of 20 checks passed
@GoKubar
GoKubar deleted the engine/math-square-relations branch September 16, 2026 04:17
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