The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.
Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by airelsopian020211, 2023-06-07 20:47:23

Math Discrete_1-20

Math Discrete_1-20

Keywords: Discrete

Notes on Discrete Mathematics James Aspnes 2022-06-08 10:27


Contents Table of contents ii List of figures xvii List of tables xix List of algorithms xx Preface xxi Resources xxii 1 Introduction 1 1.1 So why do I need to learn all this nasty mathematics? . . . . 1 1.2 But isn’t math hard? . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 Thinking about math with your heart . . . . . . . . . . . . . 3 1.4 What you should know about math . . . . . . . . . . . . . . . 3 1.4.1 Foundations and logic . . . . . . . . . . . . . . . . . . 4 1.4.2 Basic mathematics on the real numbers . . . . . . . . 4 1.4.3 Fundamental mathematical objects . . . . . . . . . . . 5 1.4.4 Modular arithmetic and polynomials . . . . . . . . . . 6 1.4.5 Linear algebra . . . . . . . . . . . . . . . . . . . . . . 6 1.4.6 Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.4.7 Counting . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.4.8 Probability . . . . . . . . . . . . . . . . . . . . . . . . 7 1.4.9 Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2 Mathematical logic 9 2.1 The basic picture . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.1.1 Axioms, models, and inference rules . . . . . . . . . . 9 ii


CONTENTS iii 2.1.2 Consistency . . . . . . . . . . . . . . . . . . . . . . . . 10 2.1.3 What can go wrong . . . . . . . . . . . . . . . . . . . 10 2.1.4 The language of logic . . . . . . . . . . . . . . . . . . 11 2.1.5 Standard axiom systems and models . . . . . . . . . . 11 2.2 Propositional logic . . . . . . . . . . . . . . . . . . . . . . . . 12 2.2.1 Operations on propositions . . . . . . . . . . . . . . . 13 2.2.1.1 Precedence . . . . . . . . . . . . . . . . . . . 15 2.2.2 Truth tables . . . . . . . . . . . . . . . . . . . . . . . . 16 2.2.3 Tautologies and logical equivalence . . . . . . . . . . . 17 2.2.3.1 Inverses, converses, and contrapositives . . . 21 2.2.3.2 Equivalences involving true and false . . . . 21 Example . . . . . . . . . . . . . . . . . . . . . . 22 2.2.4 Normal forms . . . . . . . . . . . . . . . . . . . . . . . 23 2.3 Predicate logic . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.3.1 Variables and predicates . . . . . . . . . . . . . . . . . 26 2.3.2 Quantifiers . . . . . . . . . . . . . . . . . . . . . . . . 27 2.3.2.1 Universal quantifier . . . . . . . . . . . . . . 27 2.3.2.2 Existential quantifier . . . . . . . . . . . . . 27 2.3.2.3 Negation and quantifiers . . . . . . . . . . . 28 2.3.2.4 Restricting the scope of a quantifier . . . . . 28 2.3.2.5 Nested quantifiers . . . . . . . . . . . . . . . 29 2.3.2.6 Examples . . . . . . . . . . . . . . . . . . . . 31 2.3.3 Functions . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.3.4 Equality . . . . . . . . . . . . . . . . . . . . . . . . . . 33 2.3.4.1 Uniqueness . . . . . . . . . . . . . . . . . . . 33 2.3.5 Models . . . . . . . . . . . . . . . . . . . . . . . . . . 34 2.3.5.1 Examples . . . . . . . . . . . . . . . . . . . . 34 2.4 Proofs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.4.1 Inference Rules . . . . . . . . . . . . . . . . . . . . . . 36 2.4.2 Proofs, implication, and natural deduction . . . . . . . 38 2.4.2.1 The Deduction Theorem . . . . . . . . . . . 39 2.4.2.2 Natural deduction . . . . . . . . . . . . . . . 40 2.4.3 Inference rules for equality . . . . . . . . . . . . . . . 40 2.4.4 Inference rules for quantified statements . . . . . . . . 42 2.5 Proof techniques . . . . . . . . . . . . . . . . . . . . . . . . . 43 2.6 Examples of proofs . . . . . . . . . . . . . . . . . . . . . . . . 47 2.6.1 Axioms for even numbers . . . . . . . . . . . . . . . . 47 2.6.2 A theorem and its proof . . . . . . . . . . . . . . . . . 48 2.6.3 A more general theorem . . . . . . . . . . . . . . . . . 50 2.6.4 Something we can’t prove . . . . . . . . . . . . . . . . 51


