Skip to content

Discrete Mathematics

1. Propositional and Predicate Logic

1.1 Propositional Logic

A proposition is a statement that is either true or false. Propositional logic deals with Propositions and their combinations using logical connectives.

Basic connectives:

SymbolNameMeaning
¬\negNegationNOT
\landConjunctionAND
\lorDisjunctionOR
    \impliesImplicationIF…THEN
    \iffBiconditionalIF AND ONLY IF

Truth tables. The implication p    qp \implies q is false only when pp is true and qq is false.

Logical equivalence. Two propositions are logically equivalent (\equiv) if they have the Same truth value for all assignments.

Important equivalences:

  • ¬(pq)¬p¬q\neg(p \land q) \equiv \neg p \lor \neg q (De Morgan)
  • ¬(pq)¬p¬q\neg(p \lor q) \equiv \neg p \land \neg q (De Morgan)
  • p    q¬pqp \implies q \equiv \neg p \lor q
  • p    q(p    q)(q    p)p \iff q \equiv (p \implies q) \land (q \implies p)
  • ¬(p    q)p¬q\neg(p \implies q) \equiv p \land \neg q

1.2 Predicate Logic

Predicates extend propositional logic with variables and quantifiers.

  • Universal quantifier: xP(x)\forall x\, P(x) — ”P(x)P(x) holds for all xx.”
  • Existential quantifier: xP(x)\exists x\, P(x) — “there exists xx such that P(x)P(x) holds.”

Negation of quantifiers:

¬xP(x)x¬P(x)\neg \forall x\, P(x) \equiv \exists x\, \neg P(x)

¬xP(x)x¬P(x)\neg \exists x\, P(x) \equiv \forall x\, \neg P(x)

Nested quantifiers must be read carefully. The order matters:

xyP(x,y)≢yxP(x,y)\forall x\, \exists y\, P(x, y) \not\equiv \exists y\, \forall x\, P(x, y)

The first says “for every xx there is a (possibly different) yy.” The second says “there exists a Single yy that works for all xx.“

1.3 Validity and Satisfiability

A formula is valid (a tautology) if it is true under all interpretations. A formula is satisfiable if it is true under at least one interpretation.

Theorem 1.1. A formula is valid if and only if its negation is unsatisfiable.

1.4 Truth Table Construction Methods

For a propositional formula with nn distinct variables, the truth table has 2n2^n rows (one per Assignment). Two systematic methods ensure no assignment is missed.

Method 1: Binary counting. Treat the first variable as the most significant bit. Enumerate all Binary nn-tuples from (0,,0)(0, \ldots, 0) to (1,,1)(1, \ldots, 1). The first variable changes most slowly (only every 2n12^{n-1} rows), while the last variable alternates every row.

Method 2: Recursive splitting. For nn variables, the table splits into two blocks of 2n12^{n-1} Rows: the top block has the first variable as TTThe bottom as FF. Recurse on the remaining n1n - 1 variables within each block.

Worked Example. Construct the truth table for (p    q)(q    r)(p \implies q) \land (q \implies r).

Solution

With 3 variables we have 23=82^3 = 8 rows.

ppqqrrp    qp \implies qq    rq \implies rϕ\phi
TTTTTT
TTFTFF
TFTFTF
TFFFTF
FTTTTT
FTFTFF
FFTTTT
FFFTTT

The formula is satisfiable (e.g., p=F,q=F,r=Tp = F, q = F, r = T) but not a tautology (e.g., p=T,q=T,r=Fp = T, q = T, r = F).

Worked Example. Verify that hypothetical syllogism (p    q)(q    r)    (p    r)(p \implies q) \land (q \implies r) \implies (p \implies r) is a tautology.

Solution

Extending the table above:

ppqqrrϕ\phip    rp \implies rϕ    (p    r)\phi \implies (p \implies r)
TTTTTT
TTFFFT
TFTFTT
TFFFFT
FTTTTT
FTFFTT
FFTTTT
FFFTTT

The final column is all TTConfirming the tautology.

1.5 Natural Deduction

Natural deduction is a proof system that mirrors ordinary mathematical reasoning. Each connective Has introduction rules (how to derive a formula with that connective) and elimination rules (how to use a formula with that connective).

Rules of inference:

RulePremisesConclusion
\land-IAA, BBABA \land B
\land-E1_1ABA \land BAA
\land-E2_2ABA \land BBB
\lor-I1_1AAABA \lor B
\lor-I2_2BBABA \lor B
\lor-EABA \lor B, ACA \vdash C, BCB \vdash CCC
\to-I[A]B[A] \vdash BABA \to B
\to-EAA, ABA \to BBB
¬\neg-I[A][A] \vdash \bot¬A\neg A
¬\neg-EAA, ¬A\neg A\bot
DNE¬¬A\neg\neg AAA
RAA[¬A][\neg A] \vdash \botAA

Square brackets [A][A] denote an assumption that is discharged after the rule is applied.

Worked Example. Prove: pq¬q¬pp \to q \vdash \neg q \to \neg p (contraposition).

Solution
  1. pqp \to q — premise
  2. [¬q][\neg q] — assumption (for \to-I)
  3. [p][p] — assumption (for ¬\neg-I)
  4. qq\to-E on 1, 3
  5. \bot¬\neg-E on 4, 2
  6. ¬p\neg p¬\neg-I on 3—5, discharging [p][p]
  7. ¬q¬p\neg q \to \neg p\to-I on 2—6, discharging [¬q][\neg q]

\blacksquare

Worked Example. Prove: pq,¬pqp \lor q, \neg p \vdash q (disjunctive syllogism).

Solution
  1. pqp \lor q — premise
  2. ¬p\neg p — premise
  3. [p][p] — assumption (left case for \lor-E)
  4. \bot¬\neg-E on 3, 2
  5. qq — ex falso on 4
  6. [q][q] — assumption (right case for \lor-E)
  7. qq — reiterate 6
  8. qq\lor-E on 1, 3—5, 6—7

\blacksquare

Worked Example. Prove: p(qr)(pq)(pr)p \land (q \lor r) \vdash (p \land q) \lor (p \land r) (distribution).

Solution
  1. p(qr)p \land (q \lor r) — premise
  2. pp\land-E1_1 on 1
  3. qrq \lor r\land-E2_2 on 1
  4. [q][q] — assumption (left case for \lor-E on 3)
  5. pqp \land q\land-I on 2, 4
  6. (pq)(pr)(p \land q) \lor (p \land r)\lor-I1_1 on 5
  7. [r][r] — assumption (right case for \lor-E on 3)
  8. prp \land r\land-I on 2, 7
  9. (pq)(pr)(p \land q) \lor (p \land r)\lor-I2_2 on 8
  10. (pq)(pr)(p \land q) \lor (p \land r)\lor-E on 3, 4—6, 7—9

\blacksquare

:::caution Common Pitfall In natural deduction, always track which assumptions are discharged. A common mistake is to use a Discharged assumption in a later step. Each discharged assumption is only valid within the scope Indicated by the rule that discharges it. :::

1.6 CNF and DNF

A literal is a propositional variable or its negation. A clause is a disjunction of literals. A term (or cube) is a conjunction of literals.

  • Disjunctive Normal Form (DNF): a disjunction of terms, e.g. (p¬q)(¬pr)(p \land \neg q) \lor (\neg p \land r).
  • Conjunctive Normal Form (CNF): a conjunction of clauses, e.g. (p¬q)(¬pr)(p \lor \neg q) \land (\neg p \lor r).

Theorem 1.2. Every propositional formula is equivalent to a formula in CNF and to a formula in DNF.

Conversion to CNF:

  1. Eliminate     \iff and     \implies: A    B¬ABA \implies B \equiv \neg A \lor BAnd A    B(¬AB)(A¬B)A \iff B \equiv (\neg A \lor B) \land (A \lor \neg B).
  2. Push ¬\neg inward using De Morgan”s laws and double negation (¬¬AA\neg\neg A \equiv A) until every ¬\neg applies to a single variable.
  3. Distribute \lor over \land: A(BC)(AB)(AC)A \lor (B \land C) \equiv (A \lor B) \land (A \lor C).

Conversion to DNF: Same steps 1—2; in step 3 distribute \land over \lor instead.

Worked Example. Convert (pq)(¬pr)(p \land q) \lor (\neg p \land r) to CNF.

Solution

Step 1: No     \implies or     \iff to eliminate.

Step 2: No ¬\neg to push inward.

Step 3: Distribute \lor over \land:

(pq)(¬pr)(p¬p)(pr)(q¬p)(qr)(p \land q) \lor (\neg p \land r) \equiv (p \lor \neg p) \land (p \lor r) \land (q \lor \neg p) \land (q \lor r).

Since p¬pp \lor \neg p is a tautology we may simplify to (pr)(¬pq)(qr)(p \lor r) \land (\neg p \lor q) \land (q \lor r).

Worked Example. Convert ¬(p    q)r\neg(p \implies q) \lor r to CNF.

Solution

Step 1: Eliminate     \implies: ¬(¬pq)r\neg(\neg p \lor q) \lor r.

Step 2: Push ¬\neg inward: (p¬q)r(p \land \neg q) \lor r.

Step 3: Distribute \lor over \land: (pr)(¬qr)(p \lor r) \land (\neg q \lor r).

This is in CNF.

:::caution Common Pitfall Distributing \lor over \land can cause exponential blowup. A DNF formula with nn terms can Produce up to 2n2^n clauses when converted to CNF. This exponential growth underlies the hardness Of many satisfiability problems. :::

1.7 Resolution

The resolution rule is a single inference rule that is refutation-complete for propositional Logic.

Resolution rule. From clauses (Ax)(A \lor x) and (B¬x)(B \lor \neg x)Derive the resolvent (AB)(A \lor B)Where AA and BB are (possibly empty) sets of literals and xx is a propositional Variable.

Resolution refutation. To show that clauses {C1,,Ck}\{C_1, \ldots, C_k\} entail clause CC:

  1. Add ¬C\neg C to the clause set.
  2. Repeatedly apply the resolution rule to derive new clauses.
  3. If the empty clause \bot is derived, the entailment holds.

Theorem 1.3 (Refutation completeness). If a set of clauses is unsatisfiable, the empty clause Can be derived by resolution.

Worked Example. Show that {pq,  ¬pr,  ¬q¬r}\{p \lor q,\; \neg p \lor r,\; \neg q \lor \neg r\} entails ¬r\neg r.

Solution

Add the negation of the conclusion: clause (4) rr.

Clauses: (1) pqp \lor q; (2) ¬pr\neg p \lor r; (3) ¬q¬r\neg q \lor \neg r; (4) rr.

Resolve (2) and (4) on rr: (5) ¬p\neg p. Resolve (1) and (5) on pp: (6) qq. Resolve (3) and (6) on qq: (7) ¬r\neg r. Resolve (7) and (4) on rr: (8) \bot.

Since \bot is derived, the entailment holds. \blacksquare

1.8 The SAT Problem

The Boolean satisfiability problem (SAT) asks: given a propositional formula ϕ\phiIs there a Truth assignment that makes ϕ\phi true?

