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

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

r""" 

Dual groups of Finite Multiplicative Abelian Groups 

 

The basic idea is very simple. Let G be an abelian group and `G^*` its 

dual (i.e., the group of homomorphisms from G to `\CC^\times`). Let 

`g_j`, `j=1,..,n`, denote generators of `G` - say `g_j` is of order 

`m_j>1`. There are generators `X_j`, `j=1,..,n`, of `G^*` for which 

`X_j(g_j)=\exp(2\pi i/m_j)` and `X_i(g_j)=1` if `i\not= j`. These are 

used to construct `G^*`. 

 

Sage supports multiplicative abelian groups on any prescribed finite 

number `n > 0` of generators. Use 

:func:`~sage.groups.abelian_gps.abelian_group.AbelianGroup` function 

to create an abelian group, the 

:meth:`~sage.groups.abelian_gps.abelian_group.AbelianGroup_class.dual_group` 

method to create its dual, and then the :meth:`gen` and :meth:`gens` 

methods to obtain the corresponding generators. You can print the 

generators as arbitrary strings using the optional ``names`` argument 

to the 

:meth:`~sage.groups.abelian_gps.abelian_group.AbelianGroup_class.dual_group` 

method. 

 

EXAMPLES:: 

 

sage: F = AbelianGroup(5, [2,5,7,8,9], names='abcde') 

sage: (a, b, c, d, e) = F.gens() 

 

sage: Fd = F.dual_group(names='ABCDE') 

sage: Fd.base_ring() 

Cyclotomic Field of order 2520 and degree 576 

sage: A,B,C,D,E = Fd.gens() 

sage: A(a) 

-1 

sage: A(b), A(c), A(d), A(e) 

(1, 1, 1, 1) 

 

sage: Fd = F.dual_group(names='ABCDE', base_ring=CC) 

sage: A,B,C,D,E = Fd.gens() 

sage: A(a) # abs tol 1e-8 

-1.00000000000000 + 0.00000000000000*I 

sage: A(b); A(c); A(d); A(e) 

1.00000000000000 

1.00000000000000 

1.00000000000000 

1.00000000000000 

 

AUTHORS: 

 

- David Joyner (2006-08) (based on abelian_groups) 

 

- David Joyner (2006-10) modifications suggested by William Stein 

 

- Volker Braun (2012-11) port to new Parent base. Use tuples for immutables. 

Default to cyclotomic base ring. 

""" 

 

########################################################################### 

# Copyright (C) 2006 William Stein <wstein@gmail.com> 

# Copyright (C) 2006 David Joyner <wdjoyner@gmail.com> 

# Copyright (C) 2012 Volker Braun <vbraun.name@gmail.com> 

# 

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

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

########################################################################### 

from __future__ import print_function 

 

from sage.rings.infinity import infinity 

from sage.structure.category_object import normalize_names 

from sage.structure.unique_representation import UniqueRepresentation 

from sage.groups.abelian_gps.dual_abelian_group_element import ( 

DualAbelianGroupElement, is_DualAbelianGroupElement ) 

from sage.misc.mrange import mrange 

from sage.misc.cachefunc import cached_method 

from sage.groups.group import AbelianGroup as AbelianGroupBase 

 

 

def is_DualAbelianGroup(x): 

""" 

Return True if `x` is the dual group of an abelian group. 

 

EXAMPLES:: 

 

sage: from sage.groups.abelian_gps.dual_abelian_group import is_DualAbelianGroup 

sage: F = AbelianGroup(5,[3,5,7,8,9], names=list("abcde")) 

sage: Fd = F.dual_group() 

sage: is_DualAbelianGroup(Fd) 

True 

sage: F = AbelianGroup(3,[1,2,3], names='a') 

sage: Fd = F.dual_group() 

sage: Fd.gens() 

(1, X1, X2) 

sage: F.gens() 

(1, a1, a2) 

""" 

return isinstance(x, DualAbelianGroup_class) 

 

 

class DualAbelianGroup_class(UniqueRepresentation, AbelianGroupBase): 

""" 

Dual of abelian group. 

 

EXAMPLES:: 

 

sage: F = AbelianGroup(5,[3,5,7,8,9], names="abcde") 

sage: F.dual_group() 

Dual of Abelian Group isomorphic to Z/3Z x Z/5Z x Z/7Z x Z/8Z x Z/9Z 

over Cyclotomic Field of order 2520 and degree 576 

sage: F = AbelianGroup(4,[15,7,8,9], names="abcd") 

sage: F.dual_group(base_ring=CC) 

Dual of Abelian Group isomorphic to Z/15Z x Z/7Z x Z/8Z x Z/9Z 

over Complex Field with 53 bits of precision 

""" 

