Everything on the site.

Big-O notationAlgorithms · Count the steps in real loops, then compare n, n log n, n² and 2ⁿ on a live chart.RecursionAlgorithms · Watch frames push and pop on the call stack for factorial and Fibonacci.BFS vs DFSAlgorithms · A queue against a stack: draw a graph and see which order each search visits it in.Sorting algorithmsAlgorithms · Seven sorts on the same input, with comparison, swap and write counts side by side.Binary searchAlgorithms · Halve the range, probe the middle, repeat: with lo, mid and hi drawn on the array.Sets, relations and functionsDiscrete maths · Shade any set expression on a Venn diagram and test a relation for its properties.Proof by inductionDiscrete maths · Four worked proofs revealed one step at a time, and a broken one to diagnose.CombinatoricsDiscrete maths · An exact nPr and nCr calculator, and a Pascal’s triangle that shows its own addition rule.Boolean algebraDiscrete maths · The laws, De Morgan, and normal forms, with a truth-table generator built in.Finite-state machinesTheory · Build a DFA in a table, see it drawn, and run strings through it one symbol at a time.Domain theoryTheory · Why recursion needs least fixed points, and how CPOs, Scott continuity and powerdomains supply them.Truth table generatorTools · Expression in, truth table out: with DNF, CNF, a minimal form and LaTeX.Graph traversal visualiserTools · Draw a graph, then animate BFS, DFS and Dijkstra with the frontier shown.Recursion tree visualiserTools · Paste a recursive function or a recurrence and see its call tree and call count.Gradient descentML maths · Drag the starting point, set the learning rate, and watch it converge or blow up.Vectors and embeddingsML maths · Bend the plane with a 2×2 matrix and measure how close toy word vectors are.Softmax and cross-entropyML maths · Edit the logits and watch the probabilities, the loss and the gradient update live.AttentionML maths · Q, K and V for three tokens, a live score heatmap, and the weighted sum of values.Formatting a CS paper in LaTeXLaTeX · Page limits, \documentclass, front matter, theorem environments and the bibliography.Camera-ready checklistLaTeX · Fonts embedded, PDF/A, copyright form, source bundle, and why final versions get rejected.LaTeX templatesLaTeX · Where the official classes live, plus a minimal article template you can copy.AlgorithmsSection · Step-through visualisations of sorting, searching, recursion, graph traversal and Big-O growth, each with pseudocode that highlights the line being run.Discrete mathsSection · Sets, relations and functions, proof by induction, counting, and Boolean algebra, explained with worked examples and small interactive checkers.TheorySection · Finite-state machines, automata and the mathematical semantics of programming languages, explained from first principles.ML mathsSection · Gradient descent, vectors and embeddings, softmax and cross-entropy, and attention, each with a formula, a worked numeric example and a live version.ToolsSection · A truth-table generator with CNF, DNF and LaTeX output, a graph-traversal visualiser for BFS, DFS and Dijkstra, and a recursion-tree visualiser.LaTeXSection · How to format a CS conference or workshop paper in LaTeX, a camera-ready checklist, and a minimal template you can adapt.
Discrete maths

Sets, relations and functions

Sets, relations and functions are the vocabulary the rest of discrete mathematics is written in. Shade set expressions on a Venn diagram, then test relations for the properties that make them orders, equivalences or functions.

Interactive: Venn-diagram expression shader and relation-property checkerUpdated

Sets

A set is a collection of distinct objects, its elements. Order and repetition don’t matter: {1,2,3}\{1, 2, 3\}, {3,1,2}\{3, 1, 2\} and {1,1,2,3}\{1, 1, 2, 3\} are the same set. We write x∈Ax \in A when xx is an element of AA, and describe sets either by listing elements or by a property, as in {n∈N:n is even}\{n \in \mathbb{N} : n \text{ is even}\}.

A⊆BA \subseteq B (A is a subset of B) means every element of AA is also in BB. Two sets are equal exactly when each is a subset of the other, and proving A⊆BA \subseteq B and B⊆AB \subseteq A separately is the standard way to show A=BA = B. The empty set ∅\varnothing has no elements and is a subset of every set.

Operations

OperationNotationElementsWith A = {1, 2, 3, 4}, B = {3, 4, 5, 6}
UnionA∪BA \cup Bin A or B (or both){1, 2, 3, 4, 5, 6}
IntersectionA∩BA \cap Bin both{3, 4}
DifferenceA∖BA \setminus Bin A but not B{1, 2}
Symmetric differenceA△BA \mathbin{\triangle} Bin exactly one{1, 2, 5, 6}
ComplementAcA^{c}in the universe U but not Adepends on U

Each set operation is a logical connective in disguise: x∈A∪Bx \in A \cup B means x∈A∨x∈Bx \in A \lor x \in B, intersection is “and”, complement is “not”. So the laws of Boolean algebra carry over directly, including De Morgan’s laws:

(A∪B)c=Ac∩Bc,(A∩B)c=Ac∪Bc.(A \cup B)^{c} = A^{c} \cap B^{c}, \qquad (A \cap B)^{c} = A^{c} \cup B^{c}.

The diagram below shades any expression you type. Check De Morgan by comparing (A ∪ B)ᶜ with Aᶜ ∩ Bᶜ, or the distributive law by comparing A ∩ (B ∪ C) with (A ∩ B) ∪ (A ∩ C).

Venn diagram: shade any set expression