CONTENTS iv 3 Set theory 52 3.1 Naive set theory . . . . . . . . . . . . . . . . . . . . . . . . . 52 3.2 Operations on sets . . . . . . . . . . . . . . . . . . . . . . . . 54 3.3 Proving things about sets . . . . . . . . . . . . . . . . . . . . 55 3.4 Axiomatic set theory . . . . . . . . . . . . . . . . . . . . . . . 57 3.5 Cartesian products, relations, and functions . . . . . . . . . . 59 3.5.1 Examples of functions . . . . . . . . . . . . . . . . . . 61 3.5.2 Sequences . . . . . . . . . . . . . . . . . . . . . . . . . 61 3.5.3 Functions of more (or less) than one argument . . . . 62 3.5.4 Composition of functions . . . . . . . . . . . . . . . . 62 3.5.5 Functions with special properties . . . . . . . . . . . . 62 3.5.5.1 Surjections . . . . . . . . . . . . . . . . . . . 63 3.5.5.2 Injections . . . . . . . . . . . . . . . . . . . . 63 3.5.5.3 Bijections . . . . . . . . . . . . . . . . . . . . 63 3.5.5.4 Bijections and counting . . . . . . . . . . . . 63 3.6 Constructing the universe . . . . . . . . . . . . . . . . . . . . 64 3.7 Sizes and arithmetic . . . . . . . . . . . . . . . . . . . . . . . 66 3.7.1 Infinite sets . . . . . . . . . . . . . . . . . . . . . . . . 66 3.7.2 Countable sets . . . . . . . . . . . . . . . . . . . . . . 68 3.7.3 Uncountable sets . . . . . . . . . . . . . . . . . . . . . 68 3.8 Further reading . . . . . . . . . . . . . . . . . . . . . . . . . . 69 4 The real numbers 70 4.1 Field axioms . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 4.1.1 Axioms for addition . . . . . . . . . . . . . . . . . . . 71 4.1.2 Axioms for multiplication . . . . . . . . . . . . . . . . 72 4.1.3 Axioms relating multiplication and addition . . . . . . 74 4.1.4 Other algebras satisfying the field axioms . . . . . . . 75 4.2 Order axioms . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 4.3 Least upper bounds . . . . . . . . . . . . . . . . . . . . . . . 77 4.4 What’s missing: algebraic closure . . . . . . . . . . . . . . . . 79 4.5 Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 4.6 Connection between the reals and other standard algebras . . 80 4.7 Extracting information from reals . . . . . . . . . . . . . . . . 82 5 Induction and recursion 83 5.1 Simple induction . . . . . . . . . . . . . . . . . . . . . . . . . 83 5.2 Alternative base cases . . . . . . . . . . . . . . . . . . . . . . 85 5.3 Recursive definitions work . . . . . . . . . . . . . . . . . . . . 86 5.4 Other ways to think about induction . . . . . . . . . . . . . . 86


CONTENTS v 5.5 Strong induction . . . . . . . . . . . . . . . . . . . . . . . . . 87 5.5.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . 88 5.6 Recursively-defined structures . . . . . . . . . . . . . . . . . . 89 5.6.1 Functions on recursive structures . . . . . . . . . . . . 90 5.6.2 Recursive definitions and induction . . . . . . . . . . . 90 5.6.3 Structural induction . . . . . . . . . . . . . . . . . . . 91 6 Summation notation 92 6.1 Summations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 6.1.1 Formal definition . . . . . . . . . . . . . . . . . . . . . 93 6.1.2 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 6.1.3 Summation identities . . . . . . . . . . . . . . . . . . . 95 6.1.4 Choosing and replacing index variables . . . . . . . . . 96 6.1.5 Sums over given index sets . . . . . . . . . . . . . . . 97 6.1.6 Sums without explicit bounds . . . . . . . . . . . . . . 98 6.1.7 Infinite sums . . . . . . . . . . . . . . . . . . . . . . . 98 6.1.8 Double sums . . . . . . . . . . . . . . . . . . . . . . . 99 6.2 Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 6.3 Other big operators . . . . . . . . . . . . . . . . . . . . . . . 100 6.4 Closed forms . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 6.4.1 Some standard sums . . . . . . . . . . . . . . . . . . . 101 6.4.2 Guess but verify . . . . . . . . . . . . . . . . . . . . . 103 6.4.3 Ansatzes . . . . . . . . . . . . . . . . . . . . . . . . . . 103 7 Asymptotic notation 105 7.1 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 7.2 Motivating the definitions . . . . . . . . . . . . . . . . . . . . 105 7.3 Proving asymptotic bounds . . . . . . . . . . . . . . . . . . . 106 7.4 General principles for dealing with asymptotic notation . . . 107 7.4.1 Remember the difference between big-O, big-Ω, and big-Θ . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 7.4.2 Simplify your asymptotic terms as much as possible . 108 7.4.3 Use limits (may require calculus) . . . . . . . . . . . . 108 7.5 Asymptotic notation and summations . . . . . . . . . . . . . 109 7.5.1 Pull out constant factors . . . . . . . . . . . . . . . . . 109 7.5.2 Bound using a known sum . . . . . . . . . . . . . . . . 109 7.5.2.1 Geometric series . . . . . . . . . . . . . . . . 109 7.5.2.2 Constant series . . . . . . . . . . . . . . . . . 110 7.5.2.3 Arithmetic series . . . . . . . . . . . . . . . . 110 7.5.2.4 Harmonic series . . . . . . . . . . . . . . . . 110