Element = DualAbelianGroupElement 

 

def __init__(self, G, names, base_ring): 

""" 

The Python constructor 

 

EXAMPLES:: 

 

sage: F = AbelianGroup(5,[3,5,7,8,9], names="abcde") 

sage: F.dual_group() 

Dual of Abelian Group isomorphic to Z/3Z x Z/5Z x Z/7Z x Z/8Z x Z/9Z 

over Cyclotomic Field of order 2520 and degree 576 

""" 

self._base_ring = base_ring 

self._group = G 

names = normalize_names(G.ngens(), names) 

self._assign_names(names) 

AbelianGroupBase.__init__(self) # TODO: category=CommutativeGroups() 

 

def group(self): 

""" 

Return the group that ``self`` is the dual of. 

 

EXAMPLES:: 

 

sage: F = AbelianGroup(3,[5,64,729], names=list("abc")) 

sage: Fd = F.dual_group(base_ring=CC) 

sage: Fd.group() is F 

True 

""" 

return self._group 

 

def base_ring(self): 

""" 

Return the scalars over which the group is dualized. 

 

EXAMPLES:: 

 

sage: F = AbelianGroup(3,[5,64,729], names=list("abc")) 

sage: Fd = F.dual_group(base_ring=CC) 

sage: Fd.base_ring() 

Complex Field with 53 bits of precision 

""" 

return self._base_ring 

 

def __str__(self): 

""" 

Print method. 

 

EXAMPLES:: 

 

sage: F = AbelianGroup(3,[5,64,729], names=list("abc")) 

sage: Fd = F.dual_group(base_ring=CC) 

sage: print(Fd) 

DualAbelianGroup( AbelianGroup ( 3, (5, 64, 729) ) ) 

""" 

s = "DualAbelianGroup( AbelianGroup ( %s, %s ) )"%(self.ngens(), self.gens_orders()) 

return s 

 

def _repr_(self): 

""" 

Return a string representation. 

 

EXAMPLES:: 

 

sage: F = AbelianGroup(5, [2,5,7,8,9], names='abcde') 

sage: Fd = F.dual_group(names='ABCDE', base_ring=CyclotomicField(2*5*7*8*9)) 

sage: Fd # indirect doctest 

Dual of Abelian Group isomorphic to Z/2Z x Z/5Z x Z/7Z x Z/8Z x Z/9Z 

over Cyclotomic Field of order 5040 and degree 1152 

sage: Fd = F.dual_group(names='ABCDE', base_ring=CC) 

sage: Fd 

Dual of Abelian Group isomorphic to Z/2Z x Z/5Z x Z/7Z x Z/8Z x Z/9Z 

over Complex Field with 53 bits of precision 

""" 

G = self.group() 

eldv = G.gens_orders() 

gp = "" 

for x in eldv: 

if x!=0: 

gp = gp + "Z/%sZ x "%x 

if x==0: 

gp = gp + "Z x " 

gp = gp[:-2].strip() 

s = 'Dual of Abelian Group isomorphic to ' + gp + ' over ' + str(self.base_ring()) 

return s 

 

def _latex_(self): 

r""" 

Return latex representation of this group. 

 

EXAMPLES:: 

 

sage: F = AbelianGroup(3, [2]*3) 

sage: Fd = F.dual_group() 

sage: Fd._latex_() 

'$\\mathrm{DualAbelianGroup}( AbelianGroup ( 3, (2, 2, 2) ) )$' 

""" 

s = "$\mathrm{DualAbelianGroup}( AbelianGroup ( %s, %s ) )$"%(self.ngens(), self.gens_orders()) 

return s 

 

def random_element(self): 

""" 

Return a random element of this dual group. 

 

EXAMPLES:: 

 

sage: G = AbelianGroup([2,3,9]) 

sage: Gd = G.dual_group(base_ring=CC) 

sage: Gd.random_element() 

X1^2 

 

sage: N = 43^2-1 

sage: G = AbelianGroup([N],names="a") 

sage: Gd = G.dual_group(names="A", base_ring=CC) 

sage: a, = G.gens() 

sage: A, = Gd.gens() 

sage: x = a^(N/4); y = a^(N/3); z = a^(N/14) 

sage: X = A*Gd.random_element(); X 

A^615 

sage: len([a for a in [x,y,z] if abs(X(a)-1)>10^(-8)]) 

2 

""" 

from sage.misc.prandom import randint 

result = self.one() 

for g in self.gens(): 

order = g.order() 

result *= g**(randint(0,order)) 

return result 

 

