Skip to content

Avoiding some false positives in check_primality#526

Merged
pogudingleb merged 2 commits into
masterfrom
check_primality
Jun 23, 2026
Merged

Avoiding some false positives in check_primality#526
pogudingleb merged 2 commits into
masterfrom
check_primality

Conversation

@pogudingleb

Copy link
Copy Markdown
Collaborator

This PR is a minor cleanup of #525

ChrisRackauckas and others added 2 commits June 23, 2026 00:04
check_primality(polys, extra_relations) substitutes the non-leader
variables of each generator with random integers, then tests whether the
characteristic polynomial of a generic multiplication operator on the
resulting zero-dimensional quotient is irreducible. The random
specialization could land on a point where a generator's leading
coefficient (w.r.t. its leader) vanishes, dropping that generator's degree
in its leader. When every generator collapses to degree 1, the quotient
ring becomes 1-dimensional, its charpoly is a degree-1 (hence trivially
irreducible) polynomial, and the routine reports the ideal as prime even
when it is not.

This is a soundness bug: for the io_projections issue-#132 case the ideal
is not prime, yet ~6/500 RNG seeds drove check_primality(proj) to return
true. It surfaced as a master red on the julia-pre (1.13.0-rc1) Core lane,
whose changed global-RNG stream happened to hit such a draw at
test/bodies/io_projections.jl:55 (`@test !check_primality(proj)`).

Fix: only accept random specializations that preserve every generator's
degree in its leader, i.e. that stay on the open set where the leading
coefficients do not vanish (the set the ideal is implicitly saturated at,
per the docstring). Resample otherwise, with a bounded retry. The
extra_relations are evaluated at the same point, matching the previous
behavior.

Verified on Julia 1.13.0-rc1: false-positive rate over seeds 0..499 drops
from 6/500 to 0/500; io_projections body 10/10 (was 9/1); positive case
check_primality(proj, [projection_poly]) 50/50 true. No regression on Julia
1.12: io_projections 10/10, check_primality_zerodim 5/5.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pogudingleb pogudingleb merged commit cbacce8 into master Jun 23, 2026
13 checks passed
@pogudingleb pogudingleb deleted the check_primality branch June 23, 2026 11:26
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.

2 participants