From eaa8972f657ccc3ae4e3c55495ebe3227a2dd429 Mon Sep 17 00:00:00 2001 From: Johannes Schmitt Date: Thu, 24 Oct 2024 22:23:25 +0200 Subject: [PATCH] Add `characteristic` for multivariate quotient rings over fields (#4241) --- src/Rings/MPolyQuo.jl | 8 ++++++++ test/Rings/MPolyQuo.jl | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/Rings/MPolyQuo.jl b/src/Rings/MPolyQuo.jl index a07fae42f54b..fe521d51dba1 100644 --- a/src/Rings/MPolyQuo.jl +++ b/src/Rings/MPolyQuo.jl @@ -79,6 +79,14 @@ oscar_origin_ring(Q::MPolyQuoRing) = base_ring(Q) default_ordering(Q::MPolyQuoRing) = default_ordering(base_ring(Q)) +# Only for fields for now because of things like char(ZZ[x, y]/<2>) = 2 +function characteristic(Q::MPolyQuoRing{<:MPolyRingElem{T}}) where {T <: FieldElement} + if is_zero(one(Q)) + return 1 + end + return characteristic(coefficient_ring(Q)) +end + ############################################################################## # # Quotient ring elements diff --git a/test/Rings/MPolyQuo.jl b/test/Rings/MPolyQuo.jl index 2d38f5ecfd29..31c18c00ecd3 100644 --- a/test/Rings/MPolyQuo.jl +++ b/test/Rings/MPolyQuo.jl @@ -36,6 +36,12 @@ B,q = quo(R, x^3+y,y^2; ordering=lex(R)) @test A.I == B.I + + @test characteristic(quo(R, ideal(x))[1]) == 0 + @test characteristic(quo(R, ideal(R, 1))[1]) == 1 + + S, (s, t) = GF(5)[:s, :t] + @test characteristic(quo(S, ideal([s, t]))[1]) == 5 end @testset "MpolyQuo.manipulation" begin