Skip to content
AIAI Wranglers

A Mathematical Analysis

This appendix collects the core results from real analysis and topology that underpin the mathematics of generative modelling. Rather than simply listing definitions, we develop the material from the ground up, with complete proofs and worked examples, so that the reader can appreciate why each concept matters. The journey begins with the real number line and ends, several sections later, with the function-space machinery needed for variational inference and optimal transport.

The Real Number Line

The real numbers are so familiar that one might wonder why we bother axiomatising them at all. The answer is that one particular property of , completeness, is responsible for virtually every convergence guarantee we rely on when training generative models. Without it, gradient descent could converge to a “hole” in the number line, and probability distributions could fail to have well-defined means.

We begin with two companion definitions that capture the idea of “tightest possible bound.”

Definition 1 (Supremum).

Let S be a nonempty set. A number s is the supremum (or least upper bound) of S, written s=supS, if

  1. xs for every xS (i.e. s is an upper bound), and

  2. whenever t is an upper bound of S we have st (i.e. s is the smallest such bound).

The supremum need not belong to S itself.

Definition 2 (Infimum).

Let S be nonempty. The infimum (or greatest lower bound) of S, written infS, is the largest real number satisfying x for every xS. Equivalently, infS=sup(S) where S={x:xS}.

Example 1 (Open Interval).

Consider the open interval S=(0,1). Every element of S is strictly less than 1, and for any proposed upper bound t<1 the midpoint t+12 lies in S yet exceeds t. Hence supS=1, even though 1S. By a symmetric argument, infS=0S.

Example 2 (Rationals in an Interval).

Let U={x:0<x<2}. Every element of U is rational, yet supU=2, which is irrational. This example is historically significant: it shows that the rationals alone cannot supply the supremum of a bounded set of rationals.

Example 3 (Negative Powers of Two).

Let V={2n:n}={1,12,14,}. Then supV=1V and infV=0V, since the terms decrease toward zero but never reach it.

The following axiom is what distinguishes from .

Theorem 1 (Completeness Axiom).

Every nonempty subset of that is bounded above has a supremum in .

The Completeness Axiom is not something we prove; it is taken as an axiom in the construction of . One way to appreciate its content is to observe that the analogous statement fails for : the set {q:q2<2} is bounded above in yet has no rational least upper bound.

Key Idea.

Completeness is what distinguishes from : it guarantees that limits of convergent sequences always exist within , which is essential for the convergence guarantees we need in optimisation and sampling.

An immediate and useful consequence is the Archimedean property, which says that there are no “infinitely large” or “infinitesimally small” positive reals.

Theorem 2 (Archimedean Property).

For every x with x>0 and every y, there exists n such that nx>y.

Proof.

Suppose for contradiction that no such n exists. Then nxy for every n, which means the set S={nx:n} is bounded above by y. By the Completeness Axiom (Theorem 1), s=supS exists in . Because x>0, we have sx<s, so sx is not an upper bound of S. Therefore there exists m with mx>sx, giving (m+1)x>s. But (m+1)xS, contradicting the assumption that s is an upper bound.

The next result uses completeness in a geometric way. It says that a sequence of closed intervals, each contained in the previous one and shrinking in length, must “trap” a single point.

Theorem 3 (Nested Intervals).

Let [a1,b1][a2,b2][a3,b3] be a nested sequence of nonempty closed intervals with limn(bnan)=0. Then there exists a unique point c with n=1[an,bn]={c}.

Proof.

The sequence (an) is non-decreasing and bounded above by b1, so by the Completeness Axiom it converges to c=sup{an}. Similarly, (bn) is non-increasing and bounded below by a1, so it converges to some limit c=inf{bn}. For every n we have anccbn, hence 0ccbnan0, giving c=c. Any point in the intersection must lie in every [an,bn] and hence equal c.

The Nested Intervals Theorem: a sequence of closed intervals [an,bn], each contained in the previous one and shrinking in length, traps a unique limit point c. The dashed line marks the common intersection.

Historical Note.

Richard Dedekind (1872) and Georg Cantor independently constructed from , each motivated by the need for a number system where every Cauchy sequence converges. Dedekind used “cuts” that partition into two halves, while Cantor identified each real with an equivalence class of Cauchy sequences of rationals. Both constructions yield the same ordered field, and the Completeness Axiom holds in each.

Metric Spaces

A great deal of generative modelling takes place not on the real line but in high-dimensional spaces: image pixel spaces, latent spaces, and spaces of probability distributions. To discuss convergence, continuity, and compactness in all these settings at once, we need the abstraction of a metric space. The idea is simple: distill the essence of “distance” into a small set of axioms, and then develop the theory once and for all.

Definition and Examples

Definition 3 (Metric Space).

A metric space is a pair (X,d) where X is a nonempty set and d:X×X is a function (called a metric or distance function) satisfying, for all x,y,zX:

  1. Non-negativity: d(x,y)0.

  2. Identity of indiscernibles: d(x,y)=0 if and only if x=y.

  3. Symmetry: d(x,y)=d(y,x).

  4. Triangle inequality: d(x,z)d(x,y)+d(y,z).

These four axioms capture the intuitive properties we expect of distance: distances are non-negative, zero only for identical points, symmetric, and satisfy the “shortcut cannot be longer than the detour” principle. Let us see several concrete instances.

Example 4 (Euclidean Metric).

On n, the Euclidean metric is d(𝒙,𝒚)=i=1n(xiyi)2=𝒙𝒚2. This is the distance “as the crow flies” and the default metric in most machine learning applications.

Example 5 (Discrete Metric).

