Skip to content

Commit

Permalink
Trac #31892: Conic parametrization broken
Browse files Browse the repository at this point in the history
The final output here is wrong:
{{{
sage: c = Conic(GF(2), [1,1,1,1,1,0])
....:
sage: c.parametrization()
(Scheme morphism:
   From: Projective Space of dimension 1 over Finite Field of size 2
   To:   Projective Conic Curve over Finite Field of size 2 defined by
x^2 + x*y + y^2 + x*z + y*z
   Defn: Defined on coordinates by sending (x : y) to
         (x*y + y^2 : x^2 + x*y : x^2 + x*y + y^2),
 Scheme morphism:
   From: Projective Conic Curve over Finite Field of size 2 defined by
x^2 + x*y + y^2 + x*z + y*z
   To:   Projective Space of dimension 1 over Finite Field of size 2
   Defn: Defined on coordinates by sending (x : y : z) to
         (y : x))
sage: f, g = c.parametrization()
sage: (g*f).is_one()
False
}}}
The same here:
{{{
sage: R.<x,y,z> = QQ[]
sage: C = Curve(7*x^2 + 2*y*z + z^2)
sage: f, g = C.parametrization(); f,g
(Scheme morphism:
   From: Projective Space of dimension 1 over Rational Field
   To:   Projective Conic Curve over Rational Field defined by 7*x^2 +
2*y*z + z^2
   Defn: Defined on coordinates by sending (x : y) to
         (-2*x*y : x^2 + 7*y^2 : -2*x^2),
 Scheme morphism:
   From: Projective Conic Curve over Rational Field defined by 7*x^2 +
2*y*z + z^2
   To:   Projective Space of dimension 1 over Rational Field
   Defn: Defined on coordinates by sending (x : y : z) to
         (-1/2*x : 1/7*y + 1/14*z))
sage: (g*f).is_one()
False
sage: g([0, -1, 2])
...
ValueError: [0, 0] does not define a valid point since all entries are 0
sage: p = g.domain().defining_polynomial()
sage: p([0, -1, 2])
0
}}}

URL: https://trac.sagemath.org/31892
Reported by: gh-kliem
Ticket author(s): Kwankyu Lee
Reviewer(s): Marco Streng
  • Loading branch information
Release Manager committed Oct 20, 2022
2 parents 2049b70 + b2af690 commit 36ad46e
Show file tree
Hide file tree
Showing 13 changed files with 301 additions and 76 deletions.
10 changes: 4 additions & 6 deletions src/sage/categories/homset.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@
- Simon King (2013-02): added examples
"""

# ****************************************************************************
# Copyright (C) 2005 David Kohel <kohel@maths.usyd.edu>, William Stein <wstein@gmail.com>
# Copyright (C) 2005 David Kohel <kohel@maths.usyd.edu>,
# William Stein <wstein@gmail.com>
#
# Distributed under the terms of the GNU General Public License (GPL)
#
Expand All @@ -62,7 +64,6 @@
# https://www.gnu.org/licenses/
# ****************************************************************************


from sage.categories.category import Category, JoinCategory
from . import morphism
from sage.structure.parent import Parent, Set_generic
Expand All @@ -86,7 +87,6 @@ def Hom(X, Y, category=None, check=True):
INPUT:
- ``X`` -- an object of a category
- ``Y`` -- an object of a category
Expand Down Expand Up @@ -743,8 +743,6 @@ def __bool__(self):
"""
return True



def homset_category(self):
"""
Return the category that this is a Hom in, i.e., this is typically
Expand Down Expand Up @@ -1083,7 +1081,7 @@ def __ne__(self, other):
True
"""
return not (self == other)

def __contains__(self, x):
"""
Test whether the parent of the argument is ``self``.
Expand Down
75 changes: 54 additions & 21 deletions src/sage/schemes/affine/affine_homset.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@
- Ben Hutz (2018): add numerical point support
"""


#*****************************************************************************
# Copyright (C) 2006 William Stein <wstein@gmail.com>
# *****************************************************************************
# Copyright (C) 2006 William Stein <wstein@gmail.com>
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# http://www.gnu.org/licenses/
# *****************************************************************************

from copy import copy

from sage.misc.verbose import verbose
from sage.rings.integer_ring import ZZ
Expand All @@ -42,13 +43,13 @@
from sage.categories.number_fields import NumberFields
from sage.rings.finite_rings.finite_field_constructor import is_FiniteField
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
import sage.schemes.generic.homset
from copy import copy
from sage.schemes.generic.homset import SchemeHomset_points, SchemeHomset_generic

