Applications of Abstract Algebra with MAPLE c 1999 by CRC Press LLC Applications of Abstract Algebra with MAPLE Richard E Klima Neil Sigmon Ernest Stitzinger CRC Press Boca Raton London New York Washington, D.C Library of Congress Cataloging-in-Publication Data Klima, Richard E Applications of abstract algebra with Maple / Richard E Klima, Neil P Sigmon, Ernest Stitzinger p cm - (Discrete mathematics and its applications) Includes bibliographical references and index ISBN 0-8493-8170-3 (alk paper) Algebra, Abstract—Data processing Maple (Computer file) I Stitzinger, Ernest II Sigmon, Neil P III Title IV Series QAl62.K65 1999 12´.02´02855369—dc2 99-37392 CIP This book contains information obtained from authentic and highly regarded sources Reprinted material is quoted with permission, and sources are indicated A wide variety of references are listed Reasonable efforts have been made to publish reliable data and information, but the authors and the publisher cannot assume responsibility for the validity of all materials or for the consequences of their use Neither this book nor any part may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, microfilming, and recording, or by any information storage or retrieval system, without prior permission in writing from the publisher The consent of CRC Press LLC does not extend to copying for general distribution, for promotion, for creating new works, or for resale Specific permission must be obtained in writing from CRC Press LLC for such copying Direct all inquiries to CRC Press LLC, 2000 N.W Corporate Blvd., Boca Raton, Florida 33431 Trademarks Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation, without intent to infringe Visit the CRC Press Web site at www.crcpress.com © 1999 by CRC Press LLC No claim to original U.S Government works International Standard Book Number 0-8493-8170-3 Library of Congress Card Number 99-37392 Printed in the United States of America Printed on acid-free paper Preface In 1990 we introduced a one-semester applications of algebra course at North Carolina State University for students who had successfully completed semesters of linear and abstract algebra We intended for the course to give students more exposure to basic algebraic concepts, and to show students some practical uses of these concepts The course was received enthusiastically by both students and faculty and has become one of the most popular mathematics electives at NC State When we were originally deciding on material for the course, we knew that we wanted to include several topics from coding theory, cryptography, and counting (what we call Polya theory) With this in mind, at the suggestion of Michael Singer, we used George Mackiw’s book Applications of Abstract Algebra for the first few years, and supplemented as we saw fit After several years, Mackiw’s book went out of print temporarily Rather than search for a new book for the course, we decided to write our own notes and teach the course from a coursepack About the same time, NC State incorporated the mathematics software package Maple VT M into its calculus sequence, and we decided to incorporate it into our course as well The use of Maple played a central role in the recent development of the course because it provides a way for students to see realistic examples of the topics discussed without having to struggle with extensive computations With additional notes regarding the use of Maple in the course, our coursepack evolved into this book In addition to the topics discussed in this book, we have included a number of other topics in the course However, the present material has become the constant core for the course Our philosophy concerning the use of technology in the course is that it be a useful tool and not present new problems or frustrations Consequently, we have included very detailed instructions regarding the use of Maple V is a registered trademark of Waterloo Maple, Inc., 57 Erb St W, Waterloo, Canada N2L6C2, www.maplesoft.com c 1999 by CRC Press LLC Maple in this book It is our hope that the Maple discussions are thorough enough to allow it to be used without much alternative aid As alternative aids, we have included a basic Maple tutorial in Appendix A, and an introduction to some of Maple’s linear algebra commands in Appendix B Although we not require students to produce the Maple code used in the course, we require that they obtain a level of proficiency such that they can make basic changes to provided worksheets to complete numerous Maple exercises So that this book can be used for applications of algebra courses in which Maple is not incorporated, we have separated all Maple material into sections that are clearly labeled, and separated all Maple and non-Maple exercises When teaching the course, we discuss the material in Chapter as needed rather than review it all at once More specifically, we discuss the material in Chapter through examples the first time it is needed in the applications that follow Some of the material in Chapter is review material that does not apply specifically to the applications that follow However, for students with weak backgrounds, Chapter provides a comprehensive review of all necessary prerequisite mathematics Chapter is a short chapter on block designs In Chapters 3, 4, and we discuss some topics from coding theory In Chapter we introduce error-correcting codes, and present Hadamard, Reed-Muller, and Hamming codes In Chapters and 5, we present BCH codes and Reed-Solomon codes Each of these chapters are dependent in part on the preceding chapters The dependency of Chapter on Chapter can be avoided by omitting Sections 3.2, 3.3, and 3.4 on Hadamard and Reed-Muller codes In Chapters 6, 7, and we discuss some topics from cryptography In Chapter we introduce algebraic cryptography, and present several variations of the Hill cryptosystem In Chapter we present the RSA cryptosystem and discuss some related topics, including the Diffie-Hellman key exchange In Chapter we present the ElGamal cryptosystem, and describe how elliptic curves can be incorporated into the system naturally There is a slight dependency of Chapters and on Chapter 6, and of Chapter on Chapter Chapter is a stand-alone chapter in which we discuss the Polya counting techniques, including Burnside’s Theorem and the Polya Enumeration Theorem We wish to thank all those who have been involved in the development of this course and book Pete Hardy taught from the coursepack and improved it with his suggestions Also, Michael Singer suggested various topics and wrote notes on some of them Many students have written on this material for various projects Of these, the recent master’s project by Karen Klein on elliptic curves was especially interesting Finally, we wish to c 1999 by CRC Press LLC thank our mentor, Jack Levine, for his interest in our projects, his guidance as we learned about applications of algebra, and his many contributions to the subject, especially in cryptography c 1999 by CRC Press LLC Contents Preface Preliminary Mathematics 1.1 Permutation Groups 1.2 Cosets and Quotient Groups 1.3 Rings and Euclidean Domains 1.4 Finite Fields 1.5 Finite Fields with Maple 1.6 The Euclidean Algorithm Block Designs 2.1 General Properties of Block Designs 2.2 Hadamard Matrices 2.3 Hadamard Matrices with Maple 2.4 Difference Sets 2.5 Difference Sets with Maple Error-Correcting Codes 3.1 General Properties of Codes 3.2 Hadamard Codes 3.3 Reed-Muller Codes c 1999 by CRC Press LLC 3.4 Reed-Muller Codes with Maple 3.5 Linear Codes 3.6 Hamming Codes with Maple BCH Codes 4.1 Construction of BCH Codes 4.2 Error Correction in BCH Codes 4.3 BCH Codes with Maple 4.3.1 Construction of the Generator Polynomial 4.3.2 Error Correction Reed-Solomon Codes 5.1 Construction of Reed-Solomon Codes 5.2 Error Correction in Reed-Solomon Codes 5.3 Proof of Reed-Solomon Error Correction 5.4 Binary Reed-Solomon Codes 5.5 Reed-Solomon Codes with Maple 5.5.1 5.5.2 5.6 Construction of the Codewords Error Correction Reed-Solomon Codes in Voyager Algebraic Cryptography 6.1 Some Elementary Cryptosystems 6.2 The Hill Cryptosystem 6.3 The Hill Cryptosystem with Maple 6.4 Generalizations of the Hill Cryptosystem 6.5 The Two-Message Problem The RSA Cryptosystem 7.1 Mathematical Prerequisites c 1999 by CRC Press LLC 7.2 RSA Encryption and Decryption 7.3 The RSA Cryptosystem with Maple 7.4 A Note on Modular Exponentiation 7.5 A Note on Primality Testing 7.6 A Note on Integer Factorization 7.7 A Note on Digital Signatures 7.8 The Diffie-Hellman Key Exchange Elliptic Curve Cryptography 8.1 The ElGamal Cryptosystem 8.2 The ElGamal Cryptosystem with Maple 8.3 Elliptic Curves 8.4 Elliptic Curves with Maple 8.5 Elliptic Curve Cryptography 8.6 Elliptic Curve Cryptography with Maple Polya Theory 9.1 Group Actions 9.2 Burnside’s Theorem 9.3 The Cycle Index 9.4 The Pattern Inventory 9.5 The Pattern Inventory with Maple 9.6 Switching Functions 9.7 Switching Functions with Maple Appendices A Basic Maple Tutorial A.1 Introduction to Maple A.2 Arithmetic c 1999 by CRC Press LLC A.3 Defining Variables and Functions A.4 Algebra A.5 Case Sensitivity A.6 Help File A.7 Arrays and Loops A.8 Conditional Statements A.9 Maple Procedures B Some Maple Linear Algebra Commands C User-Written Maple Procedures C.1 Chapter Procedures C.2 Chapter Procedures C.3 Chapter Procedures C.4 Chapter Procedures Hints and Solutions to Selected Written Exercises c 1999 by CRC Press LLC Appendix C User-Written Maple Procedures C.1 Chapter Procedures rscoeff := proc(f, x, p, a) local g, i, j, ng, cg, fs, field, ftable; fs := 2^(degree(p)); field := linalg[vector](fs); for i from to fs-1 field[i] := Powmod(a, i, p, a) mod 2: od: field[fs] := 0; ftable := table(); for i from to fs-1 ftable[ field[i] ] := a^i: od: ftable[ field[fs] ] := 0; g := expand(f) mod 2; ng := 0; for j from to degree(g,x) cg := coeff(g, x, j): cg := ftable[ Rem(numer(cg), p, a) mod ] / ftable[ Rem(denom(cg), p, a) mod ]; if degree(cg,a) < then c 1999 by CRC Press LLC cg := cg * a^(fs-1); fi: if degree(cg,a) = (fs-1) then cg := cg/a^(fs-1); fi: ng := ng + cg*x^j: od: g := sort(ng mod 2, x); RETURN(g); end: binmess := proc(cw, n, p, a, ml) local i, j, bvect, vs, pco, dga, binmat, binvect; for i from to ml pco := coeff(cw, x, i): if pco then dga := degree(pco, a): pco := Powmod(a, dga, p, a) mod 2: fi: vs := []: for j from to n-1 vs := [op(vs), coeff(pco, a, j)]: od: if i = then binmat := linalg[matrix](1, n, vs): else binmat := linalg[stackmatrix](binmat, vs): fi: od: binvect := convert(binmat, vector); RETURN(evalm(binvect)); end: bincoeff := proc(n, bmess) local i, j, k, bk, pcoeff, poly; pcoeff := []: bk := linalg[vectdim](bmess); i := 0; k := 0; c 1999 by CRC Press LLC while i < bk poly := 0: for j from to n poly := poly + bmess[i+j]*a^(j-1): od: pcoeff := [op(pcoeff), poly]: k := k+1; i := k*n; od: RETURN(evalm(pcoeff)): end: rseuclid := proc(t, f, g, z, p, a) local q, r, rm1, rp1, um1, u, up1, vm1, v, vp1, i; rm1 := sort(Expand(f) mod 2); r := sort(Expand(g) mod 2); um1 := 1; u := 0; vm1 := 0; v := 1; read(rscoeff); while degree(r,z) >= t rp1 := Rem(rm1, r, z, ’q’) mod 2; rp1 := rscoeff(rp1, z, p, a); q := rscoeff(q, z, p, a); vp1 := expand(vm1 - v*q) mod 2; vm1 := v; v := sort(vp1, z); v := rscoeff(v, z, p, a); up1 := expand(um1 - u*q) mod 2; um1 := u; u := sort(up1); u := rscoeff(u, z, p, a); rm1 := r; r := sort(rp1, z); print(‘Q = ‘, q, ‘ R = ‘, r, ‘ V = ‘, v, ‘ U = ‘, u); od; print(); RETURN(q, r, v, u): end: c 1999 by CRC Press LLC C.2 Chapter Procedures Note: The following two procedures are variations of procedures found in the examples folder of the Maple V Release student version (see [27]) produced by Waterloo Maple Inc and the University of Waterloo to_number := proc(mess) local sl, cn, sn, ii, ntable; ntable := table([’a’=0, ’b’=1, ’c’=2, ’d’=3, ’e’=4, ’f’=5, ’g’=6, ’h’=7, ’i’=8, ’j’=9, ’k’=10, ’l’=11, ’m’=12, ’n’=13, ’o’=14, ’p’=15, ’q’=16, ’r’=17, ’s’=18, ’t’=19, ’u’=20, ’v’=21, ’w’=22, ’x’=23, ’y’=24, ’z’=25]): sl := length(mess); cn := 0; for ii from to sl sn := ntable[substring(mess, ii ii)]: cn := 100*cn + sn: od: RETURN(cn): end: to_letter := proc(num) local cs, cn, sl, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, ltable, ans; ltable := table([0=a, 1=b, 2=c, 3=d, 4=e, 5=f, 6=g, 7=h, 8=i, 9=j, 10=k, 11=l, 12=m, 13=n, 14=o, 15=p, 16=q, 17=r, 18=s, 19=t, 20=u, 21=v, 22=w, 23=x, 24=y, 25=z]); cn := num; sl := floor(trunc(evalf(log10(cn)))/2) + 1: ans := ‘‘; for i from to sl cn := cn/100; cs := ltable[frac(cn)*100]; ans := cat(cs, ans); cn := trunc(cn); od: RETURN(ans); end: c 1999 by CRC Press LLC C.3 Chapter Procedures epoints := proc(ec, x, ub, p) local ecurve, z, pct, k, i; pct := 0; for k from to p-1 while pct ub then pct := ub: fi: seq(ecurve[i], i = pct): end: addec := proc(le, re, c, p) local i, cle, cre, lambda, res, x3, y3; cle := le mod p; cre := re mod p; if cle = or cre = then res := cle + cre; elif cle[1] = cre[1] and cle[2] = -cre[2] mod p then res := 0; else if cle[1] = cre[1] mod p and cle[2] = cre[2] mod p then lambda := ((3*cle[1]^2+c)/2/cle[2]) mod p; else lambda := (cre[2]-cle[2])/(cre[1]-cle[1]) mod p; fi: c 1999 by CRC Press LLC x3 := (lambda^2-cle[1]-cre[1]) mod p; y3 := (lambda*(cle[1]-x3)-cle[2]) mod p; res := [x3, y3]; fi: res; end: elgamal := proc(alpha, e, c, p) local calpha, n, y; read(addec); calpha := alpha; n := e; y := 0; while n > if irem(n, 2, ’n’) = then y := addec(calpha, y, c, p): fi: calpha := addec(calpha, calpha, c, p): od: y; end: C.4 Chapter Procedures switch := proc(n, x, maxsub) local vs, i, j, k, pg, bk, nsw, pe, bki, pn, allpoly, mon, nlist, dg, vres, colist, pnum, part, pgel, jnum, vt, pct, multiplicity, m; vs := linalg[vector](n, 0); vt := linalg[vector](n, 0); nsw := 2^n; read(ppoly); multiplicity := proc(y, j) j[y] := j[y] + 1; end: allpoly := 0; nlist := {}; pg := []: c 1999 by CRC Press LLC colist := []: for pnum from to combinat[numbpart](n) for i from to n j[i] := 0: od: if pnum = then part := combinat[firstpart](n); else part := combinat[nextpart](part); fi: map(multiplicity, part, ’j’): pgel := []; pct := 0; for i from to n for jnum from to j[i] pgel := [op(pgel), [seq(pct + (jnum-1)*i + k, k = i)]]; od: pct := pct + i*j[i]; od: pg := [op(pg), pgel]; colist := [op(colist), product(1/(’k’^j[’k’]*j[’k’]!), ’k’ = n)]; od: m := 1; for i from to nops(pg) pe := pg[i]; nlist := {}; mon := 1; dg := 0; for j from to nsw-1 bk := convert(j, base, 2); bki := linalg[vectdim](bk); for k from to n vs[k] := 0; od; for k from to bki vs[k] := bk[k]; od: for k from to linalg[vectdim](vs) vt[linalg[vectdim](vs)-k+1] := vs[k]; od: vres := ppoly(pe, vs, n, x, nlist, m); c 1999 by CRC Press LLC pn := vres[1]; nlist := nlist union vres[2]; dg := dg + vres[3]; m := vres[4]; mon := simplify(mon*pn); od: mon := colist[i] * mon * x[1]^(2^n-dg); allpoly := simplify(allpoly + mon); od: maxsub := m; RETURN(allpoly); end: ppoly := proc(pe, vb, n, x, nlist, max) local i, j, dcycle, clen, ob10, nb10, res, cyct, vs, vc, plist, k, dg, nsum, tmp, m, ct, tmax; vs := []; vc := []; plist := {}; tmax := max; for i from to n vs := [vb[i], op(vs)]; vc := [vb[i], op(vc)]; od: res := 1; dg := 0; cyct := 0; if linalg[vectdim](pe) = then res := res * x[1]; dg := dg + 1; fi: if linalg[vectdim](pe) then ob10 := convert([seq(vs[linalg[vectdim](vs) - ct + 1], ct = linalg[vectdim](vs))], base, 2, 10); if linalg[vectdim](ob10) > then m := linalg[vectdim](ob10); nsum := 0; for i from to m nsum := nsum + ob10[m-i+1]*10^(m-i); od: ob10 := subsop(1 = nsum, ob10); c 1999 by CRC Press LLC fi: if linalg[vectdim](ob10) = then res := res*x[1]; dg := dg+1; plist := plist union {0}; else if (member(ob10[1], nlist) = false) and (linalg[vectdim](pe) 0) then plist := plist union {ob10[1]}; nb10 := -1; cyct := 0; while nb10 ob10[1] cyct := cyct + 1; for i from to linalg[vectdim](pe) dcycle := pe[i]; clen := linalg[vectdim](dcycle); for j from to clen-1 vs := subsop(dcycle[j+1]= vc[dcycle[j]], vs); od; vs := subsop(dcycle[1] = vc[dcycle[clen]], vs); for k from to n vc := subsop(k = vs[k], vc); od: od: plist := plist union {nb10}; if linalg[vectdim](convert ([seq(vs[linalg[vectdim](vs) - ct + 1], ct = linalg[vectdim](vs))], base, 2, 10)) > then nsum := 0; tmp := convert ([seq(vs[linalg[vectdim](vs) - ct + 1], ct = linalg[vectdim](vs))], base, 2, 10); m := linalg[vectdim](tmp); for i from to m nsum := nsum + tmp[m-i+1]*10^(m-i); od: c 1999 by CRC Press LLC nb10 := nsum; else nb10 := convert ([seq(vs[linalg[vectdim](vs) - ct + 1], ct = linalg[vectdim](vs))], base, 2, 10)[1]; fi: od; dg := dg + cyct; res := res*x[cyct]; if cyct > tmax then tmax := cyct; fi: fi; fi; fi; RETURN(res, plist, dg, tmax); end: c 1999 by CRC Press LLC Hints and Solutions to Selected Written Exercises Chapter (12)(34), (13)(24), (14)(23), (123), (132), (124), (142), (134), (143), (234), (243), identity (12345), (13524), (14253), (15432), (25)(34), (13)(45), (15)(24), (12)(35), (14)(23), identity A4 and (12)A4 (a) (b) (c) (d) (e) 11 Let a be a cyclic generator for G, and suppose j is the smallest positive integer for which aj ∈ H Use the fact that Z is a Euclidean domain to show that aj is a cyclic generator for H 13 Example 1.7: An Example 1.8: The set of matrices A with det(A) = 15 Let a ∈ Sn and b ∈ An , and argue that a−1 ba ∈ An 20 Yes Use the fact that F [x] is a Euclidean domain 23 The primes c 1999 by CRC Press LLC 25 (a) Power x1 x2 x3 x4 x5 x6 x7 x8 Field Element x 2x + 2x + 2 2x x+2 x+1 (c) f (x) = (x + 5)(x + 7) in Z11 [x] 29 f (x) is irreducible but not primitive since the order of x is 5; g(x) is not irreducible since is a root of g(x), and h(x) is primitive 35 (a, b) = x2 + 1, u = x + 1, and v = x2 + x + Chapter 2 Use Propositions 2.8 and 2.9 with p = 13 and n = With the ∗ cyclic generator for Z13 , Proposition 2.8 yields the initial blocks D0 = {1, 3, 9} and D1 = {2, 6, 5} The parameters for the resulting block design are (13, 26, 6, 3, 1) Use Proposition 2.9 with p = n = In this block design, there are 150 drivers, each car is driven 24 times, and each pair of cars is driven by the same driver times Let x be a cyclic generator for the set of nonzero elements in a finite field of order 25, and construct initial blocks with elements in each one For example, the first two initial blocks are D0 = {x0 , x6 , x12 , x18 } and D1 = {x1 , x7 , x13 , x19 } Chapter The Hadamard code with m = satisfies the stated requirements The following generator matrix G and parity check matrix H are one of many correct answers G = c 1999 by CRC Press LLC 1 0 1 1 1 1 H = 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 r1 can be corrected to (11100), r2 can be corrected to (11011), and r3 cannot be corrected Chapter g(x) = p(x), which yields a [7, 4] BCH code (a) r can be corrected to (1001110) Refer to Example 4.3 Note that if we consider only the first four powers of a, then g(x) = m1 (x)m3 (x), which has degree The resulting code has 27 = 128 codewords and is 2-error correcting (a) r can be corrected to (000111011001010) (b) r can be corrected to (111100010011010) Chapter (a) g(x) = (x − a)(x − a2 )(x − a3 )(x − a4 ) = x4 + a3 x3 + x2 + ax + a3 (b) The following polynomial is one of the codewords in C (a4 x + a5 )g(x) = a4 x5 + a4 x4 + a2 x3 + a2 x + a (c) The codeword above converts to the following binary vector (010001000001011011000) (a) r(x) can be corrected to a5 x6 + a6 x4 + ax2 + a6 x + a5 (c) r(x) can be corrected to x6 + ax5 + a6 x3 + a3 x2 + a5 x + a4 (a) r(x) can be corrected to a7 x12 + a2 x11 + a8 x10 + a6 x9 + x8 + ax7 + a10 x6 + a6 x5 + a4 x4 + a7 x3 + ax2 + a6 x + a c 1999 by CRC Press LLC Chapter The following is the key matrix A for the system A = 21 12 (a) “HFXLKQOOFS” (b) “NONETOSEND” One possible way to find K is to use the × matrix A = and the × matrix B = to form the following × involutory matrix K K = 20 25 20 23 25 24 Chapter (a) The ciphertext is 222 222 128 175 250 35 118 28 222 201 99 216 175 The corresponding decryption exponent is b = 41 22 total multiplications p = 509 and q = 631 Chapter y = 16 and z = w = 2x + c 1999 by CRC Press LLC (a) E = { (1, ±5), (2, ±1), (5, ±5), (7, ±4), (0, 0), (3, 0), (8, 0), O } (b) E is not cyclic Theorem 8.3 states then that E is isomorphic to Z6 × Z2 y = (0, 1) and z = (8, 2) 10 w = (7, 4) Chapter (c) f (x1 , x2 , x3 ) = (x3 + 3x1 x2 + 2x3 ), distinct necklaces (d) R3 + R2 W + RW + R3 (a) distinct necklaces (b) distinct necklaces See Example 9.5 and the results obtained in Section 9.5 3984 distinct equivalence classes c 1999 by CRC Press LLC ... Cataloging-in-Publication Data Klima, Richard E Applications of abstract algebra with Maple / Richard E Klima, Neil P Sigmon, Ernest Stitzinger p cm - (Discrete mathematics and its applications) Includes.. .Applications of Abstract Algebra with MAPLE Richard E Klima Neil Sigmon Ernest Stitzinger CRC Press Boca Raton London New York Washington, D.C Library of Congress Cataloging-in-Publication... Construction of Reed-Solomon Codes 5.2 Error Correction in Reed-Solomon Codes 5.3 Proof of Reed-Solomon Error Correction 5.4 Binary Reed-Solomon Codes 5.5 Reed-Solomon Codes with Maple 5.5.1 5.5.2