On any set X, define d(x,y)={0if x=y,1if xy. Verification of the axioms is immediate. The discrete metric may seem artificial, but it appears naturally when X is a finite label set (e.g. class labels in a classifier).

Example 6 (Taxicab Metric).

On n, the taxicab (or Manhattan) metric is d1(𝒙,𝒚)=i=1n|xiyi|=𝒙𝒚1. In two dimensions, this measures distance by travelling along axis-aligned streets, like a taxi in Manhattan.

Example 7 (p Metric).

For any p1, the p distance on n is dp(𝒙,𝒚)=(i=1n|xiyi|p)1/p=𝒙𝒚p. The Euclidean metric corresponds to p=2 and the taxicab metric to p=1. The limiting case p gives the supremum metric d(𝒙,𝒚)=maxi|xiyi|. That the triangle inequality holds for all p1 is the content of the Minkowski inequality.

The shape of the unit ball {x2:d(0,x)1} varies dramatically with the choice of metric.

Unit balls {𝒙2:𝒙p1} for three choices of p. The Euclidean ball is a circle, the 1 ball is a diamond (rotated square), and the ball is an axis-aligned square.

Open and Closed Sets

With a metric in hand, we can formalise what it means for a set to “have no boundary points” (open) or “contain all its boundary points” (closed). These notions are essential for stating convergence theorems precisely.

Definition 4 (Open Ball).

Let (X,d) be a metric space, xX, and ε>0. The open ball of radius ε centred at x is B(x,ε)={yX:d(x,y)<ε}.

Definition 5 (Open Set).

A subset UX is open if for every xU there exists ε>0 such that B(x,ε)U. Informally, every point of U can be “wiggled” a little without leaving U.

Definition 6 (Closed Set).

A subset CX is closed if its complement XC is open.

A common misconception is that “closed” is the opposite of “open.” In fact, a set can be both open and closed (the empty set and X itself), or neither (the half-open interval [0,1) in ).

Definition 7 (Limit Point).

A point xX is a limit point (or accumulation point) of a set AX if every open ball centred at x contains a point of A other than x itself: B(x,ε)(A{x})for all ε>0. Note that x need not belong to A.

Definition 8 (Isolated Point).

A point xA is an isolated point of A if there exists ε>0 with B(x,ε)A={x}. Equivalently, xA but x is not a limit point of A.

Anatomy of a set in a metric space. An interior point (blue) has an ε-ball entirely inside A. A boundary point (red) lies on the edge: every ball around it intersects both A and XA. A limit point (orange) outside A can be approached by sequences from within A.

Interior, Closure, and Boundary

Every set A in a metric space has three closely related derived sets that describe its “inner core,” its “completed version,” and the “edge” between inside and outside.

Definition 9 (Interior).

The interior of A, denoted int(A), is the set of all points xA for which there exists ε>0 with B(x,ε)A. Equivalently, int(A) is the largest open set contained in A (i.e. the union of all open subsets of A).

Definition 10 (Closure).

The closure of A, denoted A or cl(A), is the smallest closed set containing A. Equivalently, cl(A)=AA, where A is the set of all limit points of A.

Definition 11 (Boundary).

The boundary of A is A=cl(A)int(A). A point x belongs to A if and only if every open ball centred at x intersects both A and XA.

The interior int(A) (blue region), boundary A (thick red curve), and closure cl(A)=int(A)A.

With these definitions in place, we can prove two fundamental characterisations of closed sets.

Theorem 4 (Closed Set Characterisation).

A set A in a metric space (X,d) is closed if and only if A contains all its limit points.

Proof.

() Suppose A is closed and let x be a limit point of A. We must show xA. If xA, then xXA, which is open. So there exists ε>0 with B(x,ε)XA, meaning B(x,ε)A=. But this contradicts x being a limit point, since every ball around a limit point must intersect A.

() Suppose A contains all its limit points. We show XA is open. Take any yXA. Since yA and y is not a limit point of A (because A contains all its limit points), there exists ε>0 with B(y,ε)(A{y})=. Since yA, this gives B(y,ε)A=, i.e. B(y,ε)XA. As y was arbitrary, XA is open, so A is closed.

Theorem 5 (Closure via Limit Points).

For any subset A of a metric space (X,d), cl(A)=AA, where A denotes the set of all limit points of A.

Proof.

We show both inclusions.

() We must show AAcl(A). Since cl(A) is closed and contains A, it suffices to show it contains every limit point of A. Let xA and suppose xcl(A). Then xXcl(A), which is open. So there exists ε>0 with B(x,ε)Xcl(A)XA, contradicting the fact that x is a limit point of A.

() We show cl(A)AA by proving that AA is closed. Let x be a limit point of AA. For every ε>0, B(x,ε) contains a point yAA with yx. If yA, then B(x,ε)A. If yA, then pick δ>0 small enough that B(y,δ)B(x,ε); since y is a limit point of A, B(y,δ) contains a point of A distinct from y, and hence B(x,ε)A. Either way, x is a limit point of A, so xA. Therefore AA contains all its limit points and is closed by Theorem 4. Since cl(A) is the smallest closed set containing A, we conclude cl(A)AA.

Sequences and Convergence

Sequences are the primary vehicle through which we discuss convergence in analysis. A training loop in deep learning is, at bottom, a sequence of parameter vectors 𝜽1,𝜽2,𝜽3,, and the central question is whether this sequence converges to a useful model. The concepts in this section make that question precise.

Definition 12 (Convergent Sequence).

A sequence (xn)n=1 in a metric space (X,d) converges to a point xX if for every ε>0 there exists N such that d(xn,x)<ε for all nN. We write xnx or limnxn=x.

Convergence is the demand that, no matter how tight a tolerance ε we specify, the sequence eventually enters and stays within the open ball B(x,ε).

Example 8 (Convergent and Divergent Sequences).

The sequence xn=1/n in converges to 0: given ε>0, choose N>1/ε (possible by the Archimedean property, Theorem 2), and then |xn0|=1/n<ε for all nN.

The sequence yn=(1)n does not converge. Its terms alternate between +1 and 1 and never settle within any ball of radius less than 1 around a single point.

A convergent sequence: for nN (marked in red), every term xn lies within the ε-band (blue shading) around the limit x.

A subtler notion asks whether the terms of a sequence get close to each other, without reference to any particular limit.

Definition 13 (Cauchy Sequence).

A sequence (xn) in a metric space (X,d) is a Cauchy sequence if for every ε>0 there exists N such that d(xn,xm)<ε for all n,mN.

Every convergent sequence is Cauchy, but the converse can fail: the space may have “gaps” that prevent a Cauchy sequence from finding its limit.

Theorem 6 (Convergent Implies Cauchy).

Every convergent sequence in a metric space is a Cauchy sequence.

Proof.

Suppose xnx. Given ε>0, choose N such that d(xn,x)<ε/2 for all nN. Then for n,mN, d(xn,xm)d(xn,x)+d(x,xm)<ε2+ε2=ε, where we used the triangle inequality.

Remark 1 (The Converse Fails in ).

The sequence 1,1.4,1.41,1.414,1.4142, of decimal approximations to 2 is a Cauchy sequence of rationals. Yet it does not converge in , because its limit 2 is irrational. This is precisely the kind of gap that the completeness of eliminates.

Definition 14 (Complete Metric Space).

A metric space (X,d) is complete if every Cauchy sequence in X converges to a limit in X.

Completeness is a property of the space, not of individual sequences. The rationals are incomplete; the reals are complete. In the infinite-dimensional world, Banach and Hilbert spaces are complete by definition, and this is exactly what makes them suitable homes for the function spaces used in variational inference.

Theorem 7 (Completeness of n).

n with the Euclidean metric is a complete metric space.

Proof sketch.

Let (𝒙(k))k=1 be a Cauchy sequence in n. For each coordinate i{1,,n}, the scalar sequence (xi(k))k=1 is Cauchy in (since |xi(k)xi(m)|𝒙(k)𝒙(m)2). By the completeness of (which follows from the Completeness Axiom, Theorem 1), each coordinate sequence converges: xi(k)xi. Setting 𝒙=(x1,,xn), one verifies 𝒙(k)𝒙20.

The next result is one of the jewels of real analysis. It guarantees the existence of convergent subsequences in bounded regions.

Theorem 8 (Bolzano–Weierstrass).

Every bounded sequence in n has a convergent subsequence.

Proof.

We prove the result for n=1; the general case follows by applying the one-dimensional argument to each coordinate in turn (using a diagonal subsequence extraction).

Let (xk) be a bounded sequence in , so xk[a,b] for all k. We construct a convergent subsequence by interval bisection. Divide [a,b] into two equal halves: [a,a+b2] and [a+b2,b]. At least one half contains infinitely many terms of the sequence; call it [a1,b1] and choose xk1[a1,b1]. Repeat: bisect [a1,b1], pick the half with infinitely many terms, call it [a2,b2], and choose xk2 with k2>k1.

Continuing, we obtain a subsequence (xkj) and nested intervals [aj,bj] with bjaj=(ba)/2j0 and xkj[aj,bj] for every j. By the Nested Intervals Theorem (Theorem 3), the intervals shrink to a single point c. Since |xkjc|bjaj0, we have xkjc.

For n: given a bounded sequence (𝒙(k)) in n, first extract a subsequence along which the first coordinate converges (by the one-dimensional result). From that subsequence, extract a further subsequence along which the second coordinate also converges. After n such extractions, we have a subsequence that converges in every coordinate, and hence in n.

Historical Note.

Bernhard Bolzano proved the one-dimensional result in 1817, making it one of the earliest rigorous statements about the structure of . Karl Weierstrass rediscovered and popularised it in the 1860s as part of his programme to place analysis on a firm logical foundation. The theorem was among the first results to show that has fundamentally different properties from : a bounded sequence of rationals need not have a rational limit point.

Compactness

Compactness is arguably the single most important topological property in analysis. Compact sets are “the next best thing to finite sets”: they are small enough to be controlled, yet rich enough to be useful. In optimisation, compactness guarantees that continuous functions attain their optima. In measure theory, compactness ensures that sequences of probability measures have convergent subsequences.

We begin with the covering definition, which is the most general.

Definition 15 (Open Cover).

Let (X,d) be a metric space and KX. A collection {Uα}αI of open sets is an open cover of K if KαIUα. A subcover is a subcollection that still covers K.

Definition 16 (Compact Set).

A subset K of a metric space (X,d) is compact if every open cover of K has a finite subcover: whenever KαIUα with each Uα open, there exist finitely many indices α1,,αm with KUα1Uαm.

The power of this definition lies in the word “every”: no matter how wastefully we cover K with open sets, we can always trim the cover down to a finite one.

Left: a closed interval [a,b] covered by many overlapping open sets. Right: a finite subcover (green, highlighted) suffices. Compactness guarantees that such a finite selection is always possible.

The most useful characterisation of compact subsets of n is the classical Heine–Borel theorem.

Theorem 9 (Heine–Borel).

A subset Kn is compact if and only if it is closed and bounded.

Proof.

(: compact implies closed and bounded.)

Bounded. Consider the open cover {B(𝟎,m)}m=1 of K. By compactness, finitely many balls suffice: KB(𝟎,m1)B(𝟎,mk)=B(𝟎,M) where M=max{m1,,mk}. Hence K is bounded.

Closed. We show nK is open. Fix any 𝒚K. For each 𝒙K, let r𝒙=d(𝒙,𝒚)/2>0 and consider the open balls U𝒙=B(𝒙,r𝒙). These cover K, so by compactness there exist 𝒙1,,𝒙m with KU𝒙1U𝒙m. Let ε=min{r𝒙1,,r𝒙m}>0. We claim B(𝒚,ε)nK. Indeed, if 𝒛B(𝒚,ε)K, then 𝒛U𝒙j for some j, giving d(𝒙j,𝒚)d(𝒙j,𝒛)+d(𝒛,𝒚)<r𝒙j+ε2r𝒙j=d(𝒙j,𝒚), a contradiction.

(: closed and bounded implies compact.)

Since K is bounded, it is contained in some closed box [M,M]n. Suppose for contradiction that K has an open cover {Uα} with no finite subcover. Bisect the box into 2n congruent sub-boxes. At least one sub-box intersects K in a subset that has no finite subcover from {Uα}; call this sub-box B1 and the corresponding subset K1=KB1. Repeat to obtain nested boxes B1B2 with diameters shrinking to zero and Kj=KBj having no finite subcover.

By the Nested Intervals Theorem applied coordinate-wise, the boxes shrink to a single point 𝒑. Since each Kj is nonempty and 𝒑KjK=K (as K is closed), we have 𝒑K. So 𝒑Uβ for some β, and since Uβ is open, B(𝒑,ε)Uβ for some ε>0. For sufficiently large j, BjB(𝒑,ε), so KjUβ, so a single open set covers Kj, contradicting our assumption.

There is a sequential characterisation of compactness that is often more convenient in practice.

Definition 17 (Sequential Compactness).

A metric space (X,d) (or a subset thereof) is sequentially compact if every sequence in X has a subsequence that converges to a point in X.

Theorem 10 (Compactness Equivalence in Metric Spaces).

In a metric space, a set is compact if and only if it is sequentially compact.

Proof sketch.

(Compact sequentially compact.) Let (xn) be a sequence in a compact set K. If only finitely many distinct values appear, some value repeats infinitely often and yields a (trivially) convergent subsequence. Otherwise, the set of distinct values is infinite. Suppose no subsequence converges in K. Then every point of K has a neighbourhood containing at most finitely many terms. These neighbourhoods form an open cover of K; extracting a finite subcover shows that (xn) has only finitely many terms, a contradiction.

(Sequentially compact compact.) This direction uses a technical tool called a Lebesgue number. Given an open cover {Uα} of a sequentially compact set K, one first shows that there exists δ>0 (the Lebesgue number) such that every subset of K with diameter less than δ is contained in some single Uα. Then, using sequential compactness, one shows that K can be covered by finitely many balls of radius δ/2, each of which fits inside some Uα. This produces the desired finite subcover.

The compact-implies-closed-and-bounded direction holds in any metric space. Let us record this cleanly.

Theorem 11 (Compact Sets are Closed and Bounded).

In any metric space (X,d), every compact set K is closed and bounded.

Proof.

Closed. Let x be a limit point of K. For each n, the ball B(x,1/n) intersects K, so we can pick xnB(x,1/n)K with d(xn,x)<1/n. By sequential compactness (Theorem 10), (xn) has a subsequence converging to some yK. But xnx already, so y=x, hence xK. By Theorem 4, K is closed.

Bounded. Fix any x0X and consider the open cover {B(x0,n)}n=1 of K. A finite subcover yields KB(x0,N) for some N, so K is bounded.

Three subsets of 2. Left: the closed disk {𝒙:𝒙1} is compact (closed and bounded). Centre: the open disk {𝒙:𝒙<1} is bounded but not closed, hence not compact. Right: the strip ×[12,12] is closed but unbounded, hence not compact.

Key Idea.

In generative modelling, we often work with probability distributions on compact metric spaces. The Kantorovich–Rubinstein theorem (Proof of KR Duality in the Wasserstein GAN chapter) requires compactness to guarantee that the Wasserstein distance metrises weak convergence of probability measures. Compactness also underpins the Arzelà–Ascoli theorem, which controls the complexity of function classes used in discriminator and critic networks.

Remark 2 (Why Compactness Matters for Optimisation).

The extreme value theorem (which we prove in Extreme Value Theorem below) guarantees that a continuous function on a compact set attains its maximum and minimum. This is why many optimisation problems in machine learning implicitly assume compact parameter domains or add regularisation to effectively compactify the search space. Without compactness, a continuous objective can approach but never reach its infimum, and the “optimal” parameters may not exist.

Continuity

Continuity is the mathematical formalisation of the intuitive idea that “small changes in input produce small changes in output.” For generative modelling this concept is indispensable: the decoder of a variational autoencoder must map nearby latent codes to perceptually similar images, and the loss landscape that a GAN critic traverses must be sufficiently regular for gradient-based optimisation to succeed. In this section we develop the theory of continuity from the basic ε-δ definition through to the Lipschitz condition that underpins Wasserstein GANs.

Definitions of Continuity

Definition 18 (ε-δ Continuity).

Let (X,dX) and (Y,dY) be metric spaces. A function f:XY is continuous at a point x0X if for every ε>0 there exists δ>0 such that (EPS Delta)dX(x,x0)<δdY(f(x),f(x0))<ε. The function f is continuous on X if it is continuous at every point of X.

The definition says nothing about how large or small δ must be in absolute terms; it only requires that a suitable δ exists. Crucially, δ may depend on both ε and the point x0. When it depends only on ε, we obtain the stronger notion of uniform continuity discussed in Uniform Continuity.

An equivalent and often more convenient characterisation uses sequences.

Theorem 12 (Sequential Characterisation).

Let (X,dX) and (Y,dY) be metric spaces and let f:XY. Then f is continuous at x0X if and only if for every sequence (xn)n1 in X with xnx0, we have f(xn)f(x0).

Proof.

(); Suppose f is continuous at x0 and let (xn) be a sequence with xnx0. Given ε>0, choose δ>0 as in Definition 18. Since xnx0, there exists N such that dX(xn,x0)<δ for all nN. Then dY(f(xn),f(x0))<ε for all nN, so f(xn)f(x0).

(); We prove the contrapositive. Suppose f is not continuous at x0. Then there exists ε0>0 such that for every δ>0 there is a point x with dX(x,x0)<δ yet dY(f(x),f(x0))ε0. Taking δ=1/n for n=1,2,3, produces a sequence (xn) with xnx0 but dY(f(xn),f(x0))ε0 for all n, so f(xn) does not converge to f(x0).

Extreme Value Theorem

One of the most important consequences of continuity is that continuous functions on compact sets are guaranteed to attain their extreme values. Before stating the main result, we establish that continuous maps preserve compactness.

Theorem 13 (Continuous Image of a Compact Set).

Let f:XY be a continuous map between metric spaces. If KX is compact, then f(K)Y is compact.

Proof.

Let {Vα}αA be an open cover of f(K) in Y. For each α, the preimage Uα=f1(Vα) is open in X because f is continuous. Since every yf(K) lies in some Vα, every xK lies in the corresponding Uα, so {Uα}αA is an open cover of K. By compactness of K, there exists a finite subcover {Uα1,,Uαn}. Then {Vα1,,Vαn} covers f(K): for any y=f(x)f(K) with xK, we have xUαi for some i, hence yVαi.

Theorem 14 (Extreme Value Theorem).

If f:K is continuous and K is compact, then f attains its maximum and minimum on K. That is, there exist points xmin,xmaxK such that f(xmin)f(x)f(xmax)for all xK.

Proof.

By Theorem 13, f(K) is a compact subset of . The Heine–Borel theorem tells us that compact subsets of are precisely the closed and bounded sets. Since f(K) is bounded, M=supf(K) and m=inff(K) are finite. Since f(K) is closed, both M and m belong to f(K). Therefore there exist xmaxK with f(xmax)=M and xminK with f(xmin)=m.

The Extreme Value Theorem guarantees that a continuous function on a compact set attains both its maximum and minimum values. Here f achieves its maximum at xmax and its minimum at xmin within the closed interval [a,b].

Uniform Continuity

Definition 19 (Uniform Continuity).

A function f:XY between metric spaces is uniformly continuous if for every ε>0 there exists δ>0 such that dX(x,y)<δdY(f(x),f(y))<εfor 𝑎𝑙𝑙 x,yX.

Remark 3 (Pointwise vs Uniform).

Ordinary continuity and uniform continuity differ in a subtle but important way. In the pointwise definition (Definition 18), δ may depend on both ε and the particular point x0. In the uniform definition, a single δ works simultaneously for every pair of points in the domain. The distinction vanishes on compact domains, as the next theorem shows, but is significant on unbounded or non-closed domains.

Uniform vs. pointwise continuity. Left: The linear function f(x)=x is uniformly continuous because the same δ works at every point. Right: The function f(x)=1/x on (0,1] is continuous but not uniformly continuous: as x approaches 0, the required δ for a fixed ε shrinks to zero.

On compact domains, the distinction between pointwise and uniform continuity disappears. This classical result is essential in analysis and will be used repeatedly in later chapters.

Theorem 15 (Heine–Cantor).

Every continuous function on a compact metric space is uniformly continuous.

Proof.

Let f:KY be continuous on the compact metric space K. Fix ε>0. For each xK, continuity gives a δx>0 such that dX(x,y)<δx implies dY(f(x),f(y))<ε/2. The open balls {B(x,δx/2)}xK cover K. By compactness, finitely many suffice: KB(x1,δx1/2)B(xn,δxn/2). Set δ=12min{δx1,,δxn}>0.

Now suppose dX(y,z)<δ. Since the finite collection covers K, there exists xi with yB(xi,δxi/2). Then dX(z,xi)dX(z,y)+dX(y,xi)<δ+δxi2δxi. Therefore dY(f(y),f(xi))<ε/2 and dY(f(z),f(xi))<ε/2, so by the triangle inequality dY(f(y),f(z))<ε. Since δ is independent of the choice of y and z, f is uniformly continuous.

Lipschitz Continuity

Uniform continuity guarantees a single δ for each ε, but says nothing about the rate at which the output changes with the input. Lipschitz continuity provides a quantitative bound on this rate, making it the strongest common continuity condition and the one most directly relevant to modern generative models.

Definition 20 (Lipschitz Continuity).

A function f:XY between metric spaces is L-Lipschitz (or Lipschitz continuous with constant L) if there exists a constant L0 such that (Lipschitz)dY(f(x),f(y))LdX(x,y)for all x,yX. The smallest such L is called the Lipschitz constant of f, denoted fL or Lip(f).

For differentiable functions, the Lipschitz constant has a clean gradient characterisation.

Definition 21 (Lipschitz Constant via Gradient).

Let f:n be differentiable. Then f is L-Lipschitz with respect to the Euclidean norm if and only if (Lipschitz GRAD)f(𝒙)Lfor all 𝒙n.

The various notions of continuity form a strict hierarchy.

Theorem 16 (Hierarchy of Continuity).

For functions between metric spaces, the following implications hold: Lipschitz continuousuniformly continuouscontinuous. None of the converses hold in general.

Proof.

Lipschitz uniformly continuous.; If f is L-Lipschitz, set δ=ε/L (or δ=ε if L=0). Then dX(x,y)<δ implies dY(f(x),f(y))LdX(x,y)<L(ε/L)=ε. This δ is independent of the points x and y, so f is uniformly continuous.

Uniformly continuous continuous.; Uniform continuity provides, for each ε>0, a single δ>0 that works for all points. In particular it works at any fixed point x0, so f is continuous at x0.

Converses fail.; The function f(x)=x on [0,1] is uniformly continuous (it is continuous on a compact set, so the Heine–Cantor theorem applies) but not Lipschitz: its derivative f(x)=1/(2x) is unbounded as x0+. The function g(x)=x2 on is continuous but not uniformly continuous: for ε=1, no single δ works because |(x+δ/2)2(xδ/2)2|=2xδ grows without bound as x.

Example 9 (Lipschitz Functions).

Several common functions are Lipschitz continuous:

  • The linear function f(x)=mx+b is |m|-Lipschitz on , since |f(x)f(y)|=|m||xy|.

  • The absolute value f(x)=|x| is 1-Lipschitz, by the reverse triangle inequality.

  • The sine function f(x)=sin(x) is 1-Lipschitz, since |sinxsiny||xy| by the mean value theorem and the bound |cosc|1.

  • The ReLU activation f(x)=max(0,x) is 1-Lipschitz.

Example 10 (Non-Lipschitz Functions).

Not every continuous function is Lipschitz:

  • f(x)=x2 on is not globally Lipschitz because |f(x)f(0)|/|x|=|x|.

  • f(x)=ex on fails to be Lipschitz for the same reason: its derivative grows without bound.

  • f(x)=x on [0,1] is not Lipschitz because the derivative 1/(2x) blows up at x=0.

Key Idea.

In the Wasserstein GAN framework (10), the critic function is constrained to be 1-Lipschitz. This ensures that the Kantorovich–Rubinstein dual W1(P,Q)=supfL1[𝔼P[f]𝔼Q[f]] is finite and provides a meaningful distance between the real and generated distributions. Without the Lipschitz constraint, the supremum would diverge because the critic could become arbitrarily steep, driving the difference 𝔼P[f]𝔼Q[f] to infinity. In practice, the constraint is enforced by weight clipping, gradient penalty, or spectral normalisation.

Connectedness

Compactness captures the idea that a set is “small enough” to extract finite information from infinite data. Connectedness captures a different geometric property: the set is “in one piece.” A connected space cannot be split into two separate open chunks, and this topological rigidity has deep analytic consequences, the most famous being the Intermediate Value Theorem.

Definition 22 (Connected Set).

A metric space (X,d) is connected if it cannot be written as a union X=UV of two nonempty, disjoint open sets U and V. Equivalently, X is connected if and only if every continuous function f:X{0,1} is constant (where {0,1} carries the discrete metric).

A stronger property requires that any two points can be joined by a continuous path.

Definition 23 (Path-Connected Set).

A metric space X is path-connected if for every pair of points x,yX there exists a continuous function γ:[0,1]X with γ(0)=x and γ(1)=y. The function γ is called a path from x to y.

Theorem 17 (Path-Connected Implies Connected).

Every path-connected metric space is connected.

Proof.

Suppose for contradiction that X is path-connected but not connected. Then X=UV for nonempty disjoint open sets U and V. Pick uU and vV, and let γ:[0,1]X be a path from u to v. The sets γ1(U) and γ1(V) are open in [0,1] (since γ is continuous and U, V are open), nonempty (since 0γ1(U) and 1γ1(V)), disjoint, and their union is [0,1]. But this contradicts the fact that the interval [0,1] is connected.

Remark 4 (The Converse Fails).

Path-connectedness is strictly stronger than connectedness. The classical counterexample is the topologist's sine curve: S={(x,sin(1/x)):x>0}{(0,y):1y1}. The set S is connected (one cannot separate the oscillating part from the vertical segment without breaking continuity) but not path-connected: no continuous path can traverse the infinitely many oscillations near x=0 in finite “time.”

Three subsets of 2. Left: A path-connected (hence connected) set with a path shown between two interior points. Middle: A disconnected set consisting of two separate components. Right: Two regions joined by a thin bridge remain connected.

The most celebrated application of connectedness in elementary analysis is the Intermediate Value Theorem, which guarantees that continuous functions on intervals cannot “skip” values.

Theorem 18 (Intermediate Value Theorem).

Let f:[a,b] be continuous. If c is any real number strictly between f(a) and f(b), then there exists x(a,b) such that f(x)=c.

Proof.

The interval [a,b] is connected (it is path-connected, since the identity map provides a path between any two points). By Theorem 13 (with compactness replaced by the analogous result for connectedness: the continuous image of a connected set is connected), f([a,b]) is a connected subset of . The connected subsets of are precisely the intervals. Since f(a) and f(b) both lie in f([a,b]), and c lies between them, we have cf([a,b]). Therefore there exists x[a,b] with f(x)=c. Since c is strictly between f(a) and f(b), we have xa and xb, so x(a,b).

Normed and Inner Product Spaces

Metric spaces provide a general notion of distance, but in the vector spaces that arise throughout machine learning we have additional algebraic structure: vectors can be added and scaled. A norm measures the “size” of a vector in a way that respects this algebraic structure, while an inner product adds a notion of angle and orthogonality. The hierarchy inner product spacesnormed spacesmetric spaces reflects increasing levels of geometric structure. Completeness then distinguishes Banach and Hilbert spaces as the settings where limits always exist, making calculus possible.

Normed Vector Spaces

Definition 24 (Norm).

Let V be a vector space over . A norm on V is a function :V[0,) satisfying, for all 𝒙,𝒚V and all α:

  1. Positive definiteness:; 𝒙=0 if and only if 𝒙=𝟎.

  2. Absolute homogeneity:; α𝒙=|α|𝒙.

  3. Triangle inequality:; 𝒙+𝒚𝒙+𝒚.

Definition 25 (Normed Space).

A normed vector space (or simply a normed space) is a pair (V,) consisting of a vector space V and a norm on V. Every normed space is automatically a metric space under the induced metric (Induced Metric)d(𝒙,𝒚)=𝒙𝒚.

Example 11 (p Norms on n).

For 1p<, the p norm on n is 𝒙p=(i=1n|xi|p)1/p, and the norm is 𝒙=max1in|xi|. The most commonly used cases are p=1 (Manhattan norm), p=2 (Euclidean norm), and p= (maximum norm). The Euclidean norm p=2 is special because it arises from an inner product.

Lp Function Spaces

The p norms on n have infinite-dimensional counterparts that measure the “size” of functions rather than finite-dimensional vectors.

Definition 26 (Lp Space).

Let (Ω,μ) be a measure space and let 1p<. The space Lp(Ω) consists of all (equivalence classes of) measurable functions f:Ω for which fp=(Ω|f|p𝖣μ)1/p<. For p=, the space L(Ω) consists of essentially bounded functions with norm f=esssupxΩ|f(x)|. Two functions that agree μ-almost everywhere are identified.

Remark 5 (The Importance of L2).

The space L2 occupies a privileged position in the Lp family: it is the only Lp space that is a Hilbert space (every other, for p2, is merely a Banach space). The inner product structure of L2 gives access to the powerful geometry of orthogonal projections, Fourier analysis, and least-squares methods. In machine learning, the mean squared error loss 𝔼[f(𝒙)𝒚2] is an L2 quantity, and the reproducing kernel Hilbert spaces used in kernel methods are subspaces of L2.

Inner Product Spaces

Definition 27 (Inner Product Space).

Let V be a vector space over . An inner product on V is a function ,:V×V satisfying, for all 𝒙,𝒚,𝒛V and all α:

  1. Linearity in the first argument:; α𝒙+𝒚,𝒛=α𝒙,𝒛+𝒚,𝒛.

  2. Symmetry:; 𝒙,𝒚=𝒚,𝒙.

  3. Positive definiteness:; 𝒙,𝒙0, with equality if and only if 𝒙=𝟎.

Every inner product induces a norm via 𝒙=𝒙,𝒙, and hence a metric via d(𝒙,𝒚)=𝒙𝒚.

The fundamental inequality of inner product spaces relates the inner product to the induced norm.

Theorem 19 (Cauchy–Schwarz Inequality).

For any 𝒙,𝒚 in an inner product space V, (Cauchy Schwarz)|𝒙,𝒚|𝒙𝒚. Equality holds if and only if 𝒙 and 𝒚 are linearly dependent.

Proof.

If 𝒚=𝟎, both sides are zero and the inequality holds trivially. Assume 𝒚𝟎 and consider the function g(t)=𝒙+t𝒚2=𝒙+t𝒚,𝒙+t𝒚=𝒙2+2t𝒙,𝒚+t2𝒚2. By positive definiteness of the inner product, g(t)0 for all t. This is a non-negative quadratic polynomial in t, so its discriminant must satisfy (2𝒙,𝒚)24𝒙2𝒚20, which simplifies to 𝒙,𝒚2𝒙2𝒚2. Taking square roots gives the result. Equality holds precisely when g(t)=0 for some t, which means 𝒙+t𝒚=𝟎, so 𝒙 and 𝒚 are linearly dependent.

Banach and Hilbert Spaces

The spaces n are “well-behaved” because every Cauchy sequence converges. In infinite-dimensional settings this completeness property must be imposed as an axiom, leading to the central objects of functional analysis.

Definition 28 (Banach Space).

A normed vector space (V,) is a Banach space if it is complete: every Cauchy sequence in V converges to a limit in V.

Definition 29 (Hilbert Space).

An inner product space (V,,) is a Hilbert space if it is complete with respect to the norm induced by the inner product.

Every Hilbert space is a Banach space (the inner product induces a norm, and completeness is assumed), but a Banach space need not be a Hilbert space because its norm may not arise from any inner product. A classical test is the parallelogram law: a norm comes from an inner product if and only if 𝒙+𝒚2+𝒙𝒚2=2𝒙2+2𝒚2 for all 𝒙,𝒚.

Example 12 (L2 as a Hilbert Space).

The space L2([0,1]) with the inner product f,g=01f(x)g(x)𝖣x is a Hilbert space. The induced norm is f2=(01|f(x)|2𝖣x)1/2, and completeness follows from the Riesz–Fischer theorem. Fourier series provide orthonormal bases for L2, making it the natural home for spectral analysis.

Example 13 (L1 as a Banach Space (not Hilbert)).

The space L1([0,1]) with norm f1=01|f(x)|𝖣x is a Banach space (complete) but not a Hilbert space. Its norm fails the parallelogram law, so no inner product can generate it. This means L1 lacks the orthogonal projection machinery that makes L2 so tractable.

A cornerstone result connects continuous linear functionals on a Hilbert space to elements of the space itself.

Theorem 20 (Riesz Representation).

Let H be a Hilbert space over . For every continuous linear functional φ:H, there exists a unique element gH such that (Riesz)φ(f)=f,gfor all fH. Moreover, φ=g.

The intuition behind the Riesz Representation Theorem is striking: every “measurement” that you can perform on elements of a Hilbert space (that is, every continuous linear functional) amounts to taking an inner product with some fixed element of the space. There are no “exotic” linear functionals lurking beyond the inner product structure. This makes Hilbert spaces exceptionally well-suited for optimisation and approximation theory, since searching over functionals reduces to searching over elements of the space itself.

The hierarchy of vector spaces used in analysis and machine learning. Every Hilbert space is both a Banach space (complete normed space) and an inner product space. The Lp spaces for p2 are Banach but not Hilbert, while incomplete inner product spaces (sometimes called pre-Hilbert spaces) are neither Banach nor Hilbert.

Topology

Every metric space carries a natural notion of “open set,” and it is this collection of open sets, rather than the metric itself, that determines which functions are continuous, which sets are compact, and which sequences converge. Topology abstracts this observation: it studies the properties of spaces that depend only on the open-set structure. For generative modelling the key payoff is the distinction between strong and weak topologies, which explains why the Wasserstein distance succeeds where the KL divergence fails.

Topological Spaces

Definition 30 (Topological Space).

A topological space is a pair (X,𝒯), where X is a set and 𝒯𝒫(X) is a collection of subsets of X called open sets, satisfying:

  1. The empty set and the whole space X belong to 𝒯.

  2. The intersection of any finite collection of members of 𝒯 belongs to 𝒯.

  3. The union of any (possibly infinite) collection of members of 𝒯 belongs to 𝒯.

These three axioms are deliberately minimal: they capture the essential algebraic properties of open sets in metric spaces while discarding the specific notion of distance. A closed set in a topological space is, by definition, the complement of an open set.

Definition 31 (Basis for a Topology).

A collection 𝒯 of open sets is a basis for the topology 𝒯 if every open set in 𝒯 can be written as a (possibly empty) union of members of .

Remark 6 (Metric Topology).

Every metric space (X,d) has a natural topology: the collection of all sets UX such that for every xU there exists ε>0 with B(x,ε)U. The open balls {B(x,ε):xX,ε>0} form a basis for this topology. This construction provides the bridge between the concrete metric framework of Continuity and the abstract topological viewpoint developed here. Two different metrics on the same set can generate the same topology (they are then called topologically equivalent), which is why topological properties are more fundamental than metric ones.

Strong and Weak Topologies

In finite-dimensional spaces such as n, there is essentially only one “reasonable” topology (all norms on n are equivalent). In infinite-dimensional spaces the situation is dramatically different: the same underlying set can carry multiple topologies that lead to genuinely different notions of convergence. The two most important are the strong (norm) topology and the weak topology.

The strong topology (also called the norm topology) on a normed space (V,) is simply the metric topology induced by the norm. A sequence (𝒙n) converges strongly to 𝒙 if 𝒙n𝒙0. This is the most natural and demanding form of convergence.

Definition 32 (Weak Topology).

Let (V,) be a normed space and let V denote its dual space (the set of all continuous linear functionals φ:V). The weak topology on V is the coarsest topology that makes every φV continuous. Concretely, a set UV is open in the weak topology if and only if for every 𝒙U there exist finitely many functionals φ1,,φkV and ε>0 such that {𝒚V:|φi(𝒚)φi(𝒙)|<ε for all i=1,,k}U.

Definition 33 (Weak Convergence).

A sequence (𝒙n) in a normed space V converges weakly to 𝒙V, written 𝒙n𝒙, if φ(𝒙n)φ(𝒙)for every φV. That is, 𝒙n𝒙 if and only if 𝒙n𝒙 in the weak topology.

The weak topology has fewer open sets than the strong topology (it is “coarser”), so it is easier for a sequence to converge weakly than strongly.

Theorem 21 (Strong Implies Weak).

If 𝒙n𝒙 in norm (strong convergence), then 𝒙n𝒙 (weak convergence). The converse holds in finite-dimensional spaces but fails in infinite-dimensional ones.

Proof.

Suppose 𝒙n𝒙0 and let φV be any continuous linear functional. By linearity and continuity, |φ(𝒙n)φ(𝒙)|=|φ(𝒙n𝒙)|φ𝒙n𝒙0, where φ=sup𝒚1|φ(𝒚)| is the operator norm. Therefore φ(𝒙n)φ(𝒙) for every φV, which is exactly weak convergence.

Theorem 22 (Equivalence in Finite Dimensions).

In a finite-dimensional normed space, weak convergence and strong convergence are equivalent.

Proof sketch.

Let V=n with any norm. Every continuous linear functional on n has the form φ(𝒙)=𝐚𝒙 for some 𝐚n. Suppose 𝒙n𝒙, so 𝐚𝒙n𝐚𝒙 for all 𝐚n. Choosing 𝐚=𝐞i (the i-th standard basis vector) shows that each component converges: (𝒙n)i(𝒙)i. Componentwise convergence in n implies convergence in norm (since all norms on n are equivalent), so 𝒙n𝒙 strongly.

The following example shows that in infinite dimensions the equivalence breaks down.

Example 14 (Weak But Not Strong Convergence).

In L2([0,1]), define fn(x)=2sin(nπx),n=1,2,3, Each fn has unit norm: fn2=1. By the Riemann–Lebesgue lemma, for any gL2([0,1]), fn,g=201sin(nπx)g(x)𝖣x0as n. Therefore fn0 weakly. However, fn02=1 for all n, so the sequence does not converge strongly to 0. The oscillations become ever more rapid but never diminish in amplitude.

Key Idea.

In generative modelling, we compare probability distributions, which live in infinite-dimensional function spaces. The KL divergence induces strong-topology-like behaviour: it can be infinite even when distributions are “close” in a perceptually meaningful sense (for instance, when the supports are disjoint but nearby). The Wasserstein distance, by contrast, metrises weak convergence on compact spaces: Wp(μn,μ)0 if and only if μn converges weakly to μ (and the p-th moments converge). This means the Wasserstein distance captures the intuitive notion that a sequence of distributions Pn approaches P when samples from Pn “look like” samples from P. It is precisely this property that makes the Wasserstein distance preferable to the KL divergence as a training objective in WGANs: the loss landscape is smooth even when the generator's distribution has not yet “found” the data manifold.

Historical Note.

The distinction between weak and strong convergence was first systematically studied by Stefan Banach and his Lwów school in the 1920s and 1930s. Their insights, recorded in the famous Scottish Book of open problems kept in a Lwów café, laid the foundations of modern functional analysis. Banach's 1932 monograph Théorie des opérations linéaires introduced many of the concepts discussed in this section, including the systematic use of dual spaces and weak convergence.

For generative modelling, weak convergence became directly relevant when Arjovsky, Chintala, and Bottou (2017) showed that the Wasserstein distance provides meaningful gradients where the KL divergence and Jensen–Shannon divergence fail. Their paper demonstrated that sequences of distributions approaching the data distribution may have infinite KL divergence at every step, while the Wasserstein distance decreases smoothly, a phenomenon explained precisely by the difference between strong and weak topologies.

Differentiation and Integration in n

The tools of multivariable calculus form the computational backbone of modern generative modelling. Gradients drive optimisation, Jacobians govern how densities transform under invertible maps, and integration by parts is the hidden engine behind score matching. In this section we develop these tools with enough precision to support the theoretical results used throughout the main text, while keeping an eye on the practical consequences for model design and training. Readers comfortable with undergraduate multivariable calculus will find most of this material a review, but the connections to generative modelling should be fresh.

Gradients, Jacobians, and Hessians

We begin with the three fundamental derivative objects of multivariable calculus. The gradient f captures first-order information about scalar-valued functions, the Jacobian JF generalises this to vector-valued maps, and the Hessian Hf captures second-order (curvature) information. Each appears repeatedly in the design and analysis of generative models, and understanding their interplay is essential for the developments in subsequent chapters.

Definition 34 (Gradient).

Let f:n be differentiable at 𝒙n. The gradient of f at 𝒙 is the column vector of first partial derivatives: (Gradient)f(𝒙)=(fx1(𝒙)fxn(𝒙))n. The gradient points in the direction of steepest ascent of f at 𝒙, and its magnitude f(𝒙) equals the maximum directional derivative.

The gradient is the workhorse of gradient-based optimisation: every step of stochastic gradient descent moves the parameters in the direction θ(θ), and the score function 𝒙logp(𝒙) that drives diffusion models and score matching is simply the gradient of the log-density with respect to data.

Example 15 (Gradient of a Quadratic).

For the quadratic function f(𝒙)=12𝒙A𝒙+𝒃𝒙+c where A is a symmetric matrix, 𝒃n, and c, the gradient is f(𝒙)=A𝒙+𝒃. Setting the gradient to zero gives the critical point 𝒙=A1𝒃 (when A is invertible). This is the solution to a linear system and appears throughout machine learning in closed-form solutions for linear regression and Gaussian conditioning.

Definition 35 (Jacobian Matrix).

Let F:nm be differentiable at 𝒙. The Jacobian matrix of F at 𝒙 is the m×n matrix (Jacobian)JF(𝒙)=(F1x1F1xnFmx1Fmxn), so that (JF(𝒙))ij=Fi/xj. The Jacobian provides the best linear approximation to F near 𝒙: F(𝒙+𝒉)=F(𝒙)+JF(𝒙)𝒉+o(𝒉). When m=1, the Jacobian reduces to the transpose of the gradient: Jf(𝒙)=(f(𝒙)).

Example 16 (Jacobian of an Affine Map).

The affine map F(𝒙)=A𝒙+𝒃, where Am×n and 𝒃m, has constant Jacobian JF(𝒙)=A. This is the simplest non-trivial example and already illustrates the key principle: the determinant |detA| measures how the linear map stretches volume. For a square matrix (m=n), if |detA|>1 the map expands volumes, and if |detA|<1 it compresses them. Normalizing flow layers often compose such simple maps to build expressive transformations while keeping the Jacobian determinant tractable.

Definition 36 (Hessian Matrix).

Let f:n be twice differentiable at 𝒙. The Hessian matrix of f at 𝒙 is the n×n matrix of second partial derivatives: (Hessian)Hf(𝒙)=2f(𝒙),(Hf(𝒙))ij=2fxixj(𝒙). If fC2 (all second partial derivatives exist and are continuous), then Hf(𝒙) is symmetric by Schwarz's theorem (also known as Clairaut's theorem): 2fxixj=2fxjxi. The Hessian encodes the local curvature of f. At a critical point where f=0, the eigenvalues of Hf determine whether the point is a local minimum (all positive), local maximum (all negative), or saddle point (mixed signs).

