Bite-Sized Mathematics for Computer Science

Notes on MIT's 6.042J

Eda Eren
Table of Contents

Introduction

Prerequisites & Resources

Unit 1: Proofs

00. Introduction to Proofs

02. The Well Ordering Principle

03. Logic & Propositions

04. Quantifiers and Predicate Logic

05. Sets

06. Binary Relations

07. Induction

08. State Machines — Invariants

09. Recursive Definitions

10. Infinite Sets

Unit 2: Structures

11. GCDs

12. Congruences

13. Euler's Theorem

14. RSA Encryption

15. Digraphs: Walks and Paths

16. Directed Acyclic Graphs

17. Partial Orders and Equivalence

18. Degrees & Isomorphism

19. Coloring & Connectivity

20. Trees

21. Stable Matching

Unit 3: Counting

22. Sums & Products

23. Asymptotics

24. Counting with Bijections

25. Repetitions & Binomial Theorem

26. Pigeonhole Principle, Inclusion-Exclusion

Unit 4: Probability

27. Intro to Discrete Probability

28. Conditional Probability

29. Independence & Causality

30. Random Variables, Density Functions

31. Expectation

32. Deviation: Markov & Chebyshev Bounds

33. Sampling & Confidence

34. Random Walks & PageRank

(Two) Proof Methods

Proof by Cases

Also called proof by exhaustion, or brute force method; it is simply the method of breaking a proof into cases, and proving each case separately.

Let's take a look at an example of how we might prove the statement, "if nn is an integer, n2+3n+2n^2 + 3n + 2 is even."

We can look at three cases:

The first case is when nn is even, we can write it as 2k2k. So, n=2k, kZn = 2k, \ k \in \mathbb{Z}.
Plugging it in, we get (2k)2+3(2k)+2(2k)^2 + 3(2k) + 2, which is 4k2+6k+24k^2 + 6k + 2.
We can factor out a 22, and write it as 2(2k2+3k+1)2(2k^2 + 3k + 1).
Note that what we have now is also a multiple of 22, so we can write it as 2r2r where r=2k2+3k+1r = 2k^2 + 3k + 1. But, we don't even have to do that, since it is a multiple of 22, the whole thing is even, so our proposition is true for the first case.
The second case is when nn is 00. We can just plug it in again, and get (0)2+3(0)+2(0)^2 + 3(0) + 2, which is just 22.
22 is even, so our proposition is true for the second case as well.
The third case is when nn is odd. We can write an odd number as 2k+12k + 1. Again, let's plug it in to the formula: (2k+1)2+3(2k+1)+2(2k + 1)^2 + 3(2k + 1) + 2.
We get 4k2+4k+1+6k+3+24k^2 + 4k + 1 + 6k + 3 + 2. Putting it all together, we have 4k2+10k+64k^2 + 10k + 6. We can factor out 22 here, which makes it 2(2k2+5k+3)2(2k^2 + 5k + 3).
The fact that we are able to factor out a 22 shows that it is a multiple of 22, which means that it is an even number. So, our proposition is true for the third case.
Therefore, we have showed that n2+3n+2n^2 + 3n + 2 is even if nn is an integer. \blacksquare

Proof by Contradiction

If the proposition we're dealing with is false, a false fact has to be true. Read that sentence once again.
A false fact cannot be true, therefore the proposition has to be true. And, this is the way of proof by contradiction.
This is an indirect proof.

A well-known example is proving that 2\sqrt{2} is irrational.
In this case, if the proposition "2\sqrt{2} is irrational" is false, then "2\sqrt{2} is rational" has to be true. But we're going to show that it cannot be true (a false fact), therefore, our proposition must be true.
Let's take a look at it:

So, assume that 2\sqrt{2} is rational.
By definition, in order to be rational, it has to be a ratio of integers, that is, we have to write it in the form ab\frac{a}{b} (where b0b \neq 0) in the lowest (simplest) terms: 2=ab\sqrt{2} = \frac{a}{b}
We can take the square of both sides: 2=a2b22 = \frac{a^2}{b^2}
Multiplying both sides by b2b^2 we get: 2b2=a22b^2 = a^2
Since a2a^2 is an even number, aa has to be even (the square of an even number is an even number).
That means we can write aa as 2c2c where cc is an integer.
So, now we can write the whole thing as: 2b2=(2c)22b^2 = (2c)^2
And, continue: 2b2=4c22b^2 = 4c^2
Simplifying the expression, we get: b2=2c2b^2 = 2c^2
Now, since b2b^2 is an even number, bb has to be even as well.
We see that both aa and bb are even — which means they have a common factor, and that means ab\frac{a}{b} cannot be the most simplified form. We have a contradiction, therefore 2\sqrt{2} is irrational. \blacksquare

NOTE:
You might wonder why we assumed that if "n2n^2 is even, then nn is even". Remember that with prime factorization, all integers more than 11 can be uniquely represented as a product of prime numbers. Since nn is one of the divisors of n2n^2, if 22 is among the primes that divide n2n^2, then one of the prime divisors of nn has to be 22 as well. Therefore, if n2n^2 is even, nn is even.