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

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

""" 

Ideals of non-commutative rings 

  

Generic implementation of one- and two-sided ideals of non-commutative rings. 

  

AUTHOR: 

  

- Simon King (2011-03-21), <simon.king@uni-jena.de>, :trac:`7797`. 

  

EXAMPLES:: 

  

sage: MS = MatrixSpace(ZZ,2,2) 

sage: MS*MS([0,1,-2,3]) 

Left Ideal 

( 

[ 0 1] 

[-2 3] 

) 

of Full MatrixSpace of 2 by 2 dense matrices over Integer Ring 

sage: MS([0,1,-2,3])*MS 

Right Ideal 

( 

[ 0 1] 

[-2 3] 

) 

of Full MatrixSpace of 2 by 2 dense matrices over Integer Ring 

sage: MS*MS([0,1,-2,3])*MS 

Twosided Ideal 

( 

[ 0 1] 

[-2 3] 

) 

of Full MatrixSpace of 2 by 2 dense matrices over Integer Ring 

  

See :mod:`~sage.algebras.letterplace.letterplace_ideal` for a more 

elaborate implementation in the special case of ideals in free 

algebras. 

  

TESTS:: 

  

sage: A = SteenrodAlgebra(2) 

sage: IL = A*[A.1+A.2,A.1^2]; IL 

Left Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra, milnor basis 

sage: TestSuite(IL).run(skip=['_test_category'],verbose=True) 

running ._test_eq() . . . pass 

running ._test_new() . . . pass 

running ._test_not_implemented_methods() . . . pass 

running ._test_pickling() . . . pass 

""" 

  

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

# Copyright (C) 2011 Simon King <simon.king@uni-jena.de> 

# 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License 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 __future__ import absolute_import 

  

from sage.structure.element cimport MonoidElement 

from sage.structure.parent cimport Parent 

from sage.categories.monoids import Monoids 

from sage.rings.ideal_monoid import IdealMonoid_c 

from sage.rings.ideal import Ideal_generic 

import sage 

  

  

class IdealMonoid_nc(IdealMonoid_c): 

""" 

Base class for the monoid of ideals over a non-commutative ring. 

  

.. NOTE:: 

  

This class is essentially the same as 

:class:`~sage.rings.ideal_monoid.IdealMonoid_c`, 

but does not complain about non-commutative rings. 

  

EXAMPLES:: 

  

sage: MS = MatrixSpace(ZZ,2,2) 

sage: MS.ideal_monoid() 

Monoid of ideals of Full MatrixSpace of 2 by 2 dense matrices over Integer Ring 

  

""" 

def __init__(self, R): 

""" 

Initialize ``self``. 

  

INPUT: 

  

- ``R`` -- A ring. 

  

TESTS:: 

  

sage: from sage.rings.noncommutative_ideals import IdealMonoid_nc 

sage: MS = MatrixSpace(ZZ,2,2) 

sage: IdealMonoid_nc(MS) 

Monoid of ideals of Full MatrixSpace of 2 by 2 dense matrices over Integer Ring 

  

""" 

self._IdealMonoid_c__R = R 

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

category=Monoids()) 

self._populate_coercion_lists_() 

  

def _element_constructor_(self, x): 

r""" 

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

  

INPUT: 

  

- ``x`` -- An ideal, or a list of elements. 

  

TESTS:: 

  

sage: A = SteenrodAlgebra(2) # indirect doctest 

sage: IL = A*[A.1+A.2,A.1^2]; IL 

Left Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra, milnor basis 

sage: IR = [A.1+A.2,A.1^2]*A; IR 

Right Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra, milnor basis 

sage: IT = A*[A.1+A.2,A.1^2]*A; IT 

Twosided Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra, milnor basis 

sage: M = IL.parent() 

sage: M([A.0, 1]) 

Twosided Ideal (Sq(1), 1) of mod 2 Steenrod algebra, milnor basis 

  

:: 

  

sage: IL == loads(dumps(IL)) 

True 

sage: IR == loads(dumps(IR)) 

True 

sage: IT == loads(dumps(IT)) 

True 

  

""" 

side = "twosided" 

if isinstance(x, Ideal_nc): 

side = x.side() 

x = x.gens() 

elif isinstance(x, Ideal_generic): 

x = x.gens() 

cdef MonoidElement y = self._IdealMonoid_c__R.ideal(x, side=side) 

y._parent = self 

return y 

  

  

class Ideal_nc(Ideal_generic): 

""" 

Generic non-commutative ideal. 

  

All fancy stuff such as the computation of Groebner bases must be 

implemented in sub-classes. See :class:`~sage.algebras.letterplace.letterplace_ideal.LetterplaceIdeal` 

for an example. 

  

EXAMPLES:: 

  

sage: MS = MatrixSpace(QQ,2,2) 

sage: I = MS*[MS.1,MS.2]; I 

Left Ideal 

( 

[0 1] 

[0 0], 

<BLANKLINE> 

[0 0] 

[1 0] 

) 

of Full MatrixSpace of 2 by 2 dense matrices over Rational Field 

sage: [MS.1,MS.2]*MS 

Right Ideal 

( 

[0 1] 

[0 0], 

<BLANKLINE> 

[0 0] 

[1 0] 

) 

of Full MatrixSpace of 2 by 2 dense matrices over Rational Field 

sage: MS*[MS.1,MS.2]*MS 

Twosided Ideal 

( 

[0 1] 

[0 0], 

<BLANKLINE> 

[0 0] 

[1 0] 

) 

of Full MatrixSpace of 2 by 2 dense matrices over Rational Field 

  

""" 

