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

Add Ideal.radical and Ring.nilradical #39549

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions src/sage/categories/rings.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,21 @@ def zero_ideal(self):
"""
return self._ideal_class_(1)(self, [self.zero()])

def nilradical(self):
"""
Return the nilradical of this ring.

EXAMPLES::

sage: QQ['x,y'].nilradical()
Ideal (0) of Multivariate Polynomial Ring in x, y over Rational Field

.. SEEALSO::

:meth:`~sage.categories.finite_dimensional_lie_algebras_with_basis.ParentMethods.nilradical`
"""
return self.zero_ideal().radical()

@cached_method
def unit_ideal(self):
"""
Expand Down
12 changes: 6 additions & 6 deletions src/sage/rings/finite_rings/integer_mod_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,12 +750,12 @@ def is_field(self, proof=None):
self._factory_data[3]['category'] = Fields()
else:
if self.category().is_subcategory(Fields()):
raise ValueError("""THIS SAGE SESSION MIGHT BE SERIOUSLY COMPROMISED!
The order {} is not prime, but this ring has been put
into the category of fields. This may already have consequences
in other parts of Sage. Either it was a mistake of the user,
or a probabilistic primality test has failed.
In the latter case, please inform the developers.""".format(self.order()))
raise ValueError(("THIS SAGE SESSION MIGHT BE SERIOUSLY COMPROMISED!\n"
"The order {} is not prime, but this ring has been put\n"
"into the category of fields. This may already have consequences\n"
"in other parts of Sage. Either it was a mistake of the user,\n"
"or a probabilistic primality test has failed.\n"
"In the latter case, please inform the developers.").format(self.order()))
return is_prime

@cached_method
Expand Down
11 changes: 11 additions & 0 deletions src/sage/rings/ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,17 @@ def residue_field(self):
return ZZ.residue_field(self, check=False)
raise NotImplementedError("residue_field() is only implemented for ZZ and rings of integers of number fields.")

def radical(self):
r"""
Return the radical of this ideal.

EXAMPLES::

sage: ZZ.ideal(12).radical()
Principal ideal (6) of Integer Ring
"""
return self.ring().ideal(self.gen().radical())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(for context, this is for Ideal_pid.)



class Ideal_fractional(Ideal_generic):
"""
Expand Down
3 changes: 2 additions & 1 deletion src/sage/rings/polynomial/multi_polynomial_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
from sage.misc.misc_c import prod
from sage.misc.verbose import get_verbose, verbose
from sage.rings.ideal import Ideal_generic
from sage.rings.quotient_ring import QuotientRingIdeal_generic
from sage.rings.integer import Integer
from sage.rings.integer_ring import ZZ
from sage.rings.noncommutative_ideals import Ideal_nc
Expand Down Expand Up @@ -5632,7 +5633,7 @@ def weil_restriction(self):
return result_ring.ideal(result)


class MPolynomialIdeal_quotient(MPolynomialIdeal):
class MPolynomialIdeal_quotient(QuotientRingIdeal_generic, MPolynomialIdeal):
r"""
An ideal in a quotient of a multivariate polynomial ring.

Expand Down
43 changes: 34 additions & 9 deletions src/sage/rings/quotient_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,27 @@
Ideal (3, 0) of Ring of integers modulo 9
"""

def _lift(self):
"""
Return an ideal of the cover ring that corresponds to this ideal.

EXAMPLES::

sage: Zmod(15).ideal(6)._lift()
Principal ideal (3) of Integer Ring
sage: R.<x,y> = QQ[]
sage: S = R.quotient(x)
sage: S.ideal(y)._lift()
Ideal (x, y) of Multivariate Polynomial Ring in x, y over Rational Field
"""
R = self.ring()
if hasattr(R, 'defining_ideal'):
Igens = list(R.defining_ideal().gens())
else:
Igens = [R.modulus()]

Check warning on line 1525 in src/sage/rings/quotient_ring.py

View check run for this annotation

Codecov / codecov/patch

src/sage/rings/quotient_ring.py#L1525

Added line #L1525 was not covered by tests
Igens += [g.lift() for g in self.gens()]
return R.cover_ring().ideal(Igens)

def _contains_(self, other):
r"""
Check whether this ideal contains the given element.
Expand Down Expand Up @@ -1534,15 +1555,19 @@
sage: 5-5*t in S.ideal(t^2 - 1)
True
"""
R = self.ring()
assert other in R
if hasattr(R, 'defining_ideal'):
Igens = list(R.defining_ideal().gens())
else:
Igens = [R.modulus()]
Igens += [g.lift() for g in self.gens()]
J = R.cover_ring().ideal(Igens)
return other.lift() in J
assert other in self.ring()
return other.lift() in self._lift()

def radical(self):
"""
Return the radical of this ideal.

EXAMPLES::

sage: Zmod(16).ideal(4).radical()
Principal ideal (2) of Ring of integers modulo 16
"""
return self.ring().ideal(self._lift().radical())


class QuotientRingIdeal_principal(ideal.Ideal_principal, QuotientRingIdeal_generic):
Expand Down
Loading