diff --git a/src/Rings/Laurent.jl b/src/Rings/Laurent.jl index ab97dd3f7326..bddec1aef4bb 100644 --- a/src/Rings/Laurent.jl +++ b/src/Rings/Laurent.jl @@ -61,7 +61,8 @@ function _polyringquo(R::LaurentMPolyWrapRing) get_attribute!(R, :polyring) do n = nvars(R) C = base_ring(R) - Cx, x, xinv = polynomial_ring(C,"x#" => 1:n, "x#^-1" => 1:n; cached = false) + var_names = symbols(R.mpolyring) + Cx, x, xinv = polynomial_ring(C, var_names, [Symbol("inv(", name, ")") for name in var_names]; cached = false) I = ideal(Cx, [x[i]*xinv[i] - 1 for i in 1:n]) Q, = quo(Cx, I) return _LaurentMPolyBackend(R, Q) @@ -241,3 +242,13 @@ end +function quo(R::LaurentMPolyWrapRing, I::LaurentMPolyIdeal) + @req R === base_ring(I) "ring and ideal do not match" + poly_repr = Oscar._polyringquo(R) + underlying_poly_ring_quo = codomain(poly_repr) + II = ideal(underlying_poly_ring_quo, poly_repr.(gens(I))) + Q,phi = quo(underlying_poly_ring_quo, II) + map_down(f::LaurentMPolyWrap) = phi(poly_repr(f)) + lift_up(f::MPolyQuoRingElem) = poly_repr.inv(preimage(phi,f)) + return Q, MapFromFunc(R,Q, map_down, lift_up) +end diff --git a/test/Rings/Laurent.jl b/test/Rings/Laurent.jl index ff5493829ab5..5af7230740ee 100644 --- a/test/Rings/Laurent.jl +++ b/test/Rings/Laurent.jl @@ -32,3 +32,45 @@ end end end + + +@testset "Laurent quotient" begin + # Quick test + + # Taken from issue 4814 + + R, (x, y) = laurent_polynomial_ring(GF(2), [:x, :y]) + f1 = x^2*y^3 + x*y^3 + 1 + f2 = y + y^2 + x^3 + f3 = x^9 * y^6 - 1 + f4 = y^15 - 1 + I = ideal(R, [f1, f2, f3, f4]) + + Q,phi = quo(R, I) # same as R/ideal(x^2+x+1, y^2+y+1) + + @test parent(phi(x)) == Q + @test parent(phi(y)) == Q + @test is_one(phi(x^3)) + @test is_one(phi(x)^3) + @test is_one(phi(y^3)) + @test is_one(phi(y)^3) + @test preimage(phi,phi(x)) - x in I + @test phi(x) == phi(1+x^(-1)) + + + # Ideal generated by non-polynomials + R, (x, y) = laurent_polynomial_ring(QQ, [:x, :y]) + C10 = x^2 -x +1 -x^(-1) +x^(-2) + C28 = y^6 -y^4 +y^2 -1 +y^(-2) -y^(-4) +y^(-6) + J = ideal(R, [C10,C28]) + Q,phi = quo(R,J) + u = phi(x^(-1)*y^3) + @test is_unit(u) + @test is_unit(u^(-1)) + @test is_one(u^140) + @test !is_one(u^70) + @test !is_one(u^28) + @test !is_one(u^20) + @test is_one(u*inv(u)) + @test 1/u == inv(u) +end