#23805 closed enhancement (fixed)

adding SchemeMorphism_points to coercion framework

Reported by: bhutz Owned by:
Priority: minor Milestone: sage-8.1
Component: algebraic geometry Keywords:
Cc: Merged in:
Authors: Ben Hutz Reviewers: Paul Fili, Adam Towsley
Report Upstream: N/A Work issues:
Branch: 74347ea (Commits) Commit: 74347ea0b5fd48c7e52b1e8c8eb0cb11bc9c4d52
Dependencies: Stopgaps:

Description (last modified by roed)

This is part of meta ticket #23047. The goal is to have scheme points able to be coerced when that coercion makes sense. Essentially SchemeHomeset_points needs a _coerce_map_from_ function and possibly updates to _element_constructor_.

For example, we should be able to coerce between the following objects

  • the same space type where the base rings have a coercion between them. i.e. P1(ZZ) -> P1(QQ)
  • a points of a subscheme to points of the ambient space
  • base ring elements to Affine 1 space.

Change History (13)

comment:1 Changed 11 months ago by bhutz

  • Authors set to Ben Hutz
  • Branch set to u/bhutz/scheme_point_coercion
  • Commit set to c020db966dd35e0d7effaf08d64b403a9490548b
  • Status changed from new to needs_review

Here is a first implementation of coercion for scheme points. Comments welcome.


New commits:

c020db923805: coercion for scheme points

comment:2 Changed 11 months ago by roed

  • Description modified (diff)

comment:3 Changed 11 months ago by roed

  • Status changed from needs_review to needs_work
  • There should be no coercion from list or tuple, just a conversion.
  • No coercion if the variable names on the projective/affine space are different (for consistency with multivariate polynomials).
  • For products of projective spaces and toric varieties, you need to check more than just that the relative dimensions are the same.

comment:4 Changed 11 months ago by git

  • Commit changed from c020db966dd35e0d7effaf08d64b403a9490548b to 6d26bccd251542d7d2bd7c41d01faf8220c0eef4

Branch pushed to git repo; I updated commit sha1. New commits:

6d26bcc23805: fixes from first review

comment:5 Changed 11 months ago by bhutz

Thanks for the comments. I've tried to better match what polynomial rings are doing. I don't think even a conversion from tuple/lists actually fits here very well. So I've no longer allowed that behind the scenes. i.e. being able to say P1([0,1]) == [0,1] does not work.

However, I feel out of my depth for Toric varieties. I'm not sure what type of situations it would actually be valid to coerce. Consequently, I taken to conservative approach and not done coercion for those. Would it be better to raise a NotImplementedError? than just allowing _coerce_map_from_ to return None? or does this need to wait for someone who can deal with the Toric cases?

comment:6 Changed 11 months ago by roed

I agree that P1([0,1]) == [0,1] should not work, but again, make sure you keep coercion and conversion straight. The fact that P1([0,1]) works is a conversion, and is fine. the implicit construction described by the equality test you mention is a coercion, and is not.

As for toric varieties, it's fine leaving it as None. That just means that there is no coercion now; one can be added later if appropriate.

comment:7 Changed 11 months ago by bhutz

  • Status changed from needs_work to needs_review

comment:8 Changed 11 months ago by atowsley

  • Status changed from needs_review to needs_work

I ran some functionality tests, the following examples should give true, but don't:

PQ.<x,y> = ProjectiveSpace(QQ,1)
PC.<x,y> = ProjectiveSpace(CC,1)
PQ([1,0])==PC([1,0]) , PC(CC).has_coerce_map_from(PQ(QQ))

and

R.<x> = PolynomialRing(QQ)
K.<i> = NumberField(x^2+1)
A1.<x> = AffineSpace(QQ,1)
A2.<x> = AffineSpace(K,1)
p1 = A1(1)
p2 = A2(1)
p1==p2 , A2(K).has_coerce_map_from(A1(QQ))

comment:9 Changed 11 months ago by atowsley

  • Status changed from needs_work to needs_review

Nevermind, those examples do work. My apologies.

comment:10 Changed 11 months ago by paulfili

  • Reviewers set to Paul Fili
  • Status changed from needs_review to positive_review

I reviewed the code and I tried some rather sophisticated examples (couple of examples below), wasn't able to find any problems Looks good to me.

sage: R.<X> = PolynomialRing(QQ)
sage: K.<a> = NumberField(X^2 - 2, embedding=QQbar(sqrt(2)))
sage: P.<x,y> = ProjectiveSpace(QQbar, 1)
sage: Q.<x,y> = ProjectiveSpace(K, 1)
sage: P(sqrt(2),1) == Q(a,1)
sage: P(sqrt(2),1)
(1.414213562373095? : 1)
sage: Q(a, 1)
(a : 1)
sage: P(sqrt(2),1) == Q(a,1)
True
sage: P(QQbar).has_coerce_map_from(Q(K))
True

and

sage: R.<t> = PolynomialRing(QQ)
sage: K.<a> = NumberField(t^2 - 6, embedding=QQbar(sqrt(6)))
sage: P.<x,y,z,w> = ProjectiveSpace(QQbar, 3)
sage: X = P.subscheme(y^2*z - x*(x-z)*(x-w) ); X
Closed subscheme of Projective Space of dimension 3 over Algebraic Field defined by:
  -x^3 + x^2*z + y^2*z + x^2*w - x*z*w
sage: Y = P.subscheme([y^2*z - x*(x-z)*(x-w), w - 2*z]); Y
Closed subscheme of Projective Space of dimension 3 over Algebraic Field defined by:
  -x^3 + x^2*z + y^2*z + x^2*w - x*z*w,
  (-2)*z + w
sage: Y.change_ring(K)
Closed subscheme of Projective Space of dimension 3 over Number Field in a with defining polynomial t^2 - 6 defined by:
  -x^3 + x^2*z + y^2*z + x^2*w - x*z*w,
  -2*z + w
sage: P = Y([3,a,1,2]); P
(3/2 : 1.224744871391589? : 1/2 : 1)
sage: X(P)
verbose 0 (3370: multi_polynomial_ideal.py, groebner_basis) Warning: falling back to very slow toy implementation.
verbose 0 (3370: multi_polynomial_ideal.py, groebner_basis) Warning: falling back to very slow toy implementation.
verbose 0 (3370: multi_polynomial_ideal.py, groebner_basis) Warning: falling back to very slow toy implementation.
(3/2 : 1.224744871391589? : 1/2 : 1)
sage: Q = X([3,a,1,2])
sage: P == Q
verbose 0 (3370: multi_polynomial_ideal.py, groebner_basis) Warning: falling back to very slow toy implementation.
True
sage: Q == X(P) # should be true
True
sage: Q2 = X([3,-a,1,2])
sage: Q2 == P # should not be true
False

comment:11 Changed 11 months ago by git

  • Commit changed from 6d26bccd251542d7d2bd7c41d01faf8220c0eef4 to 74347ea0b5fd48c7e52b1e8c8eb0cb11bc9c4d52
  • Status changed from positive_review to needs_review

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:

74347ea23805: add another subscheme example

comment:12 Changed 11 months ago by atowsley

  • Reviewers changed from Paul Fili to Paul Fili, Adam Towsley
  • Status changed from needs_review to positive_review

It worked appropriately for every example that I came up with.

comment:13 Changed 11 months ago by vbraun

  • Branch changed from u/bhutz/scheme_point_coercion to 74347ea0b5fd48c7e52b1e8c8eb0cb11bc9c4d52
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.