Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: irreducibility of constant polynomials over finite fields #1988

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

thofma
Copy link
Member

@thofma thofma commented Jan 8, 2025

Flint currently considers all constant polynomials irreducible, which is a bit questionable. This PR here makes these methods follow our convention, see

help?> is_irreducible
search: is_irreducible is_invertible isimmutable is_compatible isexecutable isreadable

  is_irreducible(a::RingElement)

  Return true if a is irreducible, else return false. Zero and units are by definition never
  irreducible.

(and the corresponding generic method.)

Whether this is a bug upstream is to be decided, see flintlib/flint#2140.

Copy link

codecov bot commented Jan 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.01%. Comparing base (fc77b13) to head (2fc39bc).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1988      +/-   ##
==========================================
+ Coverage   87.98%   88.01%   +0.02%     
==========================================
  Files          98       98              
  Lines       36063    36031      -32     
==========================================
- Hits        31730    31711      -19     
+ Misses       4333     4320      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

Fine by me, but see minor comments (all of course optional -- I approved, merge at will)

Comment on lines 516 to 517
is_zero(x) && return false
is_unit(x) && return false
Copy link
Member

Choose a reason for hiding this comment

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

How about this (at least when the coefficients are in a field) ?

Suggested change
is_zero(x) && return false
is_unit(x) && return false
is_constant(x) && return false

@@ -501,6 +501,9 @@ end
@test is_irreducible(x)

@test is_irreducible(x^16+2*x^9+x^8+x^2+x+1)

@test !is_irreducible(x^0)
@test !is_irreducible(0*x^0)
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to add this kind of tests to the conformance test suits for polynomial rings instead. Of course we can also test it here first, no big harm (though I think at some point we should get somebody to go through the Nemo test files and weed out tests that are completely covered by the generic conformance tests)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, it can be added it to the conformance tests. But still I have the impression that the conformance tests are nice to have, but they are a bit of a black box and it is not clear to me what they guarantee to test. This here fixes a specific bug of the various Nemo methods, so I don't see why this should not be tested explicitly here.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, to know what the conformance tests test, you need to look into them. Like so many things in AA/Nemo/Oscar that are unfortunately underdocumented :-(. At least they are relatively small, contained in a single file, and it is easy to look in there and see what is tested.

But I am not opposed to adding the tests here, I just think we should add them to the conformance tests, too. Sadly I forgot to do so when I fixed the bug here for QQMPolyRingElem in December, because then we'd have found & fixed the others fixed here a month earlier :-).

Anyway, I've added such tests now in Nemocas/AbstractAlgebra.jl#1952 (and of course that PR fails for now, until this PR here is merged :-) )

@thofma thofma enabled auto-merge (squash) January 9, 2025 19:29
@thofma
Copy link
Member Author

thofma commented Jan 9, 2025

I adjusted it to use is_constant.

@thofma thofma merged commit 9655b24 into master Jan 9, 2025
24 checks passed
@thofma thofma deleted the th/irred branch January 9, 2025 22:23
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