



































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




































ALEXANDER BORISOVICH
Swearword
Bastard Fred, who had fun with his pistol Shooting one by one city’s old spinsters, Was, with public condemn, Given an AKM, And all spinsters were gone in an instant.^1
I have always considered the standard college course of Discrete Mathematics to be the only meaningful part of the lower-division math curriculum. After all, logic – sets – induction – recursion – modular arithmetic – combinatorics – probability – graph theory, however ele- mentary, form a sapid chunk of real mathematics. So, when my son, as- piring to a EECS career, was allowed to skip this course in anticipation of a more advanced replacement, my parental pride was spiced with a grain of disappointment. Respectively, when (for reasons not worth ex- plaining) he was nonetheless, on short notice, required to demonstrate his facility with these basics on the final exam of an ongoing course, I viewed it as a potentially useful challenge, especially since some help could come from me. Thus, I immediately located the detailed syllabus for the class online, and googled up the required textbook. To my sur- prise, in a few clicks, the free PDF file was downloaded on my laptop and voila — the entire text opened to my stupefied view: I was looking at a colorful Monster of one thousand letter-size pages long! In its own way, it was a sweeping masterpiece. Indeed, what else is left to do in the business of ruining one’s hope to understand mathe- matics — a subject which proudly strives for ultimate clarity, natural elegance, intellectual depth, economy of thought, and conciseness of representation — when the traditional math circle content that fits well in a middle-schooler’s sandbox is watered down by a flood of bib- lical proportion to muddy the brain of a college student? Is there any
(^1) Reverse-engineered from a notable Russian version of an unremarkable English
limerick. In our age of prose poetry, the accents should help. 1
2 ALEXANDER BORISOVICH
more cunning way to humiliate the Queen of Sciences, and compro- mise Her in the eyes of a sensible human being, than by ritualizing the “formal mathematical proof” and then practicing it for nauseatingly meticulous derivation of an infinitude of self-obvious trivialities? And then, when the greater half of the Monster is already behind, by stun- ning the reader with a new Principle, whose very name — pigeonhole — speaks of its accessibility to a 5th-grader, and “proving” it in a page-long argument sporting several displayed formulas? As if to celebrate the success of this devilish enterprise, the records of the Monster’s authors at the Math Genealogy Project show zero number of descendants, while their professional websites, shining with scores of educationists’ publications, testify to the authors’ integrity by showing zero math productivity of any kind.
To be fair, the course’s professor contributed their bit by not follow- ing the Monster religiously, but rather omitting from the syllabus a few sections which had an unusually high concentration of genuine math- ematical content (such as, e.g., the relation between path-counting in graphs and matrix multiplication), thereby saving time for, say, (ap- parently dear to their heart) fossilized tree-searching algorithms.
What the reader finds below is a result of my instinctive defensive reaction. With numerous swearwords and the aforementioned limerick (with no obvious connection at all) constantly reverberating in my mind, I dedicated a week of my sabbatical time to sifting the waters of the Monster for anything worthwhile, adding what had to be there but wasn’t, learning what I never knew (e.g. the fossilized algorithms), correcting some crap found here and there, and ended up with what I propose as a sample of a new genre. Doesn’t a 1000-page book merit a 40-page book review? Here it is: A comprehensive monster text review — a concise, but compre- hensive exposition of all the meaningful material to be included in a semester-long college course of Discrete Mathematics. It is equipped with a minimal but sufficient supply of examples and exercises, and with complete proofs, though occasionally presented as problem sets.
Read, solve, learn, enjoy — and shoot down all the monsters!
4 ALEXANDER BORISOVICH
The propositions in the bottom line illustrate “Alice in Wonderland”: direct proposition p Ñ q is not equivalent to the converse proposition q Ñ p, but is equivalent to the contrapositive proposition q Ñ p. The converse q Ñ p is likewise equivalent to the inverse proposition p Ñ q. To prove a theorem p Ñ q “by contradiction” means to prove pp ^ qq Ñ F (assuming that the hypothesis is TRUE but the conclusion FALSE, arrive at a contradiction), while proving “by con- traposition” means to prove the equivalent theorem q Ñ p instead (assume that the conclusion is FALSE, and derive that the hypothesis must be FALSE too).
Boolean functions. There are 2^2 n Boolean functions spp 1 ,... , pnq in n Boolean variables p 1 ,... , pn and taking Boolean values T {F : Each can be specified by the choice of a value T {F for each of the 2n^ combi- nations of the values of the variables. For CS purposes, it is convenient to replace T and F with 1 and 0 respectively. Every Boolean function can be expressed by using the operations , _, ^. Indeed, for each string of input values pp 1 ,... , pnq (take for example p 1 , 1 , 0 , 1 , 0 , 0 , 1 q, where n “ 7) write the unique conjunction monomial containing either pi or pi for each i which takes the value 1 on this particular input. In our example, it is
p 1 ^ p 2 ^ p p 3 q ^ p 4 ^ p p 5 q ^ p p 6 q ^ p 7.
By taking the disjunction (_) of all such monomials over those inputs for which our Boolean function takes the value s “ 1 (and not including those for which it is 0) we obtain a Boolean expression representing our function. E.g. sp 0 , 0 q “ 0 and sp 0 , 1 q “ sp 1 , 0 q “ sp 1 , 1 q “ 1 is represented this way by p p 1 ^ p 2 q _ pp 1 ^ p 2 q _ pp 1 ^ p 2 q. Of course, this is not economical, because the function is p 1 _ p 2. There are various ways of producing minimal (in some sense, which can also vary) Boolean expressions for Boolean functions. As an exam- ple, consider minimal disjunctive normal form, which we won’t define here formally. Rather we will give an example illustrating both what it is and how to construct one. One can think of the domain of a Boolean function as the set of vertices of the unit cube in n-dimensional space (because each vertex is specified by the string of n coordinates equal 0 or 1). For example, consider the Boolean function spp, q, rq equal to 1 at the vertices marked black in Figure 1, and equal to 0 at the “white” vertices. To produce a minimal disjunctive normal form, one needs to cover the set of all black vertices by as few “faces” of the cube (the “faces” can be of any dimension from 0 to n, and may overlap) as possible in such a way that they don’t cover any white vertex. Thus,
DISCRETE MATHEMATICS 5
the 5 black vertices in the picture can be covered by two blue faces: one of dimension 2 (on top), the other of dimension 1 (the vertical blue line). The Boolean function, equal to 1 at the vertices of the top blue face only, is simply q. The Boolean function, equal to 1 at the vertices of the vertical blue edge, is p pq^ r. Therefore q _ p p^ rq (in general, the disjunction of the conjunction monomials representing the faces) is an economical Boolean expression for our function.
Figure 1
Note that the white vertices (defining the function spp, q, rq) can be covered by two green edges, leading to the expression
s ” p q ^ rq _ pp ^ qq
and consequently
s ” pp q ^ rq _ pp ^ qqq.
This representation of s is also “economical,” but not disjunctive (be- cause it is not a disjunction of conjunction monomials).
DISCRETE MATHEMATICS 7
NOR s
NAND
NOR
NOR
p
q
r
Figure 4
OR Sum
AND NOT
AND
p q
Carry
Figure 5. Half-adder
The circuit shown in Figure 6 is called a full-adder. It adds three binary digits, p, q, and r. In the binary addition of multi-digit numbers, the third summand may be a carry-over from the previous binary place. Check that it works! The key is that in the two additions needed for adding three binary digits, at most one carry-over can occur.
half−adder 1
S1 half−adder 2
p C2^ OR
q
r
Figure 6. Full-adder
8 ALEXANDER BORISOVICH
Now the addition of multi-digit binary numbers can be realized as shown in Figure 7, where... p 2 p 1 p 0 `... q 2 q 1 q 0 “... s 3 s 2 s 1 s 0.
full−adder
p
p
p
q
q
q
1
0
0
1
2 2
s
s
s
s
c
c
c 0
1
2
0
1
2
3
half−adder
full−adder
full−adder
Figure 7. Multi-digit binary addition
b “ pa pb mod 2n. That is, assuming that the sum a b fits the range between ´ 2 n´^1 and 2 n´^1 ´ 1, the correct representation of a b is obtained by adding the representations pa and pb and, if the sum pa pb reaches 2n, dropping the pn 1 qst digit (i.e. reducing the sum modulo 2n).^310 ALEXANDER BORISOVICH
Warnings. (a) A set can be described by listing its elements, e.g. S “ t 2 , 3 , 5 , 7 u is the set of all one-digit primes. However, lists with repeated objects, strictly speaking, don’t describe sets, since elements of a set cannot be “repeated”: they are either there or not. (b) One can consider the set t 3 , t 3 uu, consisting of two elements: the integer 3 P Z, and the subset t 3 u Ă Z consisting of one integer,
One defines the complement of a set, and the intersection, union, difference, and symmetric difference of two sets A and B by
px P Acq ô px R Aq x P pA X Bq ô px P Aq ^ px P Bq x P pA Y Bq ô px P Aq _ px P Bq x P pB ´ Aq ô px P Bq ^ px P Aq x P pA△Bq ô px P Aq ‘ px P Bq Exercise. Prove the following properties of the operations: pAcqc^ “ A, A△B “pA ´ Bq Y pB ´ Aq pA X Bqc^ “ Ac^ X Bc, pA Y Bqc^ “ Ac^ X Bc A X pB Y Cq “pA X Bq Y pA X Cq A Y pB X Cq “pA Y Bq X pA Y Cq Example: Venn diagrams. Let us prove a ridiculous identity about sets, e.g. that for any three sets A, B, C we have:
pA Y B Y Cq ´ pA△Bq “ pA X Bq Y pC ´ pA Y Bqq.
We can use the definitions of the operations and translate this into a Boolean identity with three propositions — a : x P A, b : x P B, and c : x P C:
pa _ b _ cq ^ pa ‘ bq ” pa ^ bq _ pc ^ pa _ bqq,
DISCRETE MATHEMATICS 11
where the left (or right) side of ” expresses the fact that x is an element of the set written on the left (resp. right) side of “. Now we can try to check the equivalence using truth tables. Consider, however, the example shown on Figure 8, where A, B, and C are three discs on the plane.
Figure 8. Venn diagrams
The area shaded green represents A△B, and the complement of it inside A Y B Y C (i.e. the relative complement) is shaded in cyan. In the right-hand picture, the relative complement of A Y B inside C is shaded in magenta, while the yellow region represents A X B. Since the total region shaded on the right coincides with the region shaded in cyan on the left, we conclude that at least for these three sets, our identity is true. So what? Have we proved the identity? Will it hold for any three sets? We claim that the answer is yes. The reason is that the three circles divide the plane into 8 regions (can you find all eight?) in which the predicates x P A, x P B, x P C assume all 8 possible truth values. Consequently, checking our identity for sets in this example is equivalent to verifying the Boolean identity by truth tables.
‚ and ¨ are commutative and associative, and obey two distribu- tive laws: a¨pbcq “ pa¨bqpa¨cq and apb¨cq “ pabq¨pacq for all a, b, c P B; ‚ there exist elements of B (denoted 0 and 1) such that a ` 0 “ a and a ¨ 1 “ a for all a P B;
DISCRETE MATHEMATICS 13
mathematical statement can be derived from the axioms of a given the- ory. Here is another similar development: The halting theorem by Alan Turing.
Theorem. There is no algorithm, which for any algorithm X and any input data D would determine whether X with the input D will loop forever, or it will halt after finitely many steps.
Proof. We will show that any algorithm, say CheckHaltspX, Dq, which for every given algorithm X and every data D outputs either halts or loopsforever, will fail to function the required way on X “ T est and D “ T est, where T est is the following algorithm (considered as both an algorithm X and text input data D):
T estpXq; a : IF CheckHaltspX, Xq “ halts T HEN GO T O a ELSE GO T O b; b : ST OP
Indeed, when CheckHaltspT est, T estq “ halts, T estpT estq loops for- ever, and when CheckHaltspT est, T estq “ loopsf orever, T estpT estq actually halts.
Example: Hash functions. How to efficiently store records of, say, up to 10, 000 students in a college, when the records are to be identified by 9-digit social security numbers (SSN)? A function Hash from the set of 10^9 possible SSNs to the set of 10^4 labels ranging from 0000 to 9999 can be defined by a simple rule, e.g. by HashpSSNq :“ the last 4 digits of the SSN. One problem is that this function might
14 ALEXANDER BORISOVICH
not be injective. When such a collision happens, a collision resolution algorithm is applied, e.g. one can assign the smallest allowed Hash value as yet unused by the database records. The resulting function Hash may look very irregular, but it will be injective.
Given two functions g : X Ñ Y , and f : Y Ñ Z, their composition h :“ f ˝ g : X Ñ Z is defined by hpxq :“ f pgpxqq. The operation of composition of functions is associative: Given three functions, h : X Ñ Y , g : Y Ñ Z, and f : Z Ñ W , the composition of f with the result of composiing g and h coincides with the result of composing f and g, composed with h: f ˝ pg ˝ hq “ pf ˝ gq ˝ h : X Ñ W. Indeed, both rules applied to x P X give the same function f pgphpxqq (which is the only way of getting from X to W using f , g, and h). In fact, whenever there is an associative operation in mathematics, it can be defined in terms of the operation of composing functions. For example, the addition of plane vectors u`v can be interpreted as the composition of translations on the plane: one by the vector u, the other by the vector v. Thus, the tautological associativity of function composition is the reason why this property is shared by many algebraic operations. The graph of function f : X Ñ Y is defined as the subset F Ă X ˆ Y in the Cartesian product^4 of X and Y consisting of all pairs px, f pxqq, that is F :“ tpx, yq P X ˆ Y | y “ f pxqu. High-school students often fail to distinguish functions (which are rules, e.g. x ÞÑ x^2 ) from their graphs, which are sets (parabola y “ x^2 on the plane R^2 :“ R ˆ R). In fact logicians do the same. Indeed, in order to reduce the number of undefinable notions, they define functions in terms of sets. Namely, a function from X to Y in their sense is a subset F Ă X ˆ Y such that for every x P X there exists a unique y P Y such that px, yq P F. Of course, to arrive at this formal definition, one needs to have the informal idea of functions as rules beforehand.
Exercises. (a) Prove that f : X Ñ Y is bijective (injective, surjec- tive) if and only if f has a two-sided inverse (resp. left inverse, right inverse) with respect to the composition operation, i.e. if there exists g : Y Ñ X such that g ˝ f “ idX (a left inverse) and f ˝ g “ idY (a right inverse), where idX and idY denote the identity maps on X and Y. (b) Show that if F Ă X ˆ Y is the graph of an invertible function, then the graph of the inverse function coincides with F considered as a subset of Y ˆ X (which can be identified with X ˆ Y by reordering the pairs).
(^4) By definition, X ˆ Y :“ tpx, yq | x P X, y P Y u, i.e. the set of all ordered pairs.
16 ALEXANDER BORISOVICH
) is also infinite, and seems smaller. However |N| “ |Z|, since the function n ÞÑ n 1 from N to Z^ establishes a one-to-one correspondence.^6 Sets with the same cardinality as Z`^ (or N) are called countable.Exercises. (a) Prove that the set Z of all integers (positive and negative) is countable. (b) Prove that the union of countably many countable sets is count- able. (Hint: Draw the 2-dimensional table whose rows contain the lists of elements of the given sets, and number all the items in the table by scanning it diagonally and skipping repeated items.) (c) Prove that the set Q of all rational numbers is countable. (Hint: Write elements of Q as fractions m{n.) (d) Prove that the real number line R has the same cardinality as any segment pa, bq :“ tx P R|a ă x ă bu with a ă b. (Hint: Use stereographic projection.) (e) The same for pa, bq and pa, bs or ra, bs, obtained from pa, bq by adding one of the endpoints or both. (Hint: Find a common countable subset in pa, bq and pa, bs.) (f) Prove that the unit interval r 0 , 1 s and the unit square r 0 , 1 s ˆ r 0 , 1 s have the same cardinality. (Hint: Encode a pair x, y of decimal
(^6) By the way, the official definition of an infinite set is that its cardinality should
not change when a new element is adjoined.
DISCRETE MATHEMATICS 17
expansions x “ 0 .x 1 x 2... and y “ 0 .y 1 y 2... , where xi and yi are decimal numerals, by a single expansion z “ 0 .x 1 y 1 x 2 y 2... .)
Let us write |X| ď |Y | if X has the same cardinality as some subset of Y. The following celebrated Cantor-Bernstein theorem shows that such ordering of cardinalities is well-defined.
Theorem. If |X| ď |Y | and |Y | ď |X|, then |X| “ |Y |. Proof. In math circles, the problem is playfully phrased in terms of two languages, Mumbo (M) and Jumbo (J), and two injective, but not surjective dictionaries: f : M Ñ J and g : J Ñ M (allowing each of the tribes to consider their language superior). The task is to construct a third dictionary, h : M Ñ J, which would be bijective. It has an elegant solution, which we recommend you to find on your own, but if you are lazy, here it is. Since the functions are injective, inverse images are unique when they exist. So, starting with m P M, we try to construct a sequence m 0 , j 0 , m 1 , j 1 ,... , where m 0 “ m, j 0 “ g´^1 pm 0 q if it exists, m 1 “ f ´^1 pj 0 q, if it exists, and so on. Here are the possibilities: (i) the result- ing sequence never terminates; (ii) it terminates in M: m 0 , ¨ ¨ ¨ , mN ; (iii) it terminates in J: m 0 , ¨ ¨ ¨ , jN. We define hpmq as f pmq in the first two cases, and as j 0 in the third. The inverse function h´^1 : J Ñ M can be described this way: given j P J, try to construct the se- quence j, m 0 , j 0 ,... using inverse images as before. If it is infinite, then m “ m 0 falls into type (i), and so h´^1 pjq “ m 0. If it is fi- nite and terminates in M, then m “ m 0 falls into type (ii), and so h´^1 pjq “ m 0 too. If it terminates in J, then m “ gpjq falls into type (iii), and so h´^1 pjq “ gpjq. (Indeed, the sequence built from m has the form m, j,... , jN (where possibly j is the last term), in which case hpmq “ j “ g´^1 pmq.) Since both h and h´^1 are well-defined everywhere on M and J respectively, they establish a one-to-one correspondence between M and J. Q.E.D.
Exercise. Prove that the set, denoted 2N, of all subsets in N (or in any other countable set) has the cardinality of the continuum. (Hint: Encode a subset by a string of binary digits which extends infinitely to the right, and fight the difficulties caused by the duplicate binary representation of some reals on r 0 , 1 s, using the Cantor-Bernstein the- orem.)
DISCRETE MATHEMATICS 19
1 ˝^ pp 0 q (the base of induction) 2 ˝^ @n P N, ppnq Ñ ppn ` 1 q (the step of induction).
The principle of mathematical induction guarantees that then all ppnq are true: 1˝^ 2 ˝^ ñ @n, ppnq. Indeed, to prove ppnq, start from pp 0 q “ T , and conclude that pp 1 q “ T (since pp 0 q Ñ pp 1 q is true), then conclude that pp 2 q “ T (since pp 1 q Ñ pp 2 q is true), and so on, and arrive after n steps to ppnq “ T. A practical conclusion from this argument is that mathematical in- duction is a powerful logical tool (as it is indeed), because without it, in order to reach pp 1000 q, one would have to make a very long argument, repeating similar steps 1000 times. The drawback is that very often induction leads to a conclusive verdict, but the intuitive comprehension of why all ppnq are true gets lost in the process. The theoretical aspect of this argument leads, however, to the notion of a well-ordered set. A (partial) ordering on a set S is a binary relation R on it, which is reflexive (@x P S, xRx), transitive (pxRyq ^ pyRzq ñ pxRzq), and anti-symmetric: pxRyq ^ pyRxq ñ py “ xq. Examples: (a) Divisibility a|b, on Z`. (b) Inclusion Ă, on the set PpUq of subsets in a given set. (c) Ordering of cardinalities |X| ď |Y | (thanks to Cantor–Bernstein). A partial ordering is total if @x, y P S, pxRyq _ pyRxq. Examples: (a) ď on R. (b) The ordering of words in a dictionary. (c) Lexicographical ordering, e.g. of points px, yq ď px^1 , y^1 q on the plane: first by x ď x^1 , and if x “ x^1 , then by y ď y^1 — as in the dictionary. Suppose that every non-empty subset X Ă S in a given totally or- dered set has its minimal element with respect to R, i.e. there exists x 0 P X such that for all x P X we have x 0 Rx. Then one says that S is well-ordered by R. The truth is that R is not well-ordered by ď (because, e.g. the set of positive reals has no minimal element), but N is well-ordered by ď: every non-empty subset of N has its minimal element. The principle of mathematical induction can be proved on the basis of this property of N. Namely, consider the set X Ă N of those n for which ppnq is false. Assume X ‰ H. Then X has the minimal element n 0. It cannot be 0, since pp 0 q “ T (the base). Therefore n 0 ´ 1 is defined, and ppn 0 ´ 1 q “ T. But since ppn 0 ´ 1 q Ñ ppn 0 q is true (the step of induction), then ppn 0 q “ T , i.e. n 0 R X. This contradiction shows that X “ H.
20 ALEXANDER BORISOVICH
Here is an example illustrating why it is dangerous to discard the base of induction as “uninteresting”.
Problem: Find the number Rpnq of the regions into which n generic straight lines divide the plane. (“Generic” here means that no two are parallel, and no three are concurrent.)
Solution. Given n´1 lines on the plane, a generic nth line intersects each of the previous n ´ 1 lines once. The n ´ 1 intersection points divide the nth line into n parts. Therefore the nth line cuts through exactly n previous regions, dividing each of them in two, and creating therefore n new ones. Thus, Rpnq “ Rpn ´ 1 q n. Thus, Rpnq “ 1 2 ¨ ¨ ¨ n “ npn 1 q{2 is the nth triangular number. For example, Rp 3 q “ 3 p 3 1 q{ 2 “ 6 — Oops! Rp 3 q “ 7. The error comes from the fact that Rp 0 q “ 1, not 0, as for the triangular numbers, and so the right answer is Rpnq “ 1 p 1 2 ¨ ¨ ¨ nq “ 1 npn 1 q{2.
The following elegant induction problem is probably included into every DM text. Removing one cell from a 2ˆ2 chess-board, one obtains a shape called a tromino.
Problem: Show that any 2n^ ˆ 2 n^ chess-board with one cell removed can be tiled by trominoes without overlaps.
Solution. Divide the board into four 2n´^1 ˆ 2 n´^1 parts. The re- moved cell falls into one of them. Place one tromino at the center so that it covers one cell from each of the remaining three parts. Now it remains to tile the four parts, each with one cell removed. By the induction hypothesis (i.e. ppn ´ 1 q) this can be done, and ppnq follows. Note that the base of induction (pp 1 q in this case) is checked in the very formulation of the problem.
Exercises. (a) Use the solution of the tiling problem as an algo- rithm to tile the 8 ˆ 8 chess-board with the cell d7 removed. (b) Find another inductive solution, based on the partitioning of the board into 2n´^1 ˆ 2 n´^1 cells of size 2 ˆ 2 each.
Remark (on well-ordering). A countable set can be well-ordered (why?) Can this be generalized to sets of other cardinalities? It turns out (and this is a deep result of mathematical logic) that generally speaking, it is not possible to construct such a well-ordering, nor prove its existence in any other way, although assuming that it is possible would not lead to any contradiction. Thus, the well-ordering principle, saying that every set admits a well-ordering, can be accepted as an axiom.