-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
Implementing SchemeMorphism_sum
#37705
Draft
grhkm21
wants to merge
21
commits into
sagemath:develop
Choose a base branch
from
grhkm21:grhkm/endomorphism-ring
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8088a11
add `.End` method
grhkm21 d58dcb7
initial SchemeMorphism_add
grhkm21 50af7fb
fix most doctests
grhkm21 5a9b44a
Hot fix for multiprocessing issue
grhkm21 a0af15e
richcmp and refactoring
grhkm21 cfccbd7
remove a random rant in my code
grhkm21 5dcc121
write documentation (examples)
grhkm21 306ddf5
fix doctest
grhkm21 6bfcc86
apply review changes (doctest + use categories)
grhkm21 031aedf
patch TestSuite (since abstract class doesn't implement element methods)
grhkm21 f98946e
move elliptic curve tests
grhkm21 d67fbb3
add hash methods
grhkm21 85a9149
fix hash doctests
grhkm21 18d7910
use categories to check for addition
grhkm21 a0b0e23
remove incorrect inheritance
grhkm21 641613f
add back methods I removed
grhkm21 43396ba
fix unhashable .an_element() for projective curves
grhkm21 906b93f
Merge branch 'develop' of github.com:sagemath/sage into grhkm/endomor…
grhkm21 dd22a16
wrap doctests
grhkm21 50ec668
Merge branch 'develop' into grhkm/endomorphism-ring
grhkm21 95e0930
review changes
grhkm21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -176,7 +176,7 @@ | |||||
from sage.categories.schemes import Schemes | ||||||
category = Schemes(base_spec) | ||||||
key = (id(X), id(Y), category, as_point_homset) | ||||||
extra = {'X':X, 'Y':Y, 'base_ring':base_ring, 'check':check} | ||||||
extra = {'X': X, 'Y': Y, 'base_ring': base_ring, 'check': check} | ||||||
return key, extra | ||||||
|
||||||
def create_object(self, version, key, **extra_args): | ||||||
|
@@ -245,9 +245,7 @@ | |||||
sage: from sage.schemes.generic.homset import SchemeHomset_generic | ||||||
sage: A2 = AffineSpace(QQ,2) | ||||||
sage: Hom = SchemeHomset_generic(A2, A2); Hom | ||||||
Set of morphisms | ||||||
From: Affine Space of dimension 2 over Rational Field | ||||||
To: Affine Space of dimension 2 over Rational Field | ||||||
Set of scheme endomorphisms of Affine Space of dimension 2 over Rational Field | ||||||
sage: Hom.category() | ||||||
Category of endsets of schemes over Rational Field | ||||||
""" | ||||||
|
@@ -265,8 +263,9 @@ | |||||
sage: loads(Hom.dumps()) == Hom | ||||||
True | ||||||
""" | ||||||
return SchemeHomset, (self.domain(), self.codomain(), self.homset_category(), | ||||||
self.base_ring(), False, False) | ||||||
return SchemeHomset, (self.domain(), self.codomain(), | ||||||
self.homset_category(), self.base_ring(), False, | ||||||
False) | ||||||
|
||||||
def __call__(self, *args, **kwds): | ||||||
r""" | ||||||
|
@@ -295,15 +294,20 @@ | |||||
EXAMPLES:: | ||||||
|
||||||
sage: A = AffineSpace(4, QQ) | ||||||
sage: print(A.structure_morphism()._repr_()) | ||||||
Scheme morphism: | ||||||
sage: print(repr(A.structure_morphism().parent())) | ||||||
Set of morphisms | ||||||
From: Affine Space of dimension 4 over Rational Field | ||||||
To: Spectrum of Rational Field | ||||||
Defn: Structure map | ||||||
|
||||||
sage: print(repr(Spec(QQ).End())) | ||||||
Set of scheme endomorphisms of Spectrum of Rational Field | ||||||
""" | ||||||
s = 'Set of morphisms' | ||||||
s += '\n From: %s' % self.domain() | ||||||
s += '\n To: %s' % self.codomain() | ||||||
if self.is_endomorphism_set(): | ||||||
return f"Set of scheme endomorphisms of {self.domain()}" | ||||||
|
||||||
s = "Set of morphisms" | ||||||
s += f'\n From: {self.domain()}' | ||||||
s += f'\n To: {self.codomain()}' | ||||||
return s | ||||||
|
||||||
def natural_map(self): | ||||||
|
@@ -324,13 +328,74 @@ | |||||
From: Affine Space of dimension 4 over Rational Field | ||||||
To: Spectrum of Rational Field | ||||||
Defn: Structure map | ||||||
|
||||||
sage: Spec(QQ).End().natural_map() | ||||||
Scheme endomorphism of Spectrum of Rational Field | ||||||
Defn: Identity map | ||||||
""" | ||||||
X = self.domain() | ||||||
Y = self.codomain() | ||||||
if is_AffineScheme(Y) and Y.coordinate_ring() == X.base_ring(): | ||||||
return SchemeMorphism_structure_map(self) | ||||||
if self.is_endomorphism_set(): | ||||||
return self.identity() | ||||||
raise NotImplementedError | ||||||
|
||||||
def identity(self): | ||||||
r""" | ||||||
Return the identity morphism in this homset. | ||||||
|
||||||
Only implemented when this homset is an endomorphism set. In this case, | ||||||
either the :meth:`identity_morphism` of the domain is returned, or a | ||||||
:class:`SchemeMorphism_id` class is constructed. | ||||||
|
||||||
.. SEEALSO:: :meth:`natural_map` | ||||||
|
||||||
EXAMPLES:: | ||||||
|
||||||
sage: End(Spec(QQ)).identity() | ||||||
Scheme endomorphism of Spectrum of Rational Field | ||||||
Defn: Identity map | ||||||
|
||||||
sage: Hom(Spec(ZZ), Spec(QQ)).identity() | ||||||
Traceback (most recent call last): | ||||||
... | ||||||
ValueError: domain and codomain must be equal | ||||||
|
||||||
Elliptic curves have a custom :meth:`identity_morphism`:: | ||||||
|
||||||
sage: E = EllipticCurve(j=42) | ||||||
sage: End(E).identity() | ||||||
Elliptic-curve endomorphism of Elliptic Curve defined by y^2 = x^3 + 5901*x + 1105454 over Rational Field | ||||||
Via: (u,r,s,t) = (1, 0, 0, 0) | ||||||
sage: End(E).identity() == E.scalar_multiplication(1) | ||||||
True | ||||||
""" | ||||||
if not self.is_endomorphism_set(): | ||||||
raise ValueError('domain and codomain must be equal') | ||||||
try: | ||||||
return self.domain().identity_morphism() | ||||||
except AttributeError: | ||||||
from sage.schemes.generic.morphism import SchemeMorphism_id | ||||||
return SchemeMorphism_id(self.domain()) | ||||||
|
||||||
def _an_element_(self): | ||||||
r""" | ||||||
Return a morphism from this homset via the | ||||||
:meth:`natural_map`, or :meth:`zero` if a natural map does | ||||||
not exist. | ||||||
|
||||||
EXAMPLES:: | ||||||
|
||||||
sage: Spec(QQ).End().an_element() | ||||||
Scheme endomorphism of Spectrum of Rational Field | ||||||
Defn: Identity map | ||||||
""" | ||||||
try: | ||||||
return self.natural_map() | ||||||
except NotImplementedError: | ||||||
return self.zero() | ||||||
|
||||||
def _element_constructor_(self, x, check=True): | ||||||
""" | ||||||
Construct a scheme morphism. | ||||||
|
@@ -380,11 +445,9 @@ | |||||
sage: A.<x,y> = AffineSpace(R) | ||||||
sage: C = A.subscheme(x*y - 1) | ||||||
sage: H = C.Hom(C); H | ||||||
Set of morphisms | ||||||
From: Closed subscheme of Affine Space of dimension 2 over Rational Field | ||||||
defined by: x*y - 1 | ||||||
To: Closed subscheme of Affine Space of dimension 2 over Rational Field | ||||||
defined by: x*y - 1 | ||||||
Set of scheme endomorphisms of Closed subscheme of Affine Space of | ||||||
dimension 2 over Rational Field defined by: | ||||||
x*y - 1 | ||||||
sage: H(1) | ||||||
Traceback (most recent call last): | ||||||
... | ||||||
|
@@ -401,7 +464,6 @@ | |||||
|
||||||
raise TypeError("x must be a ring homomorphism, list or tuple") | ||||||
|
||||||
|
||||||
# ******************************************************************* | ||||||
# Base class for points | ||||||
# ******************************************************************* | ||||||
|
@@ -582,7 +644,7 @@ | |||||
except AttributeError: # no .ambient_space | ||||||
return False | ||||||
elif isinstance(other, SchemeHomset_points): | ||||||
#we are converting between scheme points | ||||||
#we are converting between scheme points | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
source = other.codomain() | ||||||
if isinstance(target, AlgebraicScheme_subscheme): | ||||||
#subscheme coerce when there is containment | ||||||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please wrap long doctest output lines, see https://doc.sagemath.org/html/en/developer/coding_basics.html#writing-testable-examples