Opened 2 years ago

Closed 19 months ago

#21117 closed enhancement (fixed)

specialzation for polynomials, schemes, and morphisms

Reported by: bhutz Owned by:
Priority: minor Milestone: sage-7.6
Component: algebra Keywords:
Cc: Merged in:
Authors: Ben Hutz Reviewers: Paul Fili, Erik Holmes, Rebecca Lauren Miller
Report Upstream: N/A Work issues:
Branch: f41ff27 (Commits) Commit: f41ff27b8a4a6d99fa91b7389eee0ffa8fd56015
Dependencies: #21106 Stopgaps:

Description

Given a family of polynomials, schemes, or morphisms implement the ability to specialize to a member of the family by substituting a value for one of the parameters

Change History (29)

comment:1 Changed 2 years ago by bhutz

  • Branch set to u/bhutz/specialization

comment:2 Changed 2 years ago by bhutz

  • Authors set to Ben Hutz
  • Commit set to ae2984b4714cce6da6050bcd2c500498d26806bd
  • Dependencies set to 21106
  • Milestone changed from sage-7.3 to sage-7.4
  • Status changed from new to needs_review

New commits:

cf97fed21106: create polynomial ring flattening class
957589f21106: minor fixes
8c22f7521106: new version of _call_
570d9ee21106: added doc tests
f05f7db21106:cleaning
6e5094221106: change file mode
19cb17121106: Python3 compatibility + more cleaning
564bb8321117: class for SpecializationMorphism
ae2984b21117: specialization for subschemes and scheme_morphisms

comment:3 Changed 2 years ago by paulfili

  • Cc paulfili added
  • Reviewers set to Paul Fili
  • Status changed from needs_review to positive_review

All tests passed. Various examples all work. Looks good.

comment:4 Changed 2 years ago by paulfili

  • Cc paulfili removed
  • Status changed from positive_review to needs_review

Right now, if the variable comes from a FunctionField? instead of PolynomialRing?, the specialization will do nothing and return the morphism as is. We may want to issue a warning if the user tries to substitute for a variable from a FunctionField? that this is not implemented.

comment:5 Changed 2 years ago by paulfili

Otherwise, so far the functions work on the examples I have tested so far, including on nested PolynomialRings?.

comment:6 Changed 2 years ago by vdelecroix

  • Dependencies changed from 21106 to #21106