def __init__(self, ring, gens, coerce=True, side="twosided"): 

""" 

Initialize ``self``. 

  

INPUT: 

  

- ``ring`` -- A ring. 

  

- ``gens`` -- A list or tuple of elements. 

  

- ``coerce`` (optional bool, default ``True``): First coerce the given 

list of elements into the given ring. 

  

- ``side`` (option string, default ``"twosided"``): Must be ``"left"``, 

``"right"`` or ``"twosided"``. Determines whether the ideal is a 

left, right or twosided ideal. 

  

TESTS:: 

  

sage: MS = MatrixSpace(ZZ,2,2) 

sage: from sage.rings.noncommutative_ideals import Ideal_nc 

sage: Ideal_nc(MS,[MS.1,MS.2], side='left') 

Left Ideal 

( 

[0 1] 

[0 0], 

<BLANKLINE> 

[0 0] 

[1 0] 

) 

of Full MatrixSpace of 2 by 2 dense matrices over Integer Ring 

sage: Ideal_nc(MS,[MS.1,MS.2], side='right') 

Right Ideal 

( 

[0 1] 

[0 0], 

<BLANKLINE> 

[0 0] 

[1 0] 

) 

of Full MatrixSpace of 2 by 2 dense matrices over Integer Ring 

  

""" 

if side not in ['left', 'right', 'twosided']: 

raise ValueError("Ideals are left, right or twosided, but not %s" % side) 

self.__side = side 

Ideal_generic.__init__(self, ring, gens, coerce=coerce) 

  

def __repr__(self): 

""" 

Return a string representation of ``self``. 

  

TESTS:: 

  

sage: A = SteenrodAlgebra(2) 

sage: A*[A.1+A.2,A.1^2] # indirect doctest 

Left Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra, milnor basis 

sage: [A.1+A.2,A.1^2]*A 

Right Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra, milnor basis 

sage: A*[A.1+A.2,A.1^2]*A 

Twosided Ideal (Sq(2) + Sq(4), Sq(1,1)) of mod 2 Steenrod algebra, milnor basis 

  

""" 

return "%s Ideal %s of %s" % (self.__side.capitalize(), 

self._repr_short(), self.ring()) 

  

def __eq__(self, right): 

""" 

Ideals of different sidedness do not compare equal. Apart from 

that, the generators are compared. 

  

EXAMPLES:: 

  

sage: A = SteenrodAlgebra(2) 

sage: IR = [A.1+A.2,A.1^2]*A 

sage: IL = A*[A.1+A.2,A.1^2] 

sage: IT = A*[A.1+A.2,A.1^2]*A 

sage: IT == IL 

False 

sage: IR == [A.1+A.2,A.1^2]*A 

True 

  

""" 

if not isinstance(right, Ideal_nc): 

return False 

if self.side() != right.side(): 

return False 

S = set(self.gens()) 

T = set(right.gens()) 

if S == T: 

return True 

return False 

  

def __ne__(self, right): 

""" 

Ideals of different sidedness do not compare equal. Apart from 

that, the generators are compared. 

  

EXAMPLES:: 

  

sage: A = SteenrodAlgebra(2) 

sage: IR = [A.1+A.2,A.1^2]*A 

sage: IL = A*[A.1+A.2,A.1^2] 

sage: IT = A*[A.1+A.2,A.1^2]*A 

sage: IT != IL 

True 

sage: IR != [A.1+A.2,A.1^2]*A 

False 

  

""" 

return not self.__eq__(right) 

  

def side(self): 

""" 

Return a string that describes the sidedness of this ideal. 

  

EXAMPLES:: 

  

sage: A = SteenrodAlgebra(2) 

sage: IL = A*[A.1+A.2,A.1^2] 

sage: IR = [A.1+A.2,A.1^2]*A 

sage: IT = A*[A.1+A.2,A.1^2]*A 

sage: IL.side() 

'left' 

sage: IR.side() 

'right' 

sage: IT.side() 

'twosided' 

  

""" 

return self.__side 

  

def __mul__(self, other): 

""" 

Multiplication of a one-sided ideal with its ring from the other side 

yields a two-sided ideal. 

  

TESTS:: 

  

sage: MS = MatrixSpace(QQ,2,2) 

sage: IL = MS*[2*MS.0,3*MS.1]; IL 

Left Ideal 

( 

[2 0] 

[0 0], 

<BLANKLINE> 

[0 3] 

[0 0] 

) 

of Full MatrixSpace of 2 by 2 dense matrices over Rational Field 

sage: IR = MS.3*MS; IR 

Right Ideal 

( 

[0 0] 

[0 1] 

) 

of Full MatrixSpace of 2 by 2 dense matrices over Rational Field 

sage: IL*MS # indirect doctest 

Twosided Ideal 

( 

[2 0] 

[0 0], 

<BLANKLINE> 

[0 3] 

[0 0] 

) 

of Full MatrixSpace of 2 by 2 dense matrices over Rational Field 

sage: IR*IR 

Traceback (most recent call last): 

... 

NotImplementedError: Can not multiply non-commutative ideals. 

  

""" 

if not isinstance(other, Ideal_nc): 

# Perhaps other is a ring and thus has its own 

# multiplication. 

if other == self.ring(): 

if self.side() == 'right': 

return self 

return self.ring().ideal(self.gens(), side='twosided') 

if not isinstance(self, Ideal_nc): 

# This may happen... 

if self == other.ring(): 

if other.side() == 'left': 

return other 

return other.ring().ideal(other.gens(), side='twosided') 

raise NotImplementedError("Can not multiply non-commutative ideals.")