CONTENTS vi 7.5.3 Bound part of the sum . . . . . . . . . . . . . . . . . . 111 7.5.4 Integrate . . . . . . . . . . . . . . . . . . . . . . . . . 111 7.5.5 Grouping terms . . . . . . . . . . . . . . . . . . . . . . 111 7.5.6 An odd sum . . . . . . . . . . . . . . . . . . . . . . . . 111 7.5.7 Final notes . . . . . . . . . . . . . . . . . . . . . . . . 112 7.6 Variations in notation . . . . . . . . . . . . . . . . . . . . . . 112 7.6.1 Absolute values . . . . . . . . . . . . . . . . . . . . . . 112 7.6.2 Abusing the equals sign . . . . . . . . . . . . . . . . . 112 8 Number theory 114 8.1 Divisibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 8.2 The division algorithm . . . . . . . . . . . . . . . . . . . . . . 115 8.3 Modular arithmetic and residue classes . . . . . . . . . . . . . 117 8.3.1 Arithmetic on residue classes . . . . . . . . . . . . . . 117 8.4 Greatest common divisors . . . . . . . . . . . . . . . . . . . . 119 8.4.1 The Euclidean algorithm for computing gcd(m, n) . . 120 8.4.2 The extended Euclidean algorithm . . . . . . . . . . . 120 8.4.2.1 Example . . . . . . . . . . . . . . . . . . . . 121 8.4.2.2 Applications . . . . . . . . . . . . . . . . . . 121 8.5 The Fundamental Theorem of Arithmetic . . . . . . . . . . . 123 8.5.1 Unique factorization and gcd . . . . . . . . . . . . . . 124 8.6 More modular arithmetic . . . . . . . . . . . . . . . . . . . . 124 8.6.1 Division in Zm . . . . . . . . . . . . . . . . . . . . . . 124 8.6.2 The Chinese Remainder Theorem . . . . . . . . . . . . 126 8.6.3 The size of Z ∗ m and Euler’s Theorem . . . . . . . . . . 129 8.7 RSA encryption . . . . . . . . . . . . . . . . . . . . . . . . . . 130 9 Relations 132 9.1 Representing relations . . . . . . . . . . . . . . . . . . . . . . 132 9.1.1 Directed graphs . . . . . . . . . . . . . . . . . . . . . . 132 9.1.2 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . 133 9.2 Operations on relations . . . . . . . . . . . . . . . . . . . . . 134 9.2.1 Composition . . . . . . . . . . . . . . . . . . . . . . . 134 9.2.2 Inverses . . . . . . . . . . . . . . . . . . . . . . . . . . 135 9.3 Classifying relations . . . . . . . . . . . . . . . . . . . . . . . 135 9.4 Equivalence relations . . . . . . . . . . . . . . . . . . . . . . . 136 9.4.1 Why we like equivalence relations . . . . . . . . . . . . 138 9.5 Partial orders . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 9.5.1 Drawing partial orders . . . . . . . . . . . . . . . . . . 140 9.5.2 Comparability . . . . . . . . . . . . . . . . . . . . . . 140


CONTENTS vii 9.5.3 Lattices . . . . . . . . . . . . . . . . . . . . . . . . . . 141 9.5.4 Minimal and maximal elements . . . . . . . . . . . . . 142 9.5.5 Total orders . . . . . . . . . . . . . . . . . . . . . . . . 143 9.5.5.1 Topological sort . . . . . . . . . . . . . . . . 143 9.5.6 Well orders . . . . . . . . . . . . . . . . . . . . . . . . 146 9.6 Closures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 9.6.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . 150 10 Graphs 152 10.1 Types of graphs . . . . . . . . . . . . . . . . . . . . . . . . . . 153 10.1.1 Directed graphs . . . . . . . . . . . . . . . . . . . . . . 153 10.1.2 Undirected graphs . . . . . . . . . . . . . . . . . . . . 153 10.1.3 Hypergraphs . . . . . . . . . . . . . . . . . . . . . . . 154 10.2 Examples of graphs . . . . . . . . . . . . . . . . . . . . . . . . 155 10.3 Local structure of graphs . . . . . . . . . . . . . . . . . . . . 156 10.4 Some standard graphs . . . . . . . . . . . . . . . . . . . . . . 156 10.5 Subgraphs and minors . . . . . . . . . . . . . . . . . . . . . . 161 10.6 Graph products . . . . . . . . . . . . . . . . . . . . . . . . . . 162 10.7 Functions between graphs . . . . . . . . . . . . . . . . . . . . 163 10.8 Paths and connectivity . . . . . . . . . . . . . . . . . . . . . . 164 10.9 Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 10.10Proving things about graphs . . . . . . . . . . . . . . . . . . . 167 10.10.1 Paths and simple paths . . . . . . . . . . . . . . . . . 167 10.10.2 The Handshaking Lemma . . . . . . . . . . . . . . . . 168 10.10.3 Characterizations of trees . . . . . . . . . . . . . . . . 168 10.10.4 Spanning trees . . . . . . . . . . . . . . . . . . . . . . 172 10.10.5 Eulerian cycles . . . . . . . . . . . . . . . . . . . . . . 172 11 Counting 174 11.1 Basic counting techniques . . . . . . . . . . . . . . . . . . . . 175 11.1.1 Equality: reducing to a previously-solved case . . . . . 175 11.1.2 Inequalities: showing |A| ≤ |B| and |B| ≤ |A| . . . . . 175 11.1.3 Addition: the sum rule . . . . . . . . . . . . . . . . . . 176 11.1.3.1 For infinite sets . . . . . . . . . . . . . . . . 177 11.1.3.2 The Pigeonhole Principle . . . . . . . . . . . 177 11.1.4 Subtraction . . . . . . . . . . . . . . . . . . . . . . . . 178 11.1.4.1 Inclusion-exclusion for infinite sets . . . . . . 178 11.1.4.2 Combinatorial proof . . . . . . . . . . . . . . 179 11.1.5 Multiplication: the product rule . . . . . . . . . . . . 179 11.1.5.1 Examples . . . . . . . . . . . . . . . . . . . . 180