Example 17 (Hessian of the Log-Gaussian).

For the multivariate Gaussian log-density logp(𝒙)=12(𝒙𝝁)Σ1(𝒙𝝁)+const, the gradient (score) is 𝒙logp(𝒙)=Σ1(𝒙𝝁) and the Hessian is 𝒙2logp(𝒙)=Σ1, a constant matrix. This is one of the few cases where the Hessian is independent of 𝒙, reflecting the fact that a Gaussian has uniform curvature. The trace of the Hessian is trace(Σ1)=i=1n1/σi2, where σi2 are the eigenvalues of Σ.

Gradient vectors (red arrows) on the contour plot of f(x1,x2)=x12+2x22. The gradient is always perpendicular to the level curves, and its magnitude is larger where contours are closer together (steeper regions).

Insight.

The chain rule in multiple dimensions states that JGF(𝒙)=JG(F(𝒙))JF(𝒙). Taking determinants gives detJGF=detJGdetJF. For normalizing flows that compose K invertible layers Φ=ΦKΦ1, this factorisation means log|detJΦ|=k=1Klog|detJΦk|. Each layer contributes an additive term to the log-determinant, which is why composing simple layers with cheap determinants produces an expressive flow with a tractable density.

Definition 37 (Trace).

For a square matrix An×n, the trace is the sum of its diagonal entries: (Trace DEF)trace(A)=i=1nAii.

Theorem 23 (Trace Properties).

Let A,B,C be matrices of compatible dimensions and α. Then:

  1. Linearity: trace(A+αB)=trace(A)+αtrace(B).

  2. Transpose invariance: trace(A)=trace(A).

  3. Cyclic property: trace(ABC)=trace(BCA)=trace(CAB).

  4. Eigenvalue relation: If λ1,,λn are the eigenvalues of A (counted with algebraic multiplicity), then trace(A)=i=1nλi.

Proof.

Properties (i) and (ii) follow directly from the definition. For the cyclic property, let Am×p, Bp×q, Cq×m. Then (Cyclic Proof)trace(ABC)=i=1m(ABC)ii=i=1mj=1pk=1qAijBjkCki=j=1pk=1qi=1mBjkCkiAij=j=1p(BCA)jj=trace(BCA). The second equality trace(BCA)=trace(CAB) follows by applying the same argument to the product BCA. Property (iv) follows from the fact that similar matrices share the same trace, and every matrix is similar (over ) to its Jordan normal form, whose diagonal entries are the eigenvalues.

The cyclic property of the trace is surprisingly powerful. It allows us to convert scalar expressions into matrix forms and vice versa: for instance, the quadratic form 𝒙A𝒙 can be written as trace(A𝒙𝒙), a rewriting that underlies the next result.

