diff --git a/Project.toml b/Project.toml index 9132f90a2a37..96c05f1bd3c8 100644 --- a/Project.toml +++ b/Project.toml @@ -26,23 +26,23 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" cohomCalg_jll = "5558cf25-a90e-53b0-b813-cadaa3ae7ade" [compat] -AbstractAlgebra = "0.34.7" -AlgebraicSolving = "0.4.4" +AbstractAlgebra = "0.35.2" +AlgebraicSolving = "0.4.6" Distributed = "1.6" DocStringExtensions = "0.8, 0.9" GAP = "0.10.0" -Hecke = "0.23.0" +Hecke = "0.24.0" JSON = "^0.20, ^0.21" JSON3 = "1.13.2" LazyArtifacts = "1.6" -Nemo = "0.38.0" +Nemo = "0.39.1" Pkg = "1.6" Polymake = "0.11.8" Preferences = "1" Random = "1.6" RandomExtensions = "0.4.3" Serialization = "1.6" -Singular = "0.21.1" +Singular = "0.21.2" TOPCOM_jll = "0.17.8" UUIDs = "1.6" cohomCalg_jll = "0.32.0" diff --git a/docs/src/CommutativeAlgebra/rings.md b/docs/src/CommutativeAlgebra/rings.md index 6034b85013c0..f79f2ac9aaa6 100644 --- a/docs/src/CommutativeAlgebra/rings.md +++ b/docs/src/CommutativeAlgebra/rings.md @@ -82,7 +82,7 @@ QQPolyRingElem julia> T, x = polynomial_ring(GF(3), ["x[1]", "x[2]"]); julia> x -2-element Vector{fpMPolyRingElem}: +2-element Vector{FqMPolyRingElem}: x[1] x[2] @@ -126,10 +126,10 @@ Rational field ```jldoctest julia> GF(3) -Finite field of characteristic 3 +Finite field of degree 1 over GF(3) julia> GF(ZZ(2)^127 - 1) -Finite field of characteristic 170141183460469231731687303715884105727 +Finite field of degree 1 over GF(170141183460469231731687303715884105727) ``` @@ -151,7 +151,7 @@ julia> K, a = number_field(t^2 + 1, "a") (Number field of degree 2 over QQ, a) julia> F = GF(3) -Finite field of characteristic 3 +Finite field of degree 1 over GF(3) julia> T, t = polynomial_ring(F, "t") (Univariate polynomial ring in t over GF(3), t) @@ -440,10 +440,10 @@ subsection *Monomials, Terms, and More* of the section on *Gröbner/Standard Bas ```jldoctest julia> R, (x, y) = polynomial_ring(GF(5), ["x", "y"]) -(Multivariate polynomial ring in 2 variables over GF(5), fpMPolyRingElem[x, y]) +(Multivariate polynomial ring in 2 variables over GF(5), FqMPolyRingElem[x, y]) julia> c = map(GF(5), [1, 2, 3]) -3-element Vector{fpFieldElem}: +3-element Vector{FqFieldElem}: 1 2 3 @@ -459,7 +459,7 @@ x^3*y^2 + 2*x + 3*y julia> parent(f) Multivariate polynomial ring in 2 variables x, y - over finite field of characteristic 5 + over finite field of degree 1 over GF(5) julia> total_degree(f) 5 diff --git a/experimental/GModule/Cohomology.jl b/experimental/GModule/Cohomology.jl index 0e036baeeeef..62da772a37df 100644 --- a/experimental/GModule/Cohomology.jl +++ b/experimental/GModule/Cohomology.jl @@ -1834,7 +1834,7 @@ function (k::Nemo.fpField)(a::Vector) end function (k::fqPolyRepField)(a::Vector) - return k(polynomial(GF(Int(characteristic(k))), a)) + return k(polynomial(Native.GF(Int(characteristic(k))), a)) end function Oscar.order(F::AbstractAlgebra.FPModule{<:FinFieldElem}) @@ -1854,12 +1854,14 @@ function pc_group_with_isomorphism(M::AbstractAlgebra.FPModule{<:FinFieldElem}; B = PcGroup(GAP.Globals.GroupByRws(C)) FB = GAP.Globals.FamilyObj(GAP.Globals.Identity(B.X)) - function Julia_to_gap(a::AbstractAlgebra.FPModuleElem{<:Union{fpFieldElem, FpFieldElem}}) + function Julia_to_gap(a::AbstractAlgebra.FPModuleElem{<:Union{fpFieldElem, FpFieldElem, FqFieldElem}}) + F = base_ring(parent(a)) + @assert absolute_degree(F) == 1 r = ZZRingElem[] for i=1:ngens(M) if !iszero(a[i]) push!(r, i) - push!(r, lift(a[i])) + push!(r, lift(ZZ, a[i])) end end g = GAP.Globals.ObjByExtRep(FB, GAP.Obj(r, recursive = true)) diff --git a/experimental/GModule/GModule.jl b/experimental/GModule/GModule.jl index 48971ba5ebf6..8c35169d7937 100644 --- a/experimental/GModule/GModule.jl +++ b/experimental/GModule/GModule.jl @@ -367,7 +367,8 @@ function gmodule(::typeof(CyclotomicField), C::GModule) return gmodule(F, group(C), [hom(F, F, map_entries(x->K(x.data), matrix(x))) for x = C.ac]) end -function gmodule(k::Nemo.fpField, C::GModule{<:Oscar.GAPGroup, GrpAbFinGen}) +function gmodule(k::Union{Nemo.fpField, FqField}, C::GModule{<:Oscar.GAPGroup, GrpAbFinGen}) + @assert absolute_degree(k) == 1 q, mq = quo(C.M, characteristic(k)) s, ms = snf(q) @@ -512,9 +513,10 @@ function Oscar.sub(C::GModule{<:Any, <:AbstractAlgebra.FPModule{T}}, m::MatElem{ return b end -function gmodule(k::Nemo.fpField, C::GModule{<:Any, <:AbstractAlgebra.FPModule{<:FinFieldElem}}) - F = free_module(k, dim(C)*degree(base_ring(C))) - return GModule(F, group(C), [hom(F, F, hvcat(dim(C), [representation_matrix(x) for x = transpose(matrix(y))]...)) for y = C.ac]) +function gmodule(k::Nemo.FinField, C::GModule{<:Any, <:AbstractAlgebra.FPModule{<:FinFieldElem}}) + @assert absolute_degree(k) == 1 + F = free_module(k, dim(C)*absolute_degree(base_ring(C))) + return GModule(F, group(C), [hom(F, F, hvcat(dim(C), [absolute_representation_matrix(x) for x = transpose(matrix(y))]...)) for y = C.ac]) end function Hecke.frobenius(K::FinField, i::Int=1) diff --git a/experimental/MatroidRealizationSpaces/src/realization_space.jl b/experimental/MatroidRealizationSpaces/src/realization_space.jl index a723fdf58b56..7de72921da67 100644 --- a/experimental/MatroidRealizationSpaces/src/realization_space.jl +++ b/experimental/MatroidRealizationSpaces/src/realization_space.jl @@ -514,7 +514,7 @@ One realization is given by [1 0 0 1 1 1] [0 1 0 1 4 3] [0 0 1 1 3 2] -in the Finite field of characteristic 5 +in the Finite field of degree 1 over GF(5) ``` """ diff --git a/experimental/ModStd/ModStdQ.jl b/experimental/ModStd/ModStdQ.jl index cbab54c80091..7f332e970412 100644 --- a/experimental/ModStd/ModStdQ.jl +++ b/experimental/ModStd/ModStdQ.jl @@ -18,6 +18,15 @@ function (R::fpMPolyRing)(f::QQMPolyRingElem) return finish(g) end +function (R::FqMPolyRing)(f::QQMPolyRingElem) + g = MPolyBuildCtx(R) + S = base_ring(R) + for (c, v) in zip(AbstractAlgebra.coefficients(f), AbstractAlgebra.exponent_vectors(f)) + push_term!(g, S(c), v) + end + return finish(g) +end + function (S::Union{Nemo.zzModRing, Nemo.fpField})(a::QQFieldElem) return S(numerator(a))//S(denominator(a)) end diff --git a/experimental/QuadFormAndIsom/src/embeddings.jl b/experimental/QuadFormAndIsom/src/embeddings.jl index 8a847e7db7eb..7e5d80f6a355 100644 --- a/experimental/QuadFormAndIsom/src/embeddings.jl +++ b/experimental/QuadFormAndIsom/src/embeddings.jl @@ -282,8 +282,8 @@ function _cokernel_as_Fp_vector_space(HinV::TorQuadModuleMor, p::IntegerUnion) return Vp(vec(collect(v))) end - function _VptoV(v::ModuleElem{FpFieldElem}) - x = lift.(v.v) + function _VptoV(v::ModuleElem{FqFieldElem}) + x = map(z -> lift(ZZ, z), v.v) return sum(x[i]*V[i] for i in 1:n) end @@ -379,8 +379,8 @@ function _subgroups_orbit_representatives_and_stabilizers_elementary(Vinq::TorQu # invariants sub-vector spaces of given rank in the quotient (then lifting # generators and putting them with H0 will give us invariant subgroups as # wanted) - act_GV = FpMatrix[change_base_ring(base_ring(Qp), matrix(gg)) for gg in gens(GV)] - act_GV = FpMatrix[solve(VptoQp.matrix, g*VptoQp.matrix) for g in act_GV] + act_GV = dense_matrix_type(elem_type(base_ring(Qp)))[change_base_ring(base_ring(Qp), matrix(gg)) for gg in gens(GV)] + act_GV = dense_matrix_type(elem_type(base_ring(Qp)))[solve(VptoQp.matrix, g*VptoQp.matrix) for g in act_GV] MGp = matrix_group(base_ring(Qp), dim(Qp), act_GV) GVtoMGp = hom(GV, MGp, MGp.(act_GV); check = false) GtoMGp = compose(GtoGV, GVtoMGp) diff --git a/experimental/Schemes/ProjectiveModules.jl b/experimental/Schemes/ProjectiveModules.jl index 7e326ff1ffea..d1230aaae7a0 100644 --- a/experimental/Schemes/ProjectiveModules.jl +++ b/experimental/Schemes/ProjectiveModules.jl @@ -116,7 +116,7 @@ function _is_projective_without_denominators(A::MatElem; result = sum([c[k]*projectors[k] for k in 1:length(projectors)]) # Copied from below - d = lcm(_lifted_denominator.(result)) + d = reduce(lcm, _lifted_denominator.(result)) if isone(d) return true, result, 0 end diff --git a/experimental/Schemes/elliptic_surface.jl b/experimental/Schemes/elliptic_surface.jl index b1fb7b2526ab..379858dfe36f 100644 --- a/experimental/Schemes/elliptic_surface.jl +++ b/experimental/Schemes/elliptic_surface.jl @@ -319,9 +319,13 @@ function weierstrass_model(X::EllipticSurface) c = standard_covering(IP1) # rename the variables on the affine charts # to a more readable version - OO(c[1]).S = [:t] - OO(c[2]).S = [:s] - + if k isa FqField + OO(c[1]).data.S = [:t] + OO(c[2]).data.S = [:s] + else + OO(c[1]).S = [:t] + OO(c[2]).S = [:s] + end O0 = twisting_sheaf(IP1, 0) O4 = twisting_sheaf(IP1, -2*s) @@ -981,7 +985,7 @@ julia> E = EllipticCurve(ktfield,[3*t^8+24*t^7+22*t^6+15*t^5+28*t^4+20*t^3+16*t^ julia> bk = [E(collect(i)) for i in bk]; julia> Oscar._prop217(E,bk[2],2) -5-element Vector{Tuple{fpPolyRingElem, fpPolyRingElem}}: +5-element Vector{Tuple{FqPolyRingElem, FqPolyRingElem}}: (t^2 + 12*t + 7, 0) (t^3 + 8*t + 3, 0) (t^4 + 23*t + 2, 0) @@ -989,7 +993,7 @@ julia> Oscar._prop217(E,bk[2],2) (12*t + 28, t) julia> Oscar._prop217(E,bk[1],1) -2-element Vector{Tuple{fpPolyRingElem, fpPolyRingElem}}: +2-element Vector{Tuple{FqPolyRingElem, FqPolyRingElem}}: (1, 0) (t, 0) ``` diff --git a/experimental/StandardFiniteFields/src/StandardFiniteFields.jl b/experimental/StandardFiniteFields/src/StandardFiniteFields.jl index 481b2c405c2d..a716a1a0f504 100644 --- a/experimental/StandardFiniteFields/src/StandardFiniteFields.jl +++ b/experimental/StandardFiniteFields/src/StandardFiniteFields.jl @@ -28,7 +28,7 @@ function (k::Nemo.FpField)(a::Vector) return k(a[1]) end function (k::FqPolyRepField)(a::Vector) - return k(polynomial(GF(ZZ(characteristic(k))), a)) + return k(polynomial(Native.GF(ZZ(characteristic(k))), a)) end # TODO : Should be fixed in Hecke for prime fields @@ -348,7 +348,7 @@ function _extension_with_tower_basis( push!(lcoeffs, one(K)) pmat = identity_matrix(K, Int(deg)) vname = "x" * string(deg) - L, X = finite_field(polynomial(K, lcoeffs), vname) + L, X = Native.finite_field(polynomial(K, lcoeffs), vname) set_standard_finite_field!(L) set_primitive_powers_in_tower_basis!(L, pmat) @@ -439,7 +439,7 @@ function _extension_with_tower_basis( # pmat gives the primitive powers in the tower basis for the new extension vname = "x" * string(d) - L, X = finite_field(polynomial(F, poly), vname) + L, X = Native.finite_field(polynomial(F, poly), vname) set_standard_finite_field!(L) set_primitive_powers_in_tower_basis!(L, pmat) @@ -461,7 +461,7 @@ Finite field of degree 24 over GF(3) """ function standard_finite_field(p::IntegerUnion, n::IntegerUnion) @req is_prime(p) "first argument must be a prime" - F = GF(p) + F = Native.GF(p) set_standard_prime_field!(F) function _sff(N::Fac{ZZRingElem}) diff --git a/experimental/StandardFiniteFields/test/runtests.jl b/experimental/StandardFiniteFields/test/runtests.jl index d07cfe9215a0..932631533627 100644 --- a/experimental/StandardFiniteFields/test/runtests.jl +++ b/experimental/StandardFiniteFields/test/runtests.jl @@ -9,11 +9,12 @@ GAP.Packages.load("StandardFF") poly = GAP.Globals.StandardFiniteField(Int(p), n) poly = GAP.Globals.DefiningPolynomial(poly) poly = GAP.Globals.CoefficientsOfUnivariatePolynomial(poly) - poly = polynomial(GF(p), map(GF(p), Vector{GAP.FFE}(poly))) + k = Nemo.Native.GF(p) + poly = polynomial(k, map(k, Vector{GAP.FFE}(poly))) end function compare_poly(p, n) - F = GF(p) + F = Nemo.Native.GF(p) F.(collect(coefficients(MyPoly(p, n)))) == F.(collect(coefficients(GAPPoly(p, n)))) end diff --git a/src/GAP/iso_gap_oscar.jl b/src/GAP/iso_gap_oscar.jl index 7d7e7ef81684..8fd9e44c8d57 100644 --- a/src/GAP/iso_gap_oscar.jl +++ b/src/GAP/iso_gap_oscar.jl @@ -50,7 +50,7 @@ function _iso_gap_oscar_residue_ring(RG::GAP.GapObj) end function _iso_gap_oscar_field_finite(FG::GAP.GapObj) - FO = Nemo._GF(characteristic(FG), GAPWrap.DegreeOverPrimeField(FG)) + FO = GF(characteristic(FG), GAPWrap.DegreeOverPrimeField(FG)) finv, f = _iso_oscar_gap_field_finite_functions(FO, FG) diff --git a/src/Groups/group_characters.jl b/src/Groups/group_characters.jl index 5d0ab2247e85..c9ed974a7638 100644 --- a/src/Groups/group_characters.jl +++ b/src/Groups/group_characters.jl @@ -2448,7 +2448,7 @@ function character_field(chi::GAPGroupClassFunction) q = order_field_of_definition(chi) flag, e, pp = is_prime_power_with_data(q) (flag && p == pp) || error("something is wrong with 'GAPWrap.SizeOfFieldOfDefinition'") - F = Nemo._GF(p, e) + F = GF(p, e) return (F, identity_map(F)) end diff --git a/src/Groups/matrices/FiniteFormOrthogonalGroup.jl b/src/Groups/matrices/FiniteFormOrthogonalGroup.jl index d7b4a8313d62..624244039d71 100644 --- a/src/Groups/matrices/FiniteFormOrthogonalGroup.jl +++ b/src/Groups/matrices/FiniteFormOrthogonalGroup.jl @@ -124,7 +124,7 @@ function _gens_form(G::Union{ZZModMatrix, zzModMatrix}, form_constructor, p) Oq = isometry_group(q) gensOq = gens(Oq) gensOq = [change_base_ring(FF,matrix(g)) for g in gensOq] - gensOq = [change_base_ring(R,lift(g)) for g in gensOq] + gensOq = [change_base_ring(R,map(x -> lift(ZZ, x), g)) for g in gensOq] return gensOq end diff --git a/src/Groups/matrices/MatGrp.jl b/src/Groups/matrices/MatGrp.jl index 97ea6ee469cf..208ce29fb56b 100644 --- a/src/Groups/matrices/MatGrp.jl +++ b/src/Groups/matrices/MatGrp.jl @@ -560,7 +560,7 @@ end Return the general linear group of dimension `n` over the ring `R` respectively the field `GF(q)`. -Currently, this function only supports rings of type `fqPolyRepField`. +Currently, this function only supports rings of type `FqField`. # Examples ```jldoctest @@ -571,7 +571,7 @@ julia> H = general_linear_group(2,F) GL(2,7) julia> gens(H) -2-element Vector{MatrixGroupElem{fqPolyRepFieldElem, fqPolyRepMatrix}}: +2-element Vector{MatrixGroupElem{FqFieldElem, FqMatrix}}: [3 0; 0 1] [6 1; 6 0] @@ -594,7 +594,7 @@ end Return the special linear group of dimension `n` over the ring `R` respectively the field `GF(q)`. -Currently, this function only supports rings of type `fqPolyRepField`. +Currently, this function only supports rings of type `FqField`. # Examples ```jldoctest @@ -605,7 +605,7 @@ julia> H = special_linear_group(2,F) SL(2,7) julia> gens(H) -2-element Vector{MatrixGroupElem{fqPolyRepFieldElem, fqPolyRepMatrix}}: +2-element Vector{MatrixGroupElem{FqFieldElem, FqMatrix}}: [3 0; 0 5] [6 1; 6 0] @@ -629,7 +629,7 @@ end Return the symplectic group of dimension `n` over the ring `R` respectively the field `GF(q)`. The dimension `n` must be even. -Currently, this function only supports rings of type `fqPolyRepField`. +Currently, this function only supports rings of type `FqField`. # Examples ```jldoctest @@ -640,7 +640,7 @@ julia> H = symplectic_group(2,F) Sp(2,7) julia> gens(H) -2-element Vector{MatrixGroupElem{fqPolyRepFieldElem, fqPolyRepMatrix}}: +2-element Vector{MatrixGroupElem{FqFieldElem, FqMatrix}}: [3 0; 0 5] [6 1; 6 0] @@ -666,7 +666,7 @@ Return the orthogonal group of dimension `n` over the ring `R` respectively the field `GF(q)`, and of type `e`, where `e` in {`+1`,`-1`} for `n` even and `e`=`0` for `n` odd. If `n` is odd, `e` can be omitted. -Currently, this function only supports rings of type `fqPolyRepField`. +Currently, this function only supports rings of type `FqField`. # Examples ```jldoctest @@ -677,7 +677,7 @@ julia> H = symplectic_group(2,F) Sp(2,7) julia> gens(H) -2-element Vector{MatrixGroupElem{fqPolyRepFieldElem, fqPolyRepMatrix}}: +2-element Vector{MatrixGroupElem{FqFieldElem, FqMatrix}}: [3 0; 0 5] [6 1; 6 0] @@ -718,7 +718,7 @@ Return the special orthogonal group of dimension `n` over the ring `R` respectiv the field `GF(q)`, and of type `e`, where `e` in {`+1`,`-1`} for `n` even and `e`=`0` for `n` odd. If `n` is odd, `e` can be omitted. -Currently, this function only supports rings of type `fqPolyRepField`. +Currently, this function only supports rings of type `FqField`. # Examples ```jldoctest @@ -729,7 +729,7 @@ julia> H = special_orthogonal_group(1,2,F) SO+(2,7) julia> gens(H) -3-element Vector{MatrixGroupElem{fqPolyRepFieldElem, fqPolyRepMatrix}}: +3-element Vector{MatrixGroupElem{FqFieldElem, FqMatrix}}: [3 0; 0 5] [5 0; 0 3] [1 0; 0 1] @@ -771,7 +771,7 @@ Return the Omega group of dimension `n` over the field `GF(q)` of type `e`, where `e` in {`+1`,`-1`} for `n` even and `e`=`0` for `n` odd. If `n` is odd, `e` can be omitted. -Currently, this function only supports rings of type `fqPolyRepField`. +Currently, this function only supports rings of type `FqField`. # Examples ```jldoctest @@ -782,7 +782,7 @@ julia> H = omega_group(1,2,F) Omega+(2,7) julia> gens(H) -1-element Vector{MatrixGroupElem{fqPolyRepFieldElem, fqPolyRepMatrix}}: +1-element Vector{MatrixGroupElem{FqFieldElem, FqMatrix}}: [2 0; 0 4] ``` @@ -826,7 +826,7 @@ julia> H = unitary_group(2,3) GU(2,3) julia> gens(H) -2-element Vector{MatrixGroupElem{fqPolyRepFieldElem, fqPolyRepMatrix}}: +2-element Vector{MatrixGroupElem{FqFieldElem, FqMatrix}}: [o 0; 0 2*o] [2 2*o+2; 2*o+2 0] ``` @@ -852,7 +852,7 @@ julia> H = special_unitary_group(2,3) SU(2,3) julia> gens(H) -2-element Vector{MatrixGroupElem{fqPolyRepFieldElem, fqPolyRepMatrix}}: +2-element Vector{MatrixGroupElem{FqFieldElem, FqMatrix}}: [1 2*o+2; 0 1] [0 2*o+2; 2*o+2 0] ``` diff --git a/src/Groups/matrices/iso_nf_fq.jl b/src/Groups/matrices/iso_nf_fq.jl index f6336b2d2f21..f83028f34a88 100644 --- a/src/Groups/matrices/iso_nf_fq.jl +++ b/src/Groups/matrices/iso_nf_fq.jl @@ -150,11 +150,11 @@ function test_modulus(matrices::Vector{T}, p::Int) where T <: MatrixElem{nf_elem K = base_ring(matrices[1]) matrices_Fq = Vector{FqMatrix}(undef, length(matrices)) if p == 2 - return false, Nemo._GF(p, cached = false), matrices_Fq, Hecke.NfOrdToFqMor() + return false, GF(p, cached = false), matrices_Fq, Hecke.NfOrdToFqMor() end O = EquationOrder(K) if mod(discriminant(O), p) == 0 - return false, Nemo._GF(p, cached = false), matrices_Fq, Hecke.NfOrdToFqMor() + return false, GF(p, cached = false), matrices_Fq, Hecke.NfOrdToFqMor() end for M in matrices for i = 1:nrows(M) @@ -164,7 +164,7 @@ function test_modulus(matrices::Vector{T}, p::Int) where T <: MatrixElem{nf_elem end if mod(denominator(M[i, j]), p) == 0 - return false, Nemo._GF(p, cached = false), matrices_Fq, Hecke.NfOrdToFqMor() + return false, GF(p, cached = false), matrices_Fq, Hecke.NfOrdToFqMor() end end end diff --git a/src/Groups/matrices/stuff_field_gen.jl b/src/Groups/matrices/stuff_field_gen.jl index c84ea5ff2830..384576f9954f 100644 --- a/src/Groups/matrices/stuff_field_gen.jl +++ b/src/Groups/matrices/stuff_field_gen.jl @@ -14,6 +14,12 @@ function _change_type(f::PolyRingElem{T}) where T <: FinFieldElem return sum([t^i*F(lift(coeff(f,i))) for i in 0:degree(f)]) end +function _change_type(f::PolyRingElem{<: FqFieldElem}) + e,p = is_power(order(base_ring(f))) + F = GF(Int(p),Int(e)) + t = polynomial_ring(F,"t")[2] + return sum([t^i*F(lift(ZZ, coeff(f,i))) for i in 0:degree(f)]) +end # if f in F[x] and z is a root of f in the splitting field of f over F, # then return a polynomial g such that g(z) is a generator for the unit group of F(z) diff --git a/src/InvariantTheory/invariant_rings.jl b/src/InvariantTheory/invariant_rings.jl index 57cbcdc5dc98..b93eae57b46f 100644 --- a/src/InvariantTheory/invariant_rings.jl +++ b/src/InvariantTheory/invariant_rings.jl @@ -270,13 +270,13 @@ julia> M = matrix(GF(3), [0 1 0; -1 0 0; 0 0 -1]) julia> G = matrix_group(M) Matrix group of degree 3 - over finite field of characteristic 3 + over finite field of degree 1 over GF(3) julia> IR = invariant_ring(G) Invariant ring of Matrix group of degree 3 over GF(3) with generators - fpMatrix[[0 1 0; 2 0 0; 0 0 2]] + FqMatrix[[0 1 0; 2 0 0; 0 0 2]] julia> R = polynomial_ring(IR) Multivariate polynomial ring in 3 variables over GF(3) graded by @@ -285,7 +285,7 @@ Multivariate polynomial ring in 3 variables over GF(3) graded by x[3] -> [1] julia> x = gens(R) -3-element Vector{MPolyDecRingElem{fpFieldElem, fpMPolyRingElem}}: +3-element Vector{MPolyDecRingElem{FqFieldElem, FqMPolyRingElem}}: x[1] x[2] x[3] @@ -462,21 +462,21 @@ julia> M = matrix(GF(3), [0 1 0; -1 0 0; 0 0 -1]) julia> G = matrix_group(M) Matrix group of degree 3 - over finite field of characteristic 3 + over finite field of degree 1 over GF(3) julia> IR = invariant_ring(G) Invariant ring of Matrix group of degree 3 over GF(3) with generators - fpMatrix[[0 1 0; 2 0 0; 0 0 2]] + FqMatrix[[0 1 0; 2 0 0; 0 0 2]] julia> basis(IR, 2) -2-element Vector{MPolyDecRingElem{fpFieldElem, fpMPolyRingElem}}: +2-element Vector{MPolyDecRingElem{FqFieldElem, FqMPolyRingElem}}: x[1]^2 + x[2]^2 x[3]^2 julia> basis(IR, 3) -2-element Vector{MPolyDecRingElem{fpFieldElem, fpMPolyRingElem}}: +2-element Vector{MPolyDecRingElem{FqFieldElem, FqMPolyRingElem}}: x[1]*x[2]*x[3] x[1]^2*x[3] + 2*x[2]^2*x[3] ``` diff --git a/src/InvariantTheory/iterators.jl b/src/InvariantTheory/iterators.jl index 97c14fd5ab1e..98c775a75eef 100644 --- a/src/InvariantTheory/iterators.jl +++ b/src/InvariantTheory/iterators.jl @@ -174,7 +174,7 @@ all at once when calling the function. See also [`basis`](@ref). # Examples -``` +```jldoctest julia> K, a = cyclotomic_field(3, "a") (Cyclotomic field of order 3, a) @@ -189,20 +189,21 @@ julia> M2 = matrix(K, [1 0 0; 0 a 0; 0 0 -a-1]) [0 0 -a - 1] julia> G = matrix_group(M1, M2) -Matrix group of degree 3 over Cyclotomic field of order 3 +Matrix group of degree 3 + over cyclotomic field of order 3 julia> IR = invariant_ring(G) Invariant ring of -Matrix group of degree 3 over Cyclotomic field of order 3 + Matrix group of degree 3 over cyclotomic field of order 3 with generators -AbstractAlgebra.Generic.MatSpaceElem{nf_elem}[[0 0 1; 1 0 0; 0 1 0], [1 0 0; 0 a 0; 0 0 -a-1]] + AbstractAlgebra.Generic.MatSpaceElem{nf_elem}[[0 0 1; 1 0 0; 0 1 0], [1 0 0; 0 a 0; 0 0 -a-1]] julia> B = iterate_basis(IR, 6) Iterator over a basis of the component of degree 6 of Invariant ring of -Matrix group of degree 3 over Cyclotomic field of order 3 + Matrix group of degree 3 over cyclotomic field of order 3 with generators -AbstractAlgebra.Generic.MatSpaceElem{nf_elem}[[0 0 1; 1 0 0; 0 1 0], [1 0 0; 0 a 0; 0 0 -a-1]] + AbstractAlgebra.Generic.MatSpaceElem{nf_elem}[[0 0 1; 1 0 0; 0 1 0], [1 0 0; 0 a 0; 0 0 -a-1]] julia> collect(B) 4-element Vector{MPolyDecRingElem{nf_elem, AbstractAlgebra.Generic.MPoly{nf_elem}}}: @@ -217,23 +218,24 @@ julia> M = matrix(GF(3), [0 1 0; -1 0 0; 0 0 -1]) [0 0 2] julia> G = matrix_group(M) -Matrix group of degree 3 over Galois field with characteristic 3 +Matrix group of degree 3 + over finite field of degree 1 over GF(3) julia> IR = invariant_ring(G) Invariant ring of -Matrix group of degree 3 over Galois field with characteristic 3 + Matrix group of degree 3 over GF(3) with generators -fpMatrix[[0 1 0; 2 0 0; 0 0 2]] + FqMatrix[[0 1 0; 2 0 0; 0 0 2]] julia> B = iterate_basis(IR, 2) Iterator over a basis of the component of degree 2 of Invariant ring of -Matrix group of degree 3 over Galois field with characteristic 3 + Matrix group of degree 3 over GF(3) with generators -fpMatrix[[0 1 0; 2 0 0; 0 0 2]] + FqMatrix[[0 1 0; 2 0 0; 0 0 2]] julia> collect(B) -2-element Vector{MPolyDecRingElem{fpFieldElem, fpMPolyRingElem}}: +2-element Vector{MPolyDecRingElem{FqFieldElem, FqMPolyRingElem}}: x[1]^2 + x[2]^2 x[3]^2 ``` @@ -290,7 +292,7 @@ This function is only implemented in the case of characteristic zero. See also [`basis`](@ref). # Examples -``` +```jldoctest julia> K, a = cyclotomic_field(3, "a"); julia> M1 = matrix(K, [0 0 1; 1 0 0; 0 1 0]); @@ -304,9 +306,9 @@ julia> IR = invariant_ring(G); julia> B = iterate_basis(IR, 6, trivial_character(G)) Iterator over a basis of the component of degree 6 of Invariant ring of -Matrix group of degree 3 over Cyclotomic field of order 3 + Matrix group of degree 3 over cyclotomic field of order 3 with generators -AbstractAlgebra.Generic.MatSpaceElem{nf_elem}[[0 0 1; 1 0 0; 0 1 0], [1 0 0; 0 a 0; 0 0 -a-1]] + AbstractAlgebra.Generic.MatSpaceElem{nf_elem}[[0 0 1; 1 0 0; 0 1 0], [1 0 0; 0 a 0; 0 0 -a-1]] relative to a character julia> collect(B) @@ -323,14 +325,14 @@ julia> R = invariant_ring(QQ, S2); julia> F = abelian_closure(QQ)[1]; julia> chi = Oscar.class_function(S2, [ F(sign(representative(c))) for c in conjugacy_classes(S2) ]) -class_function(character table of group Sym( [ 1 .. 2 ] ), QQAbElem{nf_elem}[1, -1]) +class_function(character table of permutation group, QQAbElem{nf_elem}[1, -1]) julia> B = iterate_basis(R, 3, chi) Iterator over a basis of the component of degree 3 of Invariant ring of -Sym( [ 1 .. 2 ] ) + Permutation group of degree 2 and order 2 with generators -PermGroupElem[(1,2)] + PermGroupElem[(1,2)] relative to a character julia> collect(B) @@ -557,7 +559,7 @@ end # ################################################################################ -function vector_space_iterator(K::FieldT, basis_iterator::IteratorT) where {FieldT <: Union{Nemo.fpField, Nemo.FpField, fqPolyRepField, FqPolyRepField}, IteratorT} +function vector_space_iterator(K::FieldT, basis_iterator::IteratorT) where {FieldT <: Union{Nemo.fpField, Nemo.FpField, fqPolyRepField, FqPolyRepField, FqField}, IteratorT} return VectorSpaceIteratorFiniteField(K, basis_iterator) end diff --git a/src/InvariantTheory/types.jl b/src/InvariantTheory/types.jl index 4e71fcb175a6..157d439dcbf1 100644 --- a/src/InvariantTheory/types.jl +++ b/src/InvariantTheory/types.jl @@ -199,7 +199,7 @@ mutable struct VectorSpaceIteratorFiniteField{FieldT, IteratorT, ElemT} <: Vecto basis_iterator_state::Any # I don't know the type of this and I don't think there # is a "type-stable" way of finding it out - function VectorSpaceIteratorFiniteField(K::FieldT, basis_iterator::IteratorT) where {FieldT <: Union{Nemo.fpField, Nemo.FpField, fqPolyRepField, FqPolyRepField}, IteratorT} + function VectorSpaceIteratorFiniteField(K::FieldT, basis_iterator::IteratorT) where {FieldT <: Union{Nemo.fpField, Nemo.FpField, fqPolyRepField, FqPolyRepField, FqField}, IteratorT} VSI = new{FieldT, IteratorT, eltype(basis_iterator)}() VSI.field = K VSI.basis_iterator = basis_iterator diff --git a/src/Rings/AlgClosureFp.jl b/src/Rings/AlgClosureFp.jl index 2e9725e32c0a..47ab9c50ae90 100644 --- a/src/Rings/AlgClosureFp.jl +++ b/src/Rings/AlgClosureFp.jl @@ -104,11 +104,11 @@ function ext_of_degree(A::AlgClosure, d::Int) k = base_ring(A) if isa(k, Nemo.fpField) || isa(k, fqPolyRepField) - K = GF(Int(characteristic(k)), d, cached = false) + K = Nemo.Native.GF(Int(characteristic(k)), d, cached = false) elseif isa(k, FqField) - K = Nemo._GF(characteristic(k), d, cached = false) - else K = GF(characteristic(k), d, cached = false) + else + K = Nemo.Native.GF(characteristic(k), d, cached = false) end A.fld[d] = K return K diff --git a/src/Rings/FunctionField.jl b/src/Rings/FunctionField.jl index c2da42946881..03c5251e379b 100644 --- a/src/Rings/FunctionField.jl +++ b/src/Rings/FunctionField.jl @@ -4,19 +4,19 @@ end # conversion between fraction_field and Singular function field # univariate -function Oscar.singular_coeff_ring(F::AbstractAlgebra.Generic.FracField{T}) where T <: Union{QQPolyRingElem, fpPolyRingElem} +function Oscar.singular_coeff_ring(F::AbstractAlgebra.Generic.FracField{T}) where T <: Union{QQPolyRingElem, fpPolyRingElem, FqPolyRingElem} R = base_ring(F) return Singular.FunctionField(singular_coeff_ring(base_ring(R)), [string(R.S)])[1] end -function (F::Singular.N_FField)(x::AbstractAlgebra.Generic.Frac{T}) where T <: Union{QQPolyRingElem, fpPolyRingElem} +function (F::Singular.N_FField)(x::AbstractAlgebra.Generic.Frac{T}) where T <: Union{QQPolyRingElem, fpPolyRingElem, FqPolyRingElem} check_char(F, parent(x)) @req Singular.transcendence_degree(F) == 1 "wrong number of generators" a = Singular.transcendence_basis(F)[1] numerator(x)(a) // denominator(x)(a) end -function (F::AbstractAlgebra.Generic.FracField{T})(x::Singular.n_transExt) where T <: Union{QQPolyRingElem, fpPolyRingElem} +function (F::AbstractAlgebra.Generic.FracField{T})(x::Singular.n_transExt) where T <: Union{QQPolyRingElem, fpPolyRingElem, FqPolyRingElem} check_char(F, parent(x)) @req Singular.transcendence_degree(parent(x)) == 1 "wrong number of generators" n, d = Singular.n_transExt_to_spoly.([numerator(x), denominator(x)]) @@ -24,19 +24,19 @@ function (F::AbstractAlgebra.Generic.FracField{T})(x::Singular.n_transExt) where end # multivariate -function Oscar.singular_coeff_ring(F::AbstractAlgebra.Generic.FracField{T}) where T <: Union{QQMPolyRingElem, fpMPolyRingElem} +function Oscar.singular_coeff_ring(F::AbstractAlgebra.Generic.FracField{T}) where T <: Union{QQMPolyRingElem, fpMPolyRingElem, FqMPolyRingElem} R = base_ring(F) return Singular.FunctionField(singular_coeff_ring(base_ring(R)), _variables_for_singular(symbols(R)))[1] end -function (F::Singular.N_FField)(x::AbstractAlgebra.Generic.Frac{T}) where T <: Union{QQMPolyRingElem, fpMPolyRingElem} +function (F::Singular.N_FField)(x::AbstractAlgebra.Generic.Frac{T}) where T <: Union{QQMPolyRingElem, fpMPolyRingElem, FqMPolyRingElem} check_char(F, parent(x)) @req Singular.transcendence_degree(F) == ngens(base_ring(parent(x))) "wrong number of generators" a = Singular.transcendence_basis(F) numerator(x)(a...) // denominator(x)(a...) end -function (F::AbstractAlgebra.Generic.FracField{T})(x::Singular.n_transExt) where T <: Union{QQMPolyRingElem, fpMPolyRingElem} +function (F::AbstractAlgebra.Generic.FracField{T})(x::Singular.n_transExt) where T <: Union{QQMPolyRingElem, fpMPolyRingElem, FqMPolyRingElem} check_char(F, parent(x)) @req ngens(base_ring(F)) == Singular.transcendence_degree(parent(x)) "wrong number of generators" n, d = Singular.n_transExt_to_spoly.([numerator(x), denominator(x)]) @@ -85,10 +85,23 @@ function (F::Nemo.fpField)(x::AbstractAlgebra.Generic.Frac{T}) where T <: Union{ F(cst_num) // F(cst_denom) end +function (F::Nemo.FqField)(x::AbstractAlgebra.Generic.Frac{T}) where T <: Union{FqPolyRingElem, FqMPolyRingElem} + num = numerator(x) + cst_num = constant_coefficient(num) + denom = denominator(x) + cst_denom = constant_coefficient(denom) + if (num != cst_num || denom != cst_denom) throw(InexactError(:FqFieldElem, FqFieldElem, x)) end + F(cst_num) // F(cst_denom) +end + function (F::Nemo.fpField)(x::AbstractAlgebra.Generic.RationalFunctionFieldElem{fpFieldElem}) return F(x.d) end +function (F::Nemo.FqField)(x::AbstractAlgebra.Generic.RationalFunctionFieldElem{FqFieldElem}) + return F(x.d) +end + ################################################################################ # # Some ad hoc promote rules @@ -103,6 +116,8 @@ AbstractAlgebra.promote_rule(::Type{fpFieldElem}, ::Type{Singular.n_transExt}) = AbstractAlgebra.promote_rule(::Type{FpFieldElem}, ::Type{Singular.n_transExt}) = Singular.n_transExt +AbstractAlgebra.promote_rule(::Type{FqFieldElem}, ::Type{Singular.n_transExt}) = Singular.n_transExt + AbstractAlgebra.promote_rule(::Type{FqPolyRepFieldElem}, ::Type{Singular.n_transExt}) = Singular.n_transExt AbstractAlgebra.promote_rule(::Type{fqPolyRepFieldElem}, ::Type{Singular.n_transExt}) = Singular.n_transExt diff --git a/src/Rings/groebner.jl b/src/Rings/groebner.jl index 5d23eb00a60d..75537a0f020e 100644 --- a/src/Rings/groebner.jl +++ b/src/Rings/groebner.jl @@ -312,7 +312,7 @@ See [Fau99](@cite) for more information. # Examples ```jldoctest julia> R,(x,y,z) = polynomial_ring(GF(101), ["x","y","z"], ordering=:degrevlex) -(Multivariate polynomial ring in 3 variables over GF(101), fpMPolyRingElem[x, y, z]) +(Multivariate polynomial ring in 3 variables over GF(101), FqMPolyRingElem[x, y, z]) julia> I = ideal(R, [x+2*y+2*z-1, x^2+2*y^2+2*z^2-x, 2*x*y+2*y*z-y]) ideal(x + 2*y + 2*z + 100, x^2 + 2*y^2 + 2*z^2 + 100*x, 2*x*y + 2*y*z + 100*y) @@ -563,11 +563,11 @@ julia> J = ideal(R, [y^3]) ideal(y^3) julia> reduce(J.gens, I.gens) -1-element Vector{fpMPolyRingElem}: +1-element Vector{FqMPolyRingElem}: y^3 julia> reduce(J.gens, groebner_basis(I)) -1-element Vector{fpMPolyRingElem}: +1-element Vector{FqMPolyRingElem}: 0 julia> reduce(y^3, [x^2, x*y-y^3]) @@ -577,7 +577,7 @@ julia> reduce(y^3, [x^2, x*y-y^3], ordering=lex(R)) y^3 julia> reduce([y^3], [x^2, x*y-y^3], ordering=lex(R)) -1-element Vector{fpMPolyRingElem}: +1-element Vector{FqMPolyRingElem}: y^3 ``` """ @@ -758,7 +758,7 @@ julia> I = ideal(R, [x]); julia> J = ideal(R, [x+1]); julia> unit, M, res = reduce_with_quotients_and_unit(I.gens, J.gens, ordering = neglex(R)) -([x+1], [x], fpMPolyRingElem[0]) +([x+1], [x], FqMPolyRingElem[0]) julia> M * gens(J) + res == unit * gens(I) true @@ -767,7 +767,7 @@ julia> f = x^3*y^2-y^4-10 x^3*y^2 + 10*y^4 + 1 julia> F = [x^2*y-y^3, x^3-y^4] -2-element Vector{fpMPolyRingElem}: +2-element Vector{FqMPolyRingElem}: x^2*y + 10*y^3 x^3 + 10*y^4 @@ -815,7 +815,7 @@ with respect to the ordering degrevlex([x, y, z]) julia> M, res = reduce_with_quotients(I.gens, gb) -([1 0 0; 0 0 1], fpMPolyRingElem[y^2, 0]) +([1 0 0; 0 0 1], FqMPolyRingElem[y^2, 0]) julia> M * gens(gb) + res == gens(I) true @@ -824,7 +824,7 @@ julia> f = x^3*y^2-y^4-10 x^3*y^2 + 10*y^4 + 1 julia> F = [x^2*y-y^3, x^3-y^4] -2-element Vector{fpMPolyRingElem}: +2-element Vector{FqMPolyRingElem}: x^2*y + 10*y^3 x^3 + 10*y^4 @@ -993,19 +993,19 @@ with the degree reverse lexicographical ordering. # Examples ```jldoctest julia> R,(a,b,c) = polynomial_ring(GF(65521),["a","b","c"]) -(Multivariate polynomial ring in 3 variables over GF(65521), fpMPolyRingElem[a, b, c]) +(Multivariate polynomial ring in 3 variables over GF(65521), FqMPolyRingElem[a, b, c]) julia> J = ideal(R,[-1+c+b,-1+b+c*a+2*a*b]) ideal(b + c + 65520, 2*a*b + a*c + b + 65520) julia> A = [-1+c+b+a^3, -1+b+c*a+2*a^3, 5+c*b+c^2*a] -3-element Vector{fpMPolyRingElem}: +3-element Vector{FqMPolyRingElem}: a^3 + b + c + 65520 2*a^3 + a*c + b + 65520 a*c^2 + b*c + 5 julia> Oscar._normal_form_f4(A, J) -3-element Vector{fpMPolyRingElem}: +3-element Vector{FqMPolyRingElem}: a^3 2*a^3 + 2*a + 65519*c 65519*c^2 + 4*a + 65520*c + 5 @@ -1162,7 +1162,7 @@ to a Gröbner basis `H` w.r.t. another monomial ordering `ordering` for ``. # Examples ```jldoctest julia> R, (x1, x2, x3, x4) = polynomial_ring(GF(101), ["x1", "x2", "x3", "x4"]) -(Multivariate polynomial ring in 4 variables over GF(101), fpMPolyRingElem[x1, x2, x3, x4]) +(Multivariate polynomial ring in 4 variables over GF(101), FqMPolyRingElem[x1, x2, x3, x4]) julia> J = ideal(R, [x1+2*x2+2*x3+2*x4-1, x1^2+2*x2^2+2*x3^2+2*x4^2-x1, @@ -1597,7 +1597,9 @@ function groebner_basis_modular(I::MPolyIdeal{QQMPolyRingElem}; ordering::Monomi Zt = polynomial_ring(ZZ, [string(s) for s = symbols(Qt)], cached = false)[1] Rt, t = polynomial_ring(GF(p), [string(s) for s = symbols(Qt)], cached = false) - std_basis_mod_p_lifted = map(x->lift(Zt, x), sorted_gb(ideal(Rt, gens(I)))) + std_basis_mod_p_lifted = map(sorted_gb(ideal(Rt, gens(I)))) do x + map_coefficients(z -> lift(ZZ, z), x, parent = Zt) + end std_basis_crt_previous = std_basis_mod_p_lifted n_stable_primes = 0 @@ -1608,7 +1610,9 @@ function groebner_basis_modular(I::MPolyIdeal{QQMPolyRingElem}; ordering::Monomi while n_stable_primes < 2 p = iterate(primes, p)[1] Rt, t = polynomial_ring(GF(p), [string(s) for s = symbols(Qt)], cached = false) - std_basis_mod_p_lifted = map(x->lift(Zt, x), sorted_gb(ideal(Rt, gens(I)))) + std_basis_mod_p_lifted = map(sorted_gb(ideal(Rt, gens(I)))) do x + map_coefficients(z -> lift(ZZ, z), x, parent = Zt) + end # test for unlucky prime if any(((i, p), ) -> leading_monomial(p) != leading_monomial(std_basis_crt_previous[i]), diff --git a/src/Rings/mpoly-affine-algebras.jl b/src/Rings/mpoly-affine-algebras.jl index 106af9041343..0fe8adc34e8f 100644 --- a/src/Rings/mpoly-affine-algebras.jl +++ b/src/Rings/mpoly-affine-algebras.jl @@ -231,7 +231,6 @@ function hilbert_series(A::MPolyQuoRing; #=backend::Symbol=:Singular, algorithm: end # TODO: The method below is missing. It should be made better and put to the correct place (AA). -ngens(S::AbstractAlgebra.Generic.LaurentMPolyWrapRing) = length(gens(S)) ngens(S::AbstractAlgebra.Generic.LaurentPolyWrapRing) = 1 ngens(P::PolyRing) = 1 diff --git a/src/Rings/mpoly.jl b/src/Rings/mpoly.jl index 3c9b122ca01b..22f40880a38a 100644 --- a/src/Rings/mpoly.jl +++ b/src/Rings/mpoly.jl @@ -530,6 +530,63 @@ function singular_coeff_ring(F::fqPolyRepField) return SF end +# Nonsense for FqField (aka fq_default from flint) +function singular_coeff_ring(F::Nemo.FqField) + # we are way beyond type stability, so just do what you want + @assert is_absolute(F) + ctx = Nemo._fq_default_ctx_type(F) + if ctx == Nemo._FQ_DEFAULT_NMOD + return Singular.Fp(Int(characteristic(F))) + elseif nbits(characteristic(F)) <= 29 + # TODO: the Fp(Int(char)) can throw + minpoly = modulus(F) + Fa = parent(minpoly) + SFa, (Sa,) = Singular.FunctionField(Singular.Fp(Int(characteristic(F))), + _variables_for_singular(symbols(Fa))) + Sminpoly = SFa(lift(ZZ, coeff(minpoly, 0))) + for i in 1:degree(minpoly) + Sminpoly += SFa(lift(ZZ, coeff(minpoly, i)))*Sa^i + end + SF, _ = Singular.AlgebraicExtensionField(SFa, Sminpoly) + return SF + else + return Singular.CoefficientRing(F) + end +end + +function (K::FqField)(a::Singular.n_algExt) + SK = parent(a) + SF = parent(Singular.modulus(SK)) + SFa = SF(a) + numSa = Singular.n_transExt_to_spoly(numerator(SFa)) + denSa = first(AbstractAlgebra.coefficients(Singular.n_transExt_to_spoly(denominator(SFa)))) + @assert isone(denSa) + res = zero(K) + Ka = gen(K) + for (c, e) in zip(AbstractAlgebra.coefficients(numSa), AbstractAlgebra.exponent_vectors(numSa)) + res += K(Int(c))*Ka^e[1] + end + return res +end + +function (SF::Singular.N_AlgExtField)(a::FqFieldElem) + F = parent(a) + SFa = gen(SF) + res = SF(lift(ZZ, coeff(a, 0))) + for i in 1:degree(F)-1 + res += SF(lift(ZZ, coeff(a, i)))*SFa^i + end + return res +end + +function (F::FqField)(a::Singular.n_Zp) + return F(Int(a)) +end + +function (SF::Singular.N_ZpField)(a::FqFieldElem) + return SF(lift(ZZ, a)) +end + #### TODO stuff to move to singular.jl function (F::Singular.N_FField)(a::Union{zzModRingElem, fpFieldElem}) return F(a.data) diff --git a/src/Serialization/Fields.jl b/src/Serialization/Fields.jl index dd4953e31ffd..0a33b12ecd28 100644 --- a/src/Serialization/Fields.jl +++ b/src/Serialization/Fields.jl @@ -144,7 +144,7 @@ end function load_object(s::DeserializerState, ::Type{<: fqPolyRepField}) def_pol = load_typed_object(s, :def_pol) - K, _ = finite_field(def_pol, cached=false) + K, _ = Nemo.Native.finite_field(def_pol, cached=false) return K end @@ -196,10 +196,10 @@ function load_object(s::DeserializerState, ::Type{<: FqField}) load_node(s) do node if node isa String order = ZZRingElem(node) - return Hecke.Nemo._FiniteField(order)[1] + return finite_field(order)[1] else def_pol = load_typed_object(s) - return Hecke.Nemo._FiniteField(def_pol, cached=false)[1] + return finite_field(def_pol, cached=false)[1] end end end diff --git a/test/AlgebraicGeometry/Schemes/AffineRationalPoint.jl b/test/AlgebraicGeometry/Schemes/AffineRationalPoint.jl index c9eed59d8d17..e80825097336 100644 --- a/test/AlgebraicGeometry/Schemes/AffineRationalPoint.jl +++ b/test/AlgebraicGeometry/Schemes/AffineRationalPoint.jl @@ -57,7 +57,8 @@ A2L = Oscar.RationalPointSet(Spec(L), A2) pk = A2k([1,1]) pL = A2L(pk) # conversion - @test !(pk == pL) # no automatic coercion -> consistent with hom interpretation since the domains differ + @test_throws ErrorException pk == pL + #@test !(pk == pL) # no automatic coercion -> consistent with hom interpretation since the domains differ # reduction mod p k = ZZ diff --git a/test/GAP/iso_oscar_gap.jl b/test/GAP/iso_oscar_gap.jl index 5bfd871cdbc1..6358e2d1ff71 100644 --- a/test/GAP/iso_oscar_gap.jl +++ b/test/GAP/iso_oscar_gap.jl @@ -115,7 +115,6 @@ end end @test GAP.Globals.DefiningPolynomial(codomain(f)) == GAP.Globals.ConwayPolynomial(p, 2) - @test F.is_conway == 0 p2 = next_prime(p) @test_throws ErrorException f(GF(p2)(1)) @test_throws ErrorException image(f, GF(p2)(1)) @@ -281,11 +280,11 @@ end @testset "univariate polynomial rings" begin baserings = [QQ, # yields `QQPolyRing` ZZ, # yields `ZZPolyRing` - GF(2,2), # yields `fqPolyRepPolyRing` - FqField(ZZRingElem(2),3,:x), # yields `FqPolyRing` + GF(2,3), # yields `FqPolyRing` + Nemo.Native.GF(2,2), # yields `fqPolyRepPolyRing` FqPolyRepField(ZZRingElem(2),2,:z), # yields `FqPolyRepPolyRing` - GF(ZZRingElem(2)), # yields `FpPolyRing` - GF(2), # yields `fpPolyRing` + Nemo.Native.GF(ZZRingElem(2)),# yields `FpPolyRing` + Nemo.Native.GF(2), # yields `fpPolyRing` Nemo.zzModRing(UInt64(6)), # yields `zzModPolyRing` Nemo.ZZModRing(ZZRingElem(6)), # yields `ZZModPolyRing` ] @@ -308,9 +307,11 @@ end @testset "multivariate polynomial rings" begin baserings = [QQ, # yields `QQMPolyRing` ZZ, # yields `ZZMPolyRing` - GF(2,2), # yields `fqPolyRepMPolyRing` - GF(ZZRingElem(2)), # yields `AbstractAlgebra.Generic.MPolyRing{FpFieldElem}` - GF(2), # yields `fpMPolyRing` + GF(2,3), # yields `FqMPolyRing` + Nemo.Native.GF(2,2), # yields `fqPolyRepMPolyRing` + FqPolyRepField(ZZRingElem(2),2,:z), # yields `AbstractAlgebra.Generic.MPolyRing{FqPolyRepFieldElem}` + Nemo.Native.GF(ZZRingElem(2)),# yields `FpMPolyRing` + Nemo.Native.GF(2), # yields `fpMPolyRing` Nemo.zzModRing(UInt64(6)), # yields `zzModMPolyRing` ] #TODO: How to get `FpMPolyRing`, `FqMPolyRing`? diff --git a/test/Groups/FiniteFormOrthogonalGroup.jl b/test/Groups/FiniteFormOrthogonalGroup.jl index 8aaae16ea523..7a989df721ae 100644 --- a/test/Groups/FiniteFormOrthogonalGroup.jl +++ b/test/Groups/FiniteFormOrthogonalGroup.jl @@ -10,14 +10,14 @@ G = diagonal_matrix([R(1), R(1)]) L = Oscar._orthogonal_grp_gens_odd(G, 3) - L = [change_base_ring(F, g) for g in L] + L = [change_base_ring(F, lift(g)) for g in L] @test order(matrix_group(L)) == 8 Oscar._gens(G,2, 3) G = diagonal_matrix([R(1),R(2)]) L = Oscar._orthogonal_grp_gens_odd(G, 3) - L = [change_base_ring(F, g) for g in L] + L = [change_base_ring(F, lift(g)) for g in L] @test order(matrix_group(L)) == 4 Oscar._gens(G,2, 3) @@ -25,14 +25,14 @@ R = residue_ring(ZZ, 3^5) F = GF(3) G = diagonal_matrix([R(x) for x in [3*1, 3*1]]) - L = [change_base_ring(F,g) for g in Oscar._gens_mod_p(G, 3)] + L = [change_base_ring(F, lift(g)) for g in Oscar._gens_mod_p(G, 3)] @test order(matrix_group(L))==8 # Oscar._gens(G,2, 3) G = diagonal_matrix([R(x) for x in [1, 3, 3, 9, 2*27]]) - L = [change_base_ring(F,g) for g in Oscar._gens_mod_p(G, 3)] + L = [change_base_ring(F,lift(g)) for g in Oscar._gens_mod_p(G, 3)] @test order(matrix_group(L))==1259712 #Oscar._gens(G,2, 3) @@ -59,14 +59,14 @@ end [U, w1, w5]] GG = [diagonal_matrix(G) for G in L] GG = [Oscar._orthogonal_gens_bilinear(G) for G in GG] - GG = [matrix_group([change_base_ring(F,g) for g in G]) for G in GG] + GG = [matrix_group([change_base_ring(F, lift(g)) for g in G]) for G in GG] GG = [order(G) for G in GG] @test GG == [6, 6, 48, 48, 2, 720, 6, 48] GG = [diagonal_matrix(G) for G in [[U,V], [U, W0],[V,W0],[U,U,W0],[U,V,W0], [W1]]] GG = [Oscar._orthogonal_grp_quadratic(G) for G in GG] - GG = [matrix_group([change_base_ring(F,g) for g in G]) for G in GG] + GG = [matrix_group([change_base_ring(F, lift(g)) for g in G]) for G in GG] GG = [order(G) for G in GG] @test GG == [120, 8, 24, 1152,1920,2] @@ -126,7 +126,7 @@ end ] M = [diagonal_matrix(G) for G in L] GG = [Oscar._gens_mod_2(G) for G in M] - GG = [matrix_group([change_base_ring(F,g) for g in G]) for G in GG] + GG = [matrix_group([change_base_ring(F, lift(g)) for g in G]) for G in GG] GG = [order(G) for G in GG] @test GG == [720, 24, diff --git a/test/Groups/conjugation.jl b/test/Groups/conjugation.jl index d009bab99fa1..872699c74417 100644 --- a/test/Groups/conjugation.jl +++ b/test/Groups/conjugation.jl @@ -144,7 +144,7 @@ end x = G[2] TestConjCentr(G,x) - G = GL(3, Nemo._GF(3, 1)) + G = GL(3, GF(3, 1)) x = G[2] TestConjCentr(G,x) diff --git a/test/Groups/elements.jl b/test/Groups/elements.jl index b09dc2164204..c08788d96fee 100644 --- a/test/Groups/elements.jl +++ b/test/Groups/elements.jl @@ -92,7 +92,7 @@ end @test eltype(PermGroup)==PermGroupElem @test eltype(PcGroup)==PcGroupElem @test eltype(FPGroup)==FPGroupElem - @test eltype(GL(2,3))==MatrixGroupElem{fqPolyRepFieldElem,fqPolyRepMatrix} + @test eltype(GL(2,3))==MatrixGroupElem{elem_type(typeof(GF(2))),dense_matrix_type(GF(2))} @test eltype(DirectProductGroup)==Oscar.BasicGAPGroupElem{DirectProductGroup} @test eltype(direct_product(symmetric_group(3),cyclic_group(2)))==Oscar.BasicGAPGroupElem{DirectProductGroup} @test eltype(SemidirectProductGroup)==Oscar.BasicGAPGroupElem{SemidirectProductGroup} diff --git a/test/Groups/matrixgroups.jl b/test/Groups/matrixgroups.jl index 83c47d2fc63f..3779d7e5fd2a 100644 --- a/test/Groups/matrixgroups.jl +++ b/test/Groups/matrixgroups.jl @@ -449,7 +449,7 @@ end @test order(y)==8 @test base_ring(x)==F @test nrows(y)==2 - @test x*matrix(y) isa fqPolyRepMatrix + @test x*matrix(y) isa typeof(matrix(y)) @test matrix(x*y)==matrix(x)*y @test G(x*matrix(y))==x*y @test matrix(x)==x.elm diff --git a/test/Rings/AbelianClosure.jl b/test/Rings/AbelianClosure.jl index 3b2b9225ee5b..fc96d182278b 100644 --- a/test/Rings/AbelianClosure.jl +++ b/test/Rings/AbelianClosure.jl @@ -160,7 +160,7 @@ end end end - @testset "Reduction to finite fields" for gf_fun in [GF, Nemo._GF] + @testset "Reduction to finite fields" for gf_fun in [GF, Nemo.Native.GF] K, z = abelian_closure(QQ) F = gf_fun(2, 1) @test reduce(z(2), F) == one(F) diff --git a/test/Rings/AlgClosureFp.jl b/test/Rings/AlgClosureFp.jl index 056addfef31c..68b9db49bd19 100644 --- a/test/Rings/AlgClosureFp.jl +++ b/test/Rings/AlgClosureFp.jl @@ -5,12 +5,12 @@ function test_elem(K::AlgClosure{T}) where T <: FinField end @testset "AlgClosureFp" begin - @testset "Interface for $F" for F in [GF(3, 1), Nemo._GF(3, 1)] + @testset "Interface for $F" for F in [GF(3, 1), Nemo.Native.GF(3, 1)] K = algebraic_closure(GF(3,1)) test_Field_interface(K) end - @testset "Creation for $F" for F in [GF(3, 1), Nemo._GF(3, 1)] + @testset "Creation for $F" for F in [GF(3, 1), Nemo.Native.GF(3, 1)] K = algebraic_closure(F) @test base_field(K) === F @test characteristic(K) == characteristic(F) @@ -52,7 +52,7 @@ end @test a == b end - @testset "Printing for $F" for F in [GF(3, 1), Nemo._GF(3, 1)] + @testset "Printing for $F" for F in [GF(3, 1), Nemo.Native.GF(3, 1)] K = algebraic_closure(F) @test sprint(show, "text/plain", K) == "Algebraic Closure of Finite field of degree 1 over GF(3)" @@ -61,7 +61,7 @@ end end end - @testset "Coercion and conversion for $F1" for F1 in [GF(3, 1), Nemo._GF(3, 1)] + @testset "Coercion and conversion for $F1" for F1 in [GF(3, 1), Nemo.Native.GF(3, 1)] K = algebraic_closure(F1) F2 = ext_of_degree(K, 2) a = gen(F2) @@ -74,7 +74,7 @@ end @test_throws ErrorException F2(d) end - @testset "Arithmetic for $F1" for F1 in [GF(3, 1), Nemo._GF(3, 1)] + @testset "Arithmetic for $F1" for F1 in [GF(3, 1), Nemo.Native.GF(3, 1)] K = algebraic_closure(F1) @test is_unit(K(one(F1))) @test !is_unit(zero(K)) @@ -103,7 +103,7 @@ end end end - @testset "Ad hoc operations for $F1" for F1 in [GF(3, 1), Nemo._GF(3, 1)] + @testset "Ad hoc operations for $F1" for F1 in [GF(3, 1), Nemo.Native.GF(3, 1)] K = algebraic_closure(F1) for i in 1:10 a = test_elem(K) @@ -122,7 +122,7 @@ end end end - @testset "Comparison for $F1" for F1 in [GF(3, 1), Nemo._GF(3, 1)] + @testset "Comparison for $F1" for F1 in [GF(3, 1), Nemo.Native.GF(3, 1)] K = algebraic_closure(F1) F2 = ext_of_degree(K, 2) F3 = ext_of_degree(K, 3) @@ -136,7 +136,7 @@ end @test hash(K(one(F2)), zero(UInt)) == hash(K(one(F3)), zero(UInt)) end - @testset "Embeddings for $F1" for F1 in [GF(3, 1), Nemo._GF(3, 1)] + @testset "Embeddings for $F1" for F1 in [GF(3, 1), Nemo.Native.GF(3, 1)] K = algebraic_closure(F1) F2 = ext_of_degree(K, 2) F3 = ext_of_degree(K, 3) @@ -151,7 +151,7 @@ end @test !has_preimage(emb, K(gen(F3)))[1] end - @testset "Polynomial for $F1" for F1 in [GF(3, 1), Nemo._GF(3, 1)] + @testset "Polynomial for $F1" for F1 in [GF(3, 1), Nemo.Native.GF(3, 1)] p = characteristic(F1) K = algebraic_closure(F1) Kx, x = K["x"] @@ -161,7 +161,7 @@ end @test sort!(map(degree, r)) == [1, 1, 2, 2] end - @testset "Matrix for $F1" for F1 in [GF(3, 1), Nemo._GF(3, 1)] + @testset "Matrix for $F1" for F1 in [GF(3, 1), Nemo.Native.GF(3, 1)] p = characteristic(F1) K = algebraic_closure(F1) z = zero(K) @@ -170,7 +170,7 @@ end @test M^2 == M * M end - @testset "Singular ring for $F1" for F1 in [GF(3, 1), Nemo._GF(3, 1)] + @testset "Singular ring for $F1" for F1 in [GF(3, 1), Nemo.Native.GF(3, 1)] p = characteristic(F1) K = algebraic_closure(F1) L = Oscar.singular_coeff_ring(K) diff --git a/test/Rings/groebner.jl b/test/Rings/groebner.jl index 34f54a950084..64488af9767f 100644 --- a/test/Rings/groebner.jl +++ b/test/Rings/groebner.jl @@ -150,7 +150,7 @@ end 2*x1*x2+2*x2*x3+2*x3*x4-x2, x2^2+2*x1*x3+2*x2*x4-x3]) H = groebner_basis_f4(I); - G = fpMPolyRingElem[x1 + 2*x2 + 2*x3 + 2*x4 + 268435458 + G = [x1 + 2*x2 + 2*x3 + 2*x4 + 268435458 x3^2 + 2*x2*x4 + 76695850*x3*x4 + 115043772*x4^2 + 115043768*x2 + 191739613*x3 + 230087535*x4 x2*x3 + 268435457*x2*x4 + 230087533*x3*x4 + 76695842*x4^2 + 210913575*x2 + 38347923*x3 + 153391692*x4 x2^2 + 2*x2*x4 + 153391692*x3*x4 + 230087538*x4^2 + 230087536*x2 + 115043768*x3 + 191739613*x4 @@ -161,7 +161,7 @@ end @test isdefined(I, :gb) @test I.gb[degrevlex(gens(base_ring(I)))].O == G H = groebner_basis_f4(I, eliminate=2); - G = fpMPolyRingElem[x3^2*x4 + 73209671*x3*x4^2 + 260301051*x4^3 + 188447115*x3^2 + 167207272*x3*x4 + 120660383*x4^2 + 210590781*x3 + 109814506*x4 + G = [x3^2*x4 + 73209671*x3*x4^2 + 260301051*x4^3 + 188447115*x3^2 + 167207272*x3*x4 + 120660383*x4^2 + 210590781*x3 + 109814506*x4 x3^3 + 156877866*x3*x4^2 + 59264971*x4^3 + 224858274*x3^2 + 183605206*x3*x4 + 130731555*x4^2 + 110395535*x3 + 158620953*x4 x4^4 + 167618101*x3*x4^2 + 102789335*x4^3 + 193931678*x3^2 + 156155981*x3*x4 + 60823186*x4^2 + 239040667*x3 + 127377432*x4 x3*x4^3 + 99215126*x3*x4^2 + 261328123*x4^3 + 132228634*x3^2 + 93598185*x3*x4 + 85654356*x4^2 + 3613010*x3 + 240673711*x4] diff --git a/test/Serialization/Matrices.jl b/test/Serialization/Matrices.jl index c8fa20780742..64638d5e9802 100644 --- a/test/Serialization/Matrices.jl +++ b/test/Serialization/Matrices.jl @@ -2,8 +2,8 @@ R, x = polynomial_ring(QQ, "x") q = x^2 + 3//4 K, a = number_field(q) Z7 = residue_ring(ZZ, 7) -Z7t, t = polynomial_ring(Z7, "t") -Fin, d = finite_field(t^2 + t + 1) +Z7t, t = polynomial_ring(GF(7), "t") +Fin, d = finite_field(t^2 + t + 3) Frac = fraction_field(R) cases = [ diff --git a/test/Serialization/PolynomialsSeries.jl b/test/Serialization/PolynomialsSeries.jl index eb3b6a98a9cf..3f90ab227131 100644 --- a/test/Serialization/PolynomialsSeries.jl +++ b/test/Serialization/PolynomialsSeries.jl @@ -8,13 +8,13 @@ Tow, b = number_field(y^2 + 1, "b") NonSimRel, c = number_field([y^2 - 5 * a, y^2 - 7 * a]) Qu, u = rational_function_field(QQ, "u") Zt, t = polynomial_ring(residue_ring(ZZ, 2), "t") -Fin, d = finite_field(t^2 + t + 1) +Fin, d = Nemo.Native.finite_field(t^2 + t + 1) Frac = fraction_field(R) P7 = PadicField(7, 30) T = tropical_semiring() -F, o = Hecke.Nemo._FiniteField(4) +F, o = finite_field(4) Fs, s = F["s"] -FF, r = Hecke.Nemo._FiniteField(s^2 + o * s + 1, "r") +FF, r = finite_field(s^2 + o * s + 1, "r") cases = [ (QQ, QQFieldElem(3, 4), QQFieldElem(1, 2), "Rationals"), diff --git a/test/Serialization/upgrades/runtests.jl b/test/Serialization/upgrades/runtests.jl index b9fdbc7a76fe..033a6ea20609 100644 --- a/test/Serialization/upgrades/runtests.jl +++ b/test/Serialization/upgrades/runtests.jl @@ -9,7 +9,7 @@ @testset "< 0.12.0 Upgrade" begin Zt, t = polynomial_ring(residue_ring(ZZ, 2), "t") - Fin, d = finite_field(t^2 + t + 1) + Fin, d = Nemo.Native.finite_field(t^2 + t + 1) Rx, x = Fin["x"] p = x^2 + d * x + 1 loaded_p = load(joinpath(@__DIR__, "file_version_less_than_0.12.0.json"); params=Rx);