Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InfinitePolynomialRing with coefficients in another InfinitePolynomialRing #36788

Open
1 task done
mantepse opened this issue Nov 29, 2023 · 4 comments
Open
1 task done

Comments

@mantepse
Copy link
Contributor

Problem Description

I frequently use polynomial rings over other polynomial rings for easy extraction of terms. For example:

sage: R.<a> = QQ[]
sage: S.<x, y, z> = R[]
sage: p = (x+y+z)^2*sum(a^k for k in range(4))
sage: p.monomial_coefficient(x*y)
2*a^3 + 2*a^2 + 2*a + 2

This does not work for infinite polynomial rings:

sage: R.<a> = InfinitePolynomialRing(QQ)
sage: S.<b> = InfinitePolynomialRing(R)
sage: p = (b[0] + b[1] + b[2])^2*sum(a[k] for k in range(4))
sage: p.monomial_coefficient(b[2]*b[1])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [132], line 1
----> 1 p.monomial_coefficient(b[Integer(2)]*b[Integer(1)])

TypeError: Argument 'mon' has incorrect type (expected sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular, got InfinitePolynomial_dense)

Proposed Solution

Get someone to fix the InfinitePolynomialRing.

Alternatives Considered

Do it myself, but upon consideration, this is not a viable solution.

Additional Information

No response

Is there an existing issue for this?

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
@RuchitJagodara
Copy link
Contributor

RuchitJagodara commented Dec 9, 2023

Get someone to fix the InfinitePolynomialRing.

Can you explain me what do you men by fixing the InfinitePolynomialRing ?

I have also looked into the working of this and I didn't find any problem with InfinitePolynomialRing, instead from the error message,

TypeError Traceback (most recent call last)
Cell In [132], line 1
----> 1 p.monomial_coefficient(b[Integer(2)]*b[Integer(1)])

TypeError: Argument 'mon' has incorrect type (expected >sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular, got InfinitePolynomial_dense)

It is clear that there is an issue with monomial_coefficient() function, when I checked what is the exact issue then I found that it is taking argument mon of a particular type only (i.e. MPolynomial_libsingular), and here when we are defining an InfinitePolynomialRing then we are passing different type of argument in the function so I think we need to make a new function/files specifically for InfinitePolynomialRings because multi_polynomial_libsingular.pyx does not seem to include functions related to infinite polynomial rings.

If I am wrong somewhere, @mantepse please tell me.

@RuchitJagodara
Copy link
Contributor

@mantepse ?

@mantepse
Copy link
Contributor Author

Get someone to fix the InfinitePolynomialRing.

Can you explain me what do you mean by fixing the InfinitePolynomialRing ?

There are several problems, for example #36576, also that InfinitePolynomialRing.gens is abused, etc.

I don't have any good answers, unfortunately.

@tdupu
Copy link

tdupu commented Jul 15, 2024

I found a related problem in the way that it PolynomialRing works over InfinitePolynomialRing handles adjoining ordinary variables:

A.<x,y> = InfinitePolynomialRing(QQ, order='deglex')
R.<t>=PolynomialRing(A,1)
I=R.ideal(t^2)
Rquo=R.quo(I)
#Rquo(x[1]) #this doesn't work.
z=R(x[1]) #this is fine
Rquo(z) #this freaks out.
Error in lines 6-6
Traceback (most recent call last):
  File "sage/misc/cachefunc.pyx", line 1962, in sage.misc.cachefunc.CachedMethodCaller.__call__
    return cache[k]
KeyError: (('', None, None, False), ())

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/ext/sage/10.3/src/sage/rings/polynomial/multi_polynomial_ideal.py", line 4671, in groebner_basis
    gb = self._groebner_basis_libsingular("groebner", deg_bound=deg_bound, mult_bound=mult_bound, *args, **kwds)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ext/sage/10.3/src/sage/libs/singular/standard_options.py", line 143, in wrapper
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "/ext/sage/10.3/src/sage/rings/polynomial/multi_polynomial_ideal.py", line 554, in _groebner_basis_libsingular
    S = groebner(self)
        ^^^^^^^^^^^^^^
  File "sage/libs/singular/function.pyx", line 1297, in sage.libs.singular.function.SingularFunction.__call__
    raise TypeError("cannot call Singular function '%s' with ring parameter of type '%s'" % (self._name,type(ring)))
TypeError: cannot call Singular function 'groebner' with ring parameter of type '<class 'sage.rings.polynomial.multi_polynomial_ring.MPolynomialRing_polydict_with_category'>'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "sage/misc/cachefunc.pyx", line 1962, in sage.misc.cachefunc.CachedMethodCaller.__call__
    return cache[k]
