Skip to content

refactor: decide primality instead of hand-writing it, and commit the example field - #9300

Merged
kim-em merged 2 commits into
mainfrom
ff-manual-conway
Aug 20, 2026
Merged

refactor: decide primality instead of hand-writing it, and commit the example field#9300
kim-em merged 2 commits into
mainfrom
ff-manual-conway

Conversation

@kim-em

@kim-em kim-em commented Aug 20, 2026

Copy link
Copy Markdown
Owner

This PR adds a Decidable instance for Hex.Nat.Prime, through a bounded restatement of the divisor condition, so that a concrete prime is by decide. Nine hand-written divisor case splits across HexConway, HexBerlekamp, HexGF2Mathlib, and four manual chapters collapse to one line each.

It commits GF(5^4) as HexGFqField/Example.lean: the modulus x^4 + 2, its Rabin certificate, the checked irreducibility proof, and the field itself. Both manual worked examples previously rebuilt that certificate inline, carrying an 8M-heartbeat and 131072-recursion bump in the chapter text; they now cite the committed result instead.

Exposing checkIrreducibilityCertificateLinear and checkPowChainLinear is what makes that possible. Without exposed bodies decide gets stuck on the unreduced application from a module file, so the checker's own docstring promise that rabinTest f hmonic = true "should be discharged by decide" was unreachable for precisely the callers it was written for.

Finally, the HexConway chapter gains a section on the two table-regeneration commands and links to hex-gfq and hex-gfq-field.

🤖 Prepared with Claude Code

Kim Morrison added 2 commits August 20, 2026 05:26
… example field

Adds a Decidable instance for Hex.Nat.Prime, via a bounded restatement
of the divisor condition, so a concrete prime is by decide. Nine
hand-written divisor case splits across HexConway, HexBerlekamp,
HexGF2Mathlib, and four manual chapters collapse to one line each.

Commits GF(5^4) as HexGFqField/Example.lean: the modulus x^4 + 2, its
Rabin certificate, the checked irreducibility proof, and the field. The
manual's two worked examples cited a certificate they rebuilt inline,
with an 8M-heartbeat and 131072-recursion bump in the chapter text; they
now cite the committed result.

Exposes checkIrreducibilityCertificateLinear and checkPowChainLinear.
Without exposed bodies, decide gets stuck on the unreduced application
from a module file, so the checker's own docstring promise that
'rabinTest f hmonic = true should be discharged by decide' was
unreachable for exactly the callers it was written for.

Documents the two table-regeneration commands in the HexConway chapter
and links it downstream to hex-gfq and hex-gfq-field.

Progress file: progress/20260820T120000Z_finite-field-completion.md
… the proof-only source changes

CI reported 'pclmul did not compile on this host; skipping' and exited
zero: the x86 wrapper reads the high half with _mm_extract_epi64, which
is SSE4.1, so -mpclmul alone leaves it uninlinable. Adds -msse4.1, and
removes the skip-on-failure branch that turned that into a pass. A check
whose whole purpose is to run both compiled paths must not report success
when one of them did not build.

Records the two source changes this branch makes to measured factorization
inputs as proof-only: new declarations on a Prop-valued predicate, and two
@[expose] attributes, neither of which alters compiled code.
@kim-em
kim-em merged commit 795b315 into main Aug 20, 2026
1 check passed
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