Definition. An instance of SAT is a propositional formula. The answer is YES if ϕ\phi is Satisfiable, NO otherwise.

k-SAT. A restricted version where the formula is in CNF and every clause has exactly kk Literals.

  • 1-SAT: solvable in linear time (each clause is a single literal).
  • 2-SAT: solvable in O(n+m)O(n + m) time using the implication graph and strongly connected components, where nn is the number of variables and mm the number of clauses.
  • 3-SAT: NP-complete (Cook—Levin theorem, 1971). This was the first problem proven NP-complete.

Theorem 1.4 (Cook—Levin). SAT is NP-complete. Consequently, 3-SAT is also NP-complete.

SAT solvers (DPLL, CDCL) are widely deployed in hardware verification, software model checking, and AI planning. Modern solvers routinely handle instances with millions of variables.

:::caution Common Pitfall Do not confuse satisfiability with validity. A formula is satisfiable if it is true under some Assignment; it is valid (a tautology) if true under all assignments. Checking validity is Co-NP-complete, not NP-complete. :::

2. Sets, Relations, and Functions

2.1 Sets

Basic operations:

  • Union: AB=x:xAorxBA \cup B = \\{x : x \in A \mathrm{ or} x \in B\\}
  • Intersection: AB=x:xAandxBA \cap B = \\{x : x \in A \mathrm{ and} x \in B\\}
  • Difference: AB=x:xAandxBA \setminus B = \\{x : x \in A \mathrm{ and} x \notin B\\}
  • Complement: Ac=UAA^c = U \setminus A (where UU is the universal set)

De Morgan’s Laws:

(AB)c=AcBc,(AB)c=AcBc(A \cup B)^c = A^c \cap B^c, \quad (A \cap B)^c = A^c \cup B^c

Power set: P(A)=B:BA\mathcal{P}(A) = \\{B : B \subseteq A\\}. If A=n|A| = nThen P(A)=2n|\mathcal{P}(A)| = 2^n.

2.2 Relations

A binary relation RR from set AA to set BB is a subset of A×BA \times B.

A relation RR on AA is:

  • Reflexive: aA\forall a \in A, (a,a)R(a,a) \in R.
  • Symmetric: (a,b)R    (b,a)R(a,b) \in R \implies (b,a) \in R.
  • Antisymmetric: (a,b)R(a,b) \in R and (b,a)R    a=b(b,a) \in R \implies a = b.
  • Transitive: (a,b)R(a,b) \in R and (b,c)R    (b,c) \in R \implies(a,c) \in R$.

Equivalence relation: reflexive, symmetric, transitive. Partitions the set into equivalence classes.

Partial order: reflexive, antisymmetric, transitive. Written (A,)(A, \preceq).

A Hasse diagram is a graphical representation of a finite poset (A,)(A, \preceq): an element aa Is drawn below bb whenever aba \prec b (i.e., aba \preceq b and aba \neq b), and an edge is drawn From aa to bb whenever bb covers aa (there is no cc with acba \prec c \prec b).