CONTENTS viii 11.1.5.2 For infinite sets . . . . . . . . . . . . . . . . 180 11.1.6 Exponentiation: the exponent rule . . . . . . . . . . . 181 11.1.6.1 Counting injections . . . . . . . . . . . . . . 181 11.1.7 Division: counting the same thing in two different ways182 11.1.7.1 Binomial coefficients . . . . . . . . . . . . . . 182 11.1.7.2 Multinomial coefficients . . . . . . . . . . . . 183 11.1.8 Applying the rules . . . . . . . . . . . . . . . . . . . . 184 11.1.9 An elaborate counting problem . . . . . . . . . . . . . 186 11.1.10 Further reading . . . . . . . . . . . . . . . . . . . . . . 189 11.2 Binomial coefficients . . . . . . . . . . . . . . . . . . . . . . . 189 11.2.1 Recursive definition . . . . . . . . . . . . . . . . . . . 190 11.2.1.1 Pascal’s identity: algebraic proof . . . . . . . 191 11.2.2 Vandermonde’s identity . . . . . . . . . . . . . . . . . 192 11.2.2.1 Combinatorial proof . . . . . . . . . . . . . . 192 11.2.2.2 Algebraic proof . . . . . . . . . . . . . . . . . 193 11.2.3 Sums of binomial coefficients . . . . . . . . . . . . . . 194 11.2.4 The general inclusion-exclusion formula . . . . . . . . 194 11.2.5 Negative binomial coefficients . . . . . . . . . . . . . . 195 11.2.6 Fractional binomial coefficients . . . . . . . . . . . . . 197 11.2.7 Further reading . . . . . . . . . . . . . . . . . . . . . . 197 11.3 Generating functions . . . . . . . . . . . . . . . . . . . . . . . 197 11.3.1 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 11.3.1.1 A simple example . . . . . . . . . . . . . . . 197 11.3.1.2 Why this works . . . . . . . . . . . . . . . . 198 11.3.1.3 Formal definition . . . . . . . . . . . . . . . . 199 11.3.2 Some standard generating functions . . . . . . . . . . 202 11.3.3 More operations on formal power series and generating functions . . . . . . . . . . . . . . . . . . . . . . . . . 202 11.3.4 Counting with generating functions . . . . . . . . . . . 203 11.3.4.1 Disjoint union . . . . . . . . . . . . . . . . . 203 11.3.4.2 Cartesian product . . . . . . . . . . . . . . . 204 11.3.4.3 Repetition . . . . . . . . . . . . . . . . . . . 204 Example: (0|11)∗ . . . . . . . . . . . . . . . . . 204 Example: sequences of positive integers . . . . 204 11.3.4.4 Pointing . . . . . . . . . . . . . . . . . . . . 206 11.3.4.5 Substitution . . . . . . . . . . . . . . . . . . 206 Example: bit-strings with primes . . . . . . . . 207 Example: (0|11)* again . . . . . . . . . . . . . 207 11.3.5 Generating functions and recurrences . . . . . . . . . 207 11.3.5.1 Example: A Fibonacci-like recurrence . . . . 208


CONTENTS ix 11.3.6 Recovering coefficients from generating functions . . . 208 11.3.6.1 Partial fraction expansion and Heaviside’s cover-up method . . . . . . . . . . . . . . . . 210 Example: A simple recurrence . . . . . . . . . . 210 Example: Coughing cows . . . . . . . . . . . . 211 Example: A messy recurrence . . . . . . . . . . 212 11.3.6.2 Partial fraction expansion with repeated roots214 Solving for the PFE directly . . . . . . . . . . . 214 Solving for the PFE using the extended cover-up method . . . . . . . . . . . . . . . . 216 11.3.7 Asymptotic estimates . . . . . . . . . . . . . . . . . . 217 11.3.8 Recovering the sum of all coefficients . . . . . . . . . . 218 11.3.8.1 Example . . . . . . . . . . . . . . . . . . . . 218 11.3.9 A recursive generating function . . . . . . . . . . . . . 219 11.3.10 Summary of operations on generating functions . . . . 222 11.3.11 Variants . . . . . . . . . . . . . . . . . . . . . . . . . . 223 11.3.12 Further reading . . . . . . . . . . . . . . . . . . . . . . 223 12 Probability theory 224 12.1 Events and probabilities . . . . . . . . . . . . . . . . . . . . . 225 12.1.1 Probability axioms . . . . . . . . . . . . . . . . . . . . 225 12.1.1.1 The Kolmogorov axioms . . . . . . . . . . . . 226 12.1.1.2 Examples of probability spaces . . . . . . . . 227 12.1.2 Probability as counting . . . . . . . . . . . . . . . . . 227 12.1.2.1 Examples . . . . . . . . . . . . . . . . . . . . 228 12.1.3 Independence and the intersection of two events . . . 228 12.1.3.1 Examples . . . . . . . . . . . . . . . . . . . . 229 12.1.4 Union of events . . . . . . . . . . . . . . . . . . . . . . 230 12.1.4.1 Examples . . . . . . . . . . . . . . . . . . . . 230 12.1.5 Conditional probability . . . . . . . . . . . . . . . . . 231 12.1.5.1 Conditional probabilities and intersections of non-independent events . . . . . . . . . . . . 231 12.1.5.2 The law of total probability . . . . . . . . . . 232 12.1.5.3 Bayes’s formula . . . . . . . . . . . . . . . . 232 12.2 Random variables . . . . . . . . . . . . . . . . . . . . . . . . . 233 12.2.1 Examples of random variables . . . . . . . . . . . . . . 233 12.2.2 The distribution of a random variable . . . . . . . . . 234 12.2.2.1 Some standard distributions . . . . . . . . . 234 12.2.2.2 Joint distributions . . . . . . . . . . . . . . . 236 Examples . . . . . . . . . . . . . . . . . . . . . 236


