Hello, I'm having trouble implementing arithmetic for BooleanMonomials, which are elements of a monoid.
Multiplication of BooleanMonomials work fine using the coercion model, but the following doesn't work, since there is no coercion from ZZ to BooleanMonomialMonoid. sage: P.<x,y> = BooleanPolynomialRing(2) sage: M = P._monom_monoid sage: x_monom = M(x); y_monom = M(y) sage: x_monom*1 boom! sage: 1*x_monom boom! This works, because of the code after sage/structure/element.pyx:1083 sage:x_monom*int(1) x sage:int(1)*x_monom How should I fix this? By implementing right and left actions, and returning 0 (in ZZ) when multiplying by an even integer? I also need to have the functionality to add two BooleanMonomials, and get a BooleanPolynomial. This is a real grey area for the coercion model. For example: sage: x_monom + 1 ??? The common parent of these objects is a BooleanPolynomialRing, which is not the parent of either one, so the coercion model doesn't work here. At Sage Days 6, Robert B suggested bypassing the coercion model and implementing an __add__ method for BooleanMonomials. This solves the above problem, but fails for this case: sage: 1 + x_monom boom! I would also like the following to work: sage: 0 + x_monom x sage: x_monom + 0 #this works with the current solution x Again, since there is no coercion from ZZ to BooleanMonomialMonoids, especially no image of 0 as a BooleanMonomial, this seems to be a case to be handled outside of the coercion model. Any thoughts or suggestions? Burcin --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---