ASU · MAT 243 · Spring 2026

DISCRETE MATH STRUCTURES

The complete course — every concept, every formula, every proof technique — condensed into one galaxy-class reference.

01

Propositional Logic

Propositions

A proposition is a declarative sentence that is either true (T) or false (F), but not both. Questions, commands, and opinions are NOT propositions.

Examples

Proposition: "2 + 3 = 5" → T
Proposition: "The moon is made of cheese" → F
NOT a proposition: "What time is it?" / "Close the door."

Logical Operators (Connectives)

NameSymbolRead AsTrue When
Negation¬p"not p"p is false
Conjunctionp ∧ q"p and q"both true
Disjunctionp ∨ q"p or q"at least one true
Exclusive Orp ⊕ q"p xor q"exactly one true
Conditionalp → q"if p then q"¬p or q (false only when p=T, q=F)
Biconditionalp ↔ q"p if and only if q"both same truth value

The Conditional (p → q) — Most Tested!

pqp → q
TTT
TFF
FTT
FFT
Key Insight

p → q is only false when the hypothesis (p) is true and the conclusion (q) is false. A false hypothesis makes the whole conditional vacuously true.

Variations of Conditionals

Given the conditional p → q:

NameFormEquivalent To
Converseq → pNOT equivalent to p → q
Inverse¬p → ¬qequivalent to converse
Contrapositive¬q → ¬pequivalent to p → q
Remember

The contrapositive is always logically equivalent to the original. The converse and inverse are equivalent to each other but NOT to the original.

"Only If" Statements

"p only if q" means p → q (NOT q → p!).

Think of it as: p can be true ONLY IF q is also true. If q is false, p must be false.

Example

"You pass only if you study" = "If you pass, then you studied" = pass → studied

Tautologies, Contradictions & Contingencies

Definitions

Tautology: Always true for all truth value assignments. Example: p ∨ ¬p
Contradiction: Always false for all truth value assignments. Example: p ∧ ¬p
Contingency: Neither — sometimes true, sometimes false. Example: p ∨ q

How to Check

Build the full truth table. If the final column is ALL T → tautology. ALL F → contradiction. Mix → contingency.

02

Propositional Equivalences

Key Equivalence Laws

Two propositions are logically equivalent (p ≡ q) if they have the same truth table.

