Skip to content

Guard PARI polgalois on unsupported number-field degrees - #7168

Open
roed-math wants to merge 3 commits into
LMFDB:mainfrom
roed-math:ai/t41-nf-snippet-errors
Open

Guard PARI polgalois on unsupported number-field degrees#7168
roed-math wants to merge 3 commits into
LMFDB:mainfrom
roed-math:ai/t41-nf-snippet-errors

Conversation

@roed-math

Copy link
Copy Markdown
Contributor

Closes #6759.

Some auto-generated code snippets on number-field pages error when run. The snippet CI harness cannot catch them because it only exercises degree <= 2 fields, so I ran every number-field snippet across a spread of fields (Q, imaginary/real quadratic, monogenic and non-monogenic cubics, a quartic, and a degree-12 field). That surfaced three genuine bugs; two of them, the Magma Galois-group assignment (= instead of :=) and Magma's collapse of a degree-1 polynomial to the rationals on the Q page, have since been fixed on main by #7079, which represents Q as RationalsAsNumberField(). Those changes are dropped here, leaving a single rational-field strategy, and this PR now carries only the third fix.

PARI's polgalois hard-errors above degree 11 ("sorry, galois of degree higher than 11 is not yet implemented"), and it is unconditional only through degree 7: degrees 8 to 11 need the optional galdata package, which is not part of a stock PARI installation. The galois_group snippet in lmfdb/number_fields/code.yaml is now guarded so that either case returns an explanatory string instead of aborting the rest of the snippet file, while any other polgalois failure still propagates.

Verified in PARI 2.17.2 (via sage --gp) for degrees 2, 8 and 12, both with galdata present and with datadir pointed at a directory without it. The two committed gp snippet-test logs are updated for the new Galois line; their computed output is unchanged, and re-running the Magma snippet harness reports no change to the committed Magma logs. Two regression tests are added in lmfdb/number_fields/test_numberfield.py: one checks that the degree-12 gp download is guarded and never emits a bare polgalois(K.pol) line, the other pins the Magma representation of Q to RationalsAsNumberField() in both the field definition and the self-contained class-number-formula snippet.

One issue is intentionally left as a documented limitation: the PARI analytic-class-number-formula snippet overflows the default PARI stack on high-degree fields (a resource limit, not a code error), so no allocatemem directive is injected into a user-facing snippet.


Ported from roed-math#32, where the full write-up and comment history live.

🤖 Generated with Claude Code

roed314 and others added 3 commits July 19, 2026 12:23
Running the number field snippets across a spread of fields (Q, quadratic,
cubic, quartic, degree 12) surfaced three genuine errors that the snippet CI
harness cannot catch, since it only tests degree <= 2 fields and skips Magma:

- The Magma galois_group snippet used `=` (equality) instead of `:=`
  (assignment), erroring on every field.
- Magma's NumberField collapses a degree-1 polynomial to the rationals, so
  the Q field page (1.1.1.1) broke on unit rank, regulator, subfields and the
  class number formula; fixed with `DoLinearExtension := true` in the field
  and class-number-formula snippets.
- PARI's polgalois hard-errors above degree 11; now guarded with an if() that
  returns an explanatory message (degree <= 11 is unchanged).

Updates the two committed gp snippet-test logs for the new PARI Galois command
line (its output is unchanged). Verified by executing the fixed snippets in
sage, sage --gp and Magma across the field spread.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…t-errors

# Conflicts:
#	lmfdb/number_fields/code.yaml
)

The Magma Galois assignment and rational-field fixes carried by this branch
were superseded by LMFDB#7079, which represents Q as
RationalsAsNumberField().  Drop the DoLinearExtension templates so there is a
single rational-field strategy: with them in place the exact
replace("NumberField(x)", "RationalsAsNumberField()") in
WebNumberField.make_code_snippets() silently became dead code, and the
committed Magma logs no longer matched the templates.

Extend the PARI guard to the real support boundary.  polgalois is
unconditional only through degree 7; degrees 8 to 11 need the optional galdata
package, and above 11 it hard-errors.  Both cases now yield an explanatory
string, while any other polgalois failure still propagates.

Verified in PARI 2.17.2 via sage --gp for degrees 2, 8 and 12, with galdata
present and with datadir pointed at a directory without it.  The Magma snippet
harness reports no change to the committed Magma logs; the two gp logs differ
only in the echoed command line, with identical computed output.  Adds
regression tests for the guarded degree-12 gp download and for the Magma
representation of Q.  sage -python -m pytest
lmfdb/number_fields/test_numberfield.py -> 36 passed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

Auto-generated errors in code snippets in number fields

2 participants