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

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

Logic & Propositions

In place of specific propositions, usually the letters PP or QQ are used to indicate that these can only take on the values T (true) or F (false).

Connectives:

These are the connectives that are mostly used:

connective symbol
negation ¬P\neg P (or P\overline P) "not"
conjunction PQP \land Q "and"
disjunction PQP \lor Q "or"
exclusive disjunction PQP \oplus Q "xor (exclusive or)"
implication P    QP \implies Q "if ... then"
biconditional P    QP \iff Q "iff" ("if and only if")

From an implication (p    qp \implies q), we can construct 3 new conditional statements:

An implication and its contrapositive are equivalent:

P    Q=¬Q    ¬PP \implies Q = \neg Q \implies \neg P

An implication and its converse is the same as the biconditional:

(P    Q)(Q    P)=P    Q(P \implies Q) \land (Q \implies P) = P \iff Q


A tautology is a proposition that is always true (e.g., p¬pp \lor \neg p)

A contradiction is a proposition that is always false (e.g., p¬pp \land \neg p)

A contingency is a proposition that is neither a tautology nor a contradiction (e.g., pp)

Equivalence

Assignment of values to variables is called an environment.
For example, environment vv assigning truth values to PP, QQ, and RR: v(P)=T, v(Q)=T, v(R)=Fv(P) = T, \ v(Q) = T, \ v(R) = F.
Two propositional formulas are equivalent iff they have the same truth value in all environments. That is, the compound propositions pp and qq are logically equivalent if p    qp \implies q is a tautology. Equivalency is denoted as pqp \equiv q (e.g., ¬pqp    q\neg p \lor q \equiv p \implies q).

An example is De Morgan's Laws:

¬(pq)¬p¬q\neg (p \lor q) \equiv \neg p \land \neg q
¬(pq)¬p¬q\neg (p \land q) \equiv \neg p \lor \neg q

A half adder is a digital circuit that adds two 1-bit numbers. A full adder also adds two 1-bit numbers, but the difference is that a half adder does not have a carry input while a full adder does. (Carry is the same thing when you do decimal addition, for example, with 21+921 + 9, you first add 99 and 11, the result is 1010, so you carry the 11 to add it to 22.)

1-bit half adder 1-bit full adder
1-bit half adder 1-bit full adder

A binary addition circuit example (a "ripple carry") is as follows:

Binary addition circuit example

We can say that d0d_0 is a0b0a_0 \oplus b_0, and c0c_0 is a0b0a_0 \land b_0.
(Imagine a0a_0 as 11, and b0b_0 as 11, adding them will result in 22 which is 1010 in binary — so, you write 00 and carry the 11, and the operations hold. The bit you write is the xor of two bits, and the carry is the and of them).

If we define sis_i to be aibia_i \oplus b_i, and did_i to be ci1sic_{i - 1} \oplus s_i, cic_i is going to be (ci1si)(aibi)(c_{i - 1} \land s_i) \lor (a_i \land b_i).

What does it mean? Let's see.

Let's say a0a_0 is 11, and b0b_0 is 00.
s0s_0 is going to be the sum of them (the operation XOR), which is 11.
d0d_0 is going to be the XOR of the carry from before (c01c_{0 - 1 }) and the sum (s0s_0). We don't have a carry from a previous addition as there is none (that would be c1c_{-1}!), so it is 00. s0s_0 was 11. The XOR of them is 11, so d0d_0 is 11.
We already know we don't have a carry (1+01 + 0 doesn't have a carry), but still, let's continue decoding the formula.
c0c_0 which is our carry has to be (c01s0)(a0b0)(c_{0 - 1} \land s_0) \lor (a_0 \land b_0).
Plugging in our values, we get (01)(10)(0 \land 1) \lor (1 \land 0). It results in 000 \lor 0, so the final result is 00, which is our carry!

Satisfiability & Validity

A formula is satisfiable iff it is true in some environment (which can sometimes be true), for example, PP.

An example of a formula that is not satisfiable is P¬PP \land \neg P.

A formula is valid iff it is true in all environments (which is always true), for example, P(¬P)P \lor (\neg P) (also called a tautology).