CONTENTS x 12.2.3 Independence of random variables . . . . . . . . . . . 236 12.2.3.1 Examples . . . . . . . . . . . . . . . . . . . . 237 12.2.3.2 Independence of many random variables . . . 237 12.2.4 The expectation of a random variable . . . . . . . . . 238 12.2.4.1 Variables without expectations . . . . . . . . 239 12.2.4.2 Expectation of a sum . . . . . . . . . . . . . 239 Example . . . . . . . . . . . . . . . . . . . . . . 240 12.2.4.3 Expectation of a product . . . . . . . . . . . 240 12.2.4.4 Conditional expectation . . . . . . . . . . . . 241 Examples . . . . . . . . . . . . . . . . . . . . . 242 12.2.4.5 Conditioning on a random variable . . . . . . 244 12.2.5 Markov’s inequality . . . . . . . . . . . . . . . . . . . 245 12.2.5.1 Example . . . . . . . . . . . . . . . . . . . . 246 12.2.5.2 Conditional Markov’s inequality . . . . . . . 246 12.2.6 The variance of a random variable . . . . . . . . . . . 246 12.2.6.1 Multiplication by constants . . . . . . . . . . 247 12.2.6.2 The variance of a sum . . . . . . . . . . . . . 248 12.2.6.3 Chebyshev’s inequality . . . . . . . . . . . . 249 Application: showing that a random variable is close to its expectation . . . . . . . 249 Application: lower bounds on random variables 250 12.2.7 Probability generating functions . . . . . . . . . . . . 250 12.2.7.1 Sums . . . . . . . . . . . . . . . . . . . . . . 251 12.2.7.2 Expectation and variance . . . . . . . . . . . 251 12.2.8 Summary: effects of operations on expectation and variance of random variables . . . . . . . . . . . . . . 252 12.2.9 The general case . . . . . . . . . . . . . . . . . . . . . 253 12.2.9.1 Densities . . . . . . . . . . . . . . . . . . . . 254 12.2.9.2 Independence . . . . . . . . . . . . . . . . . . 255 12.2.9.3 Expectation . . . . . . . . . . . . . . . . . . 255 13 Linear algebra 257 13.1 Vectors and vector spaces . . . . . . . . . . . . . . . . . . . . 257 13.1.1 Relative positions and vector addition . . . . . . . . . 258 13.1.2 Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . 259 13.2 Abstract vector spaces . . . . . . . . . . . . . . . . . . . . . . 260 13.3 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 13.3.1 Interpretation . . . . . . . . . . . . . . . . . . . . . . . 262 13.3.2 Operations on matrices . . . . . . . . . . . . . . . . . 263 13.3.2.1 Transpose of a matrix . . . . . . . . . . . . . 263


CONTENTS xi 13.3.2.2 Sum of two matrices . . . . . . . . . . . . . . 263 13.3.2.3 Product of two matrices . . . . . . . . . . . . 264 13.3.2.4 The inverse of a matrix . . . . . . . . . . . . 265 Example . . . . . . . . . . . . . . . . . . . . . . 266 13.3.2.5 Scalar multiplication . . . . . . . . . . . . . . 267 13.3.3 Matrix identities . . . . . . . . . . . . . . . . . . . . . 267 13.4 Vectors as matrices . . . . . . . . . . . . . . . . . . . . . . . . 269 13.4.1 Length . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 13.4.2 Dot products and orthogonality . . . . . . . . . . . . . 271 13.5 Linear combinations and subspaces . . . . . . . . . . . . . . . 272 13.5.1 Bases . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 13.6 Linear transformations . . . . . . . . . . . . . . . . . . . . . . 274 13.6.1 Composition . . . . . . . . . . . . . . . . . . . . . . . 275 13.6.2 Role of rows and columns of M in the product Mx . . 275 13.6.3 Geometric interpretation . . . . . . . . . . . . . . . . . 276 13.6.4 Rank and inverses . . . . . . . . . . . . . . . . . . . . 278 13.6.5 Projections . . . . . . . . . . . . . . . . . . . . . . . . 279 13.7 Further reading . . . . . . . . . . . . . . . . . . . . . . . . . . 281 14 Finite fields 283 14.1 A magic trick . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 14.2 Fields and rings . . . . . . . . . . . . . . . . . . . . . . . . . . 284 14.3 Polynomials over a field . . . . . . . . . . . . . . . . . . . . . 286 14.4 Algebraic field extensions . . . . . . . . . . . . . . . . . . . . 287 14.5 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 14.5.1 Linear-feedback shift registers . . . . . . . . . . . . . . 289 14.5.2 Checksums . . . . . . . . . . . . . . . . . . . . . . . . 290 14.5.3 Cryptography . . . . . . . . . . . . . . . . . . . . . . . 291 A Sample assignments from Fall 2017 292 A.1 Assignment 1: Due Wednesday, 2017-09-13, at 5:00 pm . . . . 292 A.1.1 A curious proposition . . . . . . . . . . . . . . . . . . 293 A.1.2 Relations . . . . . . . . . . . . . . . . . . . . . . . . . 294 A.1.3 A theory of shirts . . . . . . . . . . . . . . . . . . . . . 295 A.2 Assignment 2: Due Wednesday, 2017-09-20, at 5:00 pm . . . . 297 A.2.1 Arithmetic, or is it? . . . . . . . . . . . . . . . . . . . 297 A.2.2 Some distributive laws . . . . . . . . . . . . . . . . . . 298 A.2.3 Elements and subsets . . . . . . . . . . . . . . . . . . 299 A.3 Assignment 3: Due Wednesday, 2017-09-27, at 5:00 pm . . . . 300 A.3.1 A powerful problem . . . . . . . . . . . . . . . . . . . 300