LawEquivalence
Identityp ∧ T ≡ p  /  p ∨ F ≡ p
Dominationp ∨ T ≡ T  /  p ∧ F ≡ F
Idempotentp ∨ p ≡ p  /  p ∧ p ≡ p
Double Negation¬(¬p) ≡ p
Commutativep ∨ q ≡ q ∨ p  /  p ∧ q ≡ q ∧ p
Associative(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
Distributivep ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
De Morgan's¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∨ q) ≡ ¬p ∧ ¬q
Absorptionp ∨ (p ∧ q) ≡ p  /  p ∧ (p ∨ q) ≡ p
Negationp ∨ ¬p ≡ T  /  p ∧ ¬p ≡ F

Conditional Equivalences

p → q ≡ ¬p ∨ q p → q ≡ ¬q → ¬p (contrapositive) p ↔ q ≡ (p → q) ∧ (q → p) p ↔ q ≡ (p ∧ q) ∨ (¬p ∧ ¬q)
Most Common Mistake

Students confuse p → q with q → p (converse). The conditional is NOT symmetric! Use ¬p ∨ q as your go-to rewrite.

03

Predicates & Quantifiers

Predicates

A predicate is a statement with variables that becomes a proposition when you plug in values.

Example

P(x) = "x > 5"
P(3) = "3 > 5" = F
P(7) = "7 > 5" = T

The domain (universe of discourse) is the set of all possible values the variable can take.

Quantifiers

SymbolNameMeaningTrue When
∀x P(x)Universal"for all x, P(x)"P(x) is true for EVERY x in domain
∃x P(x)Existential"there exists x such that P(x)"P(x) is true for AT LEAST ONE x

Negating Quantified Statements (De Morgan's for Quantifiers)

¬(∀x P(x)) ≡ ∃x ¬P(x) ¬(∃x P(x)) ≡ ∀x ¬P(x)
Flip & Negate Rule

To negate: flip the quantifier (∀ ↔ ∃) and negate the predicate. Repeat for nested quantifiers from left to right.

Nested Quantifiers — Order Matters!

∀x ∃y P(x,y) means: for every x, there is SOME y (y can depend on x) ∃y ∀x P(x,y) means: there is ONE y that works for ALL x (much stronger!)
Example

∀x ∃y (x + y = 0): "every number has an additive inverse" → TRUE
∃y ∀x (x + y = 0): "there is one number that is the additive inverse of every number" → FALSE

Translating English to Logic

EnglishLogic
"All dogs bark"∀x (Dog(x) → Barks(x))
"Some dogs bark"∃x (Dog(x) ∧ Barks(x))
"No dogs bark"¬∃x (Dog(x) ∧ Barks(x)) ≡ ∀x (Dog(x) → ¬Barks(x))
Critical Pattern

Universal (∀) pairs with → (conditional).
Existential (∃) pairs with ∧ (conjunction).
Mixing these up is one of the most common errors!

04

Rules of Inference

Propositional Rules of Inference

RuleFormIn Words
Modus Ponensp → q, p ∴ qIf p then q; p is true; therefore q
Modus Tollensp → q, ¬q ∴ ¬pIf p then q; q is false; therefore ¬p
Hypothetical Syllogismp → q, q → r ∴ p → rChain two conditionals
Disjunctive Syllogismp ∨ q, ¬p ∴ qOne of two; not the first; therefore the second
Additionp ∴ p ∨ qp is true so p OR anything is true
Simplificationp ∧ q ∴ pBoth true means each is true
Conjunctionp, q ∴ p ∧ qBoth true so the AND is true
Resolutionp ∨ q, ¬p ∨ r ∴ q ∨ rResolve away complementary literals

Quantified Rules of Inference

RuleForm
Universal Instantiation∀x P(x) ∴ P(c) for any c
Universal GeneralizationP(c) for arbitrary c ∴ ∀x P(x)
Existential Instantiation∃x P(x) ∴ P(c) for some specific c
Existential GeneralizationP(c) ∴ ∃x P(x)
Watch Out

For universal generalization, c must be truly arbitrary — no special assumptions about c! For existential instantiation, c is a specific (but unknown) element — you can't assume anything else about it.

Common Fallacies

FallacyInvalid FormWhy Wrong
Affirming the Consequentp → q, q ∴ pq could be true for other reasons
Denying the Antecedentp → q, ¬p ∴ ¬qq might still be true without p
05

Proof Techniques

Proof Methods Overview

1. Direct Proof (prove p → q)

Assume p is true. Use definitions, axioms, and known theorems to arrive at q.

Example

Prove: If n is even, then n² is even.
Proof: Assume n is even, so n = 2k for some integer k.
Then n² = (2k)² = 4k² = 2(2k²).
Since 2k² is an integer, n² = 2(integer), so n² is even. ∎

2. Proof by Contrapositive (prove ¬q → ¬p)

Instead of p → q, prove the equivalent contrapositive. Assume ¬q and show ¬p.

Example

Prove: If n² is odd, then n is odd.
Contrapositive: If n is even, then n² is even. (Same as above!) ∎

3. Proof by Contradiction

Assume the statement is FALSE (assume ¬S). Derive a contradiction (something impossible like p ∧ ¬p). Conclude S must be true.

Example

Prove: √2 is irrational.
Proof: Assume √2 is rational, so √2 = a/b in lowest terms (gcd(a,b) = 1).
Then 2 = a²/b², so a² = 2b², meaning a² is even → a is even → a = 2k.
Then 4k² = 2b² → b² = 2k² → b is even.
Contradiction: both a and b are even, but we said gcd(a,b) = 1. ∎

4. Proof by Cases (Exhaustive Proof)

Break into cases that cover all possibilities. Prove the result for each case.

5. Existence Proof

Constructive: find/build a specific example.
Non-constructive: prove one must exist without finding it.

6. Counterexample (to disprove ∀x P(x))

Find ONE specific x where P(x) is false. That's it — done.

Common Proof Writing Mistakes

  • Assuming what you're trying to prove (circular reasoning)
  • Using specific examples instead of general/arbitrary elements for universal proofs
  • Confusing "for all" vs "there exists" — universal proofs need arbitrary elements; existence proofs need one witness
  • Not stating assumptions clearly
  • Using ≡ when you mean = (≡ is logical equivalence, = is equality)
  • Skipping the "since __ is an integer" step when proving even/odd/divisibility

Rational & Irrational Numbers

Definition

Rational: a/b where a, b are integers and b ≠ 0.
Irrational: cannot be expressed as a/b (e.g., √2, π, e).

Key facts: rational + rational = rational. irrational + rational = irrational. The product of a nonzero rational and an irrational is irrational. But irrational + irrational can be rational (e.g., √2 + (−√2) = 0).

06

Sets

Set Basics

Definitions

A set is an unordered collection of distinct objects (elements).
x ∈ A means x is in set A.
x ∉ A means x is not in A.
|A| = cardinality (number of elements in A).

Important Sets

ℕ = {0, 1, 2, 3, ...} Natural numbers (includes 0 in this course) ℤ = {..., -2, -1, 0, 1, 2, ...} Integers ℤ⁺ = {1, 2, 3, ...} Positive integers ℚ = rationals a/b where a,b ∈ ℤ, b ≠ 0 ℝ = real numbers ∅ = {} = empty set the set with no elements

Subsets

A ⊆ B (A is a subset of B): every element of A is in B.
A ⊂ B (proper subset): A ⊆ B and A ≠ B.
Key facts: ∅ ⊆ A for any set A. A ⊆ A for any set A.

Power Set

P(A) = the set of ALL subsets of A, including ∅ and A itself.

If |A| = n, then |P(A)| = 2ⁿ
Example

A = {1, 2}
P(A) = {∅, {1}, {2}, {1,2}}
|P(A)| = 2² = 4

Cartesian Product

A × B = {(a, b) | a ∈ A and b ∈ B} |A × B| = |A| · |B|

Set Operations

OperationSymbolDefinition
UnionA ∪ B{x | x ∈ A or x ∈ B}
IntersectionA ∩ B{x | x ∈ A and x ∈ B}
DifferenceA − B{x | x ∈ A and x ∉ B}
ComplementA̅ or Aᶜ{x ∈ U | x ∉ A} (U = universal set)
Symmetric DiffA ⊕ B(A − B) ∪ (B − A)

Set Identities (mirror logic laws!)

De Morgan's: (A ∪ B)ᶜ = Aᶜ ∩ Bᶜ (A ∩ B)ᶜ = Aᶜ ∪ Bᶜ Distributive: A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)

The Empty Set — Tricky Behavior

Watch Out

∅ ∈ {∅} is TRUE (∅ is an element of the set containing ∅).
∅ ⊆ {∅} is TRUE (∅ is a subset of everything).
{∅} ≠ ∅ — one has one element, the other has zero.

Intervals (Subsets of ℝ)

[a, b] = {x ∈ ℝ | a ≤ x ≤ b} closed interval (includes endpoints) (a, b) = {x ∈ ℝ | a < x < b} open interval (excludes endpoints) [a, b) = {x ∈ ℝ | a ≤ x < b} half-open (−∞, b] = {x ∈ ℝ | x ≤ b} extends left forever [a, ∞) = {x ∈ ℝ | x ≥ a} extends right forever
07

Functions

Function Basics

Definition

A function f: A → B assigns to each element in A (domain) exactly one element in B (codomain).

Range (image) = {f(a) | a ∈ A} ⊆ B — the actual outputs used.

Function Properties

PropertyDefinitionIntuition
Injective (one-to-one)f(a) = f(b) → a = bNo two inputs share an output
Surjective (onto)∀b ∈ B, ∃a ∈ A: f(a) = bEvery element in codomain is hit
Bijective (one-to-one AND onto)Injective + SurjectivePerfect pairing; invertible

Function Composition

(f ∘ g)(x) = f(g(x)) Apply g first, then f!

Inverse Function

f⁻¹ exists only if f is bijective. Then f⁻¹(f(x)) = x and f(f⁻¹(y)) = y.

Floor & Ceiling

⌊x⌋ = floor(x) = greatest integer ≤ x ⌊3.7⌋ = 3, ⌊−1.2⌋ = −2 ⌈x⌉ = ceil(x) = smallest integer ≥ x ⌈3.2⌉ = 4, ⌈−1.8⌉ = −1
08

Sequences & Summation

Sequences

A sequence is an ordered list of elements: a₁, a₂, a₃, ... Each aₙ is a term.

Common Sequences

Arithmetic: aₙ = a₁ + (n−1)d (constant difference d) Geometric: aₙ = a₁ · rⁿ⁻¹ (constant ratio r) Fibonacci: f₁ = 1, f₂ = 1, fₙ = fₙ₋₁ + fₙ₋₂

Summation Formulas

Sum of first n positive integers: 1 + 2 + 3 + ... + n = n(n+1)/2 Sum of first n squares: 1² + 2² + ... + n² = n(n+1)(2n+1)/6 Sum of first n cubes: 1³ + 2³ + ... + n³ = [n(n+1)/2]² Geometric series: a + ar + ar² + ... + arⁿ = a(rⁿ⁺¹ − 1)/(r − 1) when r ≠ 1 Infinite geometric (|r| < 1): a + ar + ar² + ... = a/(1 − r)

Useful Summation Properties

Σ(aᵢ + bᵢ) = Σaᵢ + Σbᵢ Σ(c · aᵢ) = c · Σaᵢ Σ(i=1 to n) c = cn
09

Growth of Functions (Big-O)

Asymptotic Notation

Big-O (Upper Bound)

f(x) is O(g(x)) if there exist constants C > 0 and k such that |f(x)| ≤ C|g(x)| for all x > k.
Think: f grows no faster than g.

Big-Ω (Lower Bound)

f(x) is Ω(g(x)) if there exist constants C > 0 and k such that |f(x)| ≥ C|g(x)| for all x > k.
Think: f grows at least as fast as g.

Big-Θ (Tight Bound)

f(x) is Θ(g(x)) if f(x) is both O(g(x)) and Ω(g(x)).
Think: f grows at the same rate as g.

Growth Rate Hierarchy (slowest to fastest)

1 ≺ log n ≺ √n ≺ n ≺ n log n ≺ n² ≺ n³ ≺ 2ⁿ ≺ n! ≺ nⁿ
Why Base Doesn't Matter for Log

log_a(n) = log_b(n) / log_b(a), so any two log bases differ by a constant factor. Since Big-O ignores constants, all logarithmic bases are the same in Big-O.

Quick Rules

  • Polynomial: aₙxⁿ + ... + a₁x + a₀ is O(xⁿ) — highest power dominates
  • Sum rule: f₁ is O(g₁) and f₂ is O(g₂) → f₁ + f₂ is O(max(g₁, g₂))
  • Product rule: f₁ is O(g₁) and f₂ is O(g₂) → f₁·f₂ is O(g₁·g₂)
10

Divisibility & Modular Arithmetic

Divisibility

Definition

a | b ("a divides b") means b = a·k for some integer k. Equivalently, b/a is an integer.

Properties

If a | b and a | c, then a | (b + c) and a | (b − c) If a | b, then a | (b·c) for any integer c If a | b and b | c, then a | c (transitivity)

Division Algorithm

For any integer a and positive integer d: a = d·q + r where 0 ≤ r < d q = ⌊a/d⌋ (quotient) r = a mod d = a − d·⌊a/d⌋ (remainder)

Modular Arithmetic

Congruence

a ≡ b (mod m) means m | (a − b), i.e., a and b have the same remainder when divided by m.

If a ≡ b (mod m) and c ≡ d (mod m), then: a + c ≡ b + d (mod m) a · c ≡ b · d (mod m)
Example

17 ≡ 5 (mod 6) because 17 − 5 = 12 and 6 | 12.
Or: 17 mod 6 = 5 and 5 mod 6 = 5. Same remainder!

11

Number Systems & Integer Representations

Base Conversions

Decimal to Binary

Repeatedly divide by 2 and collect remainders (read bottom to top).

Example: 42 to Binary

42 ÷ 2 = 21 r 0
21 ÷ 2 = 10 r 1
10 ÷ 2 = 5 r 0
5 ÷ 2 = 2 r 1
2 ÷ 2 = 1 r 0
1 ÷ 2 = 0 r 1
Read up: 42₁₀ = 101010

Binary to Decimal

101010₂ = 1·2⁵ + 0·2⁴ + 1·2³ + 0·2² + 1·2¹ + 0·2⁰ = 32 + 0 + 8 + 0 + 2 + 0 = 42

Hexadecimal (Base 16)

Digits: 0-9, A=10, B=11, C=12, D=13, E=14, F=15 Hex ↔ Binary: each hex digit = 4 binary digits Example: 2A₁₆ = 0010 1010₂ = 42₁₀

Binary Arithmetic

Addition: 0+0=0, 0+1=1, 1+0=1, 1+1=10 (carry the 1) Subtraction: Borrow from next column (just like decimal) Multiplication: Shift and add (same as long multiplication)

Two's Complement (Signed Integers)

For n-bit numbers, the leftmost bit is the sign (0 = positive, 1 = negative).

Range of n-bit two's complement: −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1 To negate: flip all bits and add 1 Example (8-bit): +5 = 00000101 → flip = 11111010 → +1 = 11111011 = −5
12

Primes & GCD

Prime Numbers

Definition

An integer p > 1 is prime if its only positive divisors are 1 and p. Otherwise it's composite. Note: 1 is neither prime nor composite.

Fundamental Theorem of Arithmetic

Every integer > 1 can be written as a product of primes in exactly one way (up to ordering).

Example

360 = 2³ · 3² · 5

Testing Primality

To check if n is prime, test divisibility by all primes up to √n. If none divide n, it's prime.

GCD & LCM

gcd(a, b) = greatest common divisor (largest integer dividing both) lcm(a, b) = least common multiple (smallest positive multiple of both) Key relationship: gcd(a, b) · lcm(a, b) = a · b

Euclidean Algorithm (Finding GCD)

Repeatedly apply: gcd(a, b) = gcd(b, a mod b) until remainder = 0.

Example: gcd(252, 105)

gcd(252, 105) = gcd(105, 252 mod 105) = gcd(105, 42)
gcd(105, 42) = gcd(42, 105 mod 42) = gcd(42, 21)
gcd(42, 21) = gcd(21, 42 mod 21) = gcd(21, 0)
gcd = 21

13

Mathematical Induction

The Principle of Induction

To prove P(n) is true for all integers n ≥ b:

Step 1: Base Case

Show P(b) is true (usually b = 0 or b = 1).

Step 2: Inductive Step

Assume P(k) is true for some arbitrary k ≥ b (inductive hypothesis). Then prove P(k+1) is true.

Why It Works

Think dominoes: base case knocks over the first. Inductive step says "if any domino falls, the next one falls too." Together → all dominoes fall.

Example: Prove 1 + 2 + ... + n = n(n+1)/2

Base case (n=1): LHS = 1. RHS = 1(2)/2 = 1. ✓

Inductive step: Assume 1 + 2 + ... + k = k(k+1)/2 (inductive hypothesis).
Show: 1 + 2 + ... + k + (k+1) = (k+1)(k+2)/2.

LHS = [1 + 2 + ... + k] + (k+1)
    = k(k+1)/2 + (k+1)   ← used IH here!
    = k(k+1)/2 + 2(k+1)/2
    = (k+1)(k+2)/2 = RHS ✓ ∎

Strong Induction

Same as regular induction, but the inductive hypothesis assumes P(b), P(b+1), ..., P(k) are ALL true (not just P(k)). Then prove P(k+1).

Use strong induction when P(k+1) depends on multiple previous cases (not just P(k)).

Common Mistakes in Induction Proofs

  • Forgetting the base case. The inductive step alone proves nothing!
  • Not clearly using the inductive hypothesis. You must identify WHERE you use the assumption.
  • Using P(k+1) in the proof of P(k+1). That's circular — you assume P(k), not P(k+1).
  • Wrong base case. Make sure n = b actually works.
  • Incorrect algebra. Check every step. The inductive step is where most errors hide.
14

Structural Induction

Recursively Defined Structures

Some structures (strings, trees, formulas) are defined recursively with base elements and rules for building bigger structures from smaller ones.

How Structural Induction Works

Base step: Prove the property for the base elements.
Recursive step: Assume the property holds for the smaller sub-structures, then prove it holds for the structure built from them.

Example: Binary Trees

Recursive definition:
Base: A single node is a binary tree.
Recursive: If T₁ and T₂ are binary trees, then connecting them to a new root gives a binary tree.

Prove: A binary tree with n internal nodes has n+1 leaves.
Base: 0 internal nodes → 1 leaf (just the root). 0 + 1 = 1. ✓
Recursive step: Assume true for T₁ (k₁ internal, k₁+1 leaves) and T₂ (k₂ internal, k₂+1 leaves).
Combined tree: (k₁ + k₂ + 1) internal nodes and (k₁+1) + (k₂+1) = k₁ + k₂ + 2 = (k₁+k₂+1) + 1 leaves. ✓ ∎

15

Recurrence Relations

What's a Recurrence?

An equation defining aₙ in terms of previous terms. Plus initial conditions.

Example

aₙ = 2aₙ₋₁ + 1, with a₀ = 0
a₁ = 2(0)+1 = 1, a₂ = 2(1)+1 = 3, a₃ = 2(3)+1 = 7, ...

Solving Linear Recurrences

Homogeneous (aₙ = c₁aₙ₋₁ + c₂aₙ₋₂)

Step 1: Write the characteristic equation: r² − c₁r − c₂ = 0
Step 2: Find the roots r₁, r₂.
Step 3: General solution depends on the roots:

Distinct roots r₁ ≠ r₂: aₙ = A·r₁ⁿ + B·r₂ⁿ Repeated root r₁ = r₂ = r: aₙ = A·rⁿ + B·n·rⁿ

Step 4: Use initial conditions to solve for A and B.

Example: Fibonacci

fₙ = fₙ₋₁ + fₙ₋₂, f₀ = 0, f₁ = 1
Characteristic eq: r² − r − 1 = 0
Roots: r = (1 ± √5)/2 → φ = (1+√5)/2 and ψ = (1−√5)/2
Solution: fₙ = (φⁿ − ψⁿ)/√5

Complex Roots

If the characteristic equation has complex roots a ± bi, convert to polar form r·e^(iθ) and the solution involves rⁿcos(nθ) and rⁿsin(nθ) terms.

Complex → Real Connection

Complex numbers a + bi where i² = −1. A complex expression produces a real number when imaginary parts cancel. This happens with conjugate pairs (a+bi)(a−bi) = a² + b².

16

Combinatorics & Counting

Fundamental Counting Principles

Product Rule

If task 1 can be done m ways and task 2 can be done n ways, both tasks together can be done m × n ways.

Sum Rule

If task 1 can be done m ways OR task 2 can be done n ways (mutually exclusive), the total is m + n ways.

Permutations & Combinations

Permutations (order matters)

P(n, r) = n! / (n − r)! Choosing r items from n items where ORDER MATTERS Example: How many 3-letter "words" from {A,B,C,D,E}? P(5, 3) = 5! / 2! = 60

Combinations (order doesn't matter)

C(n, r) = n! / (r! · (n − r)!) also written as "n choose r" Choosing r items from n where ORDER DOESN'T MATTER Example: How many 3-person committees from 5 people? C(5, 3) = 5! / (3! · 2!) = 10
When to Use Which

Permutation: "arrange", "order", "rank", "sequence", "password", "lineup"
Combination: "choose", "select", "committee", "group", "team", "hand"

Key Identities

C(n, 0) = C(n, n) = 1 C(n, 1) = n C(n, r) = C(n, n−r) symmetry C(n, r) = C(n−1, r−1) + C(n−1, r) Pascal's identity

Binomial Theorem

(x + y)ⁿ = Σ(k=0 to n) C(n,k) · xⁿ⁻ᵏ · yᵏ
Example

(x+y)³ = C(3,0)x³ + C(3,1)x²y + C(3,2)xy² + C(3,3)y³
        = x³ + 3x²y + 3xy² + y³

Counting Operations in Algorithms

Count operations (comparisons, additions, multiplications) by analyzing loops:

Single loop (1 to n): n operations → O(n) Nested loops (1 to n, 1 to n): n² operations → O(n²) Loop (1 to n, 1 to i): n(n+1)/2 → O(n²) Halving loop (while n > 1, n = n/2): log₂n → O(log n)
17

Inclusion-Exclusion Principle

The Principle

When counting elements in a union, you have to correct for over-counting the overlaps.

|A ∪ B| = |A| + |B| − |A ∩ B| |A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|
Pattern

Add singles, subtract pairs, add triples, subtract quadruples, ... Alternating signs!

Example

In a class of 40: 25 take math, 20 take CS, 10 take both.
How many take math OR CS?
|M ∪ C| = 25 + 20 − 10 = 35

18

Relations

What is a Relation?

Definition

A relation R from set A to set B is a subset of A × B. If (a, b) ∈ R, we write aRb. A relation on a set A means R ⊆ A × A.

Properties of Relations (on a set A)

PropertyDefinitionMatrix Check
Reflexive∀a ∈ A: aRaAll 1s on diagonal
Irreflexive∀a ∈ A: ¬(aRa)All 0s on diagonal
SymmetricaRb → bRaMatrix equals its transpose
AntisymmetricaRb ∧ bRa → a = bIf M[i][j]=1 and i≠j, then M[j][i]=0
TransitiveaRb ∧ bRc → aRcM² has no 1 where M has 0
Important Combinations

Equivalence relation: reflexive + symmetric + transitive (partitions a set into classes)
Partial order: reflexive + antisymmetric + transitive (like ≤ on numbers)

Examples

= on ℤ: reflexive ✓, symmetric ✓, transitive ✓ → equivalence relation
on ℤ: reflexive ✓, antisymmetric ✓, transitive ✓ → partial order
< on ℤ: irreflexive, antisymmetric, transitive (strict partial order)

Composition of Relations

Definition

If R is from A to B and S is from B to C, then S ∘ R is from A to C where:
(a, c) ∈ S ∘ R if there exists b ∈ B such that (a, b) ∈ R and (b, c) ∈ S.

In matrix terms: multiply the relation matrices (using Boolean AND for multiplication and OR for addition).

Powers of Relations

R¹ = R R² = R ∘ R (apply R twice) Rⁿ = R ∘ Rⁿ⁻¹

A relation R is transitive if and only if Rⁿ ⊆ R for all n ≥ 1.

Representing Relations

As a Matrix

M[i][j] = 1 if (aᵢ, aⱼ) ∈ R, else 0.

As a Directed Graph (Digraph)

Nodes = elements, arrow from a to b if aRb. Self-loops for reflexive pairs.

Closures

Reflexive closure: add all (a,a) pairs (add self-loops) Symmetric closure: if aRb, add bRa (add reverse arrows) Transitive closure: add all paths — if aRb and bRc, add aRc Transitive closure = R ∪ R² ∪ R³ ∪ ... (Warshall's algorithm)

Quick Reference — Must-Know Facts

Formulas to Memorize

Summation: 1+2+...+n = n(n+1)/2 Geometric sum: 1+r+r²+...+rⁿ = (rⁿ⁺¹−1)/(r−1) Power set size: |P(A)| = 2ⁿ Cartesian: |A×B| = |A|·|B| Permutations: P(n,r) = n!/(n−r)! Combinations: C(n,r) = n!/(r!(n−r)!) Binomial: (x+y)ⁿ = Σ C(n,k)·xⁿ⁻ᵏ·yᵏ Inc-Exc (2 sets): |A∪B| = |A|+|B|−|A∩B| GCD·LCM = a·b Contrapositive: p→q ≡ ¬q→¬p Conditional: p→q ≡ ¬p∨q De Morgan's: ¬(p∧q) ≡ ¬p∨¬q, ¬(p∨q) ≡ ¬p∧¬q Quantifier neg: ¬∀x = ∃x¬, ¬∃x = ∀x¬

Proof Strategy Cheat Sheet

Proving...Try This Method
p → qDirect proof, contrapositive, or contradiction
p ↔ qProve p→q AND q→p separately
∀n ≥ b, P(n)Mathematical induction
∃x P(x)Find a specific example (constructive)
¬∀x P(x)Find one counterexample
Something is irrationalProof by contradiction
A ⊆ BLet x ∈ A, show x ∈ B
A = BShow A ⊆ B AND B ⊆ A
f is injectiveAssume f(a)=f(b), show a=b
f is surjectiveLet y ∈ codomain, find x where f(x)=y