Beruflich Dokumente
Kultur Dokumente
with Proof
Second Edition
Eric Gossett
Bethel University
WILEY
A JOHN WILEY & SONS, INC., PUBLICATION
Contents
Preface
Acknowledgments
To The Student
xiii
xx
xxii
1 Introduction
1.1 What Is Discrete Mathematics?
1.1.1 A Break from the Past
1.2 The Stable Marriage Problem
1.2.1 Seeking a Solution
1.2.2 The Deferred Acceptance Algorithm
1.2.3 Some Concluding Comments
1.3 Other Examples
1.3.1 A Simple Counting and Probability Example
1.3.2 Sierpinski Curves
1.3.3 The Bridges f Knigsberg
1.3.4 Kirkman's Schoolgirls
1.3.5 Finite-State Machines
1.3.6 The Set of Rational Numbers Is Countably Infinite
1.4 Exercises
1.5 Chapter Review
1.5.1 Summary
1.5.2 Notation
1
1
3
3
4
5
7
7
7
8
9
9
10
11
13
15
15
15
17
19
19
26
29
33
34
34
35
37
37
38
39
39
40
42
43
46
46
47
48
v
vi
Contents
2.4
2.5
2.6
2.7
2.8
Proof
3.1 Introduction to Mathematical Proof
3.1.1 Mathematics and Proof: The Big Picture
3.1.2 Mathematical Objects Related to Proofs
3.1.3 Exercises
3.2 Elementary Number Theory: Fuel for Practice
3.2.1 The Integers and Other Number Systems
3.2.2 Divisibility
3.2.3 Primes
3.2.4 The Well-Ordering Principle
3.2.5 Congraence, Factorials, Floor and Ceiling Functions
3.2.6 Exercises
3.3 Proof Strategies
3.3.1 Trivial Proof
3.3.2 Direct Proof
3.3.3 Indirect Proof: Proving the Contrapositive
3.3.4 Proof by Contradiction
3.3.5 Proof by Cases
3.3.6 Implications with Existential Quantifiers
3.3.7 Implications with Universal Quantifiers
3.3.8 Proofs Involving the Biconditional and
Logical Equivalence
3.3.9 Some Important Examples
3.3.10 Exercises
3.4 Applications of Elementary Number Theory
3.4.1 The Euclidean Algorithm: Calculating gcd(a, b)
3.4.2 Hashing
3.4.3 Pseudorandom Numbers
3.4.4 Linear Congruence and the Chinese Remainder Theorem
3.4.5 Fermat's Little Theorem and Fermat's Last Theorem
3.4.6 Encryption
3.4.7 Exercises
50
53
54
56
58
60
63
67
68
69
74
76
81
81
82
83
84
85
85
86
87
91
92
92
93
95
96
98
99
100
100
101
103
103
105
105
106
108
109
Ill
113
113
116
117
119
124
126
130
Contents
Vll
3.5
Mathematical Induction
3.5.1 The Principle of Mathematical Induction
3.5.2 Complete Induction
3.5.3 Interesting Mathematical Induction Problems
3.5.4 The Well-Ordering Principle, Mathematical Induction, and Complete Induction
3.5.5 Multidimensional Induction
3.5.6 Exercises
3.6 Creating Proofs: Hints and Suggestions
3.6.1 A Few Very General Suggestions
3.6.2 Some Specific Tactics
3.6.3 Exercises
3.7 Quick Check Solutions
3.8 Chapter Review
3.8.1 Summary
3.8.2 Notation
3.8.3 Additional Review Material
132
132
139
141
146
148
151
153
153
156
161
162
167
167
168
168
Algorithms
4.1 Expressing Algorithms
4.1.1 Flow of Control
4.1.2 Flow of Information
4.1.3 Exercises
4.2 Measuring Algorithm Efficiency
4.2.1 Big-0 and Its Cousins
4.2.2 Practical Big-0 Tools
4.2.3 Exercises
4.2.4 Big-0 in Action: Searching a List
4.2.5 Exercises
4.3 Pattern Matching
4.3.1 The Obvious Algorithm
4.3.2 KMP: Knuth-Morris-Pratt
4.3.3 BM: Boyer-Moore
4.3.4 Exercises
4.4 The Halting Problem
4.4.1 Setting the Stage
4.4.2 The Halting Problem
4.5 Quick Check Solutions
4.6 Chapter Review
4.6.1 Summary
4.6.2 Notation
4.6.3 Big-0 Shortcuts
4.6.4 Additional Review Material
169
170
170
176
179
180
181
185
193
195
200
202
202
204
206
213
214
214
215
217
222
222
223
224
224
Counting
5.1 Permutations and Combinations
5.1.1 Two Basic Counting Principles
5.1.2 Permutations
5.1.3 Permutations with Repetition
5.1.4 Combinations
5.1.5 Combinations with Repetition
5.1.6 Exercises .
5.1.7 More Complex Counting Problems
5.1.8 Exercises
225
226
226
229
231
231
234
237
239
246
Vlll
5.2
Contents
Combinatorial Proofs
5.2.1 Introduction to Combinatorial Proofs
5.2.2 Counting Tulips: Three Combinatorial Proofs
5.2.3 Exercises
5.3 Pigeon-Hole Principle; Inclusion-Exclusion
5.3.1 The Pigeon-Hole Principle
5.3.2 Inclusion-Exclusion
5.3.3 Exercises
5.4 Quick Check Solutions
5.5 Chapter Review
5.5.1 Summary
5.5.2 Notation
5.5.3 Some Counting Formulas
5.5.4 Additional Review Material
6 Finite Probability Theory
6.1 The Language of Probabilities
6.1.1 Sample Spaces, Outcomes, and Events
6.1.2 Probabilities of Events
6.1.3 Exercises
6.2 Conditional Probabilities and Independent Events
6.2.1 Definitions
6.2.2 Computing Probabilities
6.2.3 Exercises
6.3 Counting and Probability
6.3.1 Exercises
6.4 Expected Value
6.4.1 Exercises
6.5 The Binomial Distribution
6.5.1 Exercises
6.6 Bayes's Theorem
6.6.1 Exercises
6.7 Quick Check Solutions
6.8 Chapter Review
6.8.1 Summary
6.8.2 Notation
6.8.3 Additional Review Material
7 Recursion
7.1 Recursive Algorithms
7.1.1 General Guidelines for Creating Recursive Algorithms
7.1.2 A Detailed Example
7.1.3 When Should Recursion Be Avoided?
7.1.4 Persian Rugs
7.1.5 Drawing Sierpinski Curves
7.1.6 Adaptive Quadrature
7.1.7 Exercises
7.2 Recurrence Relations
7.2.1 Solving Recurrence Relations
7.2.2 Linear Homogeneous Recurrence Relations with Constant Coefficients
7.2.3 Repeated Roots
7.2.4 The Sordid Truth
7.2.5 Exercises
7.3 Big-0 and Recursive Algorithms: The Master Theorem
7.3.1 Exercises
248
248
251
257
258
258
261
264
266
270
270
271
272
272
273
274
274
277
281
283
283
287
294
297
299
302
308
310
315
316
319
322
327
327
328
328
329
332
333
334
336
339
342
345
349
350
353
357
366
373
375
377
389
Contents
7.4
Generating Functions
7.4.1 Exercises
7.5 The Josephus Problem
7.5.1 Exercises
7.6 Quick Check Solutions
7.7 Chapter Review
7.7.1 Summary
7.7.2 Notation
7.7.3 Generating Function Table
7.7.4 Additional Review Material
Combinatorics
8.1 Partitions, Occupancy Problems, Stirling Numbers
8.1.1 Partitions of a Positive Integer
8.1.2 Occupancy Problems
8.1.3 Stirling Numbers
8.1.4 Exercises
8.2 Latin Squares, Finite Projective Planes
8.2.1 Latin Squares
8.2.2 Finite Projective Planes
8.2.3 Finite Projective Planes and Latin Squares
8.2.4 Exercises
8.3 Balanced Incomplete Block Designs
8.3.1 Constructing Balanced Incomplete Block Designs
8.3.2 Exercises
8.4 The Knapsack Problem
8.4.1 Exercises
8.5 Error-Correcting Codes
8.5.1 The 7-Bit Hamming Code
8.5.2 A Formal Look at Coding Theory
8.5.3 Combinatorial Aspects of Coding Theory
8.5.4 Exercises
8.6 Distinct Representatives, Ramsey Numbers
8.6.1 Systems of Distinct Representatives
8.6.2 Ramsey Numbers
8.6.3 Exercises
8.7 Quick Check Solutions
8.8 Chapter Review
8.8.1 Summary
8.8.2 Notation
8.8.3 The Fano Plane
8.8.4 Occupancy Problems
8.8.5 Additional Review Material
Formal Models in Computer Science
9.1 Information
9.1.1 A General Model of Communication
9.1.2 A Mathematical Definition of Information
9.1.3 A Summary of Other Ideas in Shannon's Paper
9.1.4 Exercises
9.2 Finite-State Machines
9.2.1 Finite Automata
9.2.2 Finite-State Machines with Output
9.2.3 Exercises
IX
391
401
402
407
407
414
414
416
416
416
417
419
419
423
427
433
435
435
442
447
457
460
464
471
472
485
488
489
492
497
500
502
502
509
516
518
529
529
531
532
532
532
533
533
534
535
540
541
542
543
547
551
Contents
9.3
9.4
9.5
9.6
9.7
9.8
Formal Languages
9.3.1 Regular Grammars
9.3.2 Exercises
Regular Expressions
9.4.1 Introduction to Regular Expressions
9.4.2 Perl Extensions
9.4.3 Exercises
The Three Faces of Regular
9.5.1 Optional: Completing the Proof of Kleene's Theorem
9.5.2 Exercises
A Glimpse at More Advanced Topics
9.6.1 Context-Free Languages and Grammars
9.6.2 Turing Machines
9.6.3 Exercises
Quick Check Solutions
Chapter Review
9.8.1 Summary
9.8.2 Notation
9.8.3 Additional Review Material
10 Graphs
10.1 Terminology
10.1.1 New Graphs from Old
10.1.2 Special Graph Families
10.1.3 Exercises
10.2 Connectivity and Adjacency
10.2.1 Connectivity
10.2.2 The Adjacency Matrix
10.2.3 Exercises
10.3 Euler and Hamilton
10.3.1 Euler Circuits and Euler Trails
10.3.2 Hamilton Cycles and Hamilton Paths
10.3.3 Exercises
10.4 Representation and Isomorphism
10.4.1 Representation
10.4.2 Isomorphism
10.4.3 Exercises
10.5 The Big Theorems: Planarity, Euler, Polyhedra, Chromatic Number
10.5.1 Planarity
10.5.2 The Regular Polyhedra
10.5.3 Chromatic Number
10.5.4 Exercises
10.6 Directed Graphs and Weighted Graphs
10.6.1 Directed Graphs
10.6.2 Weighted Graphs and Shortest Paths
10.6.3 Exercises
10.7 Quick Check Solutions
10.8 Chapter Review
10.8.1 Summary
10.8.2 Notation
10.8.3 Additional Review Material
553
554
559
560
560
566
568
569
576
582
584
584
585
590
591
596
596
597
598
599
600
603
605
608
609
609
613
615
618
618
620
624
626
626
629
631
634
634
639
642
648
651
651
655
662
665
670
670
671
671
Contents
XI
11 Trees
11.1 Terminology, Counting
11.1.1 Exercises
11.2 Traversal, Searching, and Sorting
11.2.1 Traversing Binary Trees
11.2.2 Binary Search Trees
11.2.3 Sorting
11.2.4 Exercises
11.3 More Applications of Trees
11.3.1 Parse Trees
11.3.2 Huffman Compression
11.3.3 XML
11.3.4 Exercises
11.4 Spanning Trees
11.4.1 Spanning Trees in Unweighted Graphs
11.4.2 Minimal Spanning Trees in Weighted Graphs
11.4.3 Exercises
11.5 Quick Check Solutions
11.6 Chapter Review
11.6.1 Summary
11.6.2 Notation
11.6.3 Additional Review Material
673
673
680
682
682
685
689
690
692
692
694
699
708
711
711
717
722
726
729
729
729
730
731
731
731
735
737
739
739
742
746
748
748
749
751
752
757
769
772
773
775
778
784
785
785
789
793
795
797
805
805
806
806
Xll
Contents
A Number Systems
A.l The Natural Numbers
A.2 The Integers
A.3 The Rational Numbers
A.4 The Real Numbers
A.5 The Complex Numbers
A.6 Other Number Systems
A.7 Representation of Numbers
Al
Al
A2
A2
A4
A4
A6
A7
Summation Notation
A10
A12
A12
A12
A16
A18
A18
A18
A22
A23
A24
A27
E Matrices
A29
A33
G Writing Mathematics
A34
A36
A36
A36
A42
A47
A51
A54
A59
A63
A68
A71
A75
A78
A83
Bibliography
A85
Index
A90