Introduction

Why Discrete Mathematics?

Discrete mathematics is the mathematical backbone of computer science. Every CS undergraduate takes it in year one — it provides the language and tools that every other course builds on: logic for reasoning about programs, sets for data structures, relations for databases, counting for algorithm analysis, graphs for networks.

  • Algorithm analysis — big-O notation, recurrences, counting operations, asymptotic analysis all require combinatorics and recurrence theory.
  • Cryptography & security — modular arithmetic, number theory, group theory, and combinatorics are the mathematical core of every encryption scheme.
  • Formal methods & compilers — automata, grammars, and type theory all rest on predicate logic and set theory.
  • Database theory — relational algebra, functional dependencies, and normal forms are applications of set theory and relations.
  • Machine learning — graph neural networks, probabilistic graphical models, and information theory all use discrete structures.

What You'll Build

Each lesson implements the core discrete math concept in Python — not just computing answers, but understanding the underlying structures.

  1. Logic & Proofs — truth tables, quantifiers, tautologies, De Morgan's laws, proof by induction and contradiction.
  2. Sets, Relations & Functions — power sets, Cartesian products, equivalence classes, injections, bijections.
  3. Counting & Combinatorics — permutations, combinations, inclusion-exclusion, pigeonhole, Stirling numbers, Catalan numbers.
  4. Induction & Recurrences — mathematical induction, linear recurrences, characteristic equations, generating functions.
  5. Graph Theory — degree sequences, Euler circuits, graph coloring, planar graphs, Euler's formula.

In-Browser Runtime

All code runs live in your browser via Pyodide — CPython compiled to WebAssembly.

Next →