Type ∪ as | or +, ∩ as &, difference as -, symmetric difference as ^, complement as a postfix '.

Power sets and products

The power set P(A)\mathcal{P}(A) is the set of all subsets of AA. Each element is either in a subset or not, two choices per element, so a set with nn elements has 2n2^n subsets. For A={a,b}A = \{a, b\}, P(A)={∅,{a},{b},{a,b}}\mathcal{P}(A) = \{\varnothing, \{a\}, \{b\}, \{a, b\}\}.

The Cartesian product A×BA \times B is the set of ordered pairs (a,b)(a, b) with a∈Aa \in A and b∈Bb \in B. It has ∣A∣⋅∣B∣|A| \cdot |B| elements. Unlike sets, pairs are ordered: (1,2)≠(2,1)(1, 2) \ne (2, 1).

Relations

A relation from AA to BB is any subset R⊆A×BR \subseteq A \times B. We write aRba \mathrel{R} b for (a,b)∈R(a, b) \in R. “Is less than”, “divides”, “is a prerequisite of” and “has the same birthday as” are all relations. A relation on a single set AA (a subset of A×AA \times A) can be drawn as a directed graph or written as a 0/1 matrix with a 1 in row aa, column bb when aRba \mathrel{R} b.

The five properties

PropertyDefinitionIn the matrixExample
Reflexiveevery aRaa \mathrel{R} adiagonal all 1≤\le, ==
Irreflexiveno aRaa \mathrel{R} adiagonal all 0<<
SymmetricaRb⇒bRaa \mathrel{R} b \Rightarrow b \mathrel{R} amirror image across the diagonal“is a sibling of”
AntisymmetricaRb∧bRa⇒a=ba \mathrel{R} b \land b \mathrel{R} a \Rightarrow a = bno 1 has a mirrored 1 off the diagonal≤\le, “divides” on positive integers
TransitiveaRb∧bRc⇒aRca \mathrel{R} b \land b \mathrel{R} c \Rightarrow a \mathrel{R} cno shortcut is ever missing<<, “is an ancestor of”

Antisymmetric is not the opposite of symmetric. Equality is both; the relation {(1,2),(2,1),(1,3)}\{(1, 2), (2, 1), (1, 3)\} on {1,2,3}\{1, 2, 3\} is neither.

Relation property checker

Or click the matrix: row a, column b is filled when (a, b) ∈ R.

    Equivalence relations and partitions

    A relation that is reflexive, symmetric and transitive is an equivalence relation. It says when two things are “the same for our purposes”: same remainder mod 5, same parity, same connected component of a graph. Every equivalence relation splits its set into disjoint equivalence classes, and every way of splitting a set into disjoint non-empty pieces comes from exactly one equivalence relation. Choose “same parity” in the checker: the classes are the odd and the even numbers.

    Partial orders

    A relation that is reflexive, antisymmetric and transitive is a partial order. “Partial” because two elements need not be comparable: under “divides”, neither 4 nor 6 divides the other. Partial orders are drawn as Hasse diagrams, which show only the covering steps and leave the reflexive loops and transitive shortcuts implied. They are everywhere in computer science: dependency graphs, version histories, type hierarchies, and the information orderings of domain theory.

    Closures

    The transitive closure of RR is the smallest transitive relation containing it: add (a,c)(a, c) whenever there is a chain of RR-steps from aa to cc. For the relation “has a direct flight to”, the transitive closure is “can be reached by flying”. Warshall’s algorithm computes it in O(n3)O(n^3) time; the checker’s button uses it. Reflexive and symmetric closures are simpler: add the diagonal, or add every mirrored pair.

    Functions

    A function f:A→Bf : A \to B is a relation in which every a∈Aa \in A is related to exactly one b∈Bb \in B, written f(a)f(a). AA is the domain and BB the codomain. The relation-checker preset x↦x+1 mod 4x \mapsto x + 1 \bmod 4 passes the function test; “≤” fails it, since 1 is related to four elements.

    KindMeaningExample on the integers
    Injective (one-to-one)different inputs give different outputsn↦2nn \mapsto 2n
    Surjective (onto)every element of BB is hitn↦⌊n/2⌋n \mapsto \lfloor n/2 \rfloor
    Bijectiveboth: a perfect pairing, so ff has an inversen↦n+1n \mapsto n + 1

    Bijections are how mathematics compares sizes. Two finite sets have the same number of elements exactly when there is a bijection between them, and the same definition extends to infinite sets. The even numbers and the natural numbers have the same size, because n↦2nn \mapsto 2n pairs them up; Cantor’s diagonal argument shows there is no bijection between N\mathbb{N} and P(N)\mathcal{P}(\mathbb{N}), so some infinities are bigger than others.

    The pigeonhole principle If ∣A∣>∣B∣|A| > |B|, no function A→BA \to B is injective: some two elements must land in the same place. Among any 13 people, two share a birth month. It sounds obvious and proves a surprising number of things, including that any lossless compression scheme must make some files longer.

    References

    1. K. H. Rosen, Discrete Mathematics and Its Applications, 8th ed., McGraw-Hill, 2019. Chapters 2 and 9.
    2. P. R. Halmos, Naive Set Theory, Van Nostrand, 1960.
    3. S. Warshall, “A theorem on Boolean matrices”, Journal of the ACM 9(1), 1962. doi:10.1145/321105.321107
    4. “Binary relation”, Wikipedia.