Worked Example. Show that RR on Z\mathbb{{'}Z{}'} defined by aRba\,R\,b iff ab(mod5)a \equiv b \pmod{5} is An equivalence relation. Describe the equivalence classes.

Solution

Reflexive: aa=0=50a - a = 0 = 5 \cdot 0So aa(mod5)a \equiv a \pmod{5} for all aa.

Symmetric: If ab(mod5)a \equiv b \pmod{5}Then 5(ab)5 \mid (a - b)So 5(ba)5 \mid (b - a)Giving ba(mod5)b \equiv a \pmod{5}.

Transitive: If 5(ab)5 \mid (a - b) and 5(bc)5 \mid (b - c)Then 5(ab)+(bc)=ac5 \mid (a - b) + (b - c) = a - cSo ac(mod5)a \equiv c \pmod{5}.

The equivalence classes are [0]=5k:kZ[0] = \\{5k : k \in \mathbb{{'}Z{}'}\\} [1]=5k+1:kZ[1] = \\{5k+1 : k \in \mathbb{{'}Z{}'}\\} [2]=5k+2:kZ[2] = \\{5k+2 : k \in \mathbb{{'}Z{}'}\\} [3]=5k+3:kZ[3] = \\{5k+3 : k \in \mathbb{{'}Z{}'}\\} [4]=5k+4:kZ[4] = \\{5k+4 : k \in \mathbb{{'}Z{}'}\\}. There are exactly 5 equivalence classes, forming the quotient Z/5Z\mathbb{{'}Z{}'}/5\mathbb{{'}Z{}'}.

Worked Example. Let \preceq be divisibility on A=1,2,3,4,6,12A = \\{1, 2, 3, 4, 6, 12\\}: aba \preceq b iff aba \mid b. Verify this is a partial order and identify the cover relations.

Solution

Reflexive: aaa \mid a for all aAa \in A. ✓

Antisymmetric: If aba \mid b and bab \mid aThen b=kab = ka and a=lba = lb for positive k,lk, l So a=lkaa = lkaGiving lk=1lk = 1 and l=k=1l = k = 1Hence a=ba = b. ✓

Transitive: If aba \mid b and bcb \mid cThen c=lb=l(ka)=(lk)ac = lb = l(ka) = (lk)aSo aca \mid c. ✓

Cover relations (bb covers aa when aba \mid b and no element lies strictly between):

  • 12 covers 6, 4
  • 6 covers 2, 3
  • 4 covers 2
  • 3 covers 1
  • 2 covers 1

Reading from bottom to top the Hasse diagram is: 11 at the bottom with edges to 22 and 33; 22 connects up to 44 and 66; 33 connects up to 66; 44 and 66 connect up to 1212 at the top.

2.3 Functions

A function f:ABf : A \to B is a relation where each aAa \in A appears exactly once as a first element.

  • Injective (one-to-one): f(a1)=f(a2)    a1=a2f(a_1) = f(a_2) \implies a_1 = a_2.
  • Surjective (onto): for every bBb \in BThere exists aAa \in A with f(a)=bf(a) = b.
  • Bijective: both injective and surjective.

Theorem 2.1. If AA and BB are finite sets, f:ABf : A \to B is:

  • Injective if and only if AB|A| \leq |B|.
  • Surjective if and only if AB|A| \geq |B|.
  • Bijective if and only if A=B|A| = |B|.

Theorem 2.2 (Pigeonhole Principle). If A>B|A| \gt{} |B|Then no function f:ABf : A \to B is injective. Equivalently, placing nn items into mm boxes with n>mn \gt{} m forces at least one box to contain at least n/m\lceil n/m \rceil items.

Function composition. Given f:ABf : A \to B and g:BCg : B \to CThe composition gf:ACg \circ f : A \to C is defined by (gf)(a)=g(f(a))(g \circ f)(a) = g(f(a)) for all aAa \in A.

Theorem 2.3. If f:ABf : A \to B and g:BCg : B \to C are both injective, then gfg \circ f is injective.

Proof. Suppose (gf)(a1)=(gf)(a2)(g \circ f)(a_1) = (g \circ f)(a_2). Then g(f(a1))=g(f(a2))g(f(a_1)) = g(f(a_2)). Since gg is Injective, f(a1)=f(a2)f(a_1) = f(a_2). Since ff is injective, a1=a2a_1 = a_2. Hence gfg \circ f is injective. \blacksquare

Theorem 2.4. If f:ABf : A \to B and g:BCg : B \to C are both surjective, then gfg \circ f is surjective.

Proof. Let cCc \in C. Since gg is surjective, bB\exists\, b \in B with g(b)=cg(b) = c. Since ff is Surjective, aA\exists\, a \in A with f(a)=bf(a) = b. Then (gf)(a)=g(f(a))=g(b)=c(g \circ f)(a) = g(f(a)) = g(b) = c. Hence gfg \circ f is surjective. \blacksquare

Corollary 2.5. The composition of two bijections is a bijection.

A function f:ABf : A \to B is invertible if there exists f1:BAf^{-1} : B \to A such that f^{-1} \circ f = \mathrm{id{}_A and f \circ f^{-1} = \mathrm{id{}_B. A function is invertible If and only if it is bijective.

2.4 Countability

Definition. A set SS is countable if it is finite or countably infinite. A set is countably infinite if there exists a bijection NS\mathbb{{'}N{}'} \to S. A set that is not countable Is uncountable.

Theorem 2.6. Z\mathbb{{'}Z{}'} is countably infinite.

Proof. The function f:NZf : \mathbb{{'}N{}'} \to \mathbb{{'}Z{}'} defined by

f(n)={n/2if  n  is  even(n+1)/2if  n  is  oddf(n) = \begin{cases} n/2 & \mathrm{if}\; n\; \mathrm{is}\; even \\ -(n+1)/2 & \mathrm{if}\; n\; \mathrm{is}\; odd \end{cases}

Is a bijection, enumerating 0,1,1,2,2,3,3,0, -1, 1, -2, 2, -3, 3, \ldots \blacksquare

Theorem 2.7. Q\mathbb{{'}Q{}'} is countably infinite.

Proof. Every positive rational can be written as p/qp/q with p,qN+p, q \in \mathbb{{'}N{}'}^+. Arrange the Pairs (p,q)(p, q) in an infinite grid and traverse them diagonally:

1/1,  1/2,  2/1,  3/1,  1/3,  1/4,  2/3,  3/2,  4/1,1/1,\; 1/2,\; 2/1,\; 3/1,\; 1/3,\; 1/4,\; 2/3,\; 3/2,\; 4/1, \ldots

Skipping duplicates (where p/q=p/qp/q = p'/q' in reduced form) yields an enumeration of Q+\mathbb{{'}Q{}'}^+. Extending with negatives and zero gives an enumeration of Q\mathbb{{'}Q{}'}. \blacksquare

Theorem 2.8 (Cantor, 1891). R\mathbb{{'}R{}'} is uncountable.

Proof (Diagonal argument). Suppose for contradiction that R\mathbb{{'}R{}'} is countable. Then the Interval [0,1)[0, 1) can be listed as r1,r2,r3,r_1, r_2, r_3, \ldots where each rir_i has a unique decimal Expansion ri=0.di1di2di3r_i = 0.d_{i1}d_{i2}d_{i3}\ldots with each dij0,1,,9d_{ij} \in \\{0, 1, \ldots, 9\\} (choosing the expansion that does not end in all 9s to avoid dual representations).

Define s=0.s1s2s3s = 0.s_1 s_2 s_3 \ldots by

si={5if  dii56if  dii=5s_i = \begin{cases} 5 & \mathrm{if}\; d_{ii} \neq 5 \\ 6 & \mathrm{if}\; d_{ii} = 5 \end{cases}

Then s[0,1)s \in [0, 1) and ss differs from rir_i in the ii-th decimal place for every ii So sr1,r2,s \notin \\{r_1, r_2, \ldots\\}Contradicting the assumption that the list was complete. Therefore R\mathbb{{'}R{}'} is uncountable. \blacksquare

3. Proof Techniques

3.1 Direct Proof

To prove P    QP \implies Q: assume PPDerive QQ by a chain of logical deductions.

Example. Prove: if nn is odd, then n2n^2 is odd.

Proof. Let n=2k+1n = 2k + 1. Then n2=(2k+1)2=4k2+4k+1=2(2k2+2k)+1n^2 = (2k+1)^2 = 4k^2 + 4k + 1 = 2(2k^2 + 2k) + 1Which is odd. \blacksquare

Worked Example. Prove: the sum of any two rational numbers is rational.

Solution

Let a=p/qa = p/q and b=r/sb = r/s where p,q,r,sZp, q, r, s \in \mathbb{{'}Z{}'} and q,s0q, s \neq 0. Then

a+b=pq+rs=ps+rqqsa + b = \frac{p}{q} + \frac{r}{s} = \frac{ps + rq}{qs}

Since ps+rqZps + rq \in \mathbb{{'}Z{}'} and qsZ0qs \in \mathbb{{'}Z{}'} \setminus \\{0\\}The sum a+ba + b is rational. \blacksquare

3.2 Proof by Contrapositive

To prove P    QP \implies Q: prove ¬Q    ¬P\neg Q \implies \neg P instead.

Example. Prove: if n2n^2 is even, then nn is even.

Proof. Contrapositive: if nn is odd, then n2n^2 is odd. This was proved above. \blacksquare

Worked Example. Prove: if 3n+23n + 2 is odd, then nn is odd.

Solution

Contrapositive: if nn is even, then 3n+23n + 2 is even.

Let n=2kn = 2k. Then 3n+2=3(2k)+2=6k+2=2(3k+1)3n + 2 = 3(2k) + 2 = 6k + 2 = 2(3k + 1)Which is even. \blacksquare

3.3 Proof by Contradiction

To prove PP: assume ¬P\neg P and derive a contradiction.

Example (Euclid). There are infinitely many primes.

Proof. Suppose there are finitely many primes p1,p2,,pnp_1, p_2, \ldots, p_n. Consider N=p1p2pn+1N = p_1 p_2 \cdots p_n + 1. NN is not divisible by any pip_i (it leaves remainder 1). So NN is either prime itself or has a prime Factor not in the list. Either way, the list was incomplete. Contradiction. \blacksquare

Worked Example. Prove: 2\sqrt{2} is irrational.

Solution

Suppose 2=p/q\sqrt{2} = p/q in lowest terms, with p,qZ+p, q \in \mathbb{{'}Z{}'}^+ and gcd(p,q)=1\gcd(p, q) = 1. Then 2q2=p22q^2 = p^2So p2p^2 is even, hence pp is even. Write p=2rp = 2r. Then 2q2=4r22q^2 = 4r^2So q2=2r2q^2 = 2r^2Hence qq is even. But then both pp and qq are even, Contradicting gcd(p,q)=1\gcd(p, q) = 1. \blacksquare

3.4 Mathematical Induction

Principle of Mathematical Induction. To prove P(n)P(n) for all nn0n \geq n_0:

  1. Base case: Prove P(n0)P(n_0).
  2. Inductive step: Prove P(k)    P(k+1)P(k) \implies P(k+1) for all kn0k \geq n_0.

Strong Induction. The inductive step assumes P(n0),P(n0+1),,P(k)P(n_0), P(n_0+1), \ldots, P(k) to prove P(k+1)P(k+1).

Example. Prove: i=1ni=n(n+1)/2\sum_{i=1}^{n} i = n(n+1)/2 for all n1n \geq 1.

Proof. Base case: n=1n = 1: 1=12/21 = 1 \cdot 2 / 2. True.

Inductive step: Assume i=1ki=k(k+1)/2\sum_{i=1}^{k} i = k(k+1)/2. Then

i=1k+1i=k(k+1)2+(k+1)=k(k+1)+2(k+1)2=(k+1)(k+2)2\sum_{i=1}^{k+1} i = \frac{k(k+1)}{2} + (k+1) = \frac{k(k+1) + 2(k+1)}{2} = \frac{(k+1)(k+2)}{2}

\blacksquare

Worked Example. Prove by strong induction: every integer n2n \geq 2 can be factored into primes.

Solution

Base case: n=2n = 2 is prime, so it is a (trivial) product of primes.

Inductive step: Assume every integer in 2,3,,k\\{2, 3, \ldots, k\\} factors into primes, where k2k \geq 2. Consider n=k+1n = k + 1.

If k+1k + 1 is prime, it is already a product of primes (itself).

If k+1k + 1 is composite, then k+1=abk + 1 = ab where 2abk2 \leq a \leq b \leq k. By the strong induction Hypothesis, both aa and bb factor into primes. Hence k+1=abk + 1 = ab also factors into primes.

\blacksquare

Worked Example. Prove: i=0n2i=2n+11\sum_{i=0}^{n} 2^i = 2^{n+1} - 1 for all n0n \geq 0.

Solution

Base case: n=0n = 0: 20=1=20+112^0 = 1 = 2^{0+1} - 1. ✓

Inductive step: Assume i=0k2i=2k+11\sum_{i=0}^{k} 2^i = 2^{k+1} - 1. Then

i=0k+12i=2k+11+2k+1=22k+11=2k+21\sum_{i=0}^{k+1} 2^i = 2^{k+1} - 1 + 2^{k+1} = 2 \cdot 2^{k+1} - 1 = 2^{k+2} - 1

\blacksquare

3.5 Structural Induction

For recursively defined structures (lists, trees, formulas), prove a property by induction on the Structure:

  1. Base cases (empty list, leaf node, atomic formula).
  2. Inductive cases (cons, node with children, compound formula).

3.6 The Well-Ordering Principle

Well-Ordering Principle (WOP). Every nonempty set of nonnegative integers has a least element.

Theorem 3.1. The Well-Ordering Principle is equivalent to the Principle of Mathematical Induction.

Proof (WOP implies induction). Let P(n)P(n) be a property with P(0)P(0) true and P(k)    P(k+1)P(k) \implies P(k+1). Suppose for contradiction that P(n)P(n) fails for some n0n \geq 0. Let S = \\{n \geq 0 : P(n)\; \mathrm{is\; false{}\\}. By assumption SS \neq \emptysetSo by WOP, SS has a least Element mm. Since P(0)P(0) is true, m1m \geq 1. Then P(m1)P(m - 1) is true (by minimality of mm), And P(m1)    P(m)P(m - 1) \implies P(m) by the inductive hypothesis, so P(m)P(m) is true, contradicting mSm \in S. Therefore S=S = \emptyset and P(n)P(n) holds for all n0n \geq 0.

Proof (induction implies WOP). Let SNS \subseteq \mathbb{{'}N{}'} be nonempty. We prove by induction that If S0,1,,nS \cap \\{0, 1, \ldots, n\\} \neq \emptysetThen SS has a least element. For n=0n = 0, SS Contains 00Which is the least element. Assume the claim for n=kn = k. If 0S0,,k+10 \in S \cap \\{0, \ldots, k+1\\} Then 00 is the least element. Otherwise S0,,k+1=S1,,k+1S \cap \\{0, \ldots, k+1\\} = S \cap \\{1, \ldots, k+1\\}And by The induction hypothesis applied to the shifted set, a least element exists. \blacksquare

Worked Example. Use the WOP to prove that every n1n \geq 1 can be written as a sum of distinct Powers of 2.

Solution

Let SS be the set of positive integers that cannot be written as a sum of distinct powers of 2. Suppose SS \neq \emptyset. By WOP, SS has a least element mm.

Let 2k2^k be the largest power of 2 not exceeding mm (so 2km<2k+12^k \leq m \lt 2^{k+1}). Then m2k0m - 2^k \geq 0 and m2k<2km - 2^k \lt 2^k. If m2k=0m - 2^k = 0Then m=2km = 2^k is a single power of 2, Contradicting mSm \in S. If m2k>0m - 2^k \gt 0Then m2k<mm - 2^k \lt mSo m2kSm - 2^k \notin S (by minimality Of mm). Hence m2km - 2^k is a sum of distinct powers of 2, all of which are <2k\lt 2^k. Adding 2k2^k Gives mm as a sum of distinct powers of 2, contradicting mSm \in S. Therefore S=S = \emptyset. \blacksquare

4. Combinatorics

4.1 Counting Principles

Rule of Sum. If task AA can be done in mm ways and task BB in nn ways, and they cannot both be Done, then AA or BB can be done in m+nm + n ways.

Rule of Product. If task AA can be done in mm ways and task BB in nn ways independently, then AA and BB together can be done in mnmn ways.

4.2 Permutations and Combinations

Permutations: P(n,r)=n!/(nr)!P(n, r) = n! / (n-r)! — ordered arrangements of rr items from nn.

Combinations: (nr)=n!r!(nr)!\binom{n}{r} = \frac{n!}{r!(n-r)!} — unordered selections of rr items from nn.

Theorem 4.1 (Binomial Theorem).

(x+y)n=r=0n(nr)xnryr(x + y)^n = \sum_{r=0}^{n} \binom{n}{r} x^{n-r} y^r

Theorem 4.2 (Pascal’s Identity). (nr)=(n1r)+(n1r1)\binom{n}{r} = \binom{n-1}{r} + \binom{n-1}{r-1}

Proof. Every rr-subset of 1,,n\\{1, \ldots, n\\} either contains nn (giving (n1r1)\binom{n-1}{r-1} ways To choose the remaining r1r-1) or does not contain nn (giving (n1r)\binom{n-1}{r} ways to choose all rr From 1,,n1\\{1, \ldots, n-1\\}). \blacksquare

4.3 Inclusion-Exclusion Principle

Theorem 4.3 (Inclusion-Exclusion). For finite sets A1,,AnA_1, \ldots, A_n:

i=1nAi=iAii<jAiAj+i<j<kAiAjAk+(1)n+1A1An\left|\bigcup_{i=1}^{n} A_i\right| = \sum_i |A_i| - \sum_{i \lt j} |A_i \cap A_j| + \sum_{i \lt j \lt k} |A_i \cap A_j \cap A_k| - \cdots + (-1)^{n+1}|A_1 \cap \cdots \cap A_n|

Proof (for two sets). Every element of A1A2A_1 \cup A_2 is in A1A_1 or A2A_2 or both. Counting A1+A2|A_1| + |A_2| counts elements in A1A2A_1 \cap A_2 twice, so we subtract A1A2|A_1 \cap A_2| once: A1A2=A1+A2A1A2|A_1 \cup A_2| = |A_1| + |A_2| - |A_1 \cap A_2|.

For the general case, an element in exactly tt of the sets is counted (t1)(t2)+(t3)=1(11)t=1\binom{t}{1} - \binom{t}{2} + \binom{t}{3} - \cdots = 1 - (1-1)^t = 1 time, which is correct. \blacksquare

Worked Example. How many integers from 1 to 1000 are not divisible by 2, 3, or 5?

Let A2A_2 = multiples of 2, A3A_3 = multiples of 3, A5A_5 = multiples of 5.

A2=500|A_2| = 500, A3=333|A_3| = 333, A5=200|A_5| = 200.

A2A3=166|A_2 \cap A_3| = 166, A2A5=100|A_2 \cap A_5| = 100, A3A5=66|A_3 \cap A_5| = 66.

A2A3A5=33|A_2 \cap A_3 \cap A_5| = 33.

A2A3A5=500+333+20016610066+33=734|A_2 \cup A_3 \cup A_5| = 500 + 333 + 200 - 166 - 100 - 66 + 33 = 734.

Not divisible by 2, 3, or 5: 1000734=2661000 - 734 = 266. \blacksquare

Worked Example. How many integers from 1 to 500 are divisible by 3 or 7 but not by 5?

Solution

Let A3A_3 = multiples of 3, A7A_7 = multiples of 7, A5A_5 = multiples of 5 in 1,,500\\{1, \ldots, 500\\}.

A3=500/3=166|A_3| = \lfloor 500/3 \rfloor = 166 A7=500/7=71|A_7| = \lfloor 500/7 \rfloor = 71 A5=500/5=100|A_5| = \lfloor 500/5 \rfloor = 100.

A3A7=500/21=23|A_3 \cap A_7| = \lfloor 500/21 \rfloor = 23 A3A5=500/15=33|A_3 \cap A_5| = \lfloor 500/15 \rfloor = 33 A7A5=500/35=14|A_7 \cap A_5| = \lfloor 500/35 \rfloor = 14 A3A7A5=500/105=4|A_3 \cap A_7 \cap A_5| = \lfloor 500/105 \rfloor = 4.

Divisible by 3 or 7: A3A7=166+7123=214|A_3 \cup A_7| = 166 + 71 - 23 = 214.

Divisible by 3 or 7 and by 5: (A3A7)A5=A3A5+A7A5A3A7A5=33+144=43|(A_3 \cup A_7) \cap A_5| = |A_3 \cap A_5| + |A_7 \cap A_5| - |A_3 \cap A_7 \cap A_5| = 33 + 14 - 4 = 43.

Divisible by 3 or 7 but not by 5: 21443=171214 - 43 = 171. \blacksquare

4.4 Stars and Bars

Theorem 4.4. The number of ways to distribute nn identical objects into kk distinct bins is (n+k1k1)\binom{n + k - 1}{k - 1}.

Proof. The problem is equivalent to placing k1k - 1 dividers among nn objects, giving (n+k1n)=(n+k1k1)\binom{n + k - 1}{n} = \binom{n + k - 1}{k - 1} arrangements. \blacksquare

Worked Example. How many solutions does x1+x2+x3=15x_1 + x_2 + x_3 = 15 have with xi1x_i \geq 1?

Solution

Substitute yi=xi10y_i = x_i - 1 \geq 0. Then y1+y2+y3=153=12y_1 + y_2 + y_3 = 15 - 3 = 12 with yi0y_i \geq 0. By stars and bars: (12+3131)=(142)=91\binom{12 + 3 - 1}{3 - 1} = \binom{14}{2} = 91. \blacksquare

Worked Example. How many solutions does x1+x2+x3+x4=20x_1 + x_2 + x_3 + x_4 = 20 have with xi0x_i \geq 0?

Solution

Directly by stars and bars: (20+4141)=(233)=1771\binom{20 + 4 - 1}{4 - 1} = \binom{23}{3} = 1771. \blacksquare

4.5 The Pigeonhole Principle

Theorem 4.5 (Pigeonhole Principle). If nn objects are placed into kk boxes and n>kn \gt kThen at Least one box contains at least n/k\lceil n/k \rceil objects.

Proof. If every box contained at most n/k1\lceil n/k \rceil - 1 objects, the total would be at most k(n/k1)<kn/k=nk(\lceil n/k \rceil - 1) \lt k \cdot n/k = nContradicting that there are nn objects. \blacksquare

Worked Example. In a class of 400 students, at least how many were born in the same month?

Solution

There are 12 months (boxes) and 400 students (objects). By the pigeonhole principle, some month Has at least 400/12=33.33=34\lceil 400/12 \rceil = \lceil 33.33\ldots \rceil = 34 students.

Worked Example. Show that among any n+1n + 1 integers from 1,2,,2n\\{1, 2, \ldots, 2n\\}Two of them Differ by exactly nn.

Solution

Partition 1,2,,2n\\{1, 2, \ldots, 2n\\} into nn pigeonholes: 1,n+1\\{1, n+1\\}, 2,n+2\\{2, n+2\\}, \ldots n,2n\\{n, 2n\\}. Each pair sums to n+(n+k)=2n+kn + (n+k) = 2n + k… Let me rephrase.

Partition into 1,n+1\\{1, n+1\\}, 2,n+2\\{2, n+2\\}, \ldots, n,2n\\{n, 2n\\}. These are nn disjoint sets. If we select n+1n + 1 integers from 1,,2n\\{1, \ldots, 2n\\}By the pigeonhole principle two must lie in the Same set i,n+i\\{i, n+i\\}And their difference is (n+i)i=n(n + i) - i = n. \blacksquare

Worked Example. Prove that any sequence of n2+1n^2 + 1 distinct real numbers contains a monotone (increasing or decreasing) subsequence of length n+1n + 1.

Solution

Let a1,a2,,an2+1a_1, a_2, \ldots, a_{n^2+1} be the sequence. For each aia_iLet did_i be the length of the Longest increasing subsequence starting at aia_iAnd eie_i the length of the longest decreasing Subsequence starting at aia_i.

Suppose for contradiction that every monotone subsequence has length at most nn. Then 1din1 \leq d_i \leq n and 1ein1 \leq e_i \leq nSo there are at most n2n^2 distinct ordered pairs (di,ei)(d_i, e_i). Since we have n2+1n^2 + 1 elements, by the pigeonhole principle two indices i<ji \lt j Have (di,ei)=(dj,ej)(d_i, e_i) = (d_j, e_j).

If ai<aja_i \lt a_jThen didj+1d_i \geq d_j + 1 (append aia_i before the increasing subsequence starting At aja_j), contradicting di=djd_i = d_j.

If ai>aja_i \gt a_jThen eiej+1e_i \geq e_j + 1Contradicting ei=eje_i = e_j.

Either way we have a contradiction. \blacksquare

Theorem 4.6 (Generalised Pigeonhole Principle). If nn objects are placed into kk boxes, then at Least one box contains at least n/k\lceil n/k \rceil objects. Equivalently, if each box contains at most mm objects, then the total number of objects is at most kmkm.

Worked Example. A drawer contains red, blue, and yellow socks. How many socks must be drawn (without looking) to guarantee at least 4 socks of the same colour?

Solution

There are 3 colours (boxes). By the generalised pigeonhole principle, drawing nn socks guarantees At least n/3\lceil n/3 \rceil of one colour. We need n/34\lceil n/3 \rceil \geq 4So n/3>3n/3 \gt{} 3Giving n10n \geq 10.

With 9 socks it is possible to have 3 of each colour (no colour reaches 4). With 10 socks, one Colour must have at least 10/3=4\lceil 10/3 \rceil = 4.

Worked Example. Prove that in any group of nn people, there are at least two who have shaken Hands with the same number of people (within the group).

Solution

Each person can shake hands with between 0 and n1n - 1 others, giving nn possible values. But the Values 0 and n1n - 1 cannot both occur (if someone shook no hands, no one shook everyone’s hand, And vice versa). So there are at most n1n - 1 distinct handshake counts among nn people. By the Pigeonhole principle, at least two people have the same count. \blacksquare

4.6 Catalan Numbers

The nn-th Catalan number is

Cn=1n+1(2nn)=(2n)!(n+1)!n!C_n = \frac{1}{n+1}\binom{2n}{n} = \frac{(2n)!}{(n+1)!\,n!}

The first few values: C0=1C_0 = 1, C1=1C_1 = 1, C2=2C_2 = 2, C3=5C_3 = 5, C4=14C_4 = 14, C5=42C_5 = 42.

Catalan numbers count:

  • The number of valid (properly matched) sequences of nn pairs of parentheses.
  • The number of binary search trees with nn nodes.
  • The number of ways to triangulate a convex (n+2)(n+2)-gon.
  • The number of lattice paths from (0,0)(0,0) to (n,n)(n,n) that never go above the diagonal.

Recurrence. C0=1C_0 = 1 and for n1n \geq 1:

Cn=i=0n1CiCn1iC_n = \sum_{i=0}^{n-1} C_i \, C_{n-1-i}

Worked Example. Verify C3=5C_3 = 5 by listing all valid sequences of 3 pairs of parentheses.

Solution

The five valid sequences are: ((()))((())), (()())(()()), (())()(())(), ()(())()(()), ()()()()()().

Checking: C3=14(63)=1420=5C_3 = \frac{1}{4}\binom{6}{3} = \frac{1}{4} \cdot 20 = 5. ✓

4.7 Generating Functions for Combinatorics

The ordinary generating function (OGF) of a sequence an\\{a_n\\} is

G(x)=n=0anxnG(x) = \sum_{n=0}^{\infty} a_n x^n

Common generating functions:

Sequence ana_nGenerating function G(x)G(x)
1111x\dfrac{1}{1-x}
rnr^n11rx\dfrac{1}{1 - rx}
(n+kk)\binom{n+k}{k}1(1x)k+1\dfrac{1}{(1-x)^{k+1}}
nnx(1x)2\dfrac{x}{(1-x)^2}
n2n^2x(1+x)(1x)3\dfrac{x(1+x)}{(1-x)^3}

Key operations. If A(x)A(x) generates an\\{a_n\\} and B(x)B(x) generates bn\\{b_n\\}:

  • A(x)+B(x)A(x) + B(x) generates an+bn\\{a_n + b_n\\} (choice between types).
  • A(x)B(x)A(x) \cdot B(x) generates cn\\{c_n\\} where cn=i=0naibnic_n = \sum_{i=0}^{n} a_i b_{n-i} (combining two choices).

Worked Example. Find the number of ways to select nn coins from unlimited supplies of 1p, 2p, And 5p coins.

Solution

The generating function is

G(x) = \underbrace{(1 + x + x^2 + \cdots)}_{\mathrm{1p\; coins{}} \cdot \underbrace{(1 + x^2 + x^4 + \cdots)}_{\mathrm{2p\; coins{}} \cdot \underbrace{(1 + x^5 + x^{10} + \cdots)}_{\mathrm{5p\; coins{}}

=11x11x211x5= \frac{1}{1-x} \cdot \frac{1}{1-x^2} \cdot \frac{1}{1-x^5}

The coefficient of xnx^n in the expansion gives the number of ways. For example, expanding the First few terms: 1+x+2x2+2x3+3x4+4x5+1 + x + 2x^2 + 2x^3 + 3x^4 + 4x^5 + \cdotsSo there are 4 ways to make 5p (5×1p; 3×1p + 1×2p; 1×1p + 2×2p; 1×5p).

5. Graph Theory

5.1 Definitions

A graph G=(V,E)G = (V, E) consists of a set of vertices VV and a set of edges EV×VE \subseteq V \times V.

  • Simple graph: no loops, no multiple edges.
  • Directed graph (digraph): edges have direction.
  • Weighted graph: edges have weights.

The degree of a vertex vv, deg(v)\deg(v)Is the number of edges incident to vv.

Theorem 5.1 (Handshaking Lemma). vVdeg(v)=2E\sum_{v \in V} \deg(v) = 2|E|.

Proof. Each edge contributes 1 to the degree of each of its two endpoints. \blacksquare

Corollary 5.2. The number of vertices of odd degree is even.

5.2 Paths, Cycles, and Connectivity

A walk is a sequence of vertices where consecutive vertices are adjacent. A path is a walk With no repeated vertices. A cycle is a path that returns to its starting vertex.

A graph is connected if there is a path between every pair of vertices. A connected component Is a maximal connected subgraph.

Theorem 5.3. A graph with nn vertices and more than (n1)(n2)/2(n-1)(n-2)/2 edges is connected.

5.3 Trees

A tree is a connected acyclic graph. A forest is a disjoint union of trees.

Theorem 5.4. For a graph GG with nn vertices, the following are equivalent:

  1. GG is a tree.
  2. GG is connected and has n1n - 1 edges.
  3. GG is acyclic and has n1n - 1 edges.
  4. Between any two vertices, there is exactly one path.

Cayley’s Formula. The number of labelled trees on nn vertices is nn2n^{n-2}.

5.4 Planarity

A graph is planar if it can be drawn in the plane with no edge crossings.

Theorem 5.5 (Euler’s Formula for Planar Graphs). For a connected planar graph drawn in the plane With VV vertices, EE edges, and FF faces:

VE+F=2V - E + F = 2

Proof sketch. Build the graph edge by edge. Starting from a single vertex (V=1V = 1, E=0E = 0, F=1F = 1), The quantity VE+F=2V - E + F = 2 is preserved when adding an edge: if the edge connects two components, EE and VV each increase by 1; if it splits a face, EE and FF each increase by 1. \blacksquare

Corollary 5.6. For a simple planar graph with V3V \geq 3: E3V6E \leq 3V - 6.

Proof. Every face has at least 3 edges on its boundary, and every edge borders at most 2 faces, So 3F2E3F \leq 2E. By Euler’s formula, F=2V+EF = 2 - V + EGiving 3(2V+E)2E3(2 - V + E) \leq 2EI.e., E3V6E \leq 3V - 6. \blacksquare

Corollary 5.7. K5K_5 and K3,3K_{3,3} are not planar.

Proof. K5K_5 has V=5V = 5, E=10E = 10But 10>3(5)6=910 \gt 3(5) - 6 = 9. For K3,3K_{3,3}, V=6V = 6, E=9E = 9. Since K3,3K_{3,3} has no triangles, every face has at least 4 edges, giving 4F2E4F \leq 2ESo FE/2=4.5F \leq E/2 = 4.5. But VE+F=2V - E + F = 2 gives F=26+9=5>4.5F = 2 - 6 + 9 = 5 \gt 4.5. Contradiction. \blacksquare

Theorem 5.8 (Kuratowski’s Theorem). A graph is planar if and only if it does not contain a Subdivision of K5K_5 or K3,3K_{3,3} as a subgraph.

A subdivision of an edge uvuv replaces uvuv with a path uuwwvv through a new vertex ww. A graph HH is a subdivision of GG if HH can be obtained from GG by subdividing edges.

Worked Example. Show that K3,3K_{3,3} is not planar using Euler’s formula.

Solution

K3,3K_{3,3} has V=6V = 6 vertices and E=9E = 9 edges. It is bipartite (partition sizes 3 and 3), so it Contains no triangles. Every face in a planar embedding must therefore be bounded by at least 4 edges, Giving 4F2E4F \leq 2EI.e., F9/2=4.5F \leq 9/2 = 4.5.

But Euler’s formula gives F=EV+2=96+2=5F = E - V + 2 = 9 - 6 + 2 = 5. Since 5>4.55 \gt 4.5No planar embedding Exists. \blacksquare

5.5 Graph Colouring

A proper kk-colouring assigns one of kk colours to each vertex such that adjacent vertices have Different colours. The chromatic number χ(G)\chi(G) is the minimum kk for which a proper kk-colouring Exists.

Theorem 5.9 (Four Colour Theorem). Every planar graph is 4-colourable.

Theorem 5.10 (Five Colour Theorem). Every planar graph is 5-colourable. (Easier to prove.)

Theorem 5.11 (Greedy Colouring Bound). χ(G)Δ(G)+1\chi(G) \leq \Delta(G) + 1 where Δ(G)\Delta(G) is the Maximum degree.

Theorem 5.12 (Brooks’ Theorem). If GG is connected and is neither a complete graph nor an odd Cycle, then χ(G)Δ(G)\chi(G) \leq \Delta(G).

Chromatic polynomial. The chromatic polynomial P(G,k)P(G, k) counts the number of proper kk-colourings of GG.

Theorem 5.13. P(G,k)P(G, k) is a polynomial in kk.

Deletion-contraction recurrence. For any edge ee of GG:

P(G,k)=P(Ge,k)P(G/e,k)P(G, k) = P(G - e, k) - P(G / e, k)

Where GeG - e is GG with edge ee deleted, and G/eG / e is GG with ee contracted (its endpoints Merged).

Worked Example. Find the chromatic polynomial of C4C_4 (the 4-cycle).

Solution

Label the vertices of C4C_4 as v1,v2,v3,v4v_1, v_2, v_3, v_4 with edges v1v2v_1v_2, v2v3v_2v_3, v3v4v_3v_4, v4v1v_4v_1.

Pick edge e=v1v2e = v_1v_2.

GeG - e is a path on 4 vertices (a tree): P(Ge,k)=k(k1)3P(G - e, k) = k(k-1)^3.

G/eG / e merges v1v_1 and v2v_2Yielding C3C_3 (triangle): P(C3,k)=k(k1)(k2)P(C_3, k) = k(k-1)(k-2).

Therefore P(C4,k)=k(k1)3k(k1)(k2)=k(k1)[(k1)2(k2)]=k(k1)(k23k+3)P(C_4, k) = k(k-1)^3 - k(k-1)(k-2) = k(k-1)[(k-1)^2 - (k-2)] = k(k-1)(k^2 - 3k + 3).

Checking: P(C4,2)=2(1)(46+3)=2P(C_4, 2) = 2(1)(4 - 6 + 3) = 2 (two 2-colourings: alternating), and P(C4,3)=32(99+3)=18P(C_4, 3) = 3 \cdot 2 \cdot (9 - 9 + 3) = 18. \blacksquare

Worked Example. Find χ(Kn)\chi(K_n) and χ(Km,n)\chi(K_{m,n}).

Solution

KnK_n (complete graph on nn vertices): every pair of vertices is adjacent, so all nn vertices must Receive distinct colours. Hence χ(Kn)=n\chi(K_n) = n.

Km,nK_{m,n} (complete bipartite graph): no two vertices within the same partition are adjacent, so we Can colour all vertices in the first partition with colour 1 and all in the second with colour 2. Hence χ(Km,n)=2\chi(K_{m,n}) = 2 (for m,n1m, n \geq 1).

Worked Example. Find the chromatic polynomial of K3K_3 (triangle).

Solution

Choose a colour for vertex 1: kk choices. Choose a colour for vertex 2 (different from vertex 1): k1k - 1 choices. Choose a colour for vertex 3 (different from both): k2k - 2 choices.

P(K3,k)=k(k1)(k2)P(K_3, k) = k(k-1)(k-2).

Checking: P(K3,2)=210=0P(K_3, 2) = 2 \cdot 1 \cdot 0 = 0 (not 2-colourable, as expected). P(K3,3)=6P(K_3, 3) = 6.

5.6 Euler and Hamilton Paths

An Euler path visits every edge exactly once. An Euler circuit is an Euler path that starts And ends at the same vertex.

Theorem 5.14. A connected graph has an Euler circuit if and only if every vertex has even degree. It has an Euler path (but not circuit) if and only if exactly two vertices have odd degree.

Proof (sufficiency). If every vertex has even degree, start at any vertex and follow edges, never Reusing an edge. Since all degrees are even, the walk can only terminate at the starting vertex, Forming a circuit CC. If CC uses all edges, we are done. Otherwise, remove CC‘s edges; each Remaining component has all vertices of even degree (each lost an even number of incident edges). By induction, each component has an Euler circuit. Splicing these circuits into CC at shared Vertices yields an Euler circuit of the full graph. \blacksquare

Worked Example. Does K2,3K_{2,3} have an Euler circuit? An Euler path?

Solution

K2,3K_{2,3} has 5 vertices. The two vertices in the first partition each have degree 3 (connected to All three in the second partition). The three vertices in the second partition each have degree 2.

Vertices of odd degree: two (each of degree 3). Since exactly two vertices have odd degree, K2,3K_{2,3} has an Euler path (starting at one odd-degree vertex, ending at the other) but not an Euler circuit.

A Hamilton path visits every vertex exactly once. A Hamilton circuit is a Hamilton path that Returns to the start.

Theorem 5.15 (Dirac’s Theorem). If GG is a simple graph with n3n \geq 3 vertices and deg(v)n/2\deg(v) \geq n/2 for every vertex, then GG has a Hamilton circuit.

Theorem 5.16 (Ore’s Theorem). If GG is a simple graph with n3n \geq 3 vertices and deg(u)+deg(v)n\deg(u) + \deg(v) \geq n for every pair of non-adjacent vertices u,vu, vThen GG has a Hamilton Circuit.

Note that Dirac’s theorem is a corollary of Ore’s theorem.

Worked Example. Does K2,3K_{2,3} have a Hamilton circuit?

Solution

K2,3K_{2,3} has 5 vertices. A Hamilton circuit must visit all 5 vertices and return. Label the Partitions as A=a1,a2A = \\{a_1, a_2\\} and B=b1,b2,b3B = \\{b_1, b_2, b_3\\}. Any cycle in a bipartite graph alternates Between the two partitions. A Hamilton cycle would alternate between AA and BBRequiring A=B|A| = |B|. But A=23=B|A| = 2 \neq 3 = |B|So no Hamilton circuit exists.

However, K2,3K_{2,3} does have Hamilton paths (e.g., a1,b1,a2,b2,b3a_1, b_1, a_2, b_2, b_3 — wait, this doesn’t Alternate properly). Actually, in K2,3K_{2,3} edges only exist between AA and BB. A path must alternate A,B,A,B,A, B, A, B, \ldots or B,A,B,A,B, A, B, A, \ldots. A Hamilton path visits all 5 vertices, so it has the Form a,b,a,b,aa, b, a, b, a (length 5, starting and ending in AA) or b,a,b,a,bb, a, b, a, b (length 5, starting And ending in BB). The first requires 3 vertices from AABut A=2|A| = 2. The second requires 3 Vertices from BBAnd B=3|B| = 3. So a Hamilton path exists: e.g., b1,a1,b2,a2,b3b_1, a_1, b_2, a_2, b_3.

Worked Example. Let GG have vertices 1,2,3,4,5\\{1, 2, 3, 4, 5\\} and edges 12,23,34,45,51,13,3512, 23, 34, 45, 51, 13, 35. Does GG have an Euler circuit or Euler path?

Solution

Degrees: deg(1)=3\deg(1) = 3, deg(2)=2\deg(2) = 2, deg(3)=4\deg(3) = 4, deg(4)=2\deg(4) = 2, deg(5)=3\deg(5) = 3. Two vertices (1 and 5) have odd degree. Since exactly two vertices have odd degree, GG has an Euler Path (starting at 1, ending at 5) but no Euler circuit.

One Euler path: 123453151 \to 2 \to 3 \to 4 \to 5 \to 3 \to 1 \to 5. All 7 edges are used exactly once. ✓

Algorithm (Hierholzer’s). To find an Euler circuit: start at any vertex, follow unused edges Until returning to the start. If unused edges remain, find a vertex on the current circuit with Unused edges, find a subtour, and splice it in. Repeat until all edges are used.

:::caution Common Pitfall Determining whether a graph has a Hamilton path/circuit is NP-complete , whereas Euler Paths/circuits can be determined in polynomial time using the degree condition. Do not confuse the two. :::

5.7 Matching Theory

A matching MM in a graph G=(V,E)G = (V, E) is a set of pairwise disjoint edges (no two share an Endpoint). A vertex is matched if it is an endpoint of an edge in MM; otherwise it is unmatched. A perfect matching covers every vertex.

Theorem 5.17 (Hall’s Marriage Theorem, 1935). Let G=(V,E)G = (V, E) be a bipartite graph with Partitions XX and YY. There exists a matching that covers every vertex in XX if and only if for Every subset SXS \subseteq X

N(S)S|N(S)| \geq |S|

Where N(S) = \\{y \in Y : \exists\, x \in S\; \mathrm{with{}\; xy \in E\\} is the neighbourhood of SS.

Proof (necessity). If a matching covers XXEach xSx \in S is matched to a distinct yN(S)y \in N(S) So N(S)S|N(S)| \geq |S|.

Proof (sufficiency by induction on X|X|). Base case X=1|X| = 1: Hall’s condition gives N(x)1|N(\\{x\\})| \geq 1 So xx has a neighbour, and we can match xx to it.

Inductive step. Consider two cases.

Case 1: For every nonempty proper subset SXS \subsetneq X, N(S)>S|N(S)| \gt |S|. Pick any edge xyxy. In G=Gx,yG' = G - \\{x, y\\}Hall’s condition still holds (removing one element from each side preserves the Strict inequality). By the induction hypothesis, XxX \setminus \\{x\\} can be matched in GG'. Adding xyxy Gives the desired matching.

Case 2: There exists a nonempty proper TXT \subsetneq X with N(T)=T|N(T)| = |T|. Match TT to N(T)N(T) By the induction hypothesis. In G=G(TN(T))G'' = G - (T \cup N(T))For any SXTS \subseteq X \setminus T NG(S)=NG(ST)N(T)N_{G''}(S) = N_G(S \cup T) \setminus N(T)So

NG(S)=NG(ST)N(T)STT=S|N_{G''}(S)| = |N_G(S \cup T)| - |N(T)| \geq |S \cup T| - |T| = |S|

Where the inequality uses Hall’s condition on STS \cup T in GG. By the induction hypothesis, XTX \setminus T can be matched in GG''. Combining with the matching on TT gives the result. \blacksquare

Worked Example. Let X=a,b,c,dX = \\{a, b, c, d\\} and Y=1,2,3,4,5Y = \\{1, 2, 3, 4, 5\\} with edges aa1,21,2; bb1,21,2; cc2,32,3; dd3,4,53,4,5. Does a matching covering XX exist?

Solution

Check Hall’s condition for every subset SXS \subseteq X:

  • S=1|S| = 1: each vertex has at least 1 neighbour. ✓
  • S=2|S| = 2: N(a,b)=1,2N(\\{a, b\\}) = \\{1, 2\\}, N=2|N| = 2. N(a,c)=1,2,3N(\\{a, c\\}) = \\{1, 2, 3\\}, N=3|N| = 3. Similarly all pairs have N2|N| \geq 2. ✓
  • S=3|S| = 3: N(a,b,c)=1,2,3N(\\{a, b, c\\}) = \\{1, 2, 3\\}, N=3|N| = 3. N(a,c,d)=1,2,3,4,5N(\\{a, c, d\\}) = \\{1, 2, 3, 4, 5\\}, N=5|N| = 5. All triples have N3|N| \geq 3. ✓
  • S=4|S| = 4: N(X)=1,2,3,4,5N(X) = \\{1, 2, 3, 4, 5\\}, N=54|N| = 5 \geq 4. ✓

Hall’s condition is satisfied, so a matching exists. One such matching: aa11, bb22 cc33, dd44.

5.8 Network Flows

A flow network is a directed graph G=(V,E)G = (V, E) with a source ssA sink ttAnd a capacity function c:ER0c : E \to \mathbb{{'}R{}'}_{\geq 0}. A flow f:ER0f : E \to \mathbb{{'}R{}'}_{\geq 0} Satisfies:

  1. Capacity constraint: 0f(e)c(e)0 \leq f(e) \leq c(e) for all eEe \in E.
  2. Flow conservation: for all vVs,tv \in V \setminus \\{s, t\\} \sum_{e\; \mathrm{into{}\; v} f(e) = \sum_{e\; \mathrm{out\; of{}\; v} f(e).

The value of a flow is |f| = \sum_{e\; \mathrm{out\; of{}\; s} f(e) - \sum_{e\; \mathrm{into{}\; s} f(e).

An s-t cut (S,T)(S, T) partitions VV into SS (containing ss) and TT (containing tt). The capacity of the cut is c(S,T)=uS,vTc(uv)c(S, T) = \sum_{u \in S, v \in T} c(uv).

Theorem 5.18 (Max-Flow Min-Cut Theorem). In any flow network, the maximum value of a flow from ss to tt equals the minimum capacity of an ss-tt cut.

Proof sketch. Let ff^* be a maximum flow. Define the residual graph GfG_f with the same Vertices and residual capacity cf(uv)=c(uv)f(uv)c_f(uv) = c(uv) - f(uv) for forward edges and cf(vu)=f(uv)c_f(vu) = f(uv) For backward edges. Let SS be the set of vertices reachable from ss in GfG_{f^*} via edges with Positive residual capacity. Since ff^* is maximum, tSt \notin S (otherwise we could augment the Flow). The cut (S,VS)(S, V \setminus S) has capacity exactly f|f^*| (all forward edges are saturated, All backward edges have zero flow). Therefore f=c(S,VS)|f^*| = c(S, V \setminus S) \geq minimum cut Capacity f\geq |f^*|Giving equality. \blacksquare

Theorem 5.19 (Integrality Theorem). If all capacities are integers, there exists a maximum flow Where every f(e)f(e) is an integer.

Corollary 5.20. If all capacities are integers, the maximum flow value is an integer.

The Ford—Fulkerson method repeatedly finds augmenting paths in the residual graph and pushes Flow along them. When capacities are integers, each augmentation increases the flow by at least 1, Guaranteeing termination.

6. Recurrence Relations

6.1 Definition

A recurrence relation defines a sequence {an}\{a_n\} by expressing ana_n in terms of previous terms.

Example. Fibonacci: Fn=Fn1+Fn2F_n = F_{n-1} + F_{n-2}With F0=0F_0 = 0, F1=1F_1 = 1.

6.2 Linear Homogeneous Recurrences with Constant Coefficients

an+c1an1++ckank=0a_n + c_1 a_{n-1} + \cdots + c_k a_{n-k} = 0

Solution method. Form the characteristic equation:

rk+c1rk1++ck=0r^k + c_1 r^{k-1} + \cdots + c_k = 0

Case 1 (distinct roots). If r1,,rkr_1, \ldots, r_k are distinct, then an=A1r1n++Akrkna_n = A_1 r_1^n + \cdots + A_k r_k^n.

Case 2 (repeated roots). If rr has multiplicity mmThe contribution is (A1+A2n++Amnm1)rn(A_1 + A_2 n + \cdots + A_m n^{m-1}) r^n.

6.3 Worked Example

Problem. Solve an=5an16an2a_n = 5a_{n-1} - 6a_{n-2} with a0=1a_0 = 1, a1=4a_1 = 4.

Solution. Characteristic equation: r25r+6=0r^2 - 5r + 6 = 0Giving r1=2r_1 = 2, r2=3r_2 = 3.

an=A2n+B3na_n = A \cdot 2^n + B \cdot 3^n.

From initial conditions: a0=A+B=1a_0 = A + B = 1 a1=2A+3B=4a_1 = 2A + 3B = 4

Solving: B=2B = 2, A=1A = -1. So an=2n+23n=23n2na_n = -2^n + 2 \cdot 3^n = 2 \cdot 3^n - 2^n. \blacksquare

Worked Example. Solve an=4an14an2a_n = 4a_{n-1} - 4a_{n-2} with a0=1a_0 = 1, a1=6a_1 = 6.

Solution

Characteristic equation: r24r+4=0r^2 - 4r + 4 = 0So (r2)2=0(r - 2)^2 = 0. Root r=2r = 2 with multiplicity 2.

an=(A+Bn)2na_n = (A + Bn) \cdot 2^n.

From initial conditions: a0=A=1a_0 = A = 1 a1=(1+B)2=6    B=2a_1 = (1 + B) \cdot 2 = 6 \implies B = 2

So an=(1+2n)2na_n = (1 + 2n) \cdot 2^n. \blacksquare

6.4 Generating Functions

The generating function of a sequence {an}\{a_n\} is

G(x)=n=0anxnG(x) = \sum_{n=0}^{\infty} a_n x^n

Example. The generating function for an=1a_n = 1 (all ones) is G(x)=1/(1x)G(x) = 1/(1-x).

Example. The generating function for an=rna_n = r^n is G(x)=1/(1rx)G(x) = 1/(1 - rx).

Generating functions can solve recurrences by converting them to algebraic equations in G(x)G(x) Then extracting coefficients.

Worked Example. Use generating functions to solve the Fibonacci recurrence Fn=Fn1+Fn2F_n = F_{n-1} + F_{n-2} With F0=0F_0 = 0, F1=1F_1 = 1.

Solution

Let G(x)=n=0FnxnG(x) = \sum_{n=0}^{\infty} F_n x^n.

G(x)=x+n=2(Fn1+Fn2)xn=x+x(G(x)F0)+x2G(x)=x+xG(x)+x2G(x)G(x) = x + \sum_{n=2}^{\infty} (F_{n-1} + F_{n-2}) x^n = x + x(G(x) - F_0) + x^2 G(x) = x + xG(x) + x^2 G(x)

G(x)(1xx2)=x    G(x)=x1xx2G(x)(1 - x - x^2) = x \implies G(x) = \frac{x}{1 - x - x^2}

Factor: 1xx2=(1αx)(1βx)1 - x - x^2 = (1 - \alpha x)(1 - \beta x) where α=(1+5)/2\alpha = (1 + \sqrt{5})/2 and β=(15)/2\beta = (1 - \sqrt{5})/2.

Partial fractions give G(x)=15(11αx11βx)G(x) = \frac{1}{\sqrt{5}} \left(\frac{1}{1 - \alpha x} - \frac{1}{1 - \beta x}\right) So Fn=15(αnβn)F_n = \frac{1}{\sqrt{5}}(\alpha^n - \beta^n) (Binet’s formula). \blacksquare

Worked Example. Use generating functions to solve an=2an1+1a_n = 2a_{n-1} + 1 with a0=0a_0 = 0.

Solution

Let G(x)=n=0anxnG(x) = \sum_{n=0}^{\infty} a_n x^n.

G(x)=n=1(2an1+1)xn=2xG(x)+n=1xn=2xG(x)+x1xG(x) = \sum_{n=1}^{\infty} (2a_{n-1} + 1) x^n = 2x G(x) + \sum_{n=1}^{\infty} x^n = 2x G(x) + \frac{x}{1-x}

(12x)G(x)=x1x    G(x)=x(1x)(12x)(1 - 2x) G(x) = \frac{x}{1-x} \implies G(x) = \frac{x}{(1-x)(1-2x)}

Partial fractions: x(1x)(12x)=A1x+B12x\frac{x}{(1-x)(1-2x)} = \frac{A}{1-x} + \frac{B}{1-2x}.

x=A(12x)+B(1x)x = A(1-2x) + B(1-x). Setting x=0x = 0: A+B=0A + B = 0So B=AB = -A. Setting x=1x = 1: 1=A1 = -ASo A=1A = -1, B=1B = 1.

G(x)=112x11xG(x) = \frac{1}{1-2x} - \frac{1}{1-x}Giving an=2n1a_n = 2^n - 1. \blacksquare

:::caution Common Pitfall Generating functions are formal power series; they may not converge for any x0x \neq 0. Convergence Is irrelevant for combinatorial applications — the series is manipulated algebraically. :::

6.5 The Master Theorem

The Master Theorem provides asymptotic solutions to recurrences of the form

T(n)=aT(n/b)+f(n)T(n) = a\,T(n/b) + f(n)

Where a1a \geq 1, b>1b \gt 1 are constants and f(n)f(n) is asymptotically positive. Define c_{\mathrm{crit{}} = \log_b a (the critical exponent).

Theorem 6.1 (Master Theorem). Let T(n)T(n) be defined as above.

Case 1: If f(n)=O(nc)f(n) = O(n^c) for some c \lt c_{\mathrm{crit{}}Then T(n) = \Theta(n^{c_{\mathrm{crit{}}}).

Case 2: If f(n) = \Theta(n^{c_{\mathrm{crit{}}} \log^k n) for some k0k \geq 0Then T(n) = \Theta(n^{c_{\mathrm{crit{}}} \log^{k+1} n).

Case 3: If f(n)=Ω(nc)f(n) = \Omega(n^c) for some c \gt c_{\mathrm{crit{}}And af(n/b)δf(n)a\,f(n/b) \leq \delta\, f(n) For some δ<1\delta \lt 1 and sufficiently large nn (the regularity condition), then T(n)=Θ(f(n))T(n) = \Theta(f(n)).

Worked Example. Solve T(n)=3T(n/2)+n2T(n) = 3T(n/2) + n^2.

Solution

a=3a = 3, b=2b = 2, f(n)=n2f(n) = n^2. Critical exponent: c_{\mathrm{crit{}} = \log_2 3 \approx 1.585.

Since f(n)=n2=Ω(nc)f(n) = n^2 = \Omega(n^c) for any c<2c \lt 2And 2 \gt 1.585 = c_{\mathrm{crit{}}We are in Case 3 (provided the regularity condition holds). Check: 3(n/2)2=3n2/4=0.75n2δn23 \cdot (n/2)^2 = 3n^2/4 = 0.75\, n^2 \leq \delta\, n^2 For δ=0.75<1\delta = 0.75 \lt 1. ✓

Therefore T(n)=Θ(n2)T(n) = \Theta(n^2).

Worked Example. Solve T(n)=2T(n/2)+nT(n) = 2T(n/2) + n.

Solution

a=2a = 2, b=2b = 2, f(n)=nf(n) = n. Critical exponent: c_{\mathrm{crit{}} = \log_2 2 = 1.

f(n)=n=Θ(n1log0n)f(n) = n = \Theta(n^1 \log^0 n)So we are in Case 2 with k=0k = 0.

Therefore T(n)=Θ(nlogn)T(n) = \Theta(n \log n).

Worked Example. Solve T(n)=4T(n/2)+nT(n) = 4T(n/2) + n.

Solution

a=4a = 4, b=2b = 2, f(n)=nf(n) = n. Critical exponent: c_{\mathrm{crit{}} = \log_2 4 = 2.

f(n)=n=O(nc)f(n) = n = O(n^c) for any c>0c \gt 0 with c<2c \lt 2So we are in Case 1.

Therefore T(n)=Θ(n2)T(n) = \Theta(n^2).

Proof sketch of the Master Theorem. Expand the recurrence tree. At level jj (root is level 0), There are aja^j subproblems, each of size n/bjn/b^jEach contributing f(n/bj)f(n/b^j) work. The tree has logbn\log_b n levels, with a^{\log_b n} = n^{c_{\mathrm{crit{}}} leaves. The total work is

T(n) = \Theta\!\left(n^{c_{\mathrm{crit}}\right) + \sum_{j=0}^{\log_b n - 1} a^j \, f(n/b^j)}

  • Case 1: f(n)=O(nc)f(n) = O(n^c) with c \lt c_{\mathrm{crit{}}. The sum is dominated by the leaves, giving T(n) = \Theta(n^{c_{\mathrm{crit{}}}).
  • Case 2: f(n) = \Theta(n^{c_{\mathrm{crit{}}} \log^k n). Each level contributes the same order, with logbn\log_b n levels, giving T(n) = \Theta(n^{c_{\mathrm{crit{}}} \log^{k+1} n).
  • Case 3: f(n)=Ω(nc)f(n) = \Omega(n^c) with c \gt c_{\mathrm{crit{}}. The root level dominates, giving T(n)=Θ(f(n))T(n) = \Theta(f(n)). The regularity condition af(n/b)δf(n)a\,f(n/b) \leq \delta\,f(n) ensures the root dominates all levels below. The Master Theorem does not apply to recurrences like T(n)=T(n1)+nT(n) = T(n-1) + n (not of the form aT(n/b)+f(n)a\,T(n/b) + f(n)). Also, if f(n)f(n) falls between cases (e.g., f(n)=nlognf(n) = n \log n with c_{\mathrm{crit{}} = 1), the Master Theorem does not apply and the Akra—Bazzi method should be used Instead.

7. Problem Set

Problem 1. Prove that (p    q)(q    p)(p \implies q) \lor (q \implies p) is a tautology using a truth table.

Solution
ppqqp    qp \implies qq    pq \implies pdisjunction
TTTTT
TFFTT
FTTFT
FFTTT

All rows give TTSo it is a tautology.

If you get this wrong, revise: Section 1.1 and Section 1.4.

Problem 2. Convert (¬pq)(r¬s)(\neg p \lor q) \land (r \lor \neg s) to DNF.

Solution

The formula is a conjunction of two clauses. Distribute \land over \lor:

(¬pq)(r¬s)=(¬pr)(¬p¬s)(qr)(q¬s)(\neg p \lor q) \land (r \lor \neg s) = (\neg p \land r) \lor (\neg p \land \neg s) \lor (q \land r) \lor (q \land \neg s).

This is in DNF (disjunction of four terms, each a conjunction of two literals).

If you get this wrong, revise: Section 1.6.

Problem 3. Negate: “For every real number xxThere exists a real number yy such that y>xy \gt x.”

Solution

Original: xy(y>x)\forall x\, \exists y\, (y \gt x).

Negation: xy(yx)\exists x\, \forall y\, (y \leq x)I.e., “there exists a real number xx such that every Real number yy satisfies yxy \leq x.”

If you get this wrong, revise: Section 1.2.

Problem 4. Prove that ABA \subseteq B if and only if ABc=A \cap B^c = \emptyset.

Solution

(\Rightarrow) Assume ABA \subseteq B. Let xABcx \in A \cap B^c. Then xAx \in A and xBx \notin B. But ABA \subseteq B implies xBx \in BContradiction. So ABc=A \cap B^c = \emptyset.

(\Leftarrow) Assume ABc=A \cap B^c = \emptyset. Let xAx \in A. If xBx \notin BThen xBcx \in B^cSo xABc=x \in A \cap B^c = \emptysetContradiction. Hence xBx \in BProving ABA \subseteq B. \blacksquare

If you get this wrong, revise: Section 2.1.

Problem 5. Show that the relation RR on Z\mathbb{{'}Z{}'} defined by aRba\,R\,b iff aba - b is even Is an equivalence relation. How many equivalence classes are there?

Solution

Reflexive: aa=0a - a = 0Which is even. ✓ Symmetric: If aba - b is even, then ba=(ab)b - a = -(a - b) is even. ✓ Transitive: If aba - b and bcb - c are even, then ac=(ab)+(bc)a - c = (a - b) + (b - c) is even. ✓

The equivalence classes are [0] = \\{\mathrm{even\; integers{}\\} and [1] = \\{\mathrm{odd\; integers{}\\}. There are exactly 2 equivalence classes.

If you get this wrong, revise: Section 2.2.

Problem 6. Let f:RRf : \mathbb{{'}R{}'} \to \mathbb{{'}R{}'} be f(x)=2x+1f(x) = 2x + 1 and g:RRg : \mathbb{{'}R{}'} \to \mathbb{{'}R{}'} Be g(x)=x2g(x) = x^2. Find gfg \circ f and fgf \circ g. Is gfg \circ f injective?

Solution

(gf)(x)=g(f(x))=g(2x+1)=(2x+1)2=4x2+4x+1(g \circ f)(x) = g(f(x)) = g(2x + 1) = (2x + 1)^2 = 4x^2 + 4x + 1.

(fg)(x)=f(g(x))=f(x2)=2x2+1(f \circ g)(x) = f(g(x)) = f(x^2) = 2x^2 + 1.

Note gffgg \circ f \neq f \circ gSo composition is not commutative.

gfg \circ f is not injective: (gf)(0)=1(g \circ f)(0) = 1 and (gf)(1)=4(1)2+4(1)+1=1(g \circ f)(-1) = 4(-1)^2 + 4(-1) + 1 = 1 But 010 \neq -1.

If you get this wrong, revise: Section 2.3.

Problem 7. Prove that the set of all infinite binary sequences is uncountable.

Solution

Suppose the set SS of all infinite binary sequences is countable, so S=s1,s2,s3,S = \\{s_1, s_2, s_3, \ldots\\} Where si=(si1,si2,si3,)s_i = (s_{i1}, s_{i2}, s_{i3}, \ldots) with each sij0,1s_{ij} \in \\{0, 1\\}.

Define t=(t1,t2,t3,)t = (t_1, t_2, t_3, \ldots) by ti=1siit_i = 1 - s_{ii} (flip the ii-th bit of the ii-th Sequence). Then tSt \in S but tsit \neq s_i for every ii (they differ in position ii). This Contradicts S=s1,s2,S = \\{s_1, s_2, \ldots\\}. Therefore SS is uncountable. \blacksquare

If you get this wrong, revise: Section 2.4.

Problem 8. Prove: the product of any two odd integers is odd.

Solution

Let a=2m+1a = 2m + 1 and b=2n+1b = 2n + 1 be odd. Then ab=(2m+1)(2n+1)=4mn+2m+2n+1=2(2mn+m+n)+1ab = (2m+1)(2n+1) = 4mn + 2m + 2n + 1 = 2(2mn + m + n) + 1 Which is odd. \blacksquare

If you get this wrong, revise: Section 3.1.

Problem 9. Prove: if 3n+23n + 2 is odd, then nn is odd.

Solution

By contrapositive: assume nn is even, so n=2kn = 2k. Then 3n+2=6k+2=2(3k+1)3n + 2 = 6k + 2 = 2(3k + 1)Which is Even. \blacksquare

If you get this wrong, revise: Section 3.2.

Problem 10. Prove: 3\sqrt{3} is irrational.

Solution

Suppose 3=p/q\sqrt{3} = p/q in lowest terms. Then 3q2=p23q^2 = p^2So 3p23 \mid p^2Hence 3p3 \mid p. Write p=3rp = 3r. Then 3q2=9r23q^2 = 9r^2So q2=3r2q^2 = 3r^2Giving 3q23 \mid q^2 and 3q3 \mid q. But then gcd(p,q)3\gcd(p, q) \geq 3Contradicting lowest terms. \blacksquare

If you get this wrong, revise: Section 3.3.

Problem 11. Prove by induction: i=0n2i=2n+11\sum_{i=0}^{n} 2^i = 2^{n+1} - 1 for all n0n \geq 0.

Solution

Base case: n=0n = 0: 20=1=2112^0 = 1 = 2^1 - 1. ✓

Inductive step: Assume i=0k2i=2k+11\sum_{i=0}^{k} 2^i = 2^{k+1} - 1. Then

i=0k+12i=(2k+11)+2k+1=22k+11=2k+21\sum_{i=0}^{k+1} 2^i = (2^{k+1} - 1) + 2^{k+1} = 2 \cdot 2^{k+1} - 1 = 2^{k+2} - 1

\blacksquare

If you get this wrong, revise: Section 3.4.

Problem 12. Prove by strong induction that every integer n2n \geq 2 is a product of primes.

Solution

Base case: n=2n = 2 is prime, hence a product of primes.

Inductive step: Assume every integer in 2,,k\\{2, \ldots, k\\} is a product of primes (k2k \geq 2). If k+1k + 1 is prime, done. If k+1k + 1 is composite, then k+1=abk + 1 = ab where 2a,bk2 \leq a, b \leq k. By the induction hypothesis, both aa and bb are products of primes, so k+1=abk + 1 = ab is too. \blacksquare

If you get this wrong, revise: Section 3.4 (strong induction).

Problem 13. A committee of 5 is to be chosen from 12 people. How many ways if two specific People must either both serve or neither serves?

Solution

Case 1: Both serve. Choose the remaining 3 from the other 10: (103)=120\binom{10}{3} = 120. Case 2: Neither serves. Choose all 5 from the other 10: (105)=252\binom{10}{5} = 252.

Total: 120+252=372120 + 252 = 372.

If you get this wrong, revise: Section 4.2.

Problem 14. How many integers from 1 to 500 are divisible by 3 or 7 but not by 5?

Solution

A3=166|A_3| = 166, A7=71|A_7| = 71, A3A7=23|A_3 \cap A_7| = 23. Divisible by 3 or 7: 166+7123=214166 + 71 - 23 = 214.

A3A5=33|A_3 \cap A_5| = 33, A7A5=14|A_7 \cap A_5| = 14, A3A7A5=4|A_3 \cap A_7 \cap A_5| = 4. Divisible by 3 or 7 and 5: 33+144=4333 + 14 - 4 = 43.

Divisible by 3 or 7 but not 5: 21443=171214 - 43 = 171.

If you get this wrong, revise: Section 4.3.

Problem 15. How many solutions does x1+x2+x3=15x_1 + x_2 + x_3 = 15 have with xi1x_i \geq 1?

Solution

Substitute yi=xi10y_i = x_i - 1 \geq 0: y1+y2+y3=12y_1 + y_2 + y_3 = 12 with yi0y_i \geq 0. By stars and bars: (12+3131)=(142)=91\binom{12 + 3 - 1}{3 - 1} = \binom{14}{2} = 91.

If you get this wrong, revise: Section 4.4.

Problem 16. Prove that among any 13 people, at least 2 were born in the same month.

Solution

There are 12 months and 13 people. By the pigeonhole principle, at least one month contains at least 13/12=2\lceil 13/12 \rceil = 2 people.

If you get this wrong, revise: Section 4.5.

Problem 17. Verify that C3=5C_3 = 5 using the Catalan recurrence and the closed form.

Solution

By recurrence: C3=C0C2+C1C1+C2C0=12+11+21=2+1+2=5C_3 = C_0 C_2 + C_1 C_1 + C_2 C_0 = 1 \cdot 2 + 1 \cdot 1 + 2 \cdot 1 = 2 + 1 + 2 = 5.

By closed form: C3=14(63)=1420=5C_3 = \frac{1}{4}\binom{6}{3} = \frac{1}{4} \cdot 20 = 5. ✓

If you get this wrong, revise: Section 4.6.

Problem 18. Find the chromatic number of C5C_5 (the 5-cycle) and justify.

Solution

C5C_5 is an odd cycle. It cannot be 2-coloured (an odd cycle requires 3 colours: colour the first Vertex 1, alternate 2 and 1 around, and the last vertex (5th) is adjacent to both the 4th (colour 2) And the 1st (colour 1), so it needs colour 3).

A 3-colouring exists: label vertices v1,,v5v_1, \ldots, v_5; colour v1=1v_1 = 1, v2=2v_2 = 2, v3=1v_3 = 1 v4=2v_4 = 2, v5=3v_5 = 3.

Therefore χ(C5)=3\chi(C_5) = 3.

If you get this wrong, revise: Section 5.5.

Problem 19. In the bipartite graph with partitions X=1,2,3X = \\{1, 2, 3\\} and Y=a,b,c,dY = \\{a, b, c, d\\} And edges 11a,ba,b; 22b,cb,c; 33c,dc,dVerify Hall’s condition and find a matching covering XX.

Solution

Neighbourhoods: N(1)=a,bN(\\{1\\}) = \\{a, b\\}, N(2)=b,cN(\\{2\\}) = \\{b, c\\}, N(3)=c,dN(\\{3\\}) = \\{c, d\\}. N(1,2)=a,b,cN(\\{1, 2\\}) = \\{a, b, c\\}, N(1,3)=a,b,c,dN(\\{1, 3\\}) = \\{a, b, c, d\\}, N(2,3)=b,c,dN(\\{2, 3\\}) = \\{b, c, d\\}. N(1,2,3)=a,b,c,dN(\\{1, 2, 3\\}) = \\{a, b, c, d\\}.

All satisfy N(S)S|N(S)| \geq |S|. A matching: 11aa, 22bb, 33cc.

If you get this wrong, revise: Section 5.7.

Problem 20. Solve an=3an12an2a_n = 3a_{n-1} - 2a_{n-2} with a0=0a_0 = 0, a1=1a_1 = 1.

Solution

Characteristic equation: r23r+2=0r^2 - 3r + 2 = 0Giving (r1)(r2)=0(r - 1)(r - 2) = 0So r1=1r_1 = 1, r2=2r_2 = 2.

an=A1n+B2n=A+B2na_n = A \cdot 1^n + B \cdot 2^n = A + B \cdot 2^n.

a0=A+B=0    A=Ba_0 = A + B = 0 \implies A = -B. a1=A+2B=1    B+2B=B=1a_1 = A + 2B = 1 \implies -B + 2B = B = 1.

So A=1A = -1, B=1B = 1Giving an=2n1a_n = 2^n - 1. \blacksquare

If you get this wrong, revise: Section 6.2 and Section 6.3.

Common Pitfalls

  1. Dropping negative signs during algebraic manipulation — substitute back to verify your answer.

  2. Confusing the converse with the contrapositive — only the contrapositive is logically equivalent to the original implication.

Worked Examples

Example 1: Proof by Mathematical Induction

Problem. Prove that k=1nk2=n(n+1)(2n+1)6\sum_{k=1}^{n} k^2 = \frac{n(n+1)(2n+1)}{6} for all n1n \geq 1.

Solution. Base case (n=1n = 1): LHS = 1, RHS = 1236=1\frac{1 \cdot 2 \cdot 3}{6} = 1. ✓

Inductive step: assume true for nn. For n+1n+1:

k=1n+1k2=n(n+1)(2n+1)6+(n+1)2=n(n+1)(2n+1)+6(n+1)26\sum_{k=1}^{n+1} k^2 = \frac{n(n+1)(2n+1)}{6} + (n+1)^2 = \frac{n(n+1)(2n+1) + 6(n+1)^2}{6}

=(n+1)(2n2+n+6n+6)6=(n+1)(n+2)(2n+3)6= \frac{(n+1)(2n^2 + n + 6n + 6)}{6} = \frac{(n+1)(n+2)(2n+3)}{6}

Which matches the formula with nn replaced by n+1n+1. ✓

\blacksquare

Example 2: Graph Colouring

Problem. Find the chromatic number of the complete bipartite graph K3,4K_{3,4} and a cycle C5C_5.

Solution. K3,4K_{3,4}: bipartite graphs are 2-colourable. Assign colour 1 to the part of size 3 and colour 2 to the part of size 4. χ(K3,4)=2\chi(K_{3,4}) = 2.

C5C_5: odd cycle. Try 2 colours: impossible because odd length forces the first and last vertex to conflict. With 3 colours: colour vertices cyclically 1, 2, 3, 1, 2. χ(C5)=3\chi(C_5) = 3.

\blacksquare

Summary

  • Logic: propositions, predicates, quantifiers (\forall, \exists); truth tables and inference rules (modus ponens, resolution).
  • Set theory: unions, intersections, complements, power sets; cardinality of finite and infinite sets (Cantor’s diagonal argument).
  • Combinatorics: counting principles, permutations (n!n!), combinations ((nk)\binom{n}{k}), inclusion-exclusion.
  • Graph theory: Euler/Hamilton paths, planarity (Euler’s formula VE+F=2V - E + F = 2), graph colouring, trees.
  • Proof techniques: direct, contrapositive, contradiction, induction (weak and strong); structural induction for recursively defined objects.

Cross-References

TopicSiteLink
Theory of ComputationWyattsNotesView
Abstract AlgebraWyattsNotesView
Number TheoryWyattsNotesView
Discrete Mathematics — MIT 6.042JMIT OCWView