-
Notifications
You must be signed in to change notification settings - Fork 13
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
Allow polynomial coefficient fields to be finite_field where field degree > 1; and also algebraic field extensions of QQ #162
Comments
Thanks for raising this issue ! Implementing support for finite fields of degree > 1 is possible in principle, and I agree that this would be a nice feature. So that we are on the same page, I mean support for something like: using Nemo, Groebner
K, a = finite_field(7, 2, "a");
R, (x,y) = K["x","y"];
groebner([x + a*y]); Implementation-wise, I think Julia generic types simplify our life:
Line 30 in 545ec1d
So, it seems feasible, but indeed would require some work.
You are close to the truth :^). Here "ir" stands for intermediate representation. The full pipeline is: input polynomials -> ir -> internal -> F4 -> internal -> ir -> output polynomials. (The functions names are
Yes, I think this is one possible approach. Another possibly simpler option is to wrap elements of F_q^n in a struct (say inside of io_convert_polynomials_to_ir), forward field operations to existing implementation (which is say somewhere in Nemo or Oscar), and use this struct in F4: struct MyFqCoeff
actual_coeff
end
import Base: +, *
+(x::MyFqCoeff, y::MyFqCoeff) = MyFqCoeff(x.actual_coeff + y.actual_coeff)
*(x::MyFqCoeff, y::MyFqCoeff) = MyFqCoeff(x.actual_coeff * y.actual_coeff)
# etc
K, a = finite_field(7, 2, "a");
c1 = MyFqCoeff(K(5))
c1*c1 In this case, we need to teach io_convert_polynomials_to_ir and friends to recognize MyFqCoeff.
By the way, Groebner.jl already works with vectors of scalars, though for a different purpose. Here, Line 25 in 545ec1d
|
@xyz333math In the next several weeks I won't be able to work on this. If you decide to give it a try, I could try to answer your questions. Out of curiosity, what is the application where you use GB over F_q^n ? |
support need: coefficients in algebraic extensions of finite fields (elements in L):
so L is a Nemo field and I believe the type is FqField. Although I think L here would be isomorphic to some finite_field(q, n, "c") I think it may have a different structure in julia code. If we need to convert elements in L to an intermediate form like an array of Int, then it might be necessary to programmatically derive what q, n are, depending on what f(x) is, for finite_field(q, n, "c"); it'd be nice if there is a way to avoid that. Can we simply let f4 matrix entries be elements of L directly (i.e. type FqField)? Since L is a FqField, then elements of L should automatically implement all the necessary arithmetic operations, so we would add FqField to the Union of types for Coeff. My application: I'm currently a math PhD student at UTA (Texas) doing research that requires usage of multivariate polynomials over finite fields. I appreciate your offer to try to answer my questions. I may give the coding a try, I haven't quite decided yet. If I do, then there is no harm if I create a git branch right?
This has the potential for us to knock this out quickly. |
Thanks for the clarification. It seemed quite interesting so I went ahead and here is my attempt: #163. The following works now: using Nemo, Groebner
K, a = Nemo.finite_field(3, 2, "a")
R, (X, Y) = K["X", "Y"]
groebner([a*X - Y, X*Y - 1]) == [Y^2 + 2*a, X + (2*a + 1)*Y] Your example with multiple extensions should naturally work as well, but I did not test yet. The approach is simple:
Right, I also decided to do it almost like this.
That's great ! For reference:
|
That is outstanding! Thanks for doing that. I tried it out and it works! Below is the function I wrote to test it. Since I'm using Oscar (not a Groebner.jl dep) I have this function in a separate project. I'm very excited about this and I anticipate using it very heavily; so over time I could probably write a ton of unit/integrated/functional tests for you. Also I could compare results with Oscar (but Oscar doesn't support degree>1 finite fields yet which is why I tried Groebner.jl in the first place)
|
Right. The default in
For now the warning signals that generic coefficients are used. Groebner is a low-level package that targets performance, and, the generic fallback may be not as fast as one might expect in some cases.
It would be amazing if you can contribute tests for towers of fields :). Groebner.jl/test/input_output/Nemo.jl Line 28 in 5741d23
I am not too sure about adding Oscar dependency in tests (it is a bit large and does not work on Windows). We could use Nemo. |
BTW: if you would have comments on how to improve the clarity of some code in Groebner please let me know. |
But of course if you have other ideas on how to better test this, feel free to propose it. |
In my opinion you should not add Oscar as a dependency for the reasons you mentioned above and: I will make an effort to add some tests for tower of fields (create a new testset "Nemo.jl, finite-fields"). |
In Groebner.jl, no easy way I think. My workflow has been: write code - test in REPL - put in test file - run runtests.jl and go for a coffee. In general, there is https://github.com/JuliaTesting/ReTest.jl and https://discourse.julialang.org/t/prerelease-of-new-testing-framework-and-test-run-ui-in-vs-code/86355/52, which can run tests individually, but I have not tried it. |
In fact it was only used for |
Merged #163. |
Hello, I've got another similar item for you, to implement support for field extensions in general.
running this script results in an error in function io_extract_ring(polynomials) in file
|
Could you try the master branch ? |
Ok it works! Sorry, I didn't realize you had made further changes. |
Great ! Thanks for checking |
Currently the only finite fields allowed seem to be the Nemo fields of degree one, for example GF(p) where p is a prime integer;
I think that GF is the same as finite_field in Nemo.
I did a quick experiment to find out that
function io_convert_polynomials_to_ir(polynomials, options::KeywordArguments)
in ./input_output/AbstractAlgebra.jl
is the function that checks coeffient types and either allows or disallows the field type.
E.g. (suppose p=13), it will allow finite_field(13) but disallow finite_field(13, 3, "a") which are of degree 1 and 3 respectively.
Initially I was going to volunteer to try to code this change myself. But after having looked at the code briefly, I came to the conclusion that it is not at all an easy fix, especially for someone coming in cold, who is not familiar with the code. I cloned the project and played around with the code a bit. It's not obvious what is going on in the functions io_convert_polynomials_to_ir and io_convert_ir_to_polynomials which I believe would be one of the necessary changes to incorporating finite_field of degree > 1. I assume that the naming "ir_to" and "to_ir" means converting to and from internal representation? It appears that maybe the internal representation of an element of a GF(p) field is just a UINT. And if that is the case then I suppose to represent an element of a finite field of of degree 3 say would require an array of length 3 of UINTS. I.e. elements of finite_field(p, 1) are basically 1-dimensional vectors (i.e. a scalar) and elements of finite_field(p, m) are m-dimensional vectors. Furthermore if there are matrices whose entries are coefficients of monomials, which are scalars for degree 1 fields, then that would be quite a bit trickier for coeffients that are m-dimensional vectors. On the otherhand, for you guys that implemented this package, it goes without saying that it would be much easier for you to add this feature than someone coming in cold. Let me know your thoughts.
The text was updated successfully, but these errors were encountered: