Math for AI from First PrinciplesPost 0 of 10 · 10 of 10 written

0. The language of mathematics

Math for AI · 0 of 105 min readOct 2026

Most “I don’t understand this paper” moments are really “I can’t read this notation” moments. This pillar is the grammar every other pillar is written in.

Why it exists

Natural language is ambiguous: “the model is better” can mean ten things. Mathematical language exists so that a claim has exactly one meaning, and anyone can check it.

Core ideas

Sets: what kind of thing is this?

A set is a collection of distinct objects, with no order and no duplicates. You write x ∈ S for “x is an element of S”. The sets you will see constantly are ℝ (real numbers), ℕ (natural numbers), ℤ (integers) and {0, 1}.

The Cartesian product A × B is the set of all pairs (a, b). So ℝⁿ is just ℝ × ℝ × … × ℝ: every list of n real numbers. A colour image is an element of ℝ^(H×W×3), and a model’s vocabulary V is a finite set of tokens.

Other operations you need: subset ⊆, union ∪, intersection ∩, complement, and the empty set ∅. They become the language of events in probability (Pillar 3).

Functions: the core abstraction of all of AI

A function f: A → B assigns every input in A exactly one output in B. A is the domain, B the codomain. “Exactly one” is the whole definition, and it is stricter than it looks.

Composition chains functions: (g ∘ f)(x) = g(f(x)). A neural network is nothing more than a long composition, f = f_L ∘ … ∘ f₂ ∘ f₁, where each f_i is a layer.

A parameterized function f_θ(x) has knobs θ that are not inputs. The model architecture defines a whole family of functions, one per setting of θ. Training is the act of picking one member of that family.

Injective means no two inputs share an output; surjective means every output is reached. A function that is both has an inverse. These words matter when you ask whether information is lost, for example in a tokenizer or a lossy compression step.

Notation you must read aloud fluently

Symbol Read it as Example in AI
Σᵢ₌₁ⁿ xᵢ the sum of x_i for i from 1 to n summing loss over a batch
Πᵢ pᵢ the product of all p_i probability of a whole sentence
:= is defined as introducing a new symbol
∀, ∃ for all, there exists theorem statements
argmax_x f(x) the x that makes f largest (not the largest value) greedy decoding picks argmax of token probabilities
x̂ an estimate of x predicted value, estimated parameter
‖x‖ the length (norm) of vector x gradient clipping, weight decay
∝ is proportional to Bayes’ rule, unnormalized scores
∇f the gradient of f the direction the optimizer moves
𝔼[X] the expected value of X the loss we actually want to minimize
θ, W, b parameters, weight matrix, bias everything that gets trained

Convention: bold or plain lowercase (x) is a vector, uppercase (W) a matrix, Greek letters often parameters. Subscripts usually index entries or time steps; superscripts in parentheses, like x⁽ⁱ⁾, usually index training examples.

Test yourself on one real formula. Softmax turns a list of scores z into probabilities:

softmax(z)i:=ezi∑j=1Kezj\mathrm{softmax}(z)_i := \frac{e^{z_i}}{\sum_{j=1}^{K} e^{z_j}}

Read aloud: “the i-th output of softmax is e to the z_i, divided by the sum over all K entries of e to the z_j.” If you can say that and explain why every output is positive and they sum to 1, you can read papers.

Logic: what exactly is being claimed?

“If P then Q” (P ⇒ Q) is false only when P is true and Q is false. Its contrapositive, “not Q implies not P”, says the same thing. Its converse, “Q implies P”, does not.

P is sufficient for Q if P ⇒ Q; P is necessary for Q if Q ⇒ P. “If and only if” means both. Confusing necessary and sufficient is the most common reasoning error in reading results.

To negate a statement, swap ∀ and ∃ and negate the inside. The negation of “every model overfits” is “some model does not overfit”, not “no model overfits”.

Proof: how you know a claim is true

You rarely need to write proofs for AI work, but you must read them to know when a result applies. Four techniques cover most of what you will meet.

  • Direct proof: assume the premises, chain valid steps to the conclusion.
  • Contradiction: assume the claim is false and derive something impossible.
  • Induction: prove a base case, then prove “true for n implies true for n+1”. It is the mathematical twin of recursion and of loops.
  • Counterexample: one case is enough to destroy a universal claim. This is your best tool against hype.

The lesson from proofs is that every theorem has assumptions. “Gradient descent converges” really means “converges if the function is convex and the step size is small enough”. Your job is to check whether those assumptions hold in your setting.

Shapes: the habit that saves you

For every symbol, ask what set it lives in and what its shape is. If x ∈ ℝ^768 and W ∈ ℝ^(3072×768), then Wx ∈ ℝ^3072. Shape-checking an equation is the same as type-checking code, and it catches most errors before they happen.

In AI

A language model is a parameterized function from token sequences to probability distributions over the next token. An embedding is a function from the vocabulary V into ℝ^d. Every paper is a set of definitions, assumptions and claims written in this pillar’s language.

Questions to ask

  • What set does each symbol live in, and what is its shape?
  • Is this line a definition (:=) or a claim that needs justification?
  • Which symbols are inputs, which are learned parameters, and which are fixed hyperparameters?
  • Which index does this sum run over, and what does each term represent?
  • What are the assumptions of this theorem, and do they hold for my model?
  • Is the author claiming necessity, sufficiency, or just correlation?

Fluency check

  • Read the softmax formula aloud and explain why its outputs sum to 1.
  • Write a 3-layer network as a composition of functions, with the shape of every intermediate result.
  • Negate: “for every ε > 0 there exists a δ > 0 such that |x| < δ implies |f(x)| < ε”.
  • Prove by induction that 1 + 2 + … + n = n(n+1)/2.
  • Take any formula from a paper you care about and write a symbol table for it.