Ask Your Question
1

string monoid class should define one()

asked 2016-02-04 03:56:00 +0200

mark gravatar image

updated 2023-01-09 23:59:39 +0200

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 11:50:59 +0200

tmonteil gravatar image

updated 2016-02-04 11:51:48 +0200

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 14:46:27 +0200 )edit

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

kcrisman gravatar imagekcrisman ( 2016-02-04 17:53:48 +0200 )edit

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

tmonteil gravatar imagetmonteil ( 2016-02-12 23:24:16 +0200 )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-04 03:56:00 +0200

Seen: 268 times

Last updated: Feb 04 '16