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

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

r""" 

Magmas and Additive Magmas 

""" 

#***************************************************************************** 

# Copyright (C) 2010 Nicolas Borie <nicolas.borie@math.u-psud.fr> 

# 

# Distributed under the terms of the GNU General Public License (GPL) 

# http://www.gnu.org/licenses/ 

#****************************************************************************** 

 

from sage.misc.cachefunc import cached_method 

from sage.misc.lazy_import import LazyImport 

from sage.categories.category_singleton import Category_singleton 

from sage.categories.cartesian_product import CartesianProductsCategory 

from sage.categories.additive_magmas import AdditiveMagmas 

from sage.categories.magmas import Magmas 

 

class MagmasAndAdditiveMagmas(Category_singleton): 

""" 

The category of sets `(S,+,*)` with an additive operation '+' and 

a multiplicative operation `*` 

 

EXAMPLES:: 

 

sage: from sage.categories.magmas_and_additive_magmas import MagmasAndAdditiveMagmas 

sage: C = MagmasAndAdditiveMagmas(); C 

Category of magmas and additive magmas 

 

This is the base category for the categories of rings and their variants:: 

 

sage: C.Distributive() 

Category of distributive magmas and additive magmas 

sage: C.Distributive().Associative().AdditiveAssociative().AdditiveCommutative().AdditiveUnital().AdditiveInverse() 

Category of rngs 

sage: C.Distributive().Associative().AdditiveAssociative().AdditiveCommutative().AdditiveUnital().Unital() 

Category of semirings 

sage: C.Distributive().Associative().AdditiveAssociative().AdditiveCommutative().AdditiveUnital().AdditiveInverse().Unital() 

Category of rings 

 

This category is really meant to represent the intersection of the 

categories of :class:`Magmas` and :class:`AdditiveMagmas`; however 

Sage's infrastructure does not allow yet to model this:: 

 

sage: Magmas() & AdditiveMagmas() 

Join of Category of magmas and Category of additive magmas 

 

sage: Magmas() & AdditiveMagmas() # todo: not implemented 

Category of magmas and additive magmas 

 

TESTS:: 

 

sage: TestSuite(MagmasAndAdditiveMagmas()).run() 

""" 

 

class SubcategoryMethods: 

 

@cached_method 

def Distributive(self): 

r""" 

Return the full subcategory of the objects of ``self`` 

where `*` is distributive on `+`. 

 

A :class:`magma <Magmas>` and :class:`additive magma 

<AdditiveMagmas>` `M` is *distributive* if, for all 

`x,y,z \in M`, 

 

.. MATH:: 

 

x * (y+z) = x*y + x*z \text{ and } (x+y) * z = x*z + y*z 

 

EXAMPLES:: 

 

sage: from sage.categories.magmas_and_additive_magmas import MagmasAndAdditiveMagmas 

sage: C = MagmasAndAdditiveMagmas().Distributive(); C 

Category of distributive magmas and additive magmas 

 

.. NOTE:: 

 

Given that Sage does not know that 

:class:`MagmasAndAdditiveMagmas` is the intersection 

of :class:`Magmas` and :class:`AdditiveMagmas`, this 

method is not available for:: 

 

sage: Magmas() & AdditiveMagmas() 

Join of Category of magmas and Category of additive magmas 

 

Still, the natural syntax works:: 

 

sage: (Magmas() & AdditiveMagmas()).Distributive() 

Category of distributive magmas and additive magmas 

 

thanks to a workaround implemented in 

:meth:`Magmas.SubcategoryMethods.Distributive`:: 

 

sage: (Magmas() & AdditiveMagmas()).Distributive.__module__ 

'sage.categories.magmas' 

 

TESTS:: 

 

sage: TestSuite(C).run() 

sage: Fields().Distributive.__module__ 

'sage.categories.magmas_and_additive_magmas' 

""" 

return self._with_axiom('Distributive') 

 

def super_categories(self): 

""" 

EXAMPLES:: 

 

sage: from sage.categories.magmas_and_additive_magmas import MagmasAndAdditiveMagmas 

sage: MagmasAndAdditiveMagmas().super_categories() 

[Category of magmas, Category of additive magmas] 

""" 

return [Magmas(), AdditiveMagmas()] 

 

def additional_structure(self): 

r""" 

Return ``None``. 

 

Indeed, this category is meant to represent the join of 

:class:`AdditiveMagmas` and :class:`Magmas`. As such, it 

defines no additional structure. 

 

.. SEEALSO:: :meth:`Category.additional_structure` 

 

EXAMPLES:: 

 

sage: from sage.categories.magmas_and_additive_magmas import MagmasAndAdditiveMagmas 

sage: MagmasAndAdditiveMagmas().additional_structure() 

""" 

return None 

 

Distributive = LazyImport('sage.categories.distributive_magmas_and_additive_magmas', 'DistributiveMagmasAndAdditiveMagmas', at_startup=True) 

 

class CartesianProducts(CartesianProductsCategory): 

def extra_super_categories(self): 

r""" 

Implement the fact that this structure is stable under Cartesian 

products. 

 

TESTS:: 

 

sage: from sage.categories.magmas_and_additive_magmas import MagmasAndAdditiveMagmas 

sage: MagmasAndAdditiveMagmas().CartesianProducts().extra_super_categories() 

[Category of magmas and additive magmas] 

""" 

return [MagmasAndAdditiveMagmas()]