Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

r""" 

Monoids 

""" 

 

from sage.structure.parent import Parent 

from sage.misc.cachefunc import cached_method 

 

def is_Monoid(x): 

r""" 

Returns True if ``x`` is of type ``Monoid_class``. 

 

EXAMPLES:: 

 

sage: from sage.monoids.monoid import is_Monoid 

sage: is_Monoid(0) 

False 

sage: is_Monoid(ZZ) # The technical math meaning of monoid has 

....: # no bearing whatsoever on the result: it's 

....: # a typecheck which is not satisfied by ZZ 

....: # since it does not inherit from Monoid_class. 

False 

sage: is_Monoid(sage.monoids.monoid.Monoid_class(('a','b'))) 

True 

sage: F.<a,b,c,d,e> = FreeMonoid(5) 

sage: is_Monoid(F) 

True 

""" 

return isinstance(x, Monoid_class) 

 

class Monoid_class(Parent): 

def __init__(self, names): 

r""" 

EXAMPLES:: 

 

sage: from sage.monoids.monoid import Monoid_class 

sage: Monoid_class(('a','b')) 

<sage.monoids.monoid.Monoid_class_with_category object at ...> 

 

TESTS:: 

 

sage: F.<a,b,c,d,e> = FreeMonoid(5) 

sage: TestSuite(F).run() 

""" 

from sage.categories.monoids import Monoids 

category = Monoids().FinitelyGeneratedAsMagma() 

Parent.__init__(self, base=self, names=names, category=category) 

 

@cached_method 

def gens(self): 

r""" 

Returns the generators for ``self``. 

 

EXAMPLES:: 

 

sage: F.<a,b,c,d,e> = FreeMonoid(5) 

sage: F.gens() 

(a, b, c, d, e) 

""" 

return tuple(self.gen(i) for i in range(self.ngens())) 

 

def monoid_generators(self): 

r""" 

Returns the generators for ``self``. 

 

EXAMPLES:: 

 

sage: F.<a,b,c,d,e> = FreeMonoid(5) 

sage: F.monoid_generators() 

Family (a, b, c, d, e) 

""" 

from sage.sets.family import Family 

return Family(self.gens())