Ask Your Question
1

string monoid class should define one()

asked 2016-02-03 20:56:00 -0500

mark gravatar image

updated 2016-02-04 04:52:05 -0500

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-02-04 04:50:59 -0500

tmonteil gravatar image

updated 2016-02-04 04:51:48 -0500

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
edit flag offensive delete link more

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 ( 2016-02-04 07:46:27 -0500 )edit

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

kcrisman gravatar imagekcrisman ( 2016-02-04 10:53:48 -0500 )edit

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

tmonteil gravatar imagetmonteil ( 2016-02-12 16:24:16 -0500 )edit

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: 2016-02-03 20:56:00 -0500

Seen: 59 times

Last updated: Feb 04 '16