KeyError: (('groebner', Singular), (('deg_bound', None), ('mult_bound', None)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "sage/structure/category_object.pyx", line 855, in sage.structure.category_object.CategoryObject.getattr_from_category
    return self._cached_methods[name]
KeyError: '_PolynomialRing_singular_repr__singular'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/ext/sage/10.3/src/sage/rings/polynomial/polynomial_singular_interface.py", line 335, in _singular_
    R = self.__singular
        ^^^^^^^^^^^^^^^
  File "sage/structure/category_object.pyx", line 849, in sage.structure.category_object.CategoryObject.__getattr__
    return self.getattr_from_category(name)
  File "sage/structure/category_object.pyx", line 864, in sage.structure.category_object.CategoryObject.getattr_from_category
    attr = getattr_from_other_class(self, cls, name)
  File "sage/cpython/getattr.pyx", line 357, in sage.cpython.getattr.getattr_from_other_class
    raise AttributeError(dummy_error_message)
AttributeError: 'Singular' object has no attribute '_strip_prompt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/ext/sage/10.3/src/sage/rings/polynomial/multi_polynomial_ideal.py", line 4674, in groebner_basis
    gb = self._groebner_basis_singular("groebner", deg_bound=deg_bound, mult_bound=mult_bound, *args, **kwds)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ext/sage/10.3/src/sage/interfaces/singular.py", line 2805, in wrapper
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "/ext/sage/10.3/src/sage/rings/polynomial/multi_polynomial_ideal.py", line 1480, in _groebner_basis_singular
    S = self._groebner_basis_singular_raw(algorithm=algorithm, *args, **kwds)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "sage/misc/cachefunc.pyx", line 1967, in sage.misc.cachefunc.CachedMethodCaller.__call__
    w = self._instance_call(*args, **kwds)
  File "sage/misc/cachefunc.pyx", line 1842, in sage.misc.cachefunc.CachedMethodCaller._instance_call
    return self.f(self._instance, *args, **kwds)
  File "/ext/sage/10.3/src/sage/rings/polynomial/multi_polynomial_ideal.py", line 1515, in _groebner_basis_singular_raw
    S = self._singular_()   # for degBound, we need to ensure
        ^^^^^^^^^^^^^^^^^
  File "/ext/sage/10.3/src/sage/rings/polynomial/multi_polynomial_ideal.py", line 633, in _singular_
    self.ring()._singular_(singular).set_ring()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ext/sage/10.3/src/sage/rings/polynomial/polynomial_singular_interface.py", line 349, in _singular_
    return self._singular_init_(singular)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ext/sage/10.3/src/sage/rings/polynomial/polynomial_singular_interface.py", line 366, in _singular_init_
    raise TypeError("no conversion of this ring to a Singular ring defined")
TypeError: no conversion of this ring to a Singular ring defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/cocalc/lib/python3.11/site-packages/smc_sagews/sage_server.py", line 1244, in execute
    exec(
  File "", line 1, in <module>
  File "sage/structure/parent.pyx", line 901, in sage.structure.parent.Parent.__call__
    return mor._call_(x)
  File "sage/structure/coerce_maps.pyx", line 163, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_
    raise
  File "sage/structure/coerce_maps.pyx", line 158, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_
    return C._element_constructor(x)
  File "/ext/sage/10.3/src/sage/rings/quotient_ring.py", line 1084, in _element_constructor_
    return self.element_class(self, x)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ext/sage/10.3/src/sage/rings/quotient_ring_element.py", line 101, in __init__
    self._reduce_()
  File "/ext/sage/10.3/src/sage/rings/quotient_ring_element.py", line 120, in _reduce_
    self.__rep = I.reduce(self.__rep)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/ext/sage/10.3/src/sage/rings/polynomial/multi_polynomial_ideal.py", line 4965, in reduce
    gb = self.groebner_basis()
         ^^^^^^^^^^^^^^^^^^^^^
  File "sage/misc/cachefunc.pyx", line 1967, in sage.misc.cachefunc.CachedMethodCaller.__call__
    w = self._instance_call(*args, **kwds)
  File "sage/misc/cachefunc.pyx", line 1842, in sage.misc.cachefunc.CachedMethodCaller._instance_call
    return self.f(self._instance, *args, **kwds)
  File "/ext/sage/10.3/src/sage/rings/qqbar_decorators.py", line 97, in wrapper
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "/ext/sage/10.3/src/sage/rings/polynomial/multi_polynomial_ideal.py", line 4706, in groebner_basis
    gb = toy_buchberger.buchberger_improved(self, *args, **kwds)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ext/sage/10.3/src/sage/rings/polynomial/toy_buchberger.py", line 260, in buchberger_improved
    F = inter_reduction(F.gens())
        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ext/sage/10.3/src/sage/rings/polynomial/toy_buchberger.py", line 442, in inter_reduction
    h = p.reduce(Q)
        ^^^^^^^^^^^
  File "/ext/sage/10.3/src/sage/rings/polynomial/multi_polynomial_element.py", line 2433, in reduce
    raise TypeError("Can only reduce polynomials over fields.")
TypeError: Can only reduce polynomials over fields.

In general I found it difficult to define ring homomorphisms and I couldn't quite figure out what the ring homomorphism issue traced back to. My goal was to define a derivation by using a ring of dual numbers A[t]/(t^2) and then specify the homomorphism by what happens on the generators. The way that this library has a special class for generators seems to have something to do with this.

This was run on cocalc on July 15 2024.
'SageMath version 10.3, Release Date: 2024-03-19'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants