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

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

""" 

Realizations Covariant Functorial Construction 

 

.. SEEALSO:: 

 

- :func:`Sets().WithRealizations <sage.categories.with_realizations.WithRealizations>` 

for an introduction to *realizations* and *with realizations*. 

- :mod:`sage.categories.covariant_functorial_construction` 

for an introduction to covariant functorial constructions. 

- :mod:`sage.categories.examples.with_realizations` for an example. 

""" 

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

# Copyright (C) 2010-2012 Nicolas M. Thiery <nthiery at users.sf.net> 

# 

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

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

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

 

from sage.misc.bindable_class import BindableClass 

from sage.categories.category import Category 

from sage.categories.category_types import Category_over_base 

from sage.categories.covariant_functorial_construction import RegressiveCovariantConstructionCategory 

 

class RealizationsCategory(RegressiveCovariantConstructionCategory): 

""" 

An abstract base class for all categories of realizations category 

 

Relization are implemented as 

:class:`~sage.categories.covariant_functorial_construction.RegressiveCovariantConstructionCategory`. 

See there for the documentation of how the various bindings such 

as ``Sets().Realizations()`` and ``P.Realizations()``, where ``P`` 

is a parent, work. 

 

.. SEEALSO:: :func:`Sets().WithRealizations <sage.categories.with_realizations.WithRealizations>` 

 

TESTS:: 

 

sage: Sets().Realizations 

<bound method Sets_with_category.Realizations of Category of sets> 

sage: Sets().Realizations() 

Category of realizations of sets 

sage: Sets().Realizations().super_categories() 

[Category of sets] 

sage: Groups().Realizations().super_categories() 

[Category of groups, Category of realizations of unital magmas] 

""" 

 

_functor_category = "Realizations" 

 

def Realizations(self): 

""" 

Return the category of realizations of the parent ``self`` or of objects 

of the category ``self`` 

 

INPUT: 

 

- ``self`` -- a parent or a concrete category 

 

.. NOTE:: this *function* is actually inserted as a *method* in the class 

:class:`~sage.categories.category.Category` (see 

:meth:`~sage.categories.category.Category.Realizations`). It is defined 

here for code locality reasons. 

 

EXAMPLES: 

 

The category of realizations of some algebra:: 

 

sage: Algebras(QQ).Realizations() 

Join of Category of algebras over Rational Field and Category of realizations of unital magmas 

 

The category of realizations of a given algebra:: 

 

sage: A = Sets().WithRealizations().example(); A 

The subset algebra of {1, 2, 3} over Rational Field 

sage: A.Realizations() 

Category of realizations of The subset algebra of {1, 2, 3} over Rational Field 

 

sage: C = GradedHopfAlgebrasWithBasis(QQ).Realizations(); C 

Join of Category of graded hopf algebras with basis over Rational Field and Category of realizations of hopf algebras over Rational Field 

sage: C.super_categories() 

[Category of graded hopf algebras with basis over Rational Field, Category of realizations of hopf algebras over Rational Field] 

 

sage: TestSuite(C).run() 

 

.. SEEALSO:: 

 

- :func:`Sets().WithRealizations <sage.categories.with_realizations.WithRealizations>` 

- :class:`ClasscallMetaclass` 

 

.. TODO:: 

 

Add an optional argument to allow for:: 

 

sage: Realizations(A, category = Blahs()) # todo: not implemented 

""" 

if isinstance(self, Category): 

return RealizationsCategory.category_of(self) 

else: 

return getattr(self.__class__, "Realizations")(self) 

 

Category.Realizations = Realizations 

 

class Category_realization_of_parent(Category_over_base, BindableClass): 

""" 

An abstract base class for categories of all realizations of a given parent 

 

INPUT: 

 

- ``parent_with_realization`` -- a parent 

 

.. SEEALSO:: :func:`Sets().WithRealizations <sage.categories.with_realizations.WithRealizations>` 

 

EXAMPLES:: 

 

sage: A = Sets().WithRealizations().example(); A 

The subset algebra of {1, 2, 3} over Rational Field 

 

The role of this base class is to implement some technical goodies, like 

the binding ``A.Realizations()`` when a subclass ``Realizations`` is 

implemented as a nested class in ``A`` 

(see the :mod:`code of the example <sage.categories.examples.with_realizations.SubsetAlgebra>`):: 

 

sage: C = A.Realizations(); C 

Category of realizations of The subset algebra of {1, 2, 3} over Rational Field 

 

as well as the name for that category. 

""" 

def __init__(self, parent_with_realization): 

""" 

TESTS:: 

 

sage: from sage.categories.realizations import Category_realization_of_parent 

sage: A = Sets().WithRealizations().example(); A 

The subset algebra of {1, 2, 3} over Rational Field 

sage: C = A.Realizations(); C 

Category of realizations of The subset algebra of {1, 2, 3} over Rational Field 

sage: isinstance(C, Category_realization_of_parent) 

True 

sage: C.parent_with_realization 

The subset algebra of {1, 2, 3} over Rational Field 

sage: TestSuite(C).run(skip=["_test_category_over_bases"]) 

 

.. TODO:: 

 

Fix the failing test by making ``C`` a singleton 

category. This will require some fiddling with the 

assertion in :meth:`Category_singleton.__classcall__` 

""" 

Category_over_base.__init__(self, parent_with_realization) 

self.parent_with_realization = parent_with_realization 

 

def _get_name(self): 

""" 

Return a human readable string specifying which kind of bases this category is for 

 

It is obtained by splitting and lower casing the last part of 

the class name. 

 

EXAMPLES:: 

 

sage: from sage.categories.realizations import Category_realization_of_parent 

sage: class MultiplicativeBasesOnPrimitiveElements(Category_realization_of_parent): 

....: def super_categories(self): return [Objects()] 

sage: Sym = SymmetricFunctions(QQ); Sym.rename("Sym") 

sage: MultiplicativeBasesOnPrimitiveElements(Sym)._get_name() 

'multiplicative bases on primitive elements' 

""" 

import re 

return re.sub(".[A-Z]", lambda s: s.group()[0]+" "+s.group()[1], self.__class__.__base__.__name__.split(".")[-1]).lower() 

 

def _repr_object_names(self): 

""" 

Return the name of the objects of this category. 

 

.. SEEALSO:: :meth:`Category._repr_object_names` 

 

EXAMPLES:: 

 

sage: from sage.categories.realizations import Category_realization_of_parent 

sage: class MultiplicativeBasesOnPrimitiveElements(Category_realization_of_parent): 

....: def super_categories(self): return [Objects()] 

sage: Sym = SymmetricFunctions(QQ); Sym.rename("Sym") 

sage: C = MultiplicativeBasesOnPrimitiveElements(Sym); C 

Category of multiplicative bases on primitive elements of Sym 

sage: C._repr_object_names() 

'multiplicative bases on primitive elements of Sym' 

""" 

return "{} of {}".format(self._get_name(), self.base())