Ask Your Question
1

string monoid class should define one()

asked 9 years ago

mark gravatar image

updated 2 years ago

tmonteil gravatar image

Method 'one' is supposed to return the identity element of a monoid (or I guess of any magma). String monoids should define it to be the empty string. Not only have they not, the default implementation throws an error:

sage: BinaryStrings().one()

TypeError: Argument x (= 1) is of the wrong type.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 9 years ago

tmonteil gravatar image

updated 9 years ago

Good catch ! Looking at the code, it seems that this class was not touched for a while (created in 2007, last touched in 2009), so i guess nobody took care of it when the one() was created for all monoids (probably through the sategory mechanism). May i encourage you to open a ticket and fix it yourself ?

Actually, it is not correct to say that the monoid is not able to provide an identity element, you can get is as follows:

sage: b('')

sage: b('110') == b('') * b('110')
True
Preview: (hide)
link

Comments

Since the OP may not have an account, I've taken the liberty of opening http://trac.sagemath.org/ticket/20009 for this.

kcrisman gravatar imagekcrisman ( 9 years ago )

And indeed there is already a branch on it! Though it needs docstring/tests.

kcrisman gravatar imagekcrisman ( 9 years ago )

It is now positively reviewed, so the fix should enter the next Sage release.

tmonteil gravatar imagetmonteil ( 9 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 9 years ago

Seen: 351 times

Last updated: Feb 04 '16