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

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

""" 

Morphisms Between Finite Algebras 

""" 

 

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

# Copyright (C) 2011 Johan Bosman <johan.g.bosman@gmail.com> 

# Copyright (C) 2011, 2013 Peter Bruin <peter.bruin@math.uzh.ch> 

# 

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

# as published by the Free Software Foundation; either version 2 of 

# the License, or (at your option) any later version. 

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

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

 

from sage.misc.cachefunc import cached_method 

from sage.categories.homset import Hom 

from sage.rings.morphism import RingHomomorphism_im_gens 

from sage.rings.homset import RingHomset_generic 

from sage.matrix.constructor import matrix 

from sage.structure.element import is_Matrix 

 

class FiniteDimensionalAlgebraMorphism(RingHomomorphism_im_gens): 

""" 

Create a morphism between two :class:`finite-dimensional algebras <FiniteDimensionalAlgebra>`. 

 

INPUT: 

 

- ``parent`` -- the parent homset 

 

- ``f`` -- matrix of the underlying `k`-linear map 

 

- ``unitary`` -- boolean (default: ``True``); if ``True`` and ``check`` 

is also ``True``, raise a ``ValueError`` unless ``A`` and ``B`` are 

unitary and ``f`` respects unit elements 

 

- ``check`` -- boolean (default: ``True``); check whether the given 

`k`-linear map really defines a (not necessarily unitary) 

`k`-algebra homomorphism 

 

The algebras ``A`` and ``B`` must be defined over the same base field. 

 

EXAMPLES:: 

 

sage: from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra_morphism import FiniteDimensionalAlgebraMorphism 

sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) 

sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) 

sage: H = Hom(A, B) 

sage: f = H(Matrix([[1], [0]])) 

sage: f.domain() is A 

True 

sage: f.codomain() is B 

True 

sage: f(A.basis()[0]) 

e 

sage: f(A.basis()[1]) 

0 

 

.. TODO:: An example illustrating unitary flag. 

""" 

def __init__(self, parent, f, check=True, unitary=True): 

""" 

TESTS:: 

 

sage: from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra_morphism import FiniteDimensionalAlgebraMorphism 

sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) 

sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) 

sage: H = Hom(A, B) 

sage: phi = FiniteDimensionalAlgebraMorphism(H, Matrix([[1, 0]])) 

sage: TestSuite(phi).run(skip="_test_category") 

""" 

A = parent.domain() 

B = parent.codomain() 

 

RingHomomorphism_im_gens.__init__(self, parent=parent, im_gens=f.rows(), check=check) 

self._matrix = f 

 

if unitary and check and (not A.is_unitary() 

or not B.is_unitary() 

or self(A.one()) != B.one()): 

raise ValueError("homomorphism does not respect unit elements") 

 

def _repr_(self): 

""" 

TESTS:: 

 

sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) 

sage: I = A.maximal_ideal() 

sage: q = A.quotient_map(I) 

sage: q._repr_() 

'Morphism from Finite-dimensional algebra of degree 2 over Rational Field to Finite-dimensional algebra of degree 1 over Rational Field given by matrix\n[1]\n[0]' 

""" 

return "Morphism from {} to {} given by matrix\n{}".format( 

self.domain(), self.codomain(), self._matrix) 

 

def __call__(self, x): 

""" 

TESTS:: 

 

sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) 

sage: I = A.maximal_ideal() 

sage: q = A.quotient_map(I) 

sage: q(0) == 0 and q(1) == 1 

True 

""" 

x = self.domain()(x) 

B = self.codomain() 

return B.element_class(B, x.vector() * self._matrix) 

 

def __eq__(self, other): 

""" 

Check equality. 

 

TESTS:: 

 

sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) 

sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) 

sage: H = Hom(A, B) 

sage: phi = H(Matrix([[1, 0]])) 

sage: psi = H(Matrix([[1, 0]])) 

sage: phi == psi 

True 

sage: phi == H.zero() 

False 

""" 

return (isinstance(other, FiniteDimensionalAlgebraMorphism) 

and self.parent() == other.parent() 

and self._matrix == other._matrix) 

 

def __ne__(self, other): 

""" 

Check not equals. 

 

TESTS:: 

 

sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) 

sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) 

sage: H = Hom(A, B) 

sage: phi = H(Matrix([[1, 0]])) 

sage: psi = H(Matrix([[1, 0]])) 

sage: phi != psi 

False 

sage: phi != H.zero() 

True 

""" 

return not self == other 

 

def matrix(self): 

""" 

Return the matrix of ``self``. 

 

EXAMPLES:: 

 

sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) 

sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) 

sage: M = Matrix([[1], [0]]) 

sage: H = Hom(A, B) 

sage: f = H(M) 

sage: f.matrix() == M 

True 

""" 

return self._matrix 

 

def inverse_image(self, I): 

""" 

Return the inverse image of ``I`` under ``self``. 

 

INPUT: 

 

- ``I`` -- ``FiniteDimensionalAlgebraIdeal``, an ideal of ``self.codomain()`` 

 

OUTPUT: 

 

-- ``FiniteDimensionalAlgebraIdeal``, the inverse image of `I` under ``self``. 

 

EXAMPLES:: 

 

sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) 

sage: I = A.maximal_ideal() 

sage: q = A.quotient_map(I) 

sage: B = q.codomain() 

sage: q.inverse_image(B.zero_ideal()) == I 

True 

""" 

coker_I = I.basis_matrix().transpose().kernel().basis_matrix().transpose() 

return self.domain().ideal((self._matrix * coker_I).kernel().basis_matrix(), given_by_matrix=True) 

 

class FiniteDimensionalAlgebraHomset(RingHomset_generic): 

""" 

Set of morphisms between two finite-dimensional algebras. 

""" 

@cached_method 

def zero(self): 

""" 

Construct the zero morphism of ``self``. 

 

EXAMPLES:: 

 

sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) 

sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) 

sage: H = Hom(A, B) 

sage: H.zero() 

Morphism from Finite-dimensional algebra of degree 1 over Rational Field to 

Finite-dimensional algebra of degree 2 over Rational Field given by matrix 

[0 0] 

""" 

from sage.matrix.constructor import matrix 

return FiniteDimensionalAlgebraMorphism(self, matrix.zero(self.domain().ngens(), 

self.codomain().ngens()), 

False, False) 

 

def __call__(self, f, check=True, unitary=True): 

""" 

Construct a homomorphism. 

 

.. TODO:: 

 

Implement taking generator images and converting them to a matrix. 

 

EXAMPLES:: 

 

sage: A = FiniteDimensionalAlgebra(QQ, [Matrix([1])]) 

sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])]) 

sage: H = Hom(A, B) 

sage: H(Matrix([[1, 0]])) 

Morphism from Finite-dimensional algebra of degree 1 over Rational Field to 

Finite-dimensional algebra of degree 2 over Rational Field given by matrix 

[1 0] 

""" 

if isinstance(f, FiniteDimensionalAlgebraMorphism): 

if f.parent() is self: 

return f 

if f.parent() == self: 

return FiniteDimensionalAlgebraMorphism(self, f._matrix, check, unitary) 

elif is_Matrix(f): 

return FiniteDimensionalAlgebraMorphism(self, f, check, unitary) 

try: 

from sage.matrix.constructor import Matrix 

return FiniteDimensionalAlgebraMorphism(self, Matrix(f), check, unitary) 

except Exception: 

return RingHomset_generic.__call__(self, f, check)