(don't forget the # sign in the dependencies)

comment:7 Changed 2 years ago by git

  • Commit changed from ae2984b4714cce6da6050bcd2c500498d26806bd to 7681a050922f67865a5e07bd76e968f192639d26

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

7681a05Merge 7.4.beta0 into 21117

comment:8 Changed 2 years ago by eholmes

  • Reviewers changed from Paul Fili to Paul Fili, Erik Holmes
  • Status changed from needs_review to needs_work

Specialization of Dynatomic Polynomials doesn't work:

sage: R.<c>=PolynomialRing(QQ)
sage: PS.<x,y> = ProjectiveSpace(1,R); PS
Projective Space of dimension 1 over Univariate Polynomial Ring in c over Rational Field
sage: E = End(PS); E
 
Set of morphisms
  From: Projective Space of dimension 1 over Univariate Polynomial Ring in c over Rational Field
  To:   Projective Space of dimension 1 over Univariate Polynomial Ring in c over Rational Field
sage: Phi5 = f.dynatomic_polynomial(5)
sage: Phi5.specialization({c:0})
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-46-42dcbd8d3b57> in <module>()
----> 1 Phi5.specialization({c:Integer(0)})
 
/projects/d87ce228-3433-4d2c-b150-f16518d5e59a/sage-dev/src/sage/structure/element.pyx in sage.structure.element.Element.__getattr__ (/projects/sage/sage-dev/src/build
/cythonized/sage/structure/element.c:4237)()
    319             dummy_error_message.name = name
    320             raise dummy_attribute_error
--> 321         return getattr_from_other_class(self, P._abstract_element_class, name)
    322
    323     def __dir__(self):
 
/projects/d87ce228-3433-4d2c-b150-f16518d5e59a/sage-dev/src/sage/structure/misc.pyx in sage.structure.misc.getattr_from_other_class (/projects/sage/sage-dev/src/build/
cythonized/sage/structure/misc.c:1879)()
    257         dummy_error_message.cls = type(self)
    258         dummy_error_message.name = name
--> 259         raise dummy_attribute_error
    260     if isinstance(attribute, methodwrapper):
    261         dummy_error_message.cls = type(self)
 
AttributeError: 'MPolynomial_polydict' object has no attribute 'specialization'

comment:9 Changed 2 years ago by bhutz

Yes, I didn't implement the specialization function for polynomial ring elements. I see no reason not to, so I'll go ahead and add that. I hope to get to it later today.

comment:10 Changed 2 years ago by git

  • Commit changed from 7681a050922f67865a5e07bd76e968f192639d26 to 177c21cfceeb315b08b6b4910f2c8aca7685f8fd

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

177c21c21117: added specialization of polynomial elements

comment:11 Changed 2 years ago by bhutz

  • Status changed from needs_work to needs_review

added functionality for polynomial elements

comment:12 Changed 2 years ago by eholmes

  • Status changed from needs_review to needs_work

specialization seems to be giving strange errors.

  • when you also specialize x or y below it's fine, but if not we have the following:
S.<a,b> = PolynomialRing(QQ)
P.<x,y,z> = PolynomialRing(S)
R.<c,d> = PolynomialRing(P)
f = a*x^2+b*y^3+c*y^2-b*a*d+d^2-a*c*b*z^2
f.specialization(dict({a:2, z:4, d:2}))

Traceback (click to the left of this block for traceback)
...
TypeError: unable to convert x to an element of Univariate Polynomial
Ring in c over Multivariate Polynomial Ring in x, y over Univariate
Polynomial Ring in b over Rational Field


comment:13 Changed 2 years ago by git

  • Commit changed from 177c21cfceeb315b08b6b4910f2c8aca7685f8fd to 370abe1a0fed38050c92006cec7c7f766f5105b8

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

370abe121117: fix problem with unflattenning certain domains

comment:14 Changed 2 years ago by bhutz

  • Status changed from needs_work to needs_review

Yes, it seems I need to be more careful in the creation of the specialization morphism. I've kept better track of where the variable live now and it corrects your example. Are there any other examples that the new version does not address?

comment:15 Changed 2 years ago by git

  • Commit changed from 370abe1a0fed38050c92006cec7c7f766f5105b8 to 7ad71976430b4f09491a4d08223fd339697ca1d2

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

7ad719721117: update doctest

comment:16 Changed 2 years ago by bhutz

noticed that in my testing I had changed your original example, so I put it back to what you had that failed.

comment:17 Changed 2 years ago by git

  • Commit changed from 7ad71976430b4f09491a4d08223fd339697ca1d2 to 9f69b151cad22b5414d36b8cd0d4286e753c8e32

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

9f69b15Merge 7.3.beta4 into specialization

comment:18 Changed 2 years ago by bhutz

Fixed the merge issue.

What is the status of testing? Did the new fix cover any other failed examples you had?

comment:19 Changed 21 months ago by git

  • Commit changed from 9f69b151cad22b5414d36b8cd0d4286e753c8e32 to 0c7f697d28bb489b2921023c2b07cafb2c79a34a

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

0c7f697Merge branch 7.5.beta4 into t/21117/specialization

comment:20 Changed 21 months ago by bhutz

  • Milestone changed from sage-7.4 to sage-7.5

fixed merge conflict

comment:21 Changed 21 months ago by git

  • Commit changed from 0c7f697d28bb489b2921023c2b07cafb2c79a34a to 13b3865c74ffb86993cdb77857cdcc7d7e53ce21

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

13b386521117: fix error in flatten.py

comment:22 Changed 21 months ago by bhutz

Noticed that the following example failed due to the adding of flatten to quo_rem:

R.<z>=PolynomialRing(QQbar,1)
(z^4 + (-3)*z^2)/z^3

So I've made the domains match up for multi- versus uni-variate polynomial rings.

comment:23 Changed 20 months ago by git

  • Commit changed from 13b3865c74ffb86993cdb77857cdcc7d7e53ce21 to a5c8f193f5da6f07ce41984ee2bebfe25becfcf2

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

a5c8f19Merge branch 7.5beta6 into t/21117/specialization

comment:24 Changed 19 months ago by rlmiller

Errors:

R.<l> = PolynomialRing(QQ,1)
S.<k,j> = PolynomialRing(R)
K.<a> = PolynomialRing(S,1)
J.<x,y> = PolynomialRing(K)
F = x^2 + y^2
G=F.specialization({y:56,j:5})
print G
G.parent()

Doesn't distinguish between Multivariate and Univariate, also has this problem in Subschemes.

R.<l> = PolynomialRing(QQ)
S.<k,j> = PolynomialRing(R)
K.<a,b,c,d> = S[]
P.<x,y> = ProjectiveSpace(K, 1)
H = End(P)
Q=P([a^2,b^2])
Q.specialization({a:2})

Doesn't like having four variables.

Questions: Should the two examples below work?

S.<p,q> = QQ[]
A.<r> = AffineSpace(S,1)
F = (r^2 + p*r^2)/(q+p)
G=F.specialization({p:42})
A.<i,j,k> = QuaternionAlgebra(QQ, -1,-1)
R.<w,v> = PolynomialRing(A)
F = w^3 + (i+j)*w + 1
G=F.specialization({w:7})

comment:25 Changed 19 months ago by rlmiller

  • Reviewers changed from Paul Fili, Erik Holmes to Paul Fili, Erik Holmes, Rebecca Lauren Miller
  • Status changed from needs_review to needs_work

comment:26 Changed 19 months ago by git

  • Commit changed from a5c8f193f5da6f07ce41984ee2bebfe25becfcf2 to f41ff27b8a4a6d99fa91b7389eee0ffa8fd56015

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

f41ff2721117: fix issues from review

comment:27 Changed 19 months ago by bhutz

  • Milestone changed from sage-7.5 to sage-7.6
  • Status changed from needs_work to needs_review

I fixed the two examples that didn't work.

For the other two questionable examples: it would be nice if fraction field elements of polynomial rings could also be specialized, but I think that should be its own ticket. The Quaternion algebra one is not failing in this code, so no on that one.

comment:28 Changed 19 months ago by rlmiller

  • Status changed from needs_review to positive_review

Looks good to me.

comment:29 Changed 19 months ago by vbraun

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