# *******************************************************************
# Affine varieties
# *******************************************************************

#*******************************************************************
# Affine varieties
#*******************************************************************
class SchemeHomset_points_spec(sage.schemes.generic.homset.SchemeHomset_generic):
class SchemeHomset_points_spec(SchemeHomset_generic):
"""
Set of rational points of an affine variety.
Expand All @@ -62,7 +63,6 @@ class SchemeHomset_points_spec(sage.schemes.generic.homset.SchemeHomset_generic)
sage: SchemeHomset_points_spec(Spec(QQ), Spec(QQ))
Set of rational points of Spectrum of Rational Field
"""

def _element_constructor_(self, *args, **kwds):
"""
The element constructor.
Expand All @@ -86,7 +86,7 @@ def _element_constructor_(self, *args, **kwds):
Defn: Ring endomorphism of Rational Field
Defn: 1 |--> 1
"""
return sage.schemes.generic.homset.SchemeHomset_generic._element_constructor_(self, *args, **kwds)
return super()._element_constructor_(*args, **kwds)

def _repr_(self):
"""
Expand All @@ -101,14 +101,47 @@ def _repr_(self):
sage: S._repr_()
'Set of rational points of Spectrum of Rational Field'
"""
return 'Set of rational points of '+str(self.codomain())
return 'Set of rational points of {}'.format(self.codomain())


class SchemeHomset_polynomial_affine_space(SchemeHomset_generic):
"""
Set of morphisms between affine spaces defined by polynomials.
EXAMPLES::
sage: A.<x,y> = AffineSpace(2, QQ)
sage: Hom(A, A)
Set of morphisms
From: Affine Space of dimension 2 over Rational Field
To: Affine Space of dimension 2 over Rational Field
"""
def identity(self):
"""
The identity morphism of this homset.
EXAMPLES::
sage: A.<x,y> = AffineSpace(2, QQ)
sage: I = A.identity_morphism()
sage: I.parent()
Set of morphisms
From: Affine Space of dimension 2 over Rational Field
To: Affine Space of dimension 2 over Rational Field
sage: _.identity() == I
True
"""
if self.is_endomorphism_set():
from sage.schemes.generic.morphism import SchemeMorphism_polynomial_id
return SchemeMorphism_polynomial_id(self.domain())
raise TypeError("identity map is only defined for endomorphisms")


# *******************************************************************
# Affine varieties
# *******************************************************************

#*******************************************************************
# Affine varieties
#*******************************************************************
class SchemeHomset_points_affine(sage.schemes.generic.homset.SchemeHomset_points):
class SchemeHomset_points_affine(SchemeHomset_points):
"""
Set of rational points of an affine variety.
Expand Down
24 changes: 20 additions & 4 deletions src/sage/schemes/affine/affine_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,24 @@
from sage.rings.finite_rings.finite_field_constructor import is_FiniteField
from sage.categories.map import Map
from sage.categories.fields import Fields
_Fields = Fields()
from sage.categories.homset import Hom
from sage.categories.number_fields import NumberFields
from sage.misc.latex import latex
from sage.misc.mrange import cartesian_product_iterator
from sage.matrix.constructor import matrix
from sage.structure.category_object import normalize_names
from sage.schemes.generic.scheme import AffineScheme
from sage.schemes.generic.ambient_space import AmbientSpace
from sage.schemes.affine.affine_homset import SchemeHomset_points_affine
from sage.schemes.affine.affine_homset import (SchemeHomset_points_affine,
SchemeHomset_polynomial_affine_space)
from sage.schemes.affine.affine_morphism import (SchemeMorphism_polynomial_affine_space,
SchemeMorphism_polynomial_affine_space_field,
SchemeMorphism_polynomial_affine_space_finite_field)
from sage.schemes.affine.affine_point import (SchemeMorphism_point_affine,
SchemeMorphism_point_affine_field,
SchemeMorphism_point_affine_finite_field)
from sage.matrix.constructor import matrix

_Fields = Fields()

def is_AffineSpace(x):
r"""
Expand Down Expand Up @@ -225,7 +228,6 @@ def __iter__(self):
for v in cartesian_product_iterator([R for _ in range(n)]):
yield C._point(AHom, v, check=False)


