Skip to content

Guard power series square tests over unsupported rings - #42785

Merged
vbraun merged 1 commit into
sagemath:developfrom
cxzhong:codex/fix-41220-power-series-is-square
Sep 29, 2026
Merged

vbraun merged 1 commit into
sagemath:developfrom
cxzhong:codex/fix-41220-power-series-is-square

Conversation

@cxzhong

@cxzhong cxzhong commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

((x + 4)^2).is_square() over Zmod(16)[[x]] currently returns False. The valuation and leading-coefficient tests assume an integral domain; nilpotent coefficients can invalidate both tests.

Raise NotImplementedError for nonconstant series over non-integral domains before applying either test. Also reject nonconstant series in characteristic 2, where the existing field shortcut incorrectly accepts 1 + x. Zero and constant series remain directly decidable through the base ring.

This is a conservative restriction of the generic algorithm, including over reduced rings with zero divisors. Regression doctests cover the original example, an even-valuation square with nonsquare leading coefficient over Zmod(9), Zmod(15), characteristic 2, zero, and constant series.

Fixes #41220.

Validation

Rebuilt the Cython extension and passed 1,278 doctests:

  • src/sage/rings/power_series_ring_element.pyx: 520 tests
  • src/sage/rings/power_series_poly.pyx: 287 tests
  • src/sage/rings/laurent_series_ring_element.pyx: 471 tests

git diff --check also passed.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

Docstrings are updated; the documentation preview is pending.

⌛ Dependencies

None.

@github-actions

Copy link
Copy Markdown

Documentation preview for this PR (built with commit ce76ea5; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@cxzhong
cxzhong requested a review from tscrim September 15, 2026 02:44

@tscrim tscrim left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@vbraun
vbraun merged commit e6228ed into sagemath:develop Sep 29, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

is_square of power series ring fails for rings with zero divisors

3 participants