Examples of monoids¶
- sage.categories.examples.monoids.Example[source]¶
- alias of - FreeMonoid
- class sage.categories.examples.monoids.FreeMonoid(alphabet=('a', 'b', 'c', 'd'))[source]¶
- Bases: - FreeSemigroup- An example of a monoid: the free monoid. - This class illustrates a minimal implementation of a monoid. For a full featured implementation of free monoids, see - FreeMonoid().- EXAMPLES: - sage: S = Monoids().example(); S An example of a monoid: the free monoid generated by ('a', 'b', 'c', 'd') sage: S.category() Category of monoids - >>> from sage.all import * >>> S = Monoids().example(); S An example of a monoid: the free monoid generated by ('a', 'b', 'c', 'd') >>> S.category() Category of monoids - This is the free semigroup generated by: - sage: S.semigroup_generators() Family ('a', 'b', 'c', 'd') - >>> from sage.all import * >>> S.semigroup_generators() Family ('a', 'b', 'c', 'd') - with product rule given by concatenation of words: - sage: S('dab') * S('acb') 'dabacb' - >>> from sage.all import * >>> S('dab') * S('acb') 'dabacb' - and unit given by the empty word: - sage: S.one() '' - >>> from sage.all import * >>> S.one() '' - We conclude by running systematic tests on this monoid: - sage: TestSuite(S).run(verbose = True) running ._test_an_element() . . . pass running ._test_associativity() . . . pass running ._test_cardinality() . . . pass running ._test_category() . . . pass running ._test_construction() . . . pass running ._test_elements() . . . Running the test suite of self.an_element() running ._test_category() . . . pass running ._test_eq() . . . pass running ._test_new() . . . pass running ._test_not_implemented_methods() . . . pass running ._test_pickling() . . . pass pass running ._test_elements_eq_reflexive() . . . pass running ._test_elements_eq_symmetric() . . . pass running ._test_elements_eq_transitive() . . . pass running ._test_elements_neq() . . . pass running ._test_eq() . . . pass running ._test_new() . . . pass running ._test_not_implemented_methods() . . . pass running ._test_one() . . . pass running ._test_pickling() . . . pass running ._test_prod() . . . pass running ._test_some_elements() . . . pass - >>> from sage.all import * >>> TestSuite(S).run(verbose = True) running ._test_an_element() . . . pass running ._test_associativity() . . . pass running ._test_cardinality() . . . pass running ._test_category() . . . pass running ._test_construction() . . . pass running ._test_elements() . . . Running the test suite of self.an_element() running ._test_category() . . . pass running ._test_eq() . . . pass running ._test_new() . . . pass running ._test_not_implemented_methods() . . . pass running ._test_pickling() . . . pass pass running ._test_elements_eq_reflexive() . . . pass running ._test_elements_eq_symmetric() . . . pass running ._test_elements_eq_transitive() . . . pass running ._test_elements_neq() . . . pass running ._test_eq() . . . pass running ._test_new() . . . pass running ._test_not_implemented_methods() . . . pass running ._test_one() . . . pass running ._test_pickling() . . . pass running ._test_prod() . . . pass running ._test_some_elements() . . . pass - class Element[source]¶
- Bases: - ElementWrapper- wrapped_class¶
- alias of - str
 
 - monoid_generators()[source]¶
- Return the generators of this monoid. - EXAMPLES: - sage: M = Monoids().example(); M An example of a monoid: the free monoid generated by ('a', 'b', 'c', 'd') sage: M.monoid_generators() Finite family {'a': 'a', 'b': 'b', 'c': 'c', 'd': 'd'} sage: a,b,c,d = M.monoid_generators() sage: a*d*c*b 'adcb' - >>> from sage.all import * >>> M = Monoids().example(); M An example of a monoid: the free monoid generated by ('a', 'b', 'c', 'd') >>> M.monoid_generators() Finite family {'a': 'a', 'b': 'b', 'c': 'c', 'd': 'd'} >>> a,b,c,d = M.monoid_generators() >>> a*d*c*b 'adcb' 
 - one()[source]¶
- Return the one of the monoid, as per - Monoids.ParentMethods.one().- EXAMPLES: - sage: M = Monoids().example(); M An example of a monoid: the free monoid generated by ('a', 'b', 'c', 'd') sage: M.one() '' - >>> from sage.all import * >>> M = Monoids().example(); M An example of a monoid: the free monoid generated by ('a', 'b', 'c', 'd') >>> M.one() ''