Closed vbraun closed 4 years ago
Description changed:
---
+++
@@ -46,7 +46,7 @@
Here is the corresponding Singular computation:
-sage: sage: singular.eval(''' +sage: singular.eval(''' ....: ring R=0,(s,t),dp; ....: ring S=0,(x,y,z,w),dp; ....: setring R; @@ -54,9 +54,9 @@ ....: setring S; ....: ideal ker=kernel(R,f) ....: '''); -sage: sage: singular.get('ker') +sage: singular.get('ker') 'yz-xw,\nz3-yw2,\nxz2-y2w,\ny3-x2z' -sage: sage: print() +sage: print() yz-xw, z3-yw2, xz2-y2w,
Description changed:
---
+++
@@ -1,49 +1,39 @@
-It would be nice if kernels and inverse images of ring maps were implemented:
+For polynomial ring homomorphisms, this ticket implements the methods
+
+- `inverse_image` (of both ideals and individual elements)
+- `kernel`
+- `is_injective`
+- `_graph_ideal`
+
+(This also works for homomorphisms of polynomial quotient rings, number fields and Galois fields.)
+
+---
+
+The implementation is based on the following:
+
+Given a homomorphism `f: K[x] -> K[y]` of (multivariate) polynomial rings that respects the `K`-algebra structure, we can find preimages of `y` by computing normal forms modulo the graph ideal `(x-f(x))` in `K[y,x]` with respect to an elimination order. More generally, this works for morphisms of quotient rings `K[x]/I -> K[y]/J`, which allows to handle many types of ring homomorphisms in Sage.
+
+References: e.g. [BW1993] Propositions 6.44, 7.71; or [Decker-Schreyer](https://www.math.uni-sb.de/ag/schreyer/images/PDFs/teaching/ws1617ag/book.pdf), Proposition 2.5.12 and Exercise 2.5.13.
+
+See also #29723 (inverses of ring homomorphisms) and related posts on the [mailing list](https://groups.google.com/forum/#!topic/sage-support/aJn0T0jIfwU) and at [Ask-Sagemath](https://ask.sagemath.org/question/51336/implicitization-by-symmetric-polynomials/).
+
+---
+
+Example:
-sage: R.<s,t>=PolynomialRing(QQ);R -Multivariate Polynomial Ring in s, t over Rational Field -sage: S.<x,y,z,w>=PolynomialRing(QQ);S -Multivariate Polynomial Ring in x, y, z, w over Rational Field -sage: f=S.hom([s^4,s^3t,st^3,t^4],R);f -Ring morphism:
-NotImplementedError Traceback (most recent call last) +sage: R.<s,t> = PolynomialRing(QQ) +sage: S.<x,y,z,w> = PolynomialRing(QQ) +sage: f = S.hom([s^4, s^3t, st^3, t^4],R) +sage: f.inverse_image(R.ideal(0)) +Ideal (yz - xw, z^3 - yw^2, xz^2 - y^2w, y^3 - x^2z) of Multivariate Polynomial Ring in x, y, z, w over Rational Field +sage: f.inverse_image(s^3t^4(s+t)) +xw + yw +```
-/home/vbraun/opt/sage-4.5.2/devel/sage-main/sage/libs/singular/
-/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/misc/functional.pyc in kernel(x)
-/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.Element.getattr (sage/structure/element.c:2632)()
-/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/structure/parent.so in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:2835)()
-/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/structure/parent.so in sage.structure.parent.raise_attribute_error (sage/structure/parent.c:2602)()
-AttributeError: 'sage.rings.morphism.RingHomomorphism_im_gens' object has no attribute 'kernel' -``` -Here is the corresponding Singular computation: +Note that the inverse image of ideals (but not of elements) could also be computed using Singular as follows:
sage: singular.eval('''
Branch: u/gh-mwageringel/9792
New commits:
ad0dc03 | 9792: ring homomorphism: inverse_image, kernel, is_injective |
Commit: ad0dc03
Author: Markus Wageringel
Branch pushed to git repo; I updated commit sha1. New commits:
0484b3b | 9792: fix a detail |
In RingHomomorphism_cover._inverse_image_element
, you forgot the EXAMPLES::
(and indentation).
Should we also implement a (lib)singular version of the kernel for ideals? Or did you do this already and saw that it was slower?
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
fd6dee6 | 9792: fix some details |
Replying to @tscrim:
Should we also implement a (lib)singular version of the kernel for ideals? Or did you do this already and saw that it was slower?
It would probably be good to wrap the Singular functions kernel
and preimage
, yes. I have not compared it in terms of speed yet, mainly because I thought that I needed to implement the graph ideal in Sage anyway in order to compute inverses of elements. However, I have just noticed that the Singular function algebra_containment can be used for that, which I had overlooked before. I will try to figure out how to call it from Sage and then report back.
Possibly this means that this branch can be refactored such that it only wraps Singular functions, instead of constructing the graph ideal in Sage, unless we want to keep it for more control over the Gröbner basis computations.
Here is Singular code for the example from the description:
> LIB "algebra.lib";
> ring S = 0, (s,t), dp;
> ideal A = ideal(s^4, s^3*t, s*t^3, t^4);
> poly p = s^3*t^4*(s+t);
> list L = algebra_containment(p, A, 1);
> L[1];
1
> def T = L[2]; setring T; check;
y(1)*y(4)+y(2)*y(4)
Replying to @mwageringel:
Replying to @tscrim:
Should we also implement a (lib)singular version of the kernel for ideals? Or did you do this already and saw that it was slower?
It would probably be good to wrap the Singular functions
kernel
andpreimage
, yes. I have not compared it in terms of speed yet, mainly because I thought that I needed to implement the graph ideal in Sage anyway in order to compute inverses of elements. However, I have just noticed that the Singular function algebra_containment can be used for that, which I had overlooked before. I will try to figure out how to call it from Sage and then report back.Possibly this means that this branch can be refactored such that it only wraps Singular functions, instead of constructing the graph ideal in Sage, unless we want to keep it for more control over the Gröbner basis computations.
We will probably want to have both so we can have it for both generic polynomials (over more exotic base fields (integral domains?)) and specialized code for those implemented using Singular (and less back-and-forth between Singular and Sage).
Implementing this via the libsingular interface is a lot more complicated than I anticipated. It is not currently possible to use Sage's singular_function
with the Singular type qring
, and quotient rings in Sage are not even backed by qring
s in Singular. This means it is not currently possible to use the Singular function algebra_containment
with quotient rings via libsingular, but only with polynomial rings.
The implementation of algebra_containment is essentially the same as on this branch. The main difference is that algebra_containment
uses the Singular function std
for Gröbner basis computations whereas Sage uses the general purpose function groebner
, which does some preprocessing and then calls a suitable implementation. As such, the computation times can be quite different. The Singular version is often a bit faster, but when computing preimages of many elements, the caching in the Sage version seems to be more effective.
The implementation of the Singular function preimage
is a bit less transparent to me, so it might be more interesting to wrap this. In this case, by switching to the ambient ring, one can work around the problem that the qring
type is not supported. However, I still did not manage to call preimage
via libsingular, as it requires the ideals passed as arguments to have names, which our ideals apparently do not have.
The other option is to use the Singular pexpect interface to wrap preimage
and algebra_containment
. Though, as the current branch is functional, I would prefer to not implement that on this ticket here, so I am setting this back to needs_review.
Reviewer: Travis Scrimshaw
That is too bad. Thank you for trying. I agree that we should get this into Sage now, and we can revisit using libsingular later.
Thank you.
Changed branch from u/gh-mwageringel/9792 to fd6dee6
For polynomial ring homomorphisms, this ticket implements the methods
inverse_image
(of both ideals and individual elements)kernel
is_injective
_graph_ideal
(This also works for homomorphisms of polynomial quotient rings, number fields and Galois fields.)
The implementation is based on the following:
Given a homomorphism
f: K[x] -> K[y]
of (multivariate) polynomial rings that respects theK
-algebra structure, we can find preimages ofy
by computing normal forms modulo the graph ideal(x-f(x))
inK[y,x]
with respect to an elimination order. More generally, this works for morphisms of quotient ringsK[x]/I -> K[y]/J
, which allows to handle many types of ring homomorphisms in Sage.References: e.g. [BW1993] Propositions 6.44, 7.71; or Decker-Schreyer, Proposition 2.5.12 and Exercise 2.5.13.
See also #29723 (inverses of ring homomorphisms) and related posts on the mailing list and at Ask-Sagemath.
Example:
Note that the inverse image of ideals (but not of elements) could also be computed using Singular as follows:
CC: @dimpase
Component: algebra
Author: Markus Wageringel
Branch/Commit:
fd6dee6
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/9792