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

""" 

Functorial composition species 

""" 

from __future__ import absolute_import 

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

# Copyright (C) 2008 Mike Hansen <mhansen@gmail.com>, 

# 

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

# 

# This code is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

# General Public License for more details. 

# 

# The full text of the GPL is available at: 

# 

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

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

from .species import GenericCombinatorialSpecies 

from .structure import GenericSpeciesStructure 

 

class FunctorialCompositionStructure(GenericSpeciesStructure): 

pass 

 

class FunctorialCompositionSpecies(GenericCombinatorialSpecies): 

def __init__(self, F, G, min=None, max=None, weight=None): 

""" 

Returns the functorial composition of two species. 

 

EXAMPLES:: 

 

sage: E = species.SetSpecies() 

sage: E2 = species.SetSpecies(size=2) 

sage: WP = species.SubsetSpecies() 

sage: P2 = E2*E 

sage: G = WP.functorial_composition(P2) 

sage: G.isotype_generating_series().coefficients(5) 

[1, 1, 2, 4, 11] 

 

sage: G = species.SimpleGraphSpecies() 

sage: c = G.generating_series().coefficients(2) 

sage: type(G) 

<class 'sage.combinat.species.functorial_composition_species.FunctorialCompositionSpecies'> 

sage: G == loads(dumps(G)) 

True 

sage: G._check() #False due to isomorphism types not being implemented 

False 

""" 

self._F = F 

self._G = G 

self._state_info = [F, G] 

self._name = "Functorial composition of (%s) and (%s)"%(F, G) 

GenericCombinatorialSpecies.__init__(self, min=None, max=None, weight=None) 

 

_default_structure_class = FunctorialCompositionStructure 

 

def _structures(self, structure_class, s): 

""" 

EXAMPLES:: 

 

sage: G = species.SimpleGraphSpecies() 

sage: G.structures([1,2,3]).list() 

[{}, 

{{1, 2}*{3}}, 

{{1, 3}*{2}}, 

{{2, 3}*{1}}, 

{{1, 2}*{3}, {1, 3}*{2}}, 

{{1, 2}*{3}, {2, 3}*{1}}, 

{{1, 3}*{2}, {2, 3}*{1}}, 

{{1, 2}*{3}, {1, 3}*{2}, {2, 3}*{1}}] 

""" 

gs = self._G.structures(s).list() 

for f in self._F.structures(gs): 

yield f 

 

def _isotypes(self, structure_class, s): 

""" 

There is no known algorithm for efficiently generating the 

isomorphism types of the functorial composition of two species. 

 

EXAMPLES:: 

 

sage: G = species.SimpleGraphSpecies() 

sage: G.isotypes([1,2,3]).list() 

Traceback (most recent call last): 

... 

NotImplementedError 

""" 

raise NotImplementedError 

 

 

def _gs(self, series_ring, base_ring): 

""" 

EXAMPLES:: 

 

sage: G = species.SimpleGraphSpecies() 

sage: G.generating_series().coefficients(5) 

[1, 1, 1, 4/3, 8/3] 

""" 

return self._F.generating_series(base_ring).functorial_composition(self._G.generating_series(base_ring)) 

 

def _itgs(self, series_ring, base_ring): 

""" 

EXAMPLES:: 

 

sage: G = species.SimpleGraphSpecies() 

sage: G.isotype_generating_series().coefficients(5) 

[1, 1, 2, 4, 11] 

""" 

return self.cycle_index_series(base_ring).isotype_generating_series() 

 

def _cis(self, series_ring, base_ring): 

""" 

EXAMPLES:: 

 

sage: G = species.SimpleGraphSpecies() 

sage: G.cycle_index_series().coefficients(5) 

[p[], 

p[1], 

p[1, 1] + p[2], 

4/3*p[1, 1, 1] + 2*p[2, 1] + 2/3*p[3], 

8/3*p[1, 1, 1, 1] + 4*p[2, 1, 1] + 2*p[2, 2] + 4/3*p[3, 1] + p[4]] 

""" 

return self._F.cycle_index_series(base_ring).functorial_composition(self._G.cycle_index_series(base_ring)) 

 

def weight_ring(self): 

""" 

Returns the weight ring for this species. This is determined by 

asking Sage's coercion model what the result is when you multiply 

(and add) elements of the weight rings for each of the operands. 

 

EXAMPLES:: 

 

sage: G = species.SimpleGraphSpecies() 

sage: G.weight_ring() 

Rational Field 

""" 

from sage.structure.element import get_coercion_model 

cm = get_coercion_model() 

 

f_weights = self._F.weight_ring() 

g_weights = self._G.weight_ring() 

 

return cm.explain(f_weights, g_weights, verbosity=0) 

 

#Backward compatibility 

FunctorialCompositionSpecies_class = FunctorialCompositionSpecies