Hi! On 2017-03-28, Adam Mullins <[email protected]> wrote: > Hi, I create a free algebra like such: > > R.<q1,q2,q3> = FreeAlgebra(Integers(2)) > > When I try to check if the constant polynomial 1 is in R, it returns false. > But this should return true. > i.e. 1 in R returns false > > It also returns false when I write the code > 0 in R > > Is this a bug?
I believe it is a bug. By default, "1 in R" defaults to "R(1)==1 is True and doesn't raise an error, which is the case here. sage: R.<x,y,z> = FreeAlgebra(Integers(2)) sage: R(1) == 1 True The problem is that someone decided to override the default __contains__ method for CombinatorialFreeModule, so that only equality of parents is tested (a very bad notion of containment, IMHO!). If it is OK for you to only work with graded homogeneous elements, you could use the letterplace implementation of free algebras: sage: R.<x,y,z> = FreeAlgebra(Integers(2), implementation='letterplace') sage: 1 in R True but note that really only homogeneous elements can be created: sage: 1+x ... ArithmeticError: Can only add elements of the same weighted degree Third solution *should* be to implement a free algebra as a path algebra. It would have the advantage of allowing inhomogenous elements. But alas, it inherits from CombinatorialFreeModule and thus provides the same bug. I will open a trac ticket for it. Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
