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

""" 

Monoid of ideals in a commutative ring 

""" 

from __future__ import absolute_import 

 

from sage.structure.parent import Parent 

import sage.rings.integer_ring 

from . import ideal 

from sage.categories.monoids import Monoids 

 

 

def IdealMonoid(R): 

r""" 

Return the monoid of ideals in the ring ``R``. 

 

EXAMPLES:: 

 

sage: R = QQ['x'] 

sage: sage.rings.ideal_monoid.IdealMonoid(R) 

Monoid of ideals of Univariate Polynomial Ring in x over Rational Field 

""" 

return IdealMonoid_c(R) 

 

 

class IdealMonoid_c(Parent): 

r""" 

The monoid of ideals in a commutative ring. 

 

TESTS:: 

 

sage: R = QQ['x'] 

sage: M = sage.rings.ideal_monoid.IdealMonoid(R) 

sage: TestSuite(M).run() 

Failure in _test_category: 

... 

The following tests failed: _test_elements 

 

(The "_test_category" test fails but I haven't the foggiest idea why.) 

""" 

 

Element = ideal.Ideal_generic # this doesn't seem to do anything 

 

def __init__(self, R): 

r""" 

Initialize ``self``. 

 

TESTS:: 

 

sage: R = QuadraticField(-23, 'a') 

sage: M = sage.rings.ideal_monoid.IdealMonoid(R); M # indirect doctest 

Monoid of ideals of Number Field in a with defining polynomial x^2 + 23 

""" 

self.__R = R 

Parent.__init__(self, base=sage.rings.integer_ring.ZZ, 

category=Monoids()) 

self._populate_coercion_lists_() 

 

def _repr_(self): 

r""" 

Return a string representation of ``self``. 

 

TESTS:: 

 

sage: R = QuadraticField(-23, 'a') 

sage: M = sage.rings.ideal_monoid.IdealMonoid(R); M._repr_() 

'Monoid of ideals of Number Field in a with defining polynomial x^2 + 23' 

""" 

return "Monoid of ideals of %s" % self.__R 

 

def ring(self): 

r""" 

Return the ring of which this is the ideal monoid. 

 

EXAMPLES:: 

 

sage: R = QuadraticField(-23, 'a') 

sage: M = sage.rings.ideal_monoid.IdealMonoid(R); M.ring() is R 

True 

""" 

return self.__R 

 

def _element_constructor_(self, x): 

r""" 

Create an ideal in this monoid from ``x``. 

 

EXAMPLES:: 

 

sage: R.<a> = QuadraticField(-23) 

sage: M = sage.rings.ideal_monoid.IdealMonoid(R) 

sage: M(a) # indirect doctest 

Fractional ideal (a) 

sage: M([a-4, 13]) 

Fractional ideal (13, 1/2*a + 9/2) 

""" 

try: 

side = x.side() 

except (AttributeError, TypeError): 

side = None 

try: 

x = x.gens() 

except AttributeError: 

pass 

if side is None: 

y = self.__R.ideal(x) 

else: 

y = self.__R.ideal(x, side=side) 

y._set_parent(self) 

return y 

 

def _coerce_map_from_(self, x): 

r""" 

Used by coercion framework. 

 

EXAMPLES:: 

 

sage: R = QuadraticField(-23, 'a') 

sage: M = R.ideal_monoid() 

sage: M.has_coerce_map_from(R) # indirect doctest 

True 

sage: M.has_coerce_map_from(QQ.ideal_monoid()) 

True 

sage: M.has_coerce_map_from(Zmod(6)) 

False 

sage: M.has_coerce_map_from(loads(dumps(M))) 

True 

""" 

if isinstance(x, IdealMonoid_c): 

return self.ring().has_coerce_map_from(x.ring()) 

else: 

return self.ring().has_coerce_map_from(x) 

 

def __eq__(self, other): 

r""" 

Check whether ``self`` is not equal to ``other``. 

 

EXAMPLES:: 

 

sage: R = QuadraticField(-23, 'a') 

sage: M = R.ideal_monoid() 

sage: M == QQ 

False 

sage: M == 17 

False 

sage: M == R.ideal_monoid() 

True 

""" 

if not isinstance(other, IdealMonoid_c): 

return False 

else: 

return self.ring() == other.ring() 

 

def __ne__(self, other): 

r""" 

Check whether ``self`` is not equal to ``other``. 

 

EXAMPLES:: 

 

sage: R = QuadraticField(-23, 'a') 

sage: M = R.ideal_monoid() 

sage: M != QQ 

True 

sage: M != 17 

True 

sage: M != R.ideal_monoid() 

False 

""" 

return not (self == other)