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

Regarding the MPolyFactor code: using it, testing it, further development #1961

Open
fingolfin opened this issue Jan 16, 2025 · 2 comments
Open
Labels
question Further information is requested

Comments

@fingolfin
Copy link
Member

I am unsure how to use the code in src/algorithms/MPolyFactor.jl. A comment there says:

# experimental module whose parts can be overridden for specific types
# main functions are mfactor_squarefree_char_zero and mfactor_char_zero

and I think it is used by @thofma in Hecke. (Hecke also contains a file src/Misc/MPolyFactor.jl which seems to be a different (perhaps older?) version of the same code, but it also doesn't seem to be used or even included in Hecke?).

Unfortunately there are no real tests for it. In test/algorithms/MPolyFactor-test.jl a few helpers are tested and there is a comment saying:

# not much to test because we would need working univariate factorization

But in practice it still seems to work in many cases, at least in char 0 and if the coefficients support factorization (for AA that means: coefficients are in a field):

julia> R,(x,y)=QQ[:x,:y]
(Multivariate polynomial ring in 2 variables over rationals, AbstractAlgebra.Generic.MPoly{Rational{BigInt}}[x, y])

julia> AbstractAlgebra.MPolyFactor.mfactor_char_zero((x+1)^2*(x-y+2))
1 * (x + 1)^2 * (x - y + 2)

julia> collect(ans)
2-element Vector{Pair{AbstractAlgebra.Generic.MPoly{Rational{BigInt}}, Int64}}:
     x + 1 => 2
 x - y + 2 => 1

Now it does sometimes run into an error due to missing `factor, e.g.::

julia> AbstractAlgebra.MPolyFactor.mfactor_char_zero((x+1)^2*(x-y+2)*(y^2-x))
ERROR: function factor is not implemented for argument
AbstractAlgebra.Generic.Poly{Rational{BigInt}}: x^2 + 2*x

But ironically in this example it can actually factor the polynomial itself:

julia> AbstractAlgebra.MPolyFactor.mfactor_char_zero(x^2 + 2*x)
1 * (x + 2) * x

But alas one can construct examples where it really fails:

julia> AbstractAlgebra.MPolyFactor.mfactor_char_zero(x^2 + 2*x + 2)
ERROR: function factor is not implemented for argument
AbstractAlgebra.Generic.Poly{Rational{BigInt}}: x^2 + 2*x + 2

This raises two questions in my mind:

  1. would it make be useful for us to add a generic factor(::MPolyRingElem) method delegating to AbstractAlgebra.MPolyFactor.mfactor_char_zero at least if if the characteristic is 0 (and keeping issue Bug (?) in MPolyFactor when coefficients are are not in a field #1960 in mind)
  • we have plenty of precedent for such functions, i.e., functions that only work if certain other functions are implemented, possibly functions for the coefficient ring
  1. what about non-zero characteristic? What would be needed for that? Is anyone interested in this functionality? And is someone interested in implementing that?
@fingolfin fingolfin added the question Further information is requested label Jan 16, 2025
@fieker
Copy link
Contributor

fieker commented Jan 16, 2025 via email

@thofma
Copy link
Member

thofma commented Jan 16, 2025

That there is not test within AA is a consequence of moving the code to not have "type piracy". If there is no univariate factorization, there cannot be useful tests. I don't think there is anything that can be done.

The file in Hecke should indeed be removed.

Regarding the non-zero characteristic, there is no generic algorithm to reduce it to the univariate case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants