sagemath / sage

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

reduce Integer 0 in letterplace FreeAlgebra #18654

Closed 08704e68-5de8-4d82-a5c7-5ccc78990484 closed 9 years ago

08704e68-5de8-4d82-a5c7-5ccc78990484 commented 9 years ago

Would be nice the "reduce" method handle the Integer 0 It is not really a bug but one often built polynomials from Integer "0"

FreeA.<a,b> = FreeAlgebra(QQ, implementation='letterplace')
I = FreeA*[a+b]*FreeA
G=I.groebner_basis()
P=a*a*a*a
P.reduce(G)

︡{"stdout":"b*b*b*b\n"}︡

Q=P-P
Q
︡
{"stdout":"0\n"}︡

Q.reduce(G)
︡
{"stdout":"0\n"}︡
︠
Q=0
︡Q.reduce(G)
︡
{"stderr":"Error in lines 1-1\nTraceback (most recent call last):\n  File \"/projects/5d2319d7-b6e9-4ea8-984f-57412ea9d711/.sagemathcloud/sage_server.py\", line 879, in execute\n    exec compile(block+'\\n', '', 'single') in namespace, locals\n  File \"\", line 1, in <module>\n  File \"sage/structure/element.pyx\", line 431, in sage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4644)\n    return getattr_from_other_class(self, P._abstract_element_class, name)\n  File \"sage/structure/misc.pyx\", line 259, in sage.structure.misc.getattr_from_other_class (build/cythonized/sage/structure/misc.c:1670)\n    raise dummy_attribute_error\nAttributeError: 'sage.rings.integer.Integer' object has no attribute 'reduce'\n"}︡
︠}}}

CC: @saliola @simon-king-jena

Component: algebra

Keywords: days65

Reviewer: Simon King

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

simon-king-jena commented 9 years ago
comment:1

Now I understand what you mean.

That's clearly not a bug. If you do

Q=0
Q.reduce(G)

then Q is an Integer. When you do Q.reduce, you will find that an integer has no reduce method. The reduce method is for free algebra elements, and integers is something totally different. That's how object oriented programming languages such as Python work.

simon-king-jena commented 9 years ago
comment:2

As you have shown in the ticket description, the zero element in the free algebra can be reduced. The INTEGER zero element has nothing to do with free algebras, hence, reduction can not be provided.

simon-king-jena commented 9 years ago

Reviewer: Simon King

saliola commented 9 years ago

Changed keywords from none to days65