sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.33k stars 453 forks source link

conversion of quotient rings to macaulay2 #28572

Closed saliola closed 4 years ago

saliola commented 4 years ago

Currently, conversion of quotient rings to M2 is not supported; we add this functionality:

sage: R.<x,y> = PolynomialRing(QQ)
sage: I = R.ideal([x^2 - y])
sage: macaulay2(R.quotient_ring(I))

This also improves the conversion of ideals by moving the MPolynomialIdeal_macaulay2_repr._macaulay2_ to Ideal_generic._macaulay2_init_; for example, the following now work but didn't before (see the doctests for examples):

sage: R.<x> = PolynomialRing(ZZ)
sage: macaulay2(R.ideal(x^2))
sage: macaulay2(ideal(5))

Note that quotient rings in M2 inherit variable names from the ambient ring, so we mimic this behaviour in Sage::

sage: R = macaulay2("ZZ/7[x,y]")
sage: I = macaulay2("ideal (x^3 - y^2)")
sage: (R/I).gens()
{x, y}
sage: (R/I).sage().gens()
(x, y)

We also implement conversion of polynomials from quotient rings from/to M2:

sage: x, y = (R/I).gens()
sage: f = (x^3 + 2*y^2*x)^7; f
    18    14
2x*y   + y
sage: f.sage()
2*x*y^18 + y^14
sage: _.parent()
Quotient of Multivariate Polynomial Ring in x, y over Finite Field of size 7 by the ideal (x^3 - y^2)
sage: macaulay2(f.sage())
    18    14
2x*y   + y

Depends on #28567 Depends on #28571 Depends on #28074 Depends on #28591

CC: @dimpase @mwageringel @antonleykin

Component: interfaces: optional

Keywords: IMA Coding Sprint, macaulay2, interfaces

Author: Franco Saliola

Branch/Commit: 3f4f6f5

Reviewer: Markus Wageringel, Dima Pasechnik

Issue created by migration from https://trac.sagemath.org/ticket/28572

saliola commented 4 years ago

Commit: 6e734c6

saliola commented 4 years ago

Changed dependencies from 28571, 28074 to #28571, #28074

saliola commented 4 years ago

Branch: public/interfaces/m2/m2_quotient_rings

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 6e734c6 to 6a537c8

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

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

6a537c828572: fix conversion of quotient rings from Macaulay2 to Sage
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

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

5ddbe5cmark m2 doctests as optional
4b256a1add _macaulay2_init_ method to QuotientRingElement
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 6a537c8 to 4b256a1

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 4b256a1 to d1566e5

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

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

d1566e5correct inaccuracy in doctest description
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from d1566e5 to bd06a80

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

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

bd06a80properly handle conversion of quotient ring elements & inherit variable names when converting from M2 quotient rings
saliola commented 4 years ago

Description changed:

--- 
+++ 
@@ -19,3 +19,32 @@
 sage: macaulay2(ideal(5))

+ +Note that quotient rings in M2 inherit variable names from the ambient ring, so we mimic this behaviour in Sage:: + + +sage: R = macaulay2("ZZ/7[x,y]") +sage: I = macaulay2("ideal (x^3 - y^2)") +sage: (R/I).gens() +{x, y} +sage: (R/I).sage().gens() +(x, y) + + +We also implement conversion of polynomials from quotient rings from/to M2: + +``` +sage: x, y = (R/I).gens() +sage: f = (x^3 + 2y^2x)^7; f

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from bd06a80 to ec1773e

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

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

ec1773edisable caching of M2 conversion of polynomials in quotient rings (change _macaulay2_init_ to _macaulay2_)
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

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

25afa2fsimplify doctest
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from ec1773e to 25afa2f

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 25afa2f to 19d9995

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

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

19d999528572: remove unnecessary doctests
mwageringel commented 4 years ago
comment:10

The following does not work yet (not even with #28574):

sage: R = QQ['x,y'].quotient('x^2-y')['z,t']
sage: f = R.base_ring()('x')^2 - R('z^2')
sage: macaulay2(f)  # fails

This fails because the variable names in the quotient ring are named xbar,ybar in Sage, but x,y in Macaulay2. The conversion routine for polynomials does not currently take this into account when the base ring is a quotient ring.

Other than that, everything looks good to me up until here.

saliola commented 4 years ago

Changed dependencies from #28571, #28074 to #28567, #28571, #28074

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 19d9995 to 15d35e3

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

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

0d90888f4 and mgb opts for M2 gb computations
59b3215add documentation and minor fixes
1ad24c3pass F4 and MGB to M2 as strings
7038ba228567: run Macaulay2 f4 and mgb doctests over a finite field
00c028f28567: add missing optional doctest flag
15d35e3Merge remote-tracking branch 'origin/public/interfaces/m2/f4etc' into public/interfaces/m2/m2_quotient_rings
saliola commented 4 years ago
comment:13

I added a dependency to #28567 because this did not merge cleanly on top of it (and I merged it into this branch).

mwageringel commented 4 years ago
comment:14

Ok.

mwageringel commented 4 years ago

Reviewer: Markus Wageringel

vbraun commented 4 years ago
comment:15

Merge conflict (please merge in next beta)

dimpase commented 4 years ago

Changed dependencies from #28567, #28571, #28074 to #28567, #28571, #28074, #28591

dimpase commented 4 years ago
comment:17

rebased on top of the branch of #28591


Last 10 new commits:

e40eb60make tests more foolproof.
61ca2dbconversion of quotient rings to macaulay2 & improvements to conversion of ideals
84702b428572: fix conversion of quotient rings from Macaulay2 to Sage
4db4a3cmark m2 doctests as optional
80b99b9add _macaulay2_init_ method to QuotientRingElement
c185cffcorrect inaccuracy in doctest description
ca619b8properly handle conversion of quotient ring elements & inherit variable names when converting from M2 quotient rings
3a0e906disable caching of M2 conversion of polynomials in quotient rings (change _macaulay2_init_ to _macaulay2_)
117ab9fsimplify doctest
3f4f6f528572: remove unnecessary doctests
dimpase commented 4 years ago

Changed branch from public/interfaces/m2/m2_quotient_rings to u/dimpase/interfaces/m2/m2_quotient_rings

dimpase commented 4 years ago

Changed commit from 15d35e3 to 3f4f6f5

dimpase commented 4 years ago

Changed reviewer from Markus Wageringel to Markus Wageringel, Dima Pasechnik

vbraun commented 4 years ago

Changed branch from u/dimpase/interfaces/m2/m2_quotient_rings to 3f4f6f5