Discrete Mathematics Dr. J. Saxl Michælmas1995 ThesenotesaremaintainedbyPaulMetcalfe. [email protected]. Revision: 2.3 Date: 1999/10/21 11:21:05 Thefollowingpeoplehavemaintainedthesenotes. –date PaulMetcalfe Contents Introduction v 1 Integers 1 1.1 Division . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Thedivisionalgorithm . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 TheEuclideanalgorithm . . . . . . . . . . . . . . . . . . . . . . . . 2 1.4 ApplicationsoftheEuclideanalgorithm . . . . . . . . . . . . . . . . 4 1.4.1 ContinuedFractions . . . . . . . . . . . . . . . . . . . . . . 5 1.5 ComplexityofEuclideanAlgorithm . . . . . . . . . . . . . . . . . . 6 1.6 PrimeNumbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.6.1 Uniquenessofprimefactorisation . . . . . . . . . . . . . . . 7 1.7 Applicationsofprimefactorisation . . . . . . . . . . . . . . . . . . . 7 1.8 ModularArithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.9 SolvingCongruences . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.9.1 Systemsofcongruences . . . . . . . . . . . . . . . . . . . . 9 1.10 Euler’sPhiFunction . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.10.1 PublicKeyCryptography. . . . . . . . . . . . . . . . . . . . 10 2 InductionandCounting 11 2.1 ThePigeonholePrinciple . . . . . . . . . . . . . . . . . . . . . . . . 11 2.2 Induction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.3 StrongPrincipleofMathematicalInduction . . . . . . . . . . . . . . 12 2.4 RecursiveDefinitions . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2.5 SelectionandBinomialCoefficients . . . . . . . . . . . . . . . . . . 13 2.5.1 Selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2.5.2 Somemoreidentities . . . . . . . . . . . . . . . . . . . . . . 14 2.6 SpecialSequencesofIntegers . . . . . . . . . . . . . . . . . . . . . 16 2.6.1 Stirlingnumbersofthesecondkind . . . . . . . . . . . . . . 16 2.6.2 GeneratingFunctions . . . . . . . . . . . . . . . . . . . . . . 16 2.6.3 Catalannumbers . . . . . . . . . . . . . . . . . . . . . . . . 17 2.6.4 Bellnumbers . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.6.5 PartitionsofnumbersandYoungdiagrams . . . . . . . . . . 18 2.6.6 Generatingfunctionforself-conjugatepartitions . . . . . . . 20 3 Sets,FunctionsandRelations 23 3.1 Setsandindicatorfunctions . . . . . . . . . . . . . . . . . . . . . . . 23 3.1.1 DeMorgan’sLaws . . . . . . . . . . . . . . . . . . . . . . . 24 3.1.2 Inclusion-ExclusionPrinciple . . . . . . . . . . . . . . . . . 24 iii iv CONTENTS 3.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.3 Permutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.3.1 Stirlingnumbersofthefirstkind . . . . . . . . . . . . . . . . 27 3.3.2 Transpositionsandshuffles . . . . . . . . . . . . . . . . . . . 27 3.3.3 Orderofapermutation . . . . . . . . . . . . . . . . . . . . . 28 3.3.4 ConjugacyclassesinS . . . . . . . . . . . . . . . . . . . . 28 n 3.3.5 Determinantsofann×nmatrix. . . . . . . . . . . . . . . . 28 3.4 BinaryRelations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 3.5 Posets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 3.5.1 Productsofposets . . . . . . . . . . . . . . . . . . . . . . . 30 3.5.2 EulerianDigraphs . . . . . . . . . . . . . . . . . . . . . . . 30 3.6 Countability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 3.7 Biggersets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Introduction These notes are based on the course “Discrete Mathematics” given by Dr. J. Saxl in CambridgeintheMichælmasTerm1995. Thesetypesetnotesaretotallyunconnected withDr.Saxl. Othersetsofnotesareavailablefordifferentcourses. Atthetimeoftypingthese courseswere: Probability DiscreteMathematics Analysis FurtherAnalysis Methods QuantumMechanics FluidDynamics1 QuadraticMathematics Geometry DynamicsofD.E.’s FoundationsofQM Electrodynamics MethodsofMath.Phys FluidDynamics2 Waves(etc.) StatisticalPhysics GeneralRelativity DynamicalSystems PhysiologicalFluidDynamics BifurcationsinNonlinearConvection SlowViscousFlows TurbulenceandSelf-Similarity Acoustics Non-NewtonianFluids SeismicWaves Theymaybedownloadedfrom http://www.istari.ucam.org/maths/ or http://www.cam.ac.uk/CambUniv/Societies/archim/notes.htm [email protected] setsyourequire. v Copyright(c)TheArchimedeans,CambridgeUniversity. Allrightsreserved. Redistributionanduseofthesenotesinelectronicorprintedform,withorwithout modification,arepermittedprovidedthatthefollowingconditionsaremet: 1. Redistributionsoftheelectronicfilesmustretaintheabovecopyrightnotice,this listofconditionsandthefollowingdisclaimer. 2. Redistributionsinprintedformmustreproducetheabovecopyrightnotice,this listofconditionsandthefollowingdisclaimer. 3. Allmaterialsderivedfromthesenotesmustdisplaythefollowingacknowledge- ment: ThisproductincludesnotesdevelopedbyTheArchimedeans,Cambridge Universityandtheircontributors. 4. NeitherthenameofTheArchimedeansnorthenamesoftheircontributorsmay beusedtoendorseorpromoteproductsderivedfromthesenotes. 5. Neither these notes nor any derived products may be sold on a for-profit basis, althoughafeemayberequiredforthephysicalactofcopying. 6. Youmustcauseanyeditedversionstocarryprominentnoticesstatingthatyou editedthemandthedateofanychange. THESENOTESAREPROVIDEDBYTHEARCHIMEDEANSANDCONTRIB- UTORS“ASIS”ANDANYEXPRESSORIMPLIEDWARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABIL- ITYANDFITNESSFORAPARTICULARPURPOSEAREDISCLAIMED.INNO EVENTSHALLTHEARCHIMEDEANSORCONTRIBUTORSBELIABLEFOR ANYDIRECT,INDIRECT,INCIDENTAL,SPECIAL,EXEMPLARY,ORCONSE- QUENTIAL DAMAGES HOWEVER CAUSED AND ON ANY THEORY OF LI- ABILITY,WHETHERINCONTRACT,STRICTLIABILITY,ORTORT(INCLUD- INGNEGLIGENCEOROTHERWISE)ARISINGINANYWAYOUTOFTHEUSE OFTHESENOTES,EVENIFADVISEDOFTHEPOSSIBILITYOFSUCHDAM- AGE. Chapter 1 Integers Notation. The“naturalnumbers”,whichwewilldenotebyN,are {1,2,3,...}. TheintegersZare {...,−2,−1,0,1,2,...}. Wewillalsousethenon-negativeintegers,denotedeitherbyN orZ ,whichisN∪ 0 + {0}. TherearealsotherationalnumbersQandtherealnumbersR. GivenasetS,wewritex∈S ifxbelongstoS,andx∈/ S otherwise. Thereareoperations+and·onZ. Theyhavecertain“nice”propertieswhichwe willtakeforgranted. Thereisalso“ordering”. Nissaidtobe“well-ordered”,which meansthateverynon-emptysubsetofNhasaleastelement.Theprincipleofinduction followsfromwell-ordering. Proposition(PrincipleofInduction). LetP(n)beastatementaboutnforeachn∈ N. SupposeP(1)istrueandP(k)trueimpliesthatP(k+1)istrueforeachk ∈ N. ThenP istrueforalln. Proof. SupposeP isnottrueforalln. ThenconsiderthesubsetSofNofallnumbers k for which P is false. Then S has a least element l. We know that P(l−1) is true (sincel>1),sothatP(l)mustalsobetrue. ThisisacontradictionandP holdsforall n. 1.1 Division Given two integers a, b ∈ Z, we say that a divides b (and write a | b) if a (cid:54)= 0 and b = a·q forsomeq ∈ Z(aisadivisorofb). aisaproperdivisorofbifaisnot±1 or±b. Note. If a | b and b | c then a | c, for if b = q a and c = q b for q , q ∈ Z then 1 2 1 2 c=(q ·q )a.Ifd|aandd|bthend|ax+by.Theproofofthisisleftasanexercise. 1 2 1 2 CHAPTER1. INTEGERS 1.2 The division algorithm Lemma1.1. Given a, b ∈ N there exist unique integers q, r ∈ N with a = qb+r, 0≤r <b. Proof. Takeqthelargestpossiblesuchthatqb≤aandputr =a−qb.Then0≤r <b sincea−qb≥0but(q+1)b≥a. Nowsupposethata=q b+rwithq ,r ∈Nand 1 1 1 0 ≤ r < b. Then0 = (q−q )b+(r−r )andb | r−r . But−b < r−r < bso 1 1 1 1 1 thatr =r andhenceq =q . 1 1 Itisclearthatb|aiffr =0intheabove. Definition. Givena,b∈Nthend∈Nisthehighestcommonfactor(greatestcommon divisor)ofaandbif: 1. d|aandd|b, 2. ifd(cid:48) |aandd(cid:48) |bthend(cid:48) |d(d(cid:48) ∈N). Thehighestcommonfactor(henceforthhcf)ofaandbiswritten(a,b)orhcf(a,b). Thehcfisobviouslyunique—ifcandc(cid:48)arebothhcf’sthentheybothdivideeach otherandarethereforeequal. Theorem1.1(Existanceofhcf). Fora, b ∈ Nhcf(a,b)exists. Moreoverthereexist integersxandysuchthat(a,b)=ax+by. Proof. ConsiderthesetI ={ax+by :x,y ∈Zandax+by >0}. ThenI (cid:54)=∅solet dbetheleastmemberofI. Now∃x ,y suchthatd=ax +by ,sothatifd(cid:48) |aand 0 0 0 0 d(cid:48) |bthend(cid:48) |d. Now write a = qd+r with q, r ∈ N , 0 ≤ r < d. We have r = a−qd = 0 a(1−qx )+b(−qy ).Sor =0,asotherwiser ∈I:contrarytodminimal.Similiarly, 0 0 d|bandthusdisthehcfofaandb. Lemma1.2. If a, b ∈ N and a = qb + r with q, r ∈ N and 0 ≤ r < b then 0 (a,b)=(b,r). Proof. Ifc|aandc|bthenc|randthusc|(b,r). Inparticular,(a,b)|(b,r). Now notethatifc | bandc | r thenc | aandthusc | (a,b). Therefore(b,r) | (a,b)and hence(b,r)=(a,b). 1.3 The Euclidean algorithm Supposewewanttofind(525,231). Weuselemmas(1.1)and(1.2)toobtain: 525=2×231+63 231=3×63+42 63=1×42+21 42=2×21+0 So(525,231)=(231,63)=(63,42)=(42,21)=21. Ingeneral,tofind(a,b): 1.3. THEEUCLIDEANALGORITHM 3 a=q b+r with0<r <b 1 1 1 b=q r +r with0<r <r 2 1 2 2 1 r =q r +r with0<r <r 1 3 2 3 3 2 . . . r =q r +r with0<r <r i−2 i i−1 i i i−1 . . . r =q r +r with0<r <r n−3 n−1 n−2 n−1 n n−1 r =q r +0. n−2 n n−1 This process must terminate as b > r > r > ··· > r > 0. Using Lemma 1 2 n−1 (1.2), (a,b) = (b,r ) = ··· = (r ,r ) = r . So (a,b) is the last non-zero 1 n−2 n−1 n−1 remainderinthisprocess. Wenowwishtofindx andy ∈ Zwith(a,b) = ax +by . Wecandothisby 0 0 0 0 backsubstitution. 21=63−1×42 =63−(231−3×63) =4×63−231 =4×(525−2×231)−231 =4×525−9×231. This works in general but can be confusing and wasteful. These numbers can be calculatedatthesametimeas(a,b)ifweknowweshallneedthem. We introduce A and B . We put A = B = 0 and A = B = 1. We i i −1 0 0 −1 iterativelydefine A =q A +A i i i−1 i−2 B =q B +B . i i i−1 i−2 NowconsideraB −bA . j j Lemma1.3. aB −bA =(−1)j+1r . j j j Proof. Weshalldothisusingstronginduction. Wecaneasilyseethat(1.3)holdsfor j = 1 and j = 2. Now assume we are at i ≥ 2 and we have already checked that r =(−1)i−1(aB −bA )andr =(−1)i(aB −bA ). Now i−2 i−2 i−2 i−i i−1 i−1 r =r −q r i i−2 i i−1 =(−1)i−1(aB −bA )−q (−1)i(aB −bA ) i−2 i−2 i i−1 i−1 =(−1)i+1(aB −bA ),usingthedefinitionofA andB . i i i i 4 CHAPTER1. INTEGERS Lemma1.4. A B −A B =(−1)i i i+1 i+1 i Proof. ThisisdonebybacksubstitutionandusingthedefinitionofA andB . i i Animmediatecorollaryofthisisthat(A ,B )=1. i i Lemma1.5. a b A = B = . n (a,b) n (a,b) Proof. (1.3)fori = ngivesaB = bA . Therefore a B = b A . Now a n n (a,b) n (a,b) n (a,b) and b are coprime. A and B are coprime and thus this lemma is therefore an (a,b) n n immediateconsequenceofthefollowingtheorem. Theorem1.2. Ifd|ceand(c,d)=1thend|e. Proof. Since (c,d) = 1 we can write 1 = cx+dy for some x, y ∈ Z. Then e = ecx+edyandd|e. Definition. Theleastcommonmultiple(lcm)ofaandb(written[a,b])istheintegerl suchthat 1. a|landb|l, 2. ifa|l(cid:48)andb|l(cid:48)thenl|l(cid:48). Itiseasytoshowthat[a,b]= ab . (a,b) 1.4 Applications of the Euclidean algorithm Takea,bandc∈Z.Supposewewanttofindallthesolutionsx,y ∈Zofax+by =c. Anecessaryconditionforasolutiontoexististhat(a,b)|c,soassumethis. Lemma1.6. If(a,b)|cthenax+by =chassolutionsinZ. Proof. Take x(cid:48) and y(cid:48) ∈ Z such that ax(cid:48) +by(cid:48) = (a,b). Then if c = q(a,b) then if x =qx(cid:48)andy =qy(cid:48),ax +by =c. 0 0 0 0 Lemma1.7. Any other solution is of the form x = x + bk , y = y − ak for 0 (a,b) 0 (a,b) k ∈Z. Proof. These certainly work as solutions. Now suppose x and y is also a solution. 1 1 Then a (x −x ) = − b (y −y ). Since a and b are coprime we have (a,b) 0 1 (a,b) 0 1 (a,b) (a,b) a | (y − y ) and b | (x − x ). Say that y = y − ak , k ∈ Z. Then (a,b) 0 1 (a,b) 0 1 1 0 (a,b) x =x + bk . 1 0 (a,b)