本文整理汇总了Python中sage.rings.ideal.is_Ideal函数的典型用法代码示例。如果您正苦于以下问题:Python is_Ideal函数的具体用法?Python is_Ideal怎么用?Python is_Ideal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_Ideal函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ideal
def ideal(self, *gens):
"""
Returns the fractional ideal generated by ``gens``.
EXAMPLES::
sage: K.<x> = FunctionField(QQ)
sage: O = K.maximal_order()
sage: O.ideal(x)
Ideal (x) of Maximal order in Rational function field in x over Rational Field
sage: O.ideal([x,1/x]) == O.ideal(x,1/x) # multiple generators may be given as a list
True
sage: O.ideal(x^3+1,x^3+6)
Ideal (1) of Maximal order in Rational function field in x over Rational Field
sage: I = O.ideal((x^2+1)*(x^3+1),(x^3+6)*(x^2+1)); I
Ideal (x^2 + 1) of Maximal order in Rational function field in x over Rational Field
sage: O.ideal(I)
Ideal (x^2 + 1) of Maximal order in Rational function field in x over Rational Field
"""
if len(gens) == 1:
gens = gens[0]
if not isinstance(gens, (list, tuple)):
if is_Ideal(gens):
gens = gens.gens()
else:
gens = (gens,)
from .function_field_ideal import ideal_with_gens
return ideal_with_gens(self, gens)
示例2: ideal
def ideal(self, *gens, **kwds):
"""
Create an ideal in this polynomial ring.
"""
do_coerce = False
if len(gens) == 1:
from sage.rings.ideal import is_Ideal
if is_Ideal(gens[0]):
if gens[0].ring() is self:
return gens[0]
gens = gens[0].gens()
elif isinstance(gens[0], (list, tuple)):
gens = gens[0]
if not self._has_singular:
# pass through
MPolynomialRing_generic.ideal(self,gens,**kwds)
if is_SingularElement(gens):
gens = list(gens)
do_coerce = True
if is_Macaulay2Element(gens):
gens = list(gens)
do_coerce = True
elif not isinstance(gens, (list, tuple)):
gens = [gens]
if ('coerce' in kwds and kwds['coerce']) or do_coerce:
gens = [self(x) for x in gens] # this will even coerce from singular ideals correctly!
return multi_polynomial_ideal.MPolynomialIdeal(self, gens, **kwds)
示例3: __call__
def __call__(self, *args):
"""
Construct a scheme-valued or topological point of ``self``.
INPUT/OUTPUT:
The argument ``x`` must be one of the following:
- a prime ideal of the coordinate ring; the output will
be the corresponding point of `X`
- a ring or a scheme `S`; the output will be the set `X(S)` of
`S`-valued points on `X`
EXAMPLES::
sage: S = Spec(ZZ)
sage: P = S(ZZ.ideal(3)); P
Point on Spectrum of Integer Ring defined by the Principal ideal (3) of Integer Ring
sage: type(P)
<class 'sage.schemes.generic.point.SchemeTopologicalPoint_prime_ideal'>
sage: S(ZZ.ideal(next_prime(1000000)))
Point on Spectrum of Integer Ring defined by the Principal ideal (1000003) of Integer Ring
sage: R.<x, y, z> = QQ[]
sage: S = Spec(R)
sage: P = S(R.ideal(x, y, z)); P
Point on Spectrum of Multivariate Polynomial Ring
in x, y, z over Rational Field defined by the Ideal (x, y, z)
of Multivariate Polynomial Ring in x, y, z over Rational Field
This indicates the fix of :trac:`12734`::
sage: S = Spec(ZZ)
sage: S(ZZ)
Set of rational points of Spectrum of Integer Ring
Note the difference between the previous example and the
following one::
sage: S(S)
Set of morphisms
From: Spectrum of Integer Ring
To: Spectrum of Integer Ring
"""
if len(args) == 1:
from sage.rings.ideal import is_Ideal
x = args[0]
if is_Ideal(x) and x.ring() is self.coordinate_ring():
from sage.schemes.generic.point import SchemeTopologicalPoint_prime_ideal
return SchemeTopologicalPoint_prime_ideal(self, x)
return super(AffineScheme, self).__call__(*args)
示例4: __contains__
def __contains__(self, x):
"""
EXAMPLES::
sage: C = Ideals(IntegerRing())
sage: IntegerRing().zero_ideal() in C
True
"""
if super(Category_ideal, self).__contains__(x):
return True
from sage.rings.ideal import is_Ideal
if is_Ideal(x) and x.ring() == self.ring():
return True
return False
示例5: _element_constructor_
def _element_constructor_(self, x):
"""
Construct a topological point from `x`.
TESTS::
sage: S = Spec(ZZ)
sage: S(ZZ.ideal(0))
Point on Spectrum of Integer Ring defined by the Principal ideal (0) of Integer Ring
"""
if isinstance(x, self.element_class):
if x.parent() is self:
return x
elif x.parent() == self:
return self.element_class(self, x.prime_ideal())
elif is_Ideal(x) and x.ring() is self.coordinate_ring():
return self.element_class(self, x)
raise TypeError('cannot convert %s to a topological point of %s' % (x, self))
示例6: __init__
def __init__(self, S, P, check=False):
"""
INPUT:
- ``S`` -- an affine scheme
- ``P`` -- a prime ideal of the coordinate ring of `S`, or
anything that can be converted into such an ideal
TESTS::
sage: from sage.schemes.generic.point import SchemeTopologicalPoint_prime_ideal
sage: S = Spec(ZZ)
sage: P = SchemeTopologicalPoint_prime_ideal(S, 3); P
Point on Spectrum of Integer Ring defined by the Principal ideal (3) of Integer Ring
sage: SchemeTopologicalPoint_prime_ideal(S, 6, check=True)
Traceback (most recent call last):
...
ValueError: The argument Principal ideal (6) of Integer Ring must be a prime ideal of Integer Ring
sage: SchemeTopologicalPoint_prime_ideal(S, ZZ.ideal(7))
Point on Spectrum of Integer Ring defined by the Principal ideal (7) of Integer Ring
We define a parabola in the projective plane as a point
corresponding to a prime ideal::
sage: P2.<x, y, z> = ProjectiveSpace(2, QQ)
sage: SchemeTopologicalPoint_prime_ideal(P2, y*z-x^2)
Point on Projective Space of dimension 2 over Rational Field defined by the Ideal (-x^2 + y*z) of Multivariate Polynomial Ring in x, y, z over Rational Field
"""
R = S.coordinate_ring()
from sage.rings.ideal import is_Ideal
if not is_Ideal(P):
P = R.ideal(P)
elif P.ring() is not R:
P = R.ideal(P.gens())
# ideally we would have check=True by default, but
# unfortunately is_prime() is only implemented in a small
# number of cases
if check and not P.is_prime():
raise ValueError("The argument %s must be a prime ideal of %s"%(P, R))
SchemeTopologicalPoint.__init__(self, S)
self.__P = P
示例7: ideal
def ideal(self, *gens):
"""
Returns the fractional ideal generated by the elements in ``gens``.
INPUT:
- ``gens`` -- a list of generators or an ideal in a ring which
coerces to this order.
EXAMPLES::
sage: K.<y> = FunctionField(QQ)
sage: O = K.maximal_order()
sage: O.ideal(y)
Ideal (y) of Maximal order in Rational function field in y over Rational Field
sage: O.ideal([y,1/y]) == O.ideal(y,1/y) # multiple generators may be given as a list
True
A fractional ideal of a nontrivial extension::
sage: K.<x> = FunctionField(GF(7)); R.<y> = K[]
sage: O = K.maximal_order()
sage: I = O.ideal(x^2-4)
sage: L.<y> = K.extension(y^2 - x^3 - 1)
sage: S = L.equation_order()
sage: S.ideal(1/y)
Ideal (1, (6/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
sage: I2 = S.ideal(x^2-4); I2
Ideal (x^2 + 3, (x^2 + 3)*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
sage: I2 == S.ideal(I)
True
"""
if len(gens) == 1:
gens = gens[0]
if not isinstance(gens, (list, tuple)):
if is_Ideal(gens):
gens = gens.gens()
else:
gens = [gens]
from function_field_ideal import ideal_with_gens
return ideal_with_gens(self, gens)
示例8: ideal
def ideal(self, *gens):
"""
Return the fractional ideal generated by the element gens or
the elements in gens if gens is a list.
EXAMPLES::
sage: R.<y> = FunctionField(QQ)
sage: S = R.maximal_order()
sage: S.ideal(y)
Ideal (y) of Maximal order in Rational function field in y over Rational Field
A fractional ideal of a nontrivial extension::
sage: R.<x> = FunctionField(GF(7)); S.<y> = R[]
sage: L.<y> = R.extension(y^2 - x^3 - 1)
sage: M = L.equation_order()
sage: M.ideal(1/y)
Ideal (1, (6/(x^3 + 1))*y) of Order in Function field in y defined by y^2 + 6*x^3 + 6
A non-principal ideal::
sage: R.<x> = FunctionField(GF(7))
sage: S = R.maximal_order()
sage: S.ideal(x^3+1,x^3+6)
Ideal (1) of Maximal order in Rational function field in x over Finite Field of size 7
sage: S.ideal((x^2+1)*(x^3+1),(x^3+6)*(x^2+1))
Ideal (x^2 + 1) of Maximal order in Rational function field in x over Finite Field of size 7
"""
if len(gens) == 1:
gens = gens[0]
if not isinstance(gens, (list, tuple)):
if is_Ideal(gens):
gens = gens.gens()
else:
gens = [gens]
from function_field_ideal import ideal_with_gens
return ideal_with_gens(self, gens)
示例9: check_prime
def check_prime(K,P):
r"""
Function to check that `P` determines a prime of `K`, and return that ideal.
INPUT:
- ``K`` -- a number field (including `\QQ`).
- ``P`` -- an element of ``K`` or a (fractional) ideal of ``K``.
OUTPUT:
- If ``K`` is `\QQ`: the prime integer equal to or which generates `P`.
- If ``K`` is not `\QQ`: the prime ideal equal to or generated by `P`.
.. note::
If `P` is not a prime and does not generate a prime, a TypeError is raised.
EXAMPLES::
sage: from sage.schemes.elliptic_curves.ell_local_data import check_prime
sage: check_prime(QQ,3)
3
sage: check_prime(QQ,ZZ.ideal(31))
31
sage: K.<a>=NumberField(x^2-5)
sage: check_prime(K,a)
Fractional ideal (a)
sage: check_prime(K,a+1)
Fractional ideal (a + 1)
sage: [check_prime(K,P) for P in K.primes_above(31)]
[Fractional ideal (5/2*a + 1/2), Fractional ideal (5/2*a - 1/2)]
"""
if K is QQ:
if isinstance(P, (int,long,Integer)):
P = Integer(P)
if P.is_prime():
return P
else:
raise TypeError("%s is not prime"%P)
else:
if is_Ideal(P) and P.base_ring() is ZZ and P.is_prime():
return P.gen()
raise TypeError("%s is not a prime ideal of %s"%(P,ZZ))
if not is_NumberField(K):
raise TypeError("%s is not a number field"%K)
if is_NumberFieldFractionalIdeal(P):
if P.is_prime():
return P
else:
raise TypeError("%s is not a prime ideal of %s"%(P,K))
if is_NumberFieldElement(P):
if P in K:
P = K.ideal(P)
else:
raise TypeError("%s is not an element of %s"%(P,K))
if P.is_prime():
return P
else:
raise TypeError("%s is not a prime ideal of %s"%(P,K))
raise TypeError("%s is not a valid prime of %s"%(P,K))
示例10: __call__
def __call__(self, *args):
"""
Construct a scheme-valued or topological point of ``self``.
INPUT/OUTPUT:
The argument ``x`` must be one of the following:
- a prime ideal of the coordinate ring; the output will
be the corresponding point of `X`
- a ring or a scheme `S`; the output will be the set `X(S)` of
`S`-valued points on `X`
EXAMPLES::
sage: S = Spec(ZZ)
sage: P = S(ZZ.ideal(3)); P
Point on Spectrum of Integer Ring defined by the Principal ideal (3) of Integer Ring
sage: type(P)
<class 'sage.schemes.generic.scheme.AffineScheme_with_category.element_class'>
sage: S(ZZ.ideal(next_prime(1000000)))
Point on Spectrum of Integer Ring defined by the Principal ideal (1000003) of Integer Ring
sage: R.<x, y, z> = QQ[]
sage: S = Spec(R)
sage: P = S(R.ideal(x, y, z)); P
Point on Spectrum of Multivariate Polynomial Ring
in x, y, z over Rational Field defined by the Ideal (x, y, z)
of Multivariate Polynomial Ring in x, y, z over Rational Field
This indicates the fix of :trac:`12734`::
sage: S = Spec(ZZ)
sage: S(ZZ)
Set of rational points of Spectrum of Integer Ring
Note the difference between the previous example and the
following one::
sage: S(S)
Set of morphisms
From: Spectrum of Integer Ring
To: Spectrum of Integer Ring
For affine or projective varieties, passing the correct number
of elements of the base ring constructs the rational point
with these elements as coordinates::
sage: S = AffineSpace(ZZ, 1)
sage: S(0)
(0)
To prevent confusion with this usage, topological points must
be constructed by explicitly specifying a prime ideal, not
just generators::
sage: R = S.coordinate_ring()
sage: S(R.ideal(0))
Point on Affine Space of dimension 1 over Integer Ring defined by the Ideal (0) of Multivariate Polynomial Ring in x over Integer Ring
This explains why the following example raises an error rather
than constructing the topological point defined by the prime
ideal `(0)` as one might expect::
sage: S = Spec(ZZ)
sage: S(0)
Traceback (most recent call last):
...
TypeError: cannot call Spectrum of Integer Ring with arguments (0,)
"""
if len(args) == 1:
x = args[0]
if ((isinstance(x, self.element_class) and (x.parent() is self or x.parent() == self))
or (is_Ideal(x) and x.ring() is self.coordinate_ring())):
# Construct a topological point from x.
return self._element_constructor_(x)
try:
# Construct a scheme homset or a scheme-valued point from
# args using the generic Scheme.__call__() method.
return super(AffineScheme, self).__call__(*args)
except NotImplementedError:
# This arises from self._morphism() not being implemented.
# We must convert it into a TypeError to keep the coercion
# system working.
raise TypeError('cannot call %s with arguments %s' % (self, args))
示例11: ideal
def ideal(X):
if not is_Ideal(X):
return O_F.ideal(X)
return X
示例12: create_key_and_extra_args
def create_key_and_extra_args(self, domain, prime):
r"""
Create a unique key which identifies the valuation given by ``prime``
on ``domain``.
TESTS:
We specify a valuation on a function field by two different means and
get the same object::
sage: K.<x> = FunctionField(QQ)
sage: v = K.valuation(x - 1) # indirect doctest
sage: R.<x> = QQ[]
sage: w = GaussValuation(R, valuations.TrivialValuation(QQ)).augmentation(x - 1, 1)
sage: K.valuation(w) is v
True
The normalization is, however, not smart enough, to unwrap
substitutions that turn out to be trivial::
sage: w = GaussValuation(R, QQ.valuation(2))
sage: w = K.valuation(w)
sage: w is K.valuation((w, K.hom([~K.gen()]), K.hom([~K.gen()])))
False
"""
from sage.categories.function_fields import FunctionFields
if domain not in FunctionFields():
raise ValueError("Domain must be a function field.")
if isinstance(prime, tuple):
if len(prime) == 3:
# prime is a triple of a valuation on another function field with
# isomorphism information
return self.create_key_and_extra_args_from_valuation_on_isomorphic_field(domain, prime[0], prime[1], prime[2])
from sage.rings.valuation.valuation_space import DiscretePseudoValuationSpace
if prime.parent() is DiscretePseudoValuationSpace(domain):
# prime is already a valuation of the requested domain
# if we returned (domain, prime), we would break caching
# because this element has been created from a different key
# Instead, we return the key that was used to create prime
# so the caller gets back a correctly cached version of prime
if not hasattr(prime, "_factory_data"):
raise NotImplementedError("Valuations on function fields must be unique and come out of the FunctionFieldValuation factory but %r has been created by other means"%(prime,))
return prime._factory_data[2], {}
if prime in domain:
# prime defines a place
return self.create_key_and_extra_args_from_place(domain, prime)
if prime.parent() is DiscretePseudoValuationSpace(domain._ring):
# prime is a discrete (pseudo-)valuation on the polynomial ring
# that the domain is constructed from
return self.create_key_and_extra_args_from_valuation(domain, prime)
if domain.base_field() is not domain:
# prime might define a valuation on a subring of domain and have a
# unique extension to domain
base_valuation = domain.base_field().valuation(prime)
return self.create_key_and_extra_args_from_valuation(domain, base_valuation)
from sage.rings.ideal import is_Ideal
if is_Ideal(prime):
raise NotImplementedError("a place can not be given by an ideal yet")
raise NotImplementedError("argument must be a place or a pseudo-valuation on a supported subring but %r does not satisfy this for the domain %r"%(prime, domain))
示例13: check_prime
def check_prime(K,P):
r"""
Function to check that `P` determines a prime of `K`, and return that ideal.
INPUT:
- ``K`` -- a number field (including `\QQ`).
- ``P`` -- an element of ``K`` or a (fractional) ideal of ``K``.
OUTPUT:
- If ``K`` is `\QQ`: the prime integer equal to or which generates `P`.
- If ``K`` is not `\QQ`: the prime ideal equal to or generated by `P`.
.. note::
If `P` is not a prime and does not generate a prime, a TypeError is raised.
EXAMPLES::
sage: from sage.schemes.elliptic_curves.ell_local_data import check_prime
sage: check_prime(QQ,3)
3
sage: check_prime(QQ,QQ(3))
3
sage: check_prime(QQ,ZZ.ideal(31))
31
sage: K.<a>=NumberField(x^2-5)
sage: check_prime(K,a)
Fractional ideal (a)
sage: check_prime(K,a+1)
Fractional ideal (a + 1)
sage: [check_prime(K,P) for P in K.primes_above(31)]
[Fractional ideal (5/2*a + 1/2), Fractional ideal (5/2*a - 1/2)]
sage: L.<b> = NumberField(x^2+3)
sage: check_prime(K, L.ideal(5))
Traceback (most recent call last):
..
TypeError: The ideal Fractional ideal (5) is not a prime ideal of Number Field in a with defining polynomial x^2 - 5
sage: check_prime(K, L.ideal(b))
Traceback (most recent call last):
TypeError: No compatible natural embeddings found for Number Field in a with defining polynomial x^2 - 5 and Number Field in b with defining polynomial x^2 + 3
"""
if K is QQ:
if P in ZZ or isinstance(P, integer_types + (Integer,)):
P = Integer(P)
if P.is_prime():
return P
else:
raise TypeError("The element %s is not prime" % (P,) )
elif P in QQ:
raise TypeError("The element %s is not prime" % (P,) )
elif is_Ideal(P) and P.base_ring() is ZZ:
if P.is_prime():
return P.gen()
else:
raise TypeError("The ideal %s is not a prime ideal of %s" % (P, ZZ))
else:
raise TypeError("%s is neither an element of QQ or an ideal of %s" % (P, ZZ))
if not is_NumberField(K):
raise TypeError("%s is not a number field" % (K,) )
if is_NumberFieldFractionalIdeal(P) or P in K:
# if P is an ideal, making sure it is an fractional ideal of K
P = K.fractional_ideal(P)
if P.is_prime():
return P
else:
raise TypeError("The ideal %s is not a prime ideal of %s" % (P, K))
raise TypeError("%s is not a valid prime of %s" % (P, K))