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:  sage7.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
 Branch set to u/bhutz/specialization
comment:2 Changed 2 years ago by
 Commit set to ae2984b4714cce6da6050bcd2c500498d26806bd
 Dependencies set to 21106
 Milestone changed from sage7.3 to sage7.4
 Status changed from new to needs_review
comment:3 Changed 2 years ago by
 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
 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
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
 Dependencies changed from 21106 to #21106
(don't forget the #
sign in the dependencies)
comment:7 Changed 2 years ago by
 Commit changed from ae2984b4714cce6da6050bcd2c500498d26806bd to 7681a050922f67865a5e07bd76e968f192639d26
Branch pushed to git repo; I updated commit sha1. New commits:
7681a05  Merge 7.4.beta0 into 21117

comment:8 Changed 2 years ago by
 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) <ipythoninput4642dcbd8d3b57> in <module>() > 1 Phi5.specialization({c:Integer(0)}) /projects/d87ce22834334d2cb150f16518d5e59a/sagedev/src/sage/structure/element.pyx in sage.structure.element.Element.__getattr__ (/projects/sage/sagedev/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/d87ce22834334d2cb150f16518d5e59a/sagedev/src/sage/structure/misc.pyx in sage.structure.misc.getattr_from_other_class (/projects/sage/sagedev/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
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
 Commit changed from 7681a050922f67865a5e07bd76e968f192639d26 to 177c21cfceeb315b08b6b4910f2c8aca7685f8fd
Branch pushed to git repo; I updated commit sha1. New commits:
177c21c  21117: added specialization of polynomial elements

comment:11 Changed 2 years ago by
 Status changed from needs_work to needs_review
added functionality for polynomial elements
comment:12 Changed 2 years ago by
 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^2b*a*d+d^2a*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
 Commit changed from 177c21cfceeb315b08b6b4910f2c8aca7685f8fd to 370abe1a0fed38050c92006cec7c7f766f5105b8
Branch pushed to git repo; I updated commit sha1. New commits:
370abe1  21117: fix problem with unflattenning certain domains

comment:14 Changed 2 years ago by
 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
 Commit changed from 370abe1a0fed38050c92006cec7c7f766f5105b8 to 7ad71976430b4f09491a4d08223fd339697ca1d2
Branch pushed to git repo; I updated commit sha1. New commits:
7ad7197  21117: update doctest

comment:16 Changed 2 years ago by
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
 Commit changed from 7ad71976430b4f09491a4d08223fd339697ca1d2 to 9f69b151cad22b5414d36b8cd0d4286e753c8e32
Branch pushed to git repo; I updated commit sha1. New commits:
9f69b15  Merge 7.3.beta4 into specialization

comment:18 Changed 2 years ago by
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
 Commit changed from 9f69b151cad22b5414d36b8cd0d4286e753c8e32 to 0c7f697d28bb489b2921023c2b07cafb2c79a34a
Branch pushed to git repo; I updated commit sha1. New commits:
0c7f697  Merge branch 7.5.beta4 into t/21117/specialization

comment:20 Changed 21 months ago by
 Milestone changed from sage7.4 to sage7.5
fixed merge conflict
comment:21 Changed 21 months ago by
 Commit changed from 0c7f697d28bb489b2921023c2b07cafb2c79a34a to 13b3865c74ffb86993cdb77857cdcc7d7e53ce21
Branch pushed to git repo; I updated commit sha1. New commits:
13b3865  21117: fix error in flatten.py

comment:22 Changed 21 months ago by
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 univariate polynomial rings.
comment:23 Changed 20 months ago by
 Commit changed from 13b3865c74ffb86993cdb77857cdcc7d7e53ce21 to a5c8f193f5da6f07ce41984ee2bebfe25becfcf2
Branch pushed to git repo; I updated commit sha1. New commits:
a5c8f19  Merge branch 7.5beta6 into t/21117/specialization

comment:24 Changed 19 months ago by
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
 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
 Commit changed from a5c8f193f5da6f07ce41984ee2bebfe25becfcf2 to f41ff27b8a4a6d99fa91b7389eee0ffa8fd56015
Branch pushed to git repo; I updated commit sha1. New commits:
f41ff27  21117: fix issues from review

comment:27 Changed 19 months ago by
 Milestone changed from sage7.5 to sage7.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
 Status changed from needs_review to positive_review
Looks good to me.
comment:29 Changed 19 months ago by
 Branch changed from u/bhutz/specialization to f41ff27b8a4a6d99fa91b7389eee0ffa8fd56015
 Resolution set to fixed
 Status changed from positive_review to closed
New commits:
21106: create polynomial ring flattening class
21106: minor fixes
21106: new version of _call_
21106: added doc tests
21106:cleaning
21106: change file mode
21106: Python3 compatibility + more cleaning
21117: class for SpecializationMorphism
21117: specialization for subschemes and scheme_morphisms