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

Relax signature of ==(::MPolyIdeal, ::MPolyIdeal) #2937

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/src/CommutativeAlgebra/ideals.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ is_monomial(f::MPolyRingElem)
### Containment of Ideals

```@docs
is_subset(I::MPolyIdeal{T}, J::MPolyIdeal{T}) where T
is_subset(I::MPolyIdeal, J::MPolyIdeal)
```

### Equality of Ideals

```@docs
==(I::MPolyIdeal{T}, J::MPolyIdeal{T}) where T
==(I::MPolyIdeal, J::MPolyIdeal)
```

### Ideal Membership
Expand Down
14 changes: 8 additions & 6 deletions src/Rings/mpoly-ideals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ end

# elementary operations #######################################################
@doc raw"""
check_base_rings(I::MPolyIdeal{T}, J::MPolyIdeal{T}) where T
check_base_rings(I::MPolyIdeal, J::MPolyIdeal)

Throws an error if the base rings of the ideals `I` and `J` do not coincide.
"""
function check_base_rings(I::MPolyIdeal{T}, J::MPolyIdeal{T}) where T
function check_base_rings(I::MPolyIdeal, J::MPolyIdeal)
if !isequal(base_ring(I), base_ring(J))
error("Base rings must coincide.")
end
Expand Down Expand Up @@ -970,7 +970,7 @@ end

#######################################################
@doc raw"""
==(I::MPolyIdeal{T}, J::MPolyIdeal{T}) where T
==(I::MPolyIdeal, J::MPolyIdeal)

Return `true` if `I` is equal to `J`, `false` otherwise.

Expand All @@ -989,7 +989,8 @@ julia> I == J
false
```
"""
function ==(I::MPolyIdeal{T}, J::MPolyIdeal{T}) where T
function ==(I::MPolyIdeal, J::MPolyIdeal)
check_base_rings(I, J)
I === J && return true
gens(I) == gens(J) && return true
return issubset(I, J) && issubset(J, I)
Expand All @@ -999,7 +1000,7 @@ end

#######################################################
@doc raw"""
is_subset(I::MPolyIdeal{T}, J::MPolyIdeal{T}) where T
is_subset(I::MPolyIdeal, J::MPolyIdeal)

Return `true` if `I` is contained in `J`, `false` otherwise.

Expand All @@ -1018,7 +1019,8 @@ julia> is_subset(I, J)
true
```
"""
function is_subset(I::MPolyIdeal{T}, J::MPolyIdeal{T}) where T
function is_subset(I::MPolyIdeal, J::MPolyIdeal)
check_base_rings(I, J)
return Singular.iszero(Singular.reduce(singular_generators(I), singular_groebner_generators(J)))
end

Expand Down
15 changes: 8 additions & 7 deletions test/Rings/mpoly-graded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ end



@testset "homogenizaton: big principal ideal" begin
@testset "homogenization: big principal ideal" begin
# It is easy to honogenize a principal ideal: just homogenize the gen!
# Do not really need lots of vars; just a "large" single polynomial
LotsOfVars = 250;
Expand Down Expand Up @@ -463,42 +463,43 @@ end
x^3*y^2+x*y*z^3+x*y+y^2,
x^2*y^3*w+y^3*z^2*w-y*z^3*w^2-y*w^2], W1, "h");
Ih_std = homogenization(I, "h")
Ih_expected = ideal(Ih_W1)
Ih_expected = ideal(base_ring(Ih_std), Ih_W1)
@test Ih_std == Ih_expected
Ih = homogenization(I, W1, "h")
Ih_expected = ideal(base_ring(Ih), Ih_W1)
@test Ih == Ih_expected
Ih_W2 = homogenization([x*y*z^3+x^3*y^2+y^2+x*y,
x*y*z^2*w+x^3*w^2+x^3*y*w+w^2,
x^3*z*w^2+x^3*y*z*w-x^3*y^2*w+z*w^2-y^2*w-x*y*w,
x^5*w^3+x^3*y^3*z*w-y*z^2*w^2+2*x^5*y*w^2+x^2*w^3+x^5*y^2*w+y^3*z*w+x*y^2*z*w+x^2*y*w^2,
y*z^3*w^2-y^3*z^2*w-x^2*y^3*w+y*w^2],
W2, "h");
Ih_expected = ideal(Ih_W2)
Ih = homogenization(I, W2, "h")
Ih_expected = ideal(base_ring(Ih), Ih_W2)
@test Ih == Ih_expected
Ih_W3 = homogenization([x^2*y^3*w+y^3*z^2*w-y*z^3*w^2-y*w^2,
x^3*y*w+x*y*z^2*w+x^3*w^2+w^2,
x^3*y^2+y^2+x*y*z^3+x*y],
W3, "h");
Ih_expected = ideal(Ih_W3)
Ih = homogenization(I, W3, "h")
Ih_expected = ideal(base_ring(Ih), Ih_W3)
@test Ih == Ih_expected
# Ih_W4 = ????
# Ih_expected = ideal(Ih_W4)
# Ih = homogenization(I, W4, "h")
# Ih_expected = ideal(base_ring(Ih), Ih_W4)
# @test Ih = Ih_expected
Ih_W2a = homogenization([x*y*z^3+x^3*y^2+y^2+x*y,
x*y*z^2*w+x^3*w^2+x^3*y*w+w^2,
x^3*z*w^2+x^3*y*z*w-x^3*y^2*w+z*w^2-y^2*w-x*y*w,
y*z^3*w^2-y^3*z^2*w-x^2*y^3*w+y*w^2,
x^5*w^3+x^3*y^3*z*w-y*z^2*w^2+2*x^5*y*w^2+x^2*w^3+x^5*y^2*w+y^3*z*w+x*y^2*z*w+x^2*y*w^2],
W2a, "h");
Ih_expected = ideal(Ih_W2a)
Ih = homogenization(I, W2a, "h")
Ih_expected = ideal(base_ring(Ih), Ih_W2a)
@test Ih == Ih_expected
# Ih_W2b = ????
# Ih_expected = ideal(Ih_W2b)
# Ih = homogenization(I, W2b, "h")
# Ih_expected = ideal(base_ring(Ih), Ih_W2b)
# @test Ih == Ih_expected
end

Expand Down
7 changes: 7 additions & 0 deletions test/Rings/mpoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ end
@test intersect(I,J,P) == ideal(R,[x^2*y^2, x^4, x*y^4])
@test intersect(I,J,P) == intersect([I,J,P])

@test I != J
RR, (xx, yy) = grade(R, [1, 1])
@test_throws ErrorException ideal(R, [x]) == ideal(RR, [xx])
@test is_subset(I, I)
RR, (xx, yy) = polynomial_ring(QQ, ["xx", "yy"])
@test_throws ErrorException is_subset(ideal(R, [x]), ideal(RR, [xx]))

f = x^2 + y^2
g = x^4*y - x*y^3
I = [f, g]
Expand Down