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

01. (Two) Proof Methods

02. The Well Ordering Principle

03. Logic & Propositions

04. Quantifiers and Predicate Logic

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

Sets

There are a lot of things to talk about when it comes to sets.
Since it is assumed that you already know about things like union, intersection, etc., we're not going to go over set operations.

Some popular sets you might know are:

symbols set elements
\varnothing the empty set none
N\mathbb{N} natural numbers (or, nonnegative integers if you don't like to get political) {0, 1, 2, ...}\{0, \ 1, \ 2, \ ...\}
Z\mathbb{Z} integers {..., 2, 1, 0, 1, 2, ...}\{..., \ -2, \ -1, \ 0, \ 1, \ 2, \ ...\}
Q\mathbb{Q} rational numbers 12, 43, 16, etc.\frac{1}{2}, \ -\frac{4}{3}, \ 16, \ etc.
R\mathbb{R} real numbers π, e, 3, 2, etc.\pi, \ e, \ -3, \ \sqrt{2}, \ etc.
C\mathbb{C} complex numbers i, 192, 22i, etc.i, \ \frac{19}{2}, \ \sqrt{2} - 2i, \ etc.

Look at this formula:

AB=x[xA    xB]A \subseteq B = \forall x [x \in A \implies x \in B]

This is the subset notation (\subseteq), and the formula says that for all xx, if xx in AA, then xx in BB. It also implies that both sets are equal.
When talking about a proper subset, the notation is \subset, for example ABA \subset B. That means AA is a proper subset of BB, and they are not equal.

Why is \varnothing is a subset of every set?

Well, think of this: B\varnothing \subseteq B. That means x[x    xB]\forall x [x \in \varnothing \implies x \in B].
That is an implication. The first part of it is clearly false, there is nothing in an empty set, yet we say xx \in \varnothing. Remember that in an implication, when the antecedent (the "if part") is false, no matter what follows, the whole statement is true. So, both the statements F     \implies T and F     \implies F are true. It doesn't matter if xx is in BB or not, since xx \in \varnothing is clearly false, the whole statement is true.


A power set is the set of all subsets of a set.

For example, if our set is {T,F}\{T, F\} then its power set is {{T},{F},{T,F},}\{\{T\}, \{F\}, \{T, F\}, \varnothing\}.

Another example is Z+pow(Z)\mathbb{Z}^+ \in pow(\mathbb{Z}). It says that the set of positive integers is in the power set of integers.


Difference is every element in set AA and not in set BB:

AB={x  (xA)(xB)}A - B = \{x \ | \ (x \in A) \cap (x \notin B)\}

The complement of a set is the set of all elements that are not in that set. It is denoted with an overline, like B\overline{B}.

An example, if the domain we’re working with is the integers, then the complement of the nonnegative integers is the set of negative integers: N=Z\overline{\mathbb{N}} = \mathbb{Z}^-.


Finite Cardinality

When a set is finite, the number of elements it has is called its size, or cardinality, and it is denoted as A|A|.

So, A|A| means the "number of elements in set AA".


There are 2n2^n number of subsets of a set that has nn elements: (A=n)    (pow(A)=2n)(|A| = n) \implies (|pow(A)| = 2^n)

But, why is that?

Why is the size of a power set is 2n2^n?

Alright, we are going to use a string representation for all possible subsets, where an element can be in it, or not.
We're going to put 00 where the element exists in the set but not in the subset, and we're going to put 11 where the element exists both in the set and the subset.

Let's say that our set AA is {a,b,c}\{a, b, c\}.

We can say a subset could be the one where none of the elements exist — which is indeed the empty set, so we can represent it as 0,0,00, 0, 0.

Another possibility is a subset where only aa exists — we will represent it as such: 1,0,01, 0, 0. This is the subset {a}\{a\}.

Going on like this, let's see all the possibilities:

string subset
0,0,00, 0, 0 \varnothing
1,0,01, 0, 0 {a}\{a\}
0,1,00, 1, 0 {b}\{b\}
0,0,10, 0, 1 {c}\{c\}
1,1,01, 1, 0 {a,b}\{a, b\}
1,0,11, 0, 1 {a,c}\{a, c\}
0,1,10, 1, 1 {b,c}\{b, c\}
1,1,11, 1, 1 {a,b,c}\{a, b, c\}

This is indeed our power set, pow(A)pow(A) which is {,{a},{b},{c},{a,b},{a,c},{b,c},{a,b,c}}\{\varnothing, \{a\}, \{b\}, \{c\}, \{a, b\}, \{a, c\}, \{b, c\}, \{a, b, c\}\}.

The number of string representations (the number of nn bit strings) is the same as 2n2^n, which is the size of our power set!

In our case, nn is 33, so the size of our power set is 88.


And, here are some set identities:

Identity Laws
A=AA \cup \varnothing = A
AU=AA \cap U = A
Domination Laws
AU=UA \cup U = U
A=A \cap \varnothing = \varnothing
Idempotent Laws
AA=AA \cup A = A
AA=AA \cap A = A
Complementation Law
(A)=A\overline{(\overline A)} = A
Commutative Law
AB=BAA \cup B = B \cup A
AB=BAA \cap B = B \cap A
Associative Laws
A(BC)=(AB)CA \cup (B \cup C) = (A \cup B) \cup C
A(BC)=(AB)CA \cap (B \cap C) = (A \cap B) \cap C
Distributive Laws
A(BC)=(AB)(AB)A \cap (B \cup C) = (A \cap B) \cup (A \cap B)
A(BC)=(AB)(AB)A \cup (B \cap C) = (A \cup B) \cap (A \cup B)
De Morgan's Laws
AB=AB\overline{A \cup B} = \overline A \cap \overline B
AB=AB\overline{A \cap B} = \overline A \cup \overline B
Absorption Laws
A(AB)=AA \cup (A \cap B) = A
A(AB)=AA \cap (A \cup B) = A
Complement Laws
AA=UA \cup \overline{A} = U
AA=A \cap \overline{A} = \varnothing

For a deep dive into an introduction to set theory, you can check out this wonderful book from Open Logic Project.