Definition 38 (Hutchinson's Trace Estimator).

For any square matrix An×n, the trace can be expressed as the expectation (Hutchinson)trace(A)=𝔼[𝒗A𝒗], where 𝒗 is a random vector satisfying 𝔼[𝒗]=0 and 𝔼[𝒗𝒗]=I. Common choices for the distribution of 𝒗 include Rademacher random vectors (each entry independently ±1 with equal probability) and standard Gaussian vectors.

Proof.

Using the cyclic property of the trace and the linearity of expectation: 𝔼[𝒗A𝒗]=𝔼[trace(𝒗A𝒗)]=𝔼[trace(A𝒗𝒗)]=trace(A𝔼[𝒗𝒗])=trace(AI)=trace(A). The key step is interchanging trace and 𝔼, which is justified by the linearity of both operators.

The variance of the estimator depends on the distribution of 𝒗 and the structure of A. For Rademacher vectors, 𝖵ar(𝒗A𝒗)=2AF22iAii2, where AF is the Frobenius norm. Gaussian probe vectors give higher variance, 𝖵ar=2AF2, but are easier to generate. In practice, a small number of random projections (often just one per training step) provides sufficient gradient signal.

Remark 7 (Hutchinson's Estimator and Score Matching).

Hutchinson's estimator is the computational trick that makes sliced score matching practical. In score matching, one must evaluate trace(𝒙2logpθ(𝒙)), which naively requires O(n) backward passes through the network (one per diagonal entry of the Hessian). Hutchinson's estimator replaces this with a single random projection 𝒗, yielding the unbiased estimate 𝒗𝒙2logpθ(𝒙)𝒗, computable with just one forward-backward pass via the identity 𝒗2f𝒗=𝒗(f𝒗). This reduces the cost from O(n) to O(1) backward passes per sample.

Integration by Parts

Integration by parts transfers a derivative from one factor of an integrand to another. This seemingly modest operation is the single most important analytical tool in the theory of score matching. We first state the familiar one-dimensional version and then extend it to n, where it takes on the form of the divergence theorem.

Theorem 24 (Integration by Parts (One Dimension)).

If f and g are continuously differentiable on [a,b], then (IBP 1D)abf(x)g(x)dx=[f(x)g(x)]ababf(x)g(x)dx.

Proof.

The product rule gives (fg)=fg+fg, so fg=(fg)fg. Integrating both sides over [a,b] and applying the fundamental theorem of calculus to the first term yields abfgdx=ab(fg)dxabfgdx=[fg]ababfgdx.

Theorem 25 (Multivariate Integration by Parts).

Let 𝒇:nn be a continuously differentiable vector field and g:n a continuously differentiable function. If g(𝒙)𝒇(𝒙)0 as 𝒙, then (IBP Multi)ng(𝒙)(𝒇)(𝒙)d𝒙=n(g(𝒙))𝒇(𝒙)d𝒙, where 𝒇=i=1nfi/xi is the divergence of 𝒇.

Proof.

We apply the one-dimensional integration by parts formula to each coordinate. For the i-th component, integrating with respect to xi while holding all other variables fixed: g(𝒙)fixi(𝒙)dxi=[g(𝒙)fi(𝒙)]xi=xi=gxi(𝒙)fi(𝒙)dxi. The boundary term [gfi] vanishes by the decay assumption g(𝒙)𝒇(𝒙)0 as 𝒙. Summing over i=1,,n and integrating over all remaining variables gives ng(𝒇)d𝒙=i=1nngxifid𝒙=n(g)𝒇d𝒙.

Key Idea.

Integration by parts is the fundamental tool behind score matching. Hyvärinen's key insight was to apply integration by parts to the Fisher divergence 𝔼pd[𝒙logpθ(𝒙)𝒙logpd(𝒙)2], which appears intractable because it involves the unknown data score 𝒙logpd. By expanding the square and integrating by parts, the cross-term 𝔼pd[(logpd)(logpθ)] can be rewritten in terms of trace(2logpθ) and logpθ alone. The derivative is effectively “transferred” from the unknown pd onto the known model pθ. The boundary terms vanish precisely because probability densities decay to zero at infinity.

Change of Variables

The change-of-variables formula describes how integrals transform under smooth, invertible coordinate changes. It is the mathematical bedrock upon which normalizing flows are built. The basic intuition is straightforward: when we “stretch” or “compress” a region of space through a smooth map, volumes change by a factor determined by the Jacobian determinant. For probability densities, which must integrate to one, this volume factor appears as a correction term that ensures the transformed density remains properly normalised.

Theorem 26 (Change of Variables (One Dimension)).

If φ:[a,b][c,d] is a C1 diffeomorphism (smooth bijection with smooth inverse), then for any integrable function f, (COV 1D)cdf(y)dy=abf(φ(x))|φ(x)|dx. The absolute value |φ(x)| accounts for the possibility that φ reverses orientation (i.e., is decreasing).

Proof.

If φ is increasing, then φ>0 and the result follows directly from the substitution y=φ(x), dy=φ(x)dx. If φ is decreasing, then φ<0 and the substitution reverses the limits of integration. The two sign changes (from φ<0 and from reversing limits) cancel, yielding the absolute value.

Theorem 27 (Change of Variables (Multivariate)).

Let Φ:UV be a C1 diffeomorphism between open subsets U,Vn. Then for any integrable function f:V, (COV Multi)Vf(𝒚)d𝒚=Uf(Φ(𝒙))|detJΦ(𝒙)|d𝒙, where JΦ is the n×n Jacobian matrix of Φ.

The factor |detJΦ(𝒙)| measures how Φ locally stretches or compresses volume. If Φ doubles all lengths, the determinant is 2n and the volume element is scaled accordingly.

Proof sketch of Theorem 27.

The idea is to approximate Φ locally by its linear part. Partition U into small cubes Qk of side length δ. On each cube, Φ is approximately affine: Φ(𝒙)Φ(𝒙k)+JΦ(𝒙k)(𝒙𝒙k) for some centre point 𝒙kQk. The image Φ(Qk) is approximately a parallelepiped whose volume is |detJΦ(𝒙k)|δn. Thus Vf(𝒚)d𝒚kf(Φ(𝒙k))|detJΦ(𝒙k)|δnUf(Φ(𝒙))|detJΦ(𝒙)|d𝒙. Making this approximation rigorous requires showing that the error vanishes as δ0, which uses the differentiability of Φ and standard measure-theoretic arguments. The full proof can be found in any graduate real analysis text.

Example 18 (Polar Coordinates).

Define Φ(r,θ)=(rcosθ,rsinθ) for r>0, θ(0,2π). The Jacobian is JΦ=(cosθrsinθsinθrcosθ),detJΦ=r. The change-of-variables formula gives 2f(𝒙)d𝒙=002πf(rcosθ,rsinθ)rdθdr, recovering the familiar area element rdrdθ in polar coordinates. This conversion is used throughout probability to compute expectations of radially symmetric densities, including the Gaussian integral.

Key Idea.

The change-of-variables formula is the mathematical foundation of normalizing flows. A normalizing flow transforms a simple base density pZ(𝒛) (typically a standard Gaussian) through an invertible map Φ to produce a complex target density. If 𝒙=Φ(𝒛), the density of 𝒙 is pX(𝒙)=pZ(Φ1(𝒙))|detJΦ1(𝒙)|. Taking logarithms, logpX(𝒙)=logpZ(Φ1(𝒙))log|detJΦ(Φ1(𝒙))|. Training requires evaluating log|detJΦ|, which costs O(n3) for a dense Jacobian. This motivates flow architectures with structured Jacobians: autoregressive flows and coupling layers have triangular Jacobians, reducing the determinant computation to O(n) (since the determinant of a triangular matrix is just the product of its diagonal entries). Continuous normalizing flows (CNFs) take a different approach, using Hutchinson's trace estimator (Definition 38) to estimate ddtlog|detJΦ|=trace(JΦ1dJΦdt) stochastically, avoiding the determinant computation entirely.

Dominated Convergence Theorem

When can we exchange a limit and an integral? This question arises constantly in machine learning, for instance when differentiating an expected loss with respect to model parameters, when taking the limit of a sequence of approximate objectives, or when justifying Monte Carlo gradient estimators. The naive answer “whenever it seems reasonable” is dangerously insufficient: there are well-known counterexamples where pointwise convergence of the integrands does not imply convergence of the integrals. The monotone and dominated convergence theorems provide rigorous sufficient conditions that cover the vast majority of cases arising in practice.

Theorem 28 (Monotone Convergence Theorem).

Let {fn} be a sequence of measurable functions satisfying 0f1f2 pointwise, with fnf pointwise. Then limnfndμ=fdμ.

The monotone convergence theorem requires the sequence to be non-decreasing and non-negative, which limits its direct applicability. However, it is the right tool when dealing with sums (since partial sums of non-negative terms form a monotone sequence) and is the backbone of many measure-theoretic constructions. The dominated convergence theorem relaxes the monotonicity requirement to a mere boundedness condition, making it far more versatile in practice.

Theorem 29 (Dominated Convergence Theorem).

Let {fn} be a sequence of measurable functions with fnf pointwise. Suppose there exists an integrable function g (i.e., gdμ<) such that |fn|g for all n. Then f is integrable and (DCT)limnfndμ=fdμandlimn|fnf|dμ=0.

The dominating function g plays a crucial role: it must be integrable and must bound all the fn simultaneously. In practice, finding g often amounts to bounding the integrand uniformly in the parameter that varies (the index n, or a model parameter θ).

Proof sketch.

Since |fn|g pointwise and fnf, we also have |f|g, so f is integrable. Define gn=2g|fnf|. Since |fnf||fn|+|f|2g, we have gn0. Moreover, gn2g pointwise. By Fatou's lemma applied to the non-negative sequence {gn}: 2gdμlim infngndμ=2gdμlim supn|fnf|dμ. Rearranging gives lim supn|fnf|dμ0. Since integrals of non-negative functions are non-negative, we conclude |fnf|dμ0, and the first claim follows from |fnf||fnf|.

Remark 8 (Interchanging Limits and Integrals).

The dominated convergence theorem is the standard tool for justifying the interchange limfn=limfn. In generative modelling, this arises when we differentiate through expectations: θ𝔼p[f(𝒙,θ)]=𝔼p[θf(𝒙,θ)] requires conditions on f to justify moving θ inside the integral. The Leibniz integral rule, stated next, makes this precise. Without such conditions, the gradient of the expected loss could differ from the expected gradient, leading to biased gradient estimates during training.

Leibniz Integral Rule

A natural extension of the dominated convergence theorem is to the setting where the parameter is continuous rather than discrete. The Leibniz integral rule is the continuous analogue: it justifies differentiating through an integral with respect to a continuous parameter θ.

Theorem 30 (Leibniz Integral Rule).

Let f(x,θ) and f/θ(x,θ) be continuous. Suppose there exists an integrable function g(x) such that |fθ(x,θ)|g(x)for all θ. Then the function F(θ)=f(x,θ)dx is differentiable and (Leibniz)ddθf(x,θ)dx=fθ(x,θ)dx.

Proof sketch.

Consider the difference quotient F(θ+h)F(θ)h=f(x,θ+h)f(x,θ)hdx. By the mean value theorem, the integrand equals fθ(x,θ) for some θ between θ and θ+h, and hence is bounded in absolute value by g(x). As h0, the integrand converges pointwise to f/θ(x,θ), and the dominating function g is independent of h. The dominated convergence theorem (Theorem 29) then justifies interchanging the limit and the integral.

Remark 9 (Applications in Generative Modelling).

The Leibniz integral rule is the rigorous justification for differentiating through the ELBO in VAE training, through the diffusion loss in DDPM training, and through essentially every gradient-based training procedure that involves an expectation. Whenever we write θ𝔼p(𝒙)[(𝒙,θ)]=𝔼p(𝒙)[θ(𝒙,θ)], we are implicitly invoking this theorem. Note that this result applies only when the distribution p does not depend on θ. When it does (as in the reparameterisation trick for VAEs), a change of variables is needed first to move the θ-dependence out of the measure and into the integrand, after which Leibniz's rule can be applied.

Example 19 (Leibniz Rule Applied to a Gaussian Model).

Consider the parametric family f(x,σ)=1σ2πexp(x2/(2σ2)) for σ>0. Then fσ(x,σ)=1σ2πexp(x22σ2)(x2σ31σ). This is bounded by g(x)=C(1+x2)exp(x2/(2σmax2)) for σ in any compact interval [σmin,σmax], and g is integrable. The Leibniz rule then gives ddσf(x,σ)dx=fσdx. Since fdx=1 for all σ, the left-hand side is zero, confirming the normalisation constraint is preserved under differentiation.

Historical Note.

Leibniz stated this rule informally in the seventeenth century as part of his development of calculus. The rigorous version, grounded in the dominated convergence theorem, was established by Lebesgue in the early twentieth century. Richard Feynman famously called “differentiating under the integral sign” his secret weapon for solving physics problems, writing in his autobiography that it was “a technique not taught enough in the universities” yet effective on a surprising range of integrals that stymied his colleagues.

Regularity and Function Classes

The theoretical guarantees behind score matching, integration by parts, and density estimation all rely on the functions involved being “sufficiently nice.” This section makes that notion precise by introducing the standard smoothness and decay conditions that appear in the analysis of generative models. We organise the discussion from the most basic regularity (continuity and differentiability classes) through rapid-decay conditions (the Schwartz class) to the Sobolev spaces that provide weak differentiability, and finally state the explicit assumptions used in score matching proofs.

Definition 39 (Smoothness Class Ck).

A function f:n belongs to the smoothness class Ck if all partial derivatives of f up to and including order k exist and are continuous. The class C0 consists of continuous functions, and C=k=0Ck denotes the class of infinitely differentiable (smooth) functions.

Example 20 (Smoothness Hierarchy).

  • Polynomials and the Gaussian density exp(𝒙2/2) are C.

  • The function f(x)=|x| is C0 but not C1 at x=0, since the left and right derivatives disagree.

  • The function f(x)=x|x| is C1 (with f(x)=2|x|), but not C2 at x=0.

  • The ReLU activation f(x)=max(0,x) is C0 but not C1, while the softplus activation f(x)=log(1+ex) is C and approximates ReLU for large arguments.

Definition 40 (Schwartz Class).

The Schwartz class 𝒮(n) consists of all smooth functions whose derivatives of every order decay faster than any polynomial. Formally, f𝒮(n) if and only if for all multi-indices α,β, (Schwartz)sup𝒙n|𝒙αDβf(𝒙)|<, where 𝒙α=x1α1xnαn and Dβ=|β|/x1β1xnβn. Gaussian densities are the prototypical Schwartz functions: the factor e𝒙2/2 kills any polynomial growth. The Schwartz class is closed under multiplication, differentiation, and Fourier transform, making it the ideal setting for analysis involving all three operations simultaneously.

The Schwartz class sits strictly inside every Lp space and inside every Sobolev space, making it the “safest” function class for analytical manipulations. When we establish a result for Schwartz-class densities, it often extends by density arguments (approximating a general function by Schwartz functions) to broader classes.

Remark 10 (Decay Conditions in Score Matching).

Score matching proofs require the boundary terms from integration by parts to vanish. This happens when the data density p(𝒙) and the model score 𝒙logpθ(𝒙) decay sufficiently fast as 𝒙. Specifically, we need p(𝒙)𝒙logpθ(𝒙)0as 𝒙, which is guaranteed when p belongs to the Schwartz class (as Gaussian and Gaussian-mixture densities do). Densities with heavy tails, such as the Cauchy distribution, can violate this condition and require special treatment.

Comparison of polynomial, exponential, and Gaussian decay rates. Schwartz-class functions such as Gaussians decay faster than any polynomial, ensuring that integration-by-parts boundary terms vanish.

The hierarchy C0C1C2C𝒮 provides increasingly strong regularity. For many purposes in generative modelling, C2 suffices (since we need second derivatives for the Hessian trace in score matching), but the Schwartz class is the “gold standard” where all analytical manipulations are guaranteed to be valid.

We briefly introduce Sobolev spaces, which provide the natural functional-analytic setting for score functions and weak derivatives. While we will not need the full theory of Sobolev spaces, it is worth understanding the basic idea, as it explains why neural networks with non-smooth activations can still be analysed rigorously.

Definition 41 (Sobolev Space (Informal)).

The Sobolev space Wk,p(Ω) consists of functions defined on Ωn whose weak derivatives up to order k all belong to Lp(Ω). The most commonly encountered case in generative modelling is W1,2(Ω)=H1(Ω), the space of functions with square-integrable first derivatives. A function fH1 may not be classically differentiable everywhere, but possesses a well-defined gradient in the L2 sense.

Remark 11 (Why Sobolev Spaces Matter).

Sobolev spaces provide the natural setting for score functions. A score 𝒙logp(𝒙) that belongs to an appropriate Sobolev space has enough regularity for integration by parts to hold in the weak (distributional) sense, even when classical derivatives may not exist at isolated points. This allows the theory to cover neural network score models that use non-smooth activations like ReLU, provided their outputs have square-integrable gradients almost everywhere.

Understanding which regularity class a function belongs to is important in generative modelling for several reasons. First, score matching requires the model log-density to be at least C2 so that the Hessian trace trace(2logpθ) exists. Second, the convergence theory of diffusion models relies on the score function satisfying Lipschitz conditions, which places the score in C0,1 (Lipschitz continuous but not necessarily differentiable). Third, neural networks with smooth activations (such as GELU or softplus) produce C outputs, while those using ReLU produce only C0 outputs, with consequences for the regularity of the learned density.

The following assumptions collect the standard regularity conditions used in score matching and related results throughout this text. These are not merely technical requirements: each corresponds to a failure mode that can arise in practice when the assumptions are violated.

Assumption 1 (Score Regularity).

The model score function 𝒔θ(𝒙)=𝒙logpθ(𝒙) is continuously differentiable in 𝒙 for each θ, and satisfies the finite Fisher information condition: (Score REG)𝔼pd[𝒔θ(𝒙)2]<.

Assumption 2 (Boundary Decay).

The product of the data density and the model score vanishes at infinity: (Boundary)pd(𝒙)𝒔θ(𝒙)0as 𝒙, ensuring that the boundary terms arising from integration by parts are zero.

Assumption 3 (Positivity).

The model density is everywhere positive: pθ(𝒙)>0 for all 𝒙n and all θ in the parameter space. This ensures that the score function 𝒙logpθ(𝒙) is well-defined everywhere.

Assumption 4 (Identifiability).

The model family {pθ} is identifiable: if pθ1(𝒙)=pθ2(𝒙) for almost every 𝒙, then θ1=θ2. This ensures that the minimiser of the score matching objective, if it exists, uniquely determines the model parameters.

These four assumptions together form the standard regularity package for score matching. Assumptions Assumption 1 and Assumption 2 are needed for the integration-by-parts step, Assumption 3 ensures the score is everywhere defined, and Assumption 4 ensures that the optimisation problem has a unique solution. When any of these assumptions is violated, the score matching estimator may be inconsistent, have infinite variance, or converge to the wrong parameter values.

In practice, neural network score models with smooth activations, trained on data from sub-Gaussian distributions, satisfy these assumptions at least approximately. The theoretical analysis assuming exact satisfaction provides guidance for architecture and distribution choices, even when the assumptions hold only in an approximate sense.

Contraction Mappings and Fixed Points

Many iterative algorithms in machine learning can be understood through the lens of contraction mappings. The central question is simple: given a mapping T that we apply repeatedly, does the sequence of iterates x0,T(x0),T(T(x0)), converge, and if so, to what? The Banach fixed point theorem provides a clean and complete answer when T is a contraction: the iterates always converge to a unique fixed point, regardless of the starting point, and the convergence rate is geometric. This makes it one of the most practical existence theorems in all of mathematics.

Definition 42 (Contraction Mapping).

Let (X,d) be a metric space. A function T:XX is a contraction mapping (or contraction) if there exists a constant 0κ<1 such that (Contraction)d(T(x),T(y))κd(x,y)for all x,yX. The constant κ is called the contraction factor. Every contraction is Lipschitz continuous with Lipschitz constant κ<1, and in particular is uniformly continuous.

Example 21 (A Simple Contraction).

The map T(x)=12x+1 on (,||) is a contraction with factor κ=1/2, since |T(x)T(y)|=12|xy|. Its unique fixed point satisfies x=12x+1, giving x=2. Starting from x0=0, the iterates are xn=2(12n), which converge geometrically to 2. This example, despite its simplicity, illustrates the key features of the theorem: existence, uniqueness, and a concrete convergence rate.

Theorem 31 (Banach Fixed Point Theorem).

Let (X,d) be a complete metric space and T:XX a contraction with factor κ[0,1). Then:

  1. T has a unique fixed point x, i.e., T(x)=x.

  2. For any starting point x0X, the iterates xn+1=T(xn) converge to x.

  3. The rate of convergence is geometric: (Banach RATE)d(xn,x)κn1κd(x0,x1).

Proof.

Existence. Fix any x0X and define xn=T(xn1) for n1. We first show that {xn} is a Cauchy sequence. By the contraction property, d(xn+1,xn)=d(T(xn),T(xn1))κd(xn,xn1)κnd(x1,x0). For any m>n, the triangle inequality gives (Cauchy Bound)d(xm,xn)k=nm1d(xk+1,xk)d(x1,x0)k=nm1κkd(x1,x0)κn1κ. Since κ<1, the right-hand side tends to zero as n, so {xn} is Cauchy. By completeness of (X,d), there exists xX with xnx.

x is a fixed point. We show T(x)=x using the triangle inequality: d(T(x),x)d(T(x),T(xn))+d(xn+1,x)κd(x,xn)+d(xn+1,x)0. Hence d(T(x),x)=0, so T(x)=x.

Uniqueness. Suppose T(x)=x and T(y)=y. Then d(x,y)=d(T(x),T(y))κd(x,y). Since κ<1, this forces d(x,y)=0, so x=y.

Convergence rate. Letting m in (Cauchy Bound) gives d(x,xn)κnd(x1,x0)/(1κ). This is a geometric (exponential) rate: the error decreases by a factor of at least κ at each iteration.

The beauty of the Banach fixed point theorem lies in its constructive nature: unlike many existence theorems in analysis (such as those relying on Zorn's lemma or the axiom of choice), it not only asserts that a fixed point exists but provides an explicit algorithm (repeated iteration) to find it and a quantitative bound on how quickly the algorithm converges. This constructive character makes it particularly valuable in computational settings, where an existence result is only useful if accompanied by a practical method to compute the object in question.

The error bound in part (iii) is an a priori estimate: it depends only on the starting point x0, the first iterate x1, and the contraction factor κ, not on the (unknown) fixed point x. This makes it directly computable before the algorithm terminates.

Cobweb diagram for the contraction T(x)=12x+1 with fixed point x=2. Starting from x0=0, the iterates x1=1, x2=1.5, x3=1.75, converge geometrically to x with contraction factor κ=1/2.

Key Idea.

The Sinkhorn algorithm for optimal transport converges because each Sinkhorn iteration is a contraction mapping on the space of scaling vectors (in the Hilbert projective metric). The Banach fixed point theorem guarantees geometric convergence to the unique optimal coupling. Similarly, many iterative algorithms in machine learning can be analysed as contractions or approximate contractions:

  • Expectation-maximisation (EM): Under regularity conditions, the EM operator is a contraction near the true parameter value, giving local geometric convergence.

  • Proximal gradient methods: The proximal operator of a strongly convex function is a contraction, ensuring convergence of iterative proximal algorithms.

  • Belief propagation on trees: Message-passing updates on tree-structured graphical models are contractions, guaranteeing convergence to the exact marginals.

The contraction factor κ directly controls how many iterations are needed to reach a desired accuracy: to achieve d(xn,x)ε, we need nlog(ε(1κ)/d(x0,x1))/logκ iterations.

Historical Note.

Stefan Banach proved his fixed point theorem in his 1922 doctoral thesis at the University of Lwów (now Lviv, Ukraine), making it one of the earliest results in the then-nascent field of functional analysis. Despite its remarkably simple proof, the theorem has proved to be one of the most widely applied existence and uniqueness results in all of mathematics. Picard's existence theorem for ordinary differential equations (1890), the convergence of Newton's method near a root, the implicit function theorem, and the uniqueness of solutions to certain integral equations are all consequences or close relatives of Banach's theorem. In the words of the mathematician Jean Dieudonné, it is “one of the most fertile ideas of modern analysis.”

Exercises

The following exercises reinforce the material from all sections of this appendix. They range from routine verifications (suitable for building intuition) to more substantial proofs. Exercises marked with a generative-modelling flavour connect abstract results to the applications developed in the main text.

Exercise 1 (Supremum Characterisation).

Let S be a nonempty set that is bounded above, and let s=supS. Prove that for every ε>0, there exists an element xS such that sε<xs. State and prove the analogous result for the infimum.

Exercise 2 (Arithmetic of Suprema).

Let A and B be nonempty bounded subsets of . Define A+B={a+b|aA,bB}. Prove that sup(A+B)=supA+supBandinf(A+B)=infA+infB.

Exercise 3 (Epsilon–N Convergence).

Using the εN definition of convergence, prove that the sequence an=3n+1n+2 converges to 3 as n. That is, given ε>0, find an explicit N such that |an3|<ε for all nN. Hint: first simplify |an3| algebraically.

Exercise 4 (Closed Sets and Limit Points).

Let (X,d) be a metric space and let AX. Prove that A is closed if and only if A contains all of its limit points.

Exercise 5 (Cauchy Sequences Are Bounded).

Let (X,d) be a metric space and let {xn} be a Cauchy sequence in X. Prove that {xn} is bounded, i.e., there exists M>0 and x0X such that d(xn,x0)M for all n. Hint: use the Cauchy property with ε=1 to control all but finitely many terms, then handle the finitely many remaining terms separately.

Exercise 6 (Heine–Borel in ).

Prove the Heine–Borel theorem for : a subset K is compact if and only if it is closed and bounded. Hint: for the “if” direction, use the Bolzano–Weierstrass theorem to extract a convergent subsequence from any sequence in K.

Exercise 7 (Continuity vs. Uniform Continuity).

Prove that f(x)=x2 is continuous but not uniformly continuous on . Specifically, show that for any δ>0, there exist x,y with |xy|<δ but |f(x)f(y)|1. Hint: choose x large enough that the slope of f near x exceeds 1/δ. What does this tell you about why unbounded domains require care in optimisation?

Exercise 8 (Lipschitz Algebra).

Let f,g: be Lipschitz continuous with Lipschitz constants Lf and Lg respectively. Prove:

  1. f+g is Lipschitz with constant at most Lf+Lg.

  2. fg is Lipschitz with constant at most LfLg.

  3. Give an example showing that fg need not be Lipschitz, even when both f and g are Lipschitz. Hint: try f(x)=g(x)=x.

Exercise 9 (Gaussian Score Function).

Let p(x)=12πex2/2 be the standard Gaussian density.

  1. Compute the score function xlogp(x).

  2. Compute the Hessian x2logp(x).

  3. Verify that p(x)xlogp(x)0 as |x|.

  4. Compute 𝔼p[xlogp(x)2] and verify it equals trace(x2logp(x))=1 (consistent with the score matching identity).

Exercise 10 (Change of Variables for Affine Transforms).

Let Z𝒩(0,1) and define X=μ+σZ for constants μ and σ>0. Use the change-of-variables formula (Theorem 26) to show that X has density pX(x)=1σ2πexp((xμ)22σ2).

Exercise 11 (Integration by Parts Computation).

Apply integration by parts to compute 0xexdx without using the gamma function directly. Then generalise: use repeated integration by parts to show that 0xnexdx=n! for all n.

Exercise 12 (Failure of Boundary Decay).

Give an example of a probability density pC() that does not satisfy the boundary decay condition (Assumption 2) for some reasonable model score 𝒔θ. Explain what goes wrong when one attempts to apply integration by parts in the score matching derivation. Hint: consider a density whose tails oscillate, such as a smooth density with bumps at x=n for n=1,2,3, whose heights decrease but whose score values do not decay fast enough.

Exercise 13 (Cauchy Distribution and Score Regularity).

Consider the Cauchy density p(x)=1π(1+x2).

  1. Show that p has a well-defined score function xlogp(x)=2x/(1+x2).

  2. Prove that 𝔼p[|xlogp(x)|2]=, violating the score regularity assumption (Assumption 1).

  3. Explain the practical implications: why does this make score matching unreliable for heavy-tailed data?

Exercise 14 (Cosine Contraction).

Let T(x)=cos(x) restricted to the interval [0,π/2].

  1. Show that T maps [0,π/2] into itself.

  2. Show that T is a contraction on [0,π/2] and find an upper bound on the contraction factor. Hint: use the mean value theorem and |T(x)|=|sin(x)|1. Can you find a tighter bound?

  3. Starting from x0=1, compute 10 iterates x1,x2,,x10 and report the fixed point to 4 decimal places.

Exercise 15 (Newton's Method as a Contraction).

For a fixed a>0, consider the iteration xn+1=T(xn) where T(x)=12(x+a/x) (Newton's method for computing a).

  1. Show that T maps [a,) into itself.

  2. Compute T(x) and show that |T(x)|12 for all xa, so T is a contraction on [a,) with factor κ1/2.

  3. Identify the unique fixed point of T and explain why the iterates converge to a.

  4. In practice, Newton's method for square roots converges much faster than the geometric rate κ=1/2 suggests. Explain why. Hint: consider the error en=xna and show that en+1=en2/(2xn), giving quadratic convergence.

Exercise 16 (Weak but Not Strong Convergence in 2).

In the Hilbert space 2 of square-summable sequences, let 𝒆n denote the sequence with 1 in position n and 0 elsewhere.

  1. Show that 𝒆n=1 for all n, so {𝒆n} does not converge strongly to 0 (or to any other element).

  2. Prove that 𝒆n0 weakly, meaning 𝒆n,𝒇0 for every 𝒇2. Hint: for 𝒇=(f1,f2,)2, observe that 𝒆n,𝒇=fn and use the fact that n|fn|2< implies fn0.

  3. Explain why this example shows that the unit ball in an infinite-dimensional Hilbert space is not sequentially compact in the strong topology, but is sequentially compact in the weak topology (by the Banach–Alaoglu theorem). Why does this distinction matter for convergence of probability measures in generative modelling?