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

Move dim from schemes to rings #4280

Merged
merged 8 commits into from
Nov 13, 2024
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
42 changes: 2 additions & 40 deletions src/AlgebraicGeometry/Schemes/AffineSchemes/Objects/Attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -399,52 +399,14 @@ julia> dim(Y) # one dimension comes from ZZ and two from x1 and x2
3
```
"""
dim(X::AbsAffineScheme)

@attr Any function dim(X::AbsAffineScheme{<:Ring, <:MPolyQuoLocRing})
error("Not implemented")
end

@attr Any function dim(X::AbsAffineScheme{<:Ring, <:MPolyQuoLocRing{<:Any,<:Any,<:MPolyRing,<:MPolyRingElem, <:MPolyPowersOfElement}})
return dim(closure(X))
end

@attr Any function dim(X::AbsAffineScheme{<:Ring, <:MPolyQuoLocRing{<:Any,<:Any,<:MPolyRing,<:MPolyRingElem, <:Union{MPolyComplementOfPrimeIdeal, MPolyComplementOfKPointIdeal}}})
# Spec (R / I)_P
R = OO(X)
P = prime_ideal(inverted_set(R))
I = saturated_ideal(modulus(R))
return dim(I) - dim(P)
end

@attr Any function dim(X::AbsAffineScheme{<:Ring, <:MPolyLocRing})
error("Not implemented")
end

@attr Any function dim(X::AbsAffineScheme{<:Ring, <:MPolyLocRing{<:Any,<:Any,<:MPolyRing,<:MPolyRingElem, <:MPolyPowersOfElement}})
# zariski open subset of A^n
return dim(closure(X))
end

@attr Any function dim(X::AbsAffineScheme{<:Ring, <:MPolyLocRing{<:Any,<:Any,<:MPolyRing,<:MPolyRingElem, <:Union{MPolyComplementOfPrimeIdeal, MPolyComplementOfKPointIdeal}}})
P = prime_ideal(inverted_set(OO(X)))
return codim(P)
end

@attr Any function dim(X::AbsAffineScheme{<:Ring, <:MPolyRing})
return dim(ideal(ambient_coordinate_ring(X), [zero(ambient_coordinate_ring(X))]))
end

@attr Any function dim(X::AbsAffineScheme{<:Ring, <:MPolyQuoRing})
return dim(modulus(OO(X)))
end
dim(X::AbsAffineScheme) = dim(OO(X))

@doc raw"""
codim(X::AbsAffineScheme)

Return the codimension of ``X`` in its ambient affine space.

Throws and error if ``X`` does not have an ambient affine space.
Throws an error if ``X`` does not have an ambient affine space.

# Examples
```jldoctest
Expand Down
13 changes: 11 additions & 2 deletions src/Rings/mpoly-affine-algebras.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ julia> dim(A)
```
"""
function dim(A::MPolyQuoRing)
I = A.I
return dim(I)
return dim(modulus(A))
end

function dim(A::zzModRing)
modulus(A) == 1 && error("Function `dim` gives wrong answers if the base ring is the zero ring.")
return 0
end

function dim(A::ZZModRing)
modulus(A) == 1 && error("Function `dim` gives wrong answers if the base ring is the zero ring.")
return 0
end

@doc raw"""
Expand Down
31 changes: 30 additions & 1 deletion src/Rings/mpolyquo-localizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2565,7 +2565,36 @@ function small_generating_set(
end::Vector{elem_type(base_ring(I))}
end

dim(R::MPolyQuoLocRing{<:Field, <:FieldElem, <:MPolyRing, <:MPolyRingElem, <:MPolyComplementOfPrimeIdeal}) = dim(saturated_ideal(modulus(R))) - dim(prime_ideal(inverted_set(R)))
@attr Int function dim(R::MPolyLocRing)
error("Not implemented")
end

@attr Int function dim(R::MPolyQuoLocRing{<:Any, <:Any, <:MPolyRing, <:MPolyRingElem, <:Union{MPolyComplementOfPrimeIdeal, MPolyComplementOfKPointIdeal}})
P = prime_ideal(inverted_set(R))
I = saturated_ideal(modulus(R))
return dim(I) - dim(P)
end
Comment on lines +2572 to +2576
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please handle them separately. For MPolyComplementOfKPointIdeal P is certified to be zero-dimensional so that we do not need to compute dim(P).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P is certified to be zero-dimensional

It seems that this is not true.

julia> R, (x, y) = ZZ[:x, :y]
(Multivariate polynomial ring in 2 variables over ZZ, ZZMPolyRingElem[x, y])

julia> S = complement_of_point_ideal(R, [0, 0])
Complement
  of maximal ideal corresponding to rational point with coordinates (0, 0)
  in multivariate polynomial ring in 2 variables over ZZ

julia> I = ideal(R, 0)
Ideal generated by
  0

julia> L, _ = localization(R, S)
(Localization of multivariate polynomial ring in 2 variables over ZZ at complement of maximal ideal of point (0, 0), Hom: R -> localized ring)

julia> W, _ = quo(L, L(I))
(Localization of quotient of multivariate polynomial ring at complement of maximal ideal, hom: Localized ring -> Localized quotient of multivariate polynomial ring)

julia> P = prime_ideal(inverted_set(W))
Ideal generated by
  x
  y

julia> dim(P)
1

So I will leave it as it is for now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is that complement_of_point_ideal silently assumes that we are working over a field? Perhaps the type and constructor should be restricted accordingly what do you think @afkafkafk13 ?

Copy link
Collaborator

@afkafkafk13 afkafkafk13 Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

julia> S = complement_of_point_ideal(R, [0, 0])
Complement
of maximal ideal corresponding to rational point with coordinates (0, 0)
in multivariate polynomial ring in 2 variables over ZZ

This is indeed a problem with complement_of_point_ideal:
This ideal is NOT maximal as we do not get a field as the quotient of the ring by it. This needs to be handled in complement_of_point_ideal. My suggestion: check dimension (not number of entries!!) of the ideal before doing anything else in complement_of_point_ideal, throw an error if it is not maximal (i.e. dim(ideal) is not zero -- this should already be working in Oscar) and point the user to complement_of_prime_ideal.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bit fuzzy what a "point" is here. Will we get anything computationally effective for the "point" given by the maximal ideal (2,x,y) in Z[x,y]? I impression was that ComplementOfKPointIdeal just assumes a base field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I impression was that ComplementOfKPointIdeal just assumes a base field.

I think it does assume but does not check for this (although it should).

I would leave fixing complement_of_point_ideal to a separate issue.

Copy link
Collaborator

@afkafkafk13 afkafkafk13 Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. fine with me. But we urgently need to fix complement_of_point_ideal. Maybe we can just check

@simonbrandhorst no, we won't get anything computationally effective currently. You are right. We should just tell the user to use complement_of_prime_ideal instead, whenever we are not over a field.

Edit: This is a strategic decision and breaks some tests. I opened PR We need to discuss this. Over a ring this is not a point ideal and hence should not be used via this localization, anyway. Moreover, the localization at <x_1,\dots,x_n> in ZZ[x_1,\dots,x_n] is not what is produced here, as we are localizing w.r.t. a monomial ordering and continue working over ZZ and do not pass to QQ, even though ZZ \cap <x_1,\dots,x_n> = 0.


@attr Int function dim(R::MPolyQuoLocRing{<:Any, <:Any, <:MPolyRing, <:MPolyRingElem, <:MPolyPowersOfElement})
return dim(saturated_ideal(modulus(R)))
end

@attr Int function dim(R::MPolyLocRing{<:Any,<:Any,<:MPolyRing,<:MPolyRingElem, <:MPolyPowersOfElement})
# zariski open subset of A^n
return dim(base_ring(R))
end

@attr Int function dim(R::MPolyLocRing{<:Any,<:Any,<:MPolyRing,<:MPolyRingElem, <:MPolyComplementOfPrimeIdeal})
P = prime_ideal(inverted_set(R))
return codim(P)
end


@attr Int function dim(R::MPolyLocRing{<:Field,<:Any,<:MPolyRing,<:MPolyRingElem, <:MPolyComplementOfKPointIdeal})
# localization of a polynomial ring over a field at a maximal ideal does not change the dimension
# because all maximal ideals have the same dimension in this case.
return dim(base_ring(R))
end

########################################################################
# Localizations of graded rings #
Expand Down
Loading