def ngens(self):
"""
Return the number of generators of self, i.e. the number of
Expand Down Expand Up @@ -363,6 +365,20 @@ def _morphism(self, *args, **kwds):
"""
return SchemeMorphism_polynomial_affine_space(*args, **kwds)

def _homset(self, *args, **kwds):
"""
Construct the Hom-set.
EXAMPLES::
sage: A.<x,y> = AffineSpace(2, QQ)
sage: Hom(A, A)
Set of morphisms
From: Affine Space of dimension 2 over Rational Field
To: Affine Space of dimension 2 over Rational Field
"""
return SchemeHomset_polynomial_affine_space(*args, **kwds)

def _point_homset(self, *args, **kwds):
"""
Construct a Hom-set for this affine space.
Expand Down
16 changes: 16 additions & 0 deletions src/sage/schemes/generic/algebraic_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,22 @@ def ambient_space(self):
"""
return self.__A

def identity_morphism(self):
"""
Return the identity morphism.
OUTPUT: the identity morphism of the scheme ``self``
EXAMPLES::
sage: X = Spec(QQ)
sage: X.identity_morphism()
Scheme endomorphism of Spectrum of Rational Field
Defn: Identity map
"""
from sage.schemes.generic.morphism import SchemeMorphism_polynomial_id
return SchemeMorphism_polynomial_id(self)

def embedding_morphism(self):
r"""
Return the default embedding morphism of ``self``.
Expand Down
21 changes: 21 additions & 0 deletions src/sage/schemes/generic/ambient_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,27 @@ def defining_polynomials(self):
"""
return ()

def identity_morphism(self):
"""
Return the identity morphism.
OUTPUT: the identity morphism of the scheme ``self``
EXAMPLES::
sage: A = AffineSpace(2, GF(3))
sage: A.identity_morphism()
Scheme endomorphism of Affine Space of dimension 2 over Finite Field of size 3
Defn: Identity map
sage: P = ProjectiveSpace(3, ZZ)
sage: P.identity_morphism()
Scheme endomorphism of Projective Space of dimension 3 over Integer Ring
Defn: Identity map
"""
from sage.schemes.generic.morphism import SchemeMorphism_polynomial_id
return SchemeMorphism_polynomial_id(self)

######################################################################
# Associated MPolynomial ring generators
######################################################################
Expand Down
38 changes: 20 additions & 18 deletions src/sage/schemes/generic/homset.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@
- Ben Hutz (June 2012): added support for projective ring
"""


#*****************************************************************************
# Copyright (C) 2011 Volker Braun <vbraun.name@gmail.com>
# Copyright (C) 2006 William Stein <wstein@gmail.com>
# *****************************************************************************
# Copyright (C) 2011 Volker Braun <vbraun.name@gmail.com>
# Copyright (C) 2006 William Stein <wstein@gmail.com>
#
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# http://www.gnu.org/licenses/
# *****************************************************************************

from sage.categories.homset import HomsetWithBase
from sage.structure.factory import UniqueFactory
Expand Down Expand Up @@ -70,9 +69,10 @@ def is_SchemeHomset(H):
return isinstance(H, SchemeHomset_generic)


#*******************************************************************
# Factory for Hom sets of schemes
#*******************************************************************
# *******************************************************************
# Factory for Hom sets of schemes
# *******************************************************************

class SchemeHomsetFactory(UniqueFactory):
"""
Factory for Hom-sets of schemes.
Expand Down Expand Up @@ -212,10 +212,10 @@ def create_object(self, version, key, **extra_args):
SchemeHomset = SchemeHomsetFactory('sage.schemes.generic.homset.SchemeHomset')


# *******************************************************************
# Base class
# *******************************************************************

#*******************************************************************
# Base class
#*******************************************************************
class SchemeHomset_generic(HomsetWithBase):
r"""
The base class for Hom-sets of schemes.
Expand Down Expand Up @@ -393,9 +393,11 @@ def _element_constructor_(self, x, check=True):

raise TypeError("x must be a ring homomorphism, list or tuple")

#*******************************************************************
# Base class for points
#*******************************************************************

# *******************************************************************
# Base class for points
# *******************************************************************

class SchemeHomset_points(SchemeHomset_generic):
"""
Set of rational points of the scheme.
Expand Down
Loading

0 comments on commit 36ad46e

Please sign in to comment.