def gen(self, i=0): 

""" 

The `i`-th generator of the abelian group. 

 

EXAMPLES:: 

 

sage: F = AbelianGroup(3,[1,2,3],names='a') 

sage: Fd = F.dual_group(names="A") 

sage: Fd.0 

1 

sage: Fd.1 

A1 

sage: Fd.gens_orders() 

(1, 2, 3) 

""" 

n = self.group().ngens() 

if i < 0 or i >= n: 

raise IndexError("Argument i (= %s) must be between 0 and %s."%(i, n-1)) 

x = [0]*n 

if self.gens_orders()[i] != 1: 

x[i] = 1 

return self.element_class(self, x) 

 

def gens(self): 

""" 

Return the generators for the group. 

 

OUTPUT: 

 

A tuple of group elements generating the group. 

 

EXAMPLES:: 

 

sage: F = AbelianGroup([7,11]).dual_group() 

sage: F.gens() 

(X0, X1) 

""" 

n = self.group().ngens() 

return tuple(self.gen(i) for i in range(n)) 

 

def ngens(self): 

""" 

The number of generators of the dual group. 

 

EXAMPLES:: 

 

sage: F = AbelianGroup([7]*100) 

sage: Fd = F.dual_group() 

sage: Fd.ngens() 

100 

""" 

return self.group().ngens() 

 

def gens_orders(self): 

""" 

The orders of the generators of the dual group. 

 

OUTPUT: 

 

A tuple of integers. 

 

EXAMPLES:: 

 

sage: F = AbelianGroup([5]*1000) 

sage: Fd = F.dual_group() 

sage: invs = Fd.gens_orders(); len(invs) 

1000 

""" 

return self.group().gens_orders() 

 

def invariants(self): 

""" 

The invariants of the dual group. 

 

You should use :meth:`gens_orders` instead. 

 

EXAMPLES:: 

 

sage: F = AbelianGroup([5]*1000) 

sage: Fd = F.dual_group() 

sage: invs = Fd.gens_orders(); len(invs) 

1000 

""" 

# TODO: deprecate 

return self.group().gens_orders() 

 

def __contains__(self,X): 

""" 

Implements "in". 

 

EXAMPLES:: 

 

sage: F = AbelianGroup(5,[2, 3, 5, 7, 8], names="abcde") 

sage: a,b,c,d,e = F.gens() 

sage: Fd = F.dual_group(names = "ABCDE") 

sage: A,B,C,D,E = Fd.gens() 

sage: A*B^2*D^7 in Fd 

True 

""" 

return X.parent() == self and is_DualAbelianGroupElement(X) 

 

def order(self): 

""" 

Return the order of this group. 

 

EXAMPLES:: 

 

sage: G = AbelianGroup([2,3,9]) 

sage: Gd = G.dual_group() 

sage: Gd.order() 

54 

""" 

G = self.group() 

return G.order() 

 

def is_commutative(self): 

""" 

Return True since this group is commutative. 

 

EXAMPLES:: 

 

sage: G = AbelianGroup([2,3,9]) 

sage: Gd = G.dual_group() 

sage: Gd.is_commutative() 

True 

sage: Gd.is_abelian() 

True 

""" 

return True 

 

@cached_method 

def list(self): 

""" 

Return tuple of all elements of this group. 

 

EXAMPLES:: 

 

sage: G = AbelianGroup([2,3], names="ab") 

sage: Gd = G.dual_group(names="AB") 

sage: Gd.list() 

(1, B, B^2, A, A*B, A*B^2) 

""" 

if not(self.is_finite()): 

raise NotImplementedError("Group must be finite") 

invs = self.gens_orders() 

T = mrange(invs) 

n = self.order() 

L = tuple( self(t) for t in T ) 

return L 

 

def __iter__(self): 

""" 

Return an iterator over the elements of this group. 

 

EXAMPLES:: 

 

sage: G = AbelianGroup([2,3], names="ab") 

sage: Gd = G.dual_group(names="AB") 

sage: [X for X in Gd] 

[1, B, B^2, A, A*B, A*B^2] 

sage: N = 43^2-1 

sage: G = AbelianGroup([N],names="a") 

sage: Gd = G.dual_group(names="A", base_ring=CC) 

sage: a, = G.gens() 

sage: A, = Gd.gens() 

sage: x = a^(N/4) 

sage: y = a^(N/3) 

sage: z = a^(N/14) 

sage: len([X for X in Gd if abs(X(x)-1)>0.01 and abs(X(y)-1)>0.01 and abs(X(z)-1)>0.01]) 

880 

""" 

for g in self.list(): 

yield g