CONTENTS xii A.3.2 A correspondence . . . . . . . . . . . . . . . . . . . . . 300 A.3.3 Inverses . . . . . . . . . . . . . . . . . . . . . . . . . . 301 A.4 Assignment 4: Due Wednesday, 2017-10-04, at 5:00 pm . . . . 301 A.4.1 Covering a set with itself . . . . . . . . . . . . . . . . 301 A.4.2 More inverses . . . . . . . . . . . . . . . . . . . . . . . 301 A.4.3 Rational and irrational . . . . . . . . . . . . . . . . . . 302 A.5 Assignment 5: Due Wednesday, 2017-10-11, at 5:00 pm . . . . 302 A.5.1 A recursive sequence . . . . . . . . . . . . . . . . . . . 302 A.5.2 Comparing products . . . . . . . . . . . . . . . . . . . 303 A.5.3 Rubble removal . . . . . . . . . . . . . . . . . . . . . . 304 A.6 Assignment 6: Due Wednesday, 2017-10-25, at 5:00 pm . . . . 305 A.6.1 An oscillating sum . . . . . . . . . . . . . . . . . . . . 305 A.6.2 An approximate sum . . . . . . . . . . . . . . . . . . . 307 A.6.3 A stretched function . . . . . . . . . . . . . . . . . . . 307 A.7 Assignment 7: Due Wednesday, 2017-11-01, at 5:00 pm . . . . 308 A.7.1 Divisibility . . . . . . . . . . . . . . . . . . . . . . . . 308 A.7.2 Squares . . . . . . . . . . . . . . . . . . . . . . . . . . 309 A.7.3 A Series of Unfortunate Exponents . . . . . . . . . . . 309 A.8 Assignment 8: Due Wednesday, 2017-11-08, at 5:00 pm . . . . 310 A.8.1 Minimal and maximal elements . . . . . . . . . . . . . 310 A.8.2 No trailing zeros . . . . . . . . . . . . . . . . . . . . . 311 A.8.3 Domination . . . . . . . . . . . . . . . . . . . . . . . . 313 A.9 Assignment 9: Due Wednesday, 2017-11-15, at 5:00 pm . . . . 314 A.9.1 Quadrangle closure . . . . . . . . . . . . . . . . . . . . 314 A.9.2 Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 A.9.3 Deleting a graph . . . . . . . . . . . . . . . . . . . . . 316 A.10 Assignment 10: Due Wednesday, 2017-11-29, at 5:00 pm . . . 317 A.10.1 Too many injections . . . . . . . . . . . . . . . . . . . 317 A.10.2 Binomial coefficients . . . . . . . . . . . . . . . . . . . 317 A.10.3 Variable names . . . . . . . . . . . . . . . . . . . . . . 318 B Sample exams from Fall 2017 322 B.1 CPSC 202 Exam 1, October 17th, 2017 . . . . . . . . . . . . 322 B.1.1 Factorials (20 points) . . . . . . . . . . . . . . . . . . 322 B.1.2 A tautology (20 points) . . . . . . . . . . . . . . . . . 322 B.1.3 Subsets (20 points) . . . . . . . . . . . . . . . . . . . . 323 B.1.4 Surjective functions (20 points) . . . . . . . . . . . . . 323 B.2 CPSC 202 Exam 2, December 7th, 2017 . . . . . . . . . . . . 323 B.2.1 Non-decreasing sequences (20 points) . . . . . . . . . . 324 B.2.2 Perfect matchings (20 points) . . . . . . . . . . . . . . 325


CONTENTS xiii B.2.3 Quadratic forms (20 points) . . . . . . . . . . . . . . . 326 B.2.4 Minimal lattices (20 points) . . . . . . . . . . . . . . . 327 C Sample assignments from Fall 2013 328 C.1 Assignment 1: due Thursday, 2013-09-12, at 5:00 pm . . . . . 328 C.1.1 Tautologies . . . . . . . . . . . . . . . . . . . . . . . . 328 C.1.2 Positively equivalent . . . . . . . . . . . . . . . . . . . 330 C.1.3 A theory of leadership . . . . . . . . . . . . . . . . . . 331 C.2 Assignment 2: due Thursday, 2013-09-19, at 5:00 pm . . . . . 332 C.2.1 Subsets . . . . . . . . . . . . . . . . . . . . . . . . . . 332 C.2.2 A distributive law . . . . . . . . . . . . . . . . . . . . 333 C.2.3 Exponents . . . . . . . . . . . . . . . . . . . . . . . . . 333 C.3 Assignment 3: due Thursday, 2013-09-26, at 5:00 pm . . . . . 334 C.3.1 Surjections . . . . . . . . . . . . . . . . . . . . . . . . 334 C.3.2 Proving an axiom the hard way . . . . . . . . . . . . . 335 C.3.3 Squares and bigger squares . . . . . . . . . . . . . . . 335 C.4 Assignment 4: due Thursday, 2013-10-03, at 5:00 pm . . . . . 336 C.4.1 A fast-growing function . . . . . . . . . . . . . . . . . 336 C.4.2 A slow-growing set . . . . . . . . . . . . . . . . . . . . 337 C.4.3 Double factorials . . . . . . . . . . . . . . . . . . . . . 338 C.5 Assignment 5: due Thursday, 2013-10-10, at 5:00 pm . . . . . 339 C.5.1 A bouncy function . . . . . . . . . . . . . . . . . . . . 339 C.5.2 Least common multiples of greatest common divisors . 340 C.5.3 Adding and subtracting . . . . . . . . . . . . . . . . . 341 C.6 Assignment 6: due Thursday, 2013-10-31, at 5:00 pm . . . . . 341 C.6.1 Factorials mod n . . . . . . . . . . . . . . . . . . . . . 341 C.6.2 Indivisible and divisible . . . . . . . . . . . . . . . . . 342 C.6.3 Equivalence relations . . . . . . . . . . . . . . . . . . . 342 C.7 Assignment 7: due Thursday, 2013-11-07, at 5:00 pm . . . . 343 C.7.1 Flipping lattices with a function . . . . . . . . . . . . 343 C.7.2 Splitting graphs with a mountain . . . . . . . . . . . . 344 C.7.3 Drawing stars with modular arithmetic . . . . . . . . 344 C.8 Assignment 8: due Thursday, 2013-11-14, at 5:00 pm . . . . 347 C.8.1 Two-path graphs . . . . . . . . . . . . . . . . . . . . . 347 C.8.2 Even teams . . . . . . . . . . . . . . . . . . . . . . . . 349 C.8.3 Inflected sequences . . . . . . . . . . . . . . . . . . . . 350 C.9 Assignment 9: due Thursday, 2013-11-21, at 5:00 pm . . . . 351 C.9.1 Guessing the median . . . . . . . . . . . . . . . . . . . 351 C.9.2 Two flushes . . . . . . . . . . . . . . . . . . . . . . . . 352 C.9.3 Dice and more dice . . . . . . . . . . . . . . . . . . . . 354


CONTENTS xiv D Sample exams from Fall 2013 356 D.1 CS202 Exam 1, October 17th, 2013 . . . . . . . . . . . . . . . 356 D.1.1 A tautology (20 points) . . . . . . . . . . . . . . . . . 356 D.1.2 A system of equations (20 points) . . . . . . . . . . . 357 D.1.3 A sum of products (20 points) . . . . . . . . . . . . . 357 D.1.4 A subset problem (20 points) . . . . . . . . . . . . . . 358 D.2 CS202 Exam 2, December 4th, 2013 . . . . . . . . . . . . . . 358 D.2.1 Minimum elements (20 points) . . . . . . . . . . . . . 359 D.2.2 Quantifiers (20 points) . . . . . . . . . . . . . . . . . . 359 D.2.3 Quadratic matrices (20 points) . . . . . . . . . . . . . 359 D.2.4 Low-degree connected graphs (20 points) . . . . . . . 361 E Midterm exams from earlier semesters 362 E.1 Midterm Exam, October 12th, 2005 . . . . . . . . . . . . . . 362 E.1.1 A recurrence (20 points) . . . . . . . . . . . . . . . . . 362 E.1.2 An induction proof (20 points) . . . . . . . . . . . . . 363 E.1.3 Some binomial coefficients (20 points) . . . . . . . . . 364 E.1.4 A probability problem (20 points) . . . . . . . . . . . 364 E.2 Midterm Exam, October 24th, 2007 . . . . . . . . . . . . . . 365 E.2.1 Dueling recurrences (20 points) . . . . . . . . . . . . . 365 E.2.2 Seating arrangements (20 points) . . . . . . . . . . . . 365 E.2.3 Non-attacking rooks (20 points) . . . . . . . . . . . . . 366 E.2.4 Subsets (20 points) . . . . . . . . . . . . . . . . . . . . 367 E.3 Midterm Exam, October 24th, 2008 . . . . . . . . . . . . . . 367 E.3.1 Some sums (20 points) . . . . . . . . . . . . . . . . . . 367 E.3.2 Nested ranks (20 points) . . . . . . . . . . . . . . . . . 367 E.3.3 Nested sets (20 points) . . . . . . . . . . . . . . . . . . 368 E.3.4 An efficient grading method (20 points) . . . . . . . . 369 E.4 Midterm exam, October 21st, 2010 . . . . . . . . . . . . . . . 369 E.4.1 A partial order (20 points) . . . . . . . . . . . . . . . 370 E.4.2 Big exponents (20 points) . . . . . . . . . . . . . . . . 370 E.4.3 At the playground (20 points) . . . . . . . . . . . . . . 370 E.4.4 Gauss strikes back (20 points) . . . . . . . . . . . . . . 371 F Final exams from earlier semesters 372 F.1 CS202 Final Exam, December 15th, 2004 . . . . . . . . . . . 372 F.1.1 A multiplicative game (20 points) . . . . . . . . . . . 372 F.1.2 An equivalence in space (20 points) . . . . . . . . . . . 374 F.1.3 A very big fraction (20 points) . . . . . . . . . . . . . 374 F.1.4 A pair of odd vertices (20 points) . . . . . . . . . . . . 375


CONTENTS xv F.1.5 How many magmas? (20 points) . . . . . . . . . . . . 375 F.1.6 A powerful relationship (20 points) . . . . . . . . . . . 375 F.1.7 A group of archaeologists (20 points) . . . . . . . . . . 376 F.2 CS202 Final Exam, December 16th, 2005 . . . . . . . . . . . 376 F.2.1 Order (20 points) . . . . . . . . . . . . . . . . . . . . . 377 F.2.2 Count the subgroups (20 points) . . . . . . . . . . . . 377 F.2.3 Two exits (20 points) . . . . . . . . . . . . . . . . . . . 377 F.2.4 Victory (20 points) . . . . . . . . . . . . . . . . . . . . 378 F.2.5 An aggressive aquarium (20 points) . . . . . . . . . . 378 F.2.6 A subspace of matrices (20 points) . . . . . . . . . . . 379 F.3 CS202 Final Exam, December 20th, 2007 . . . . . . . . . . . 380 F.3.1 A coin-flipping problem (20 points) . . . . . . . . . . . 380 F.3.2 An ordered group (20 points) . . . . . . . . . . . . . . 381 F.3.3 Weighty vectors (20 points) . . . . . . . . . . . . . . . 381 F.3.4 A dialectical problem (20 points) . . . . . . . . . . . . 382 F.3.5 A predictable pseudorandom generator (20 points) . . 383 F.3.6 At the robot factory (20 points) . . . . . . . . . . . . 384 F.4 CS202 Final Exam, December 19th, 2008 . . . . . . . . . . . 384 F.4.1 Some logical sets (20 points) . . . . . . . . . . . . . . 384 F.4.2 Modularity (20 points) . . . . . . . . . . . . . . . . . . 385 F.4.3 Coin flipping (20 points) . . . . . . . . . . . . . . . . . 385 F.4.4 A transitive graph (20 points) . . . . . . . . . . . . . . 386 F.4.5 A possible matrix identity (20 points) . . . . . . . . . 386 F.5 CS202 Final Exam, December 14th, 2010 . . . . . . . . . . . 387 F.5.1 Backwards and forwards (20 points) . . . . . . . . . . 387 F.5.2 Linear transformations (20 points) . . . . . . . . . . . 388 F.5.3 Flipping coins (20 points) . . . . . . . . . . . . . . . . 389 F.5.4 Subtracting dice (20 points) . . . . . . . . . . . . . . . 390 F.5.5 Scanning an array (20 points) . . . . . . . . . . . . . . 391 G How to write mathematics 392 G.1 By hand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 G.2 LATEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392 G.3 Microsoft Word equation editor . . . . . . . . . . . . . . . . . 393 G.4 Google Docs equation editor . . . . . . . . . . . . . . . . . . . 396 G.5 ASCII and/or Unicode art . . . . . . . . . . . . . . . . . . . . 396 G.6 Markdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397


CONTENTS xvi H Tools from calculus 398 H.1 Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398 H.2 Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400 H.3 Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402 I The natural numbers 405 I.1 The Peano axioms . . . . . . . . . . . . . . . . . . . . . . . . 405 I.2 A simple proof . . . . . . . . . . . . . . . . . . . . . . . . . . 407 I.3 Defining addition . . . . . . . . . . . . . . . . . . . . . . . . . 408 I.3.1 Other useful properties of addition . . . . . . . . . . . 410 I.4 A scary induction proof involving even numbers . . . . . . . . 411 I.5 Defining more operations . . . . . . . . . . . . . . . . . . . . 412 Bibliography 414 Index 417


List of Figures 8.1 Trace of extended Euclidean algorithm . . . . . . . . . . . . . 121 8.2 Python code for extended Euclidean algorithm . . . . . . . . 122 9.1 A directed graph . . . . . . . . . . . . . . . . . . . . . . . . . 133 9.2 Relation as a directed graph . . . . . . . . . . . . . . . . . . . 133 9.3 Factors of 12 partially ordered by divisibility . . . . . . . . . 141 9.4 Maximal and minimal elements . . . . . . . . . . . . . . . . . 142 9.5 Topological sort . . . . . . . . . . . . . . . . . . . . . . . . . . 144 9.6 Reflexive, symmetric, and transitive closures . . . . . . . . . . 149 9.7 Strongly-connected components . . . . . . . . . . . . . . . . . 150 10.1 A directed graph . . . . . . . . . . . . . . . . . . . . . . . . . 153 10.2 A graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 10.3 Two representations of a hypergraph . . . . . . . . . . . . . . 155 10.4 Complete graphs K1 through K10 . . . . . . . . . . . . . . . . 157 10.5 Cycle graphs C3 through C11 . . . . . . . . . . . . . . . . . . 158 10.6 Path graphs P0 through P4 . . . . . . . . . . . . . . . . . . . 159 10.7 Complete bipartite graph K3,4 . . . . . . . . . . . . . . . . . 159 10.8 star graphs K1,3 through K1,8 . . . . . . . . . . . . . . . . . . 160 10.9 Cayley graph of D4 . . . . . . . . . . . . . . . . . . . . . . . . 160 10.10Two presentations of the cube graph Q3 . . . . . . . . . . . . 161 10.11Subgraphs and minors . . . . . . . . . . . . . . . . . . . . . . 162 10.12Cycles and closed walks . . . . . . . . . . . . . . . . . . . . . 166 13.1 Geometric interpretation of vector addition . . . . . . . . . . 258 C.1 Examples of Sm,k for Problem C.7.3 . . . . . . . . . . . . . . 345 C.2 All 90 two-path graphs on five vertices . . . . . . . . . . . . . 346 G.1 Source code for sample LATEX document. . . . . . . . . . . . . 394 xvii


LIST OF FIGURES xviii G.2 Formatted sample LATEX document. . . . . . . . . . . . . . . 395


List of Tables 2.1 Compound propositions . . . . . . . . . . . . . . . . . . . . . 15 2.2 Common logical equivalences . . . . . . . . . . . . . . . . . . 20 2.3 Absorption laws . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.4 Natural deduction: introduction and elimination rules . . . . 41 2.5 Natural deduction: introduction and elimination rules for quantifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 2.6 Proof techniques . . . . . . . . . . . . . . . . . . . . . . . . . 47 3.1 Set comprehension vs list comprehension . . . . . . . . . . . . 54 4.1 Features of various standard algebras . . . . . . . . . . . . . . 82 8.1 Arithmetic in Z5 . . . . . . . . . . . . . . . . . . . . . . . . . 119 8.2 Multiplication table for Z9 . . . . . . . . . . . . . . . . . . . . 125 H.1 Table of derivatives . . . . . . . . . . . . . . . . . . . . . . . . 401 H.2 Table of integrals . . . . . . . . . . . . . . . . . . . . . . . . . 403 xix


List of Algorithms xx


Click to View FlipBook Version