0. Mathematical Language, Proofs & Limits

Sets, quantifiers, functions, proof techniques, limits, suprema, compactness and O-notation

Before you start

Start here with ordinary arithmetic and school algebra. The reminders below help you recover the rest:

No earlier primer is needed. Read Sections 1–3 in order; return to the application boxes after the definitions feel familiar.

Book contents · Apply this chapter to a real decision · Glossary

Contents
Start: Algebra warm-up practice 1. Sets, Quantifiers & Logic Practice: Sets & logic (Easy → Hard) 2. Functions, Maps & Fixed Points Practice: Functions & fixed points (Easy → Hard) 3. Reading and Writing Proofs Practice: Proofs (Easy → Hard) 4. Sequences, Limits & Series Practice: Sequences, limits and series (Easy → Hard) 5. Supremum, Infimum & Bounds Practice: Suprema, infima and bounds (Easy → Hard) 6. Open, Closed & Compact Sets; Continuity Practice: Topology, existence and grid certificates (Easy → Hard) 7. Asymptotic Notation & Rates Practice: Rates, constants and computational budgets (Easy → Hard) Interactive: Fixed-Point Iteration & Geometric Series Application lab & chapter review Exercises Further Reading Flashcards

The modules speak the language of analysis: "for every state in $C$ there exists an input", "$\sup_x\|J_f(x)\|$", "a compact sublevel set", "regret $O(\sqrt T)$". This primer makes that language precise and trains the proof patterns the modules repeat: induction over time steps, chains of inequalities, geometric series, and contradiction plus compactness.

A route through this primer

This chapter has 80 exercises with worked solutions: six algebra warm-ups, 63 local guided and graded questions, four application-lab questions, and seven mixed review problems. Every existing question is retained, and 30 new guided questions build the steps needed to solve them. The worked answers explain substitutions, algebra, proof choices and checks.

For a first pass, begin with the algebra warm-up if needed. In each section, attempt the guided build-up before the original Easy exercises. Continue to Medium when you can explain the steps with the answer closed. Return to Hard and mixed review after the simpler work feels independent; you can spread the chapter across several study sessions.

Use a hint after a first attempt. Then compare your reasoning with the full answer, write the reason for each step, close it, and solve the question again. Matching the final value is only one check: also verify the domain, comparison direction and assumptions.

Jump to sets & logic, functions & fixed points, proofs, sequences, bounds, topology, or rates.

Notation — used throughout this page
$\mathbb N=\{0,1,2,\dots\}$ (time starts at $0$); $\|x\|=\sqrt{x^\top x}$ and $d(x,y)=\|x-y\|$ on $\mathbb R^n$; intervals $[a,b]$ closed, $(a,b)$ open. $t$ is a time step, $k$ an iteration counter, $T$ a horizon, $\gamma\in[0,1)$ a discount factor. $C=\{x:h(x)\ge0\}$ is a safe set with barrier function $h$ (in the safe-BO modules, and in the SafeOpt examples of Sections 2, 3 and 5, $h$ is instead a scalar safety threshold), and $x_{t+1}=F(x_t)$ a closed loop (the modules' $f(x,\pi(x))$). $\nabla h$ is the gradient of $h$ (the vector of its partial derivatives) and $J_f$ the Jacobian of a vector-valued $f$ (the matrix of its partial derivatives), both from Primer B. $:=$ means "is defined as"; $\blacksquare$ ends a proof.

Warm-up: the algebra behind the examples

If a calculation is slowing you down, rebuild it one operation at a time. The examples below are enough to start the set and function exercises; you do not need calculus for Sections 1–3.

Background — Signs, fractions, powers and inequalities

Signs and squares: $(-3)^2=(-3)(-3)=9$, whereas $-3^2=-(3^2)=-9$. Absolute value discards the sign: $|-3|=3$. Thus the distance between $-2$ and $1$ is $|-2-1|=3$.

Fractions: $\tfrac12+\tfrac13=\tfrac36+\tfrac26=\tfrac56$. Dividing by a nonzero fraction multiplies by its reciprocal: $2/(1/2)=4$. For $t\ge0$, $1/(t+1)$ is defined and positive; increasing its denominator decreases the value.

Powers: $2^{-3}=1/2^3=1/8$, $a^{m+n}=a^ma^n$, and $a^0=1$ for $a\ne0$. In particular, $0.5^0+0.5^1+0.5^2=1+1/2+1/4=7/4$. The index under a summation sign tells you where to start: $\sum_{t=0}^{2}0.5^t$ means precisely those three terms.

Equations and inequalities: $2x+1=5$ gives $2x=4$ and then $x=2$. Subtracting the same quantity from both sides preserves an inequality. Multiplying or dividing by a negative number reverses it: $-2x\le4$ gives $x\ge-2$. Hence $x^2\le4$ means $-2\le x\le2$, with both signs included.

A quick self-check: before closing this box, reconstruct $(-2)^2=4$, $\tfrac14+\tfrac12=\tfrac34$, $2^{-2}=\tfrac14$ and $-3x\gt6\iff x\lt-2$. If one line is unfamiliar, use its rule on a new number and check by substitution.

Practice: Algebra warm-up

Start here if signs, fractions or inequality steps need a refresher. Work through the six guided questions before the set exercises.

Exercise 0.W1 — Easy: Keep the sign and the brackets

Calculate $(-3)^2$, $-3^2$, $(-2)^3$, $|-2-3|$, and $|2-(-3)|$. Write the multiplication or subtraction before giving the answer. Explain which two expressions measure a distance.

Review: Algebra warm-up

Show hint

A power acts on its bracketed base. Without brackets, the power is evaluated before a leading minus. Distance is the absolute value of the difference between two positions.

Show worked solution

Step 1: Identify the base of each power. In $(-3)^2$, the base is the whole number $-3$. Squaring it means multiplying two copies:

$$(-3)^2=(-3)(-3)=9.$$

The product of two negative numbers is positive. In $-3^2$, the base of the power is $3$; the leading minus is applied afterwards. Thus $-3^2=-(3\cdot3)=-9$. The brackets change the order of operations, so these two expressions have different values.

Step 2: Expand the odd power. Three copies of $-2$ give $(-2)^3=(-2)(-2)(-2)$. Multiply the first two to obtain $4$, then multiply $4$ by $-2$ to obtain $-8$. An odd number of negative factors leaves a negative product.

Step 3: Perform subtraction before taking absolute value. First, $-2-3=-5$, so $|-2-3|=|-5|=5$. Second, subtracting a negative adds its positive opposite: $2-(-3)=2+3=5$, so $|2-(-3)|=|5|=5$. Absolute value measures how far a number lies from zero; that distance cannot be negative.

Step 4: Interpret the two distances. $|-2-3|$ is the distance between positions $-2$ and $3$, and $|2-(-3)|$ is the distance between $2$ and $-3$. Each interval has length $5$. Swapping the two positions changes the sign of their difference but preserves its absolute value. This is the scalar distance used in later error and contraction bounds.

Exercise 0.W2 — Easy: Add fractions and divide by a fraction

Calculate $1/4+2/3$, $(1/2+3)/4$, and $2/(1/2)$. Then solve $x/3+1/2=5/6$ and check your answer in the original equation. Show common denominators explicitly.

Review: Algebra warm-up

Show hint

Adding fractions requires equal denominators. Dividing by a nonzero number multiplies by its reciprocal. Apply the same operation to both sides of the equation.

Show worked solution

Step 1: Put the first two fractions over a common denominator. A denominator divisible by both $4$ and $3$ is $12$. Multiplying a fraction's numerator and denominator by the same nonzero number preserves its value:

$$\frac14+\frac23=\frac3{12}+\frac8{12}=\frac{11}{12}.$$

We add numerators because each now counts twelfths. Adding the denominators would change the size of the pieces and would not perform the required addition.

Step 2: Complete the bracket before dividing. Write $3=6/2$. Then $(1/2+3)/4=(7/2)/4=(7/2)(1/4)=7/8$. Division by $4$ multiplies by $1/4$; it does not divide both numerator and denominator by $4$.

Step 3: Divide by a fraction. The reciprocal of $1/2$ is $2$, since $(1/2)2=1$. Therefore $2/(1/2)=2\cdot2=4$. As a check, four halves fit into two whole units, and $4(1/2)=2$.

Step 4: Isolate the unknown. Subtract $1/2=3/6$ from both sides of $x/3+1/2=5/6$. This leaves $x/3=5/6-3/6=2/6=1/3$. Multiply both sides by $3$ to get $x=1$.

Step 5: Check the original equation. Substitution gives $1/3+1/2=2/6+3/6=5/6$, as required. Checking the original form can catch an arithmetic mistake introduced while rearranging. The same common-denominator steps will appear when we calculate fixed-point iterates.

Exercise 0.W3 — Easy: Read powers and a finite sum

Calculate $2^{-3}$ and $(1/2)^0$. Expand $\sum_{t=0}^{3}(1/2)^t$ into individual terms and add them. How many terms are there? Explain why $\sum_{t=1}^{3}(1/2)^t$ has a different value.

Review: Algebra warm-up

Show hint

A negative exponent takes a reciprocal. A sum includes both its starting and ending indices; the index is a placeholder replaced by each integer in that range.

Show worked solution

Step 1: Translate the exponent rules into arithmetic. $2^{-3}=1/2^3=1/(2\cdot2\cdot2)=1/8$. For a nonzero base, the zeroth power is $1$, so $(1/2)^0=1$. These are two different rules: a negative power takes a reciprocal, whereas a zeroth power supplies the starting unit.

Step 2: List the indices before evaluating. In $\sum_{t=0}^{3}(1/2)^t$, the symbol $t$ takes values $0,1,2,3$. The upper index is included. There are $3-0+1=4$ terms:

$$\sum_{t=0}^{3}(1/2)^t=1+\frac12+\frac14+\frac18.$$

Step 3: Add with one denominator. Writing all four terms in eighths gives $(8+4+2+1)/8=15/8=1.875$. The sum is less than $2$; we will later show that the infinite sum is exactly $2$.

Step 4: Change the starting index carefully. The second sum uses only $t=1,2,3$. Its value is $1/2+1/4+1/8=(4+2+1)/8=7/8$. It is smaller than the first sum by the omitted $t=0$ term, which is $1$. A horizon of $T$ terms starting at time $0$ therefore ends at time $T-1$, not time $T$.

Exercise 0.W4 — Easy: Solve an inequality without losing its direction

Solve $-3x+2\le8$ over the reals and write the answer as an interval. Then solve $1\le2x+3\lt7$. Check an endpoint, an interior point and an excluded point for each answer.

Review: Algebra warm-up

Show hint

Subtracting the same number preserves order. Dividing by a negative number reverses order. A double inequality imposes two conditions at once.

Show worked solution

Step 1: Remove the constant term. Subtract $2$ from both sides of $-3x+2\le8$, obtaining $-3x\le6$.

Step 2: Divide by the coefficient and account for its sign. The coefficient $-3$ is negative. Division reverses the inequality, so $x\ge6/(-3)=-2$. The complete solution set is $[-2,\infty)$. Its left endpoint is included because the original comparison allows equality; infinity is never an included real endpoint.

Step 3: Verify three inputs. At $x=-2$, the original left side is $6+2=8$, so the endpoint works. At $x=0$, it is $2\le8$, so this interior point works. At $x=-3$, it is $9+2=11\gt8$, so this excluded point fails. Had we kept the wrong direction when dividing, these checks would reveal it.

Step 4: Solve both sides of the double inequality. Subtract $3$ from all three expressions to obtain $-2\le2x\lt4$. Divide by the positive number $2$, preserving both directions: $-1\le x\lt2$. The solution interval is $[-1,2)$.

Step 5: Check both endpoint types. At $x=-1$, $2x+3=1$, so the non-strict lower condition holds. At $x=0$, the value is $3$, between $1$ and $7$. At $x=2$, the value is $7$, so the strict upper condition fails. The different brackets record different requirements.

Exercise 0.W5 — Medium: Turn an absolute-value test into an interval

Solve $|x-2|\le3$ and $x^2\le4$ over $\mathbb R$. Compare the latter with $x^2\lt4$. Show why taking a square root must keep both possible signs of $x$.

Review: Algebra warm-up

Show hint

For $r\ge0$, $|z|\le r$ means $-r\le z\le r$. Also $\sqrt{x^2}=|x|$ on the whole real line.

Show worked solution

Step 1: Read the distance condition. $|x-2|\le3$ says that $x$ is at most $3$ units from the centre $2$. Equivalently, $-3\le x-2\le3$. Adding $2$ to all three parts gives $-1\le x\le5$. Thus the answer is $[-1,5]$. Both endpoints have distance $3$ from the centre and are allowed.

Step 2: Take square roots between nonnegative quantities. The square-root function preserves their order, so $x^2\le4$ is equivalent to $\sqrt{x^2}\le\sqrt4$, or $|x|\le2$. It is not equivalent just to $x\le2$: that would incorrectly permit $x=-3$, whose square is $9$.

Step 3: Resolve the absolute value. If $x\ge0$, $|x|=x$, giving $0\le x\le2$. If $x\lt0$, $|x|=-x$, giving $-x\le2$, hence $x\ge-2$ after reversing the inequality when multiplying by $-1$. Combining the two branches gives $[-2,2]$.

Step 4: Track strictness. For $x^2\lt4$ the same argument gives $|x|\lt2$, hence $-2\lt x\lt2$. The answer is now $(-2,2)$. At $x=\pm2$, the square is exactly $4$, so those endpoints pass the non-strict question and fail the strict one. At $x=0$, both questions pass. This distinction later changes whether an iteration budget meets an error tolerance.

Exercise 0.W6 — Medium: Solve a power bound and round the iteration count

Find the smallest integer $k\ge0$ such that $3(1/2)^k\le0.1$. First solve for a real $k$ using logarithms, then check neighbouring integer powers. How does the reasoning change when you divide an inequality by $\log(1/2)$?

Review: Algebra warm-up

Show hint

Natural logarithms increase on positive numbers, but $\log(1/2)$ is negative. An integer budget must be rounded up after solving a lower bound on $k$.

Show worked solution

Step 1: Isolate the exponential. Divide the original inequality by $3\gt0$ to get $(1/2)^k\le1/30$. Both sides are positive, so applying the increasing natural logarithm preserves the direction:

$$k\log(1/2)\le\log(1/30).$$

Step 2: Check the sign before dividing. Since $0\lt1/2\lt1$, its logarithm is negative. Dividing reverses the inequality, giving $k\ge\log(1/30)/\log(1/2)=\log30/\log2\approx4.907$. The two minus signs cancel in the ratio; they do not remove the need to reverse the comparison.

Step 3: Choose an integer. The least integer at least $4.907$ is $5$, denoted $\lceil4.907\rceil$. Rounding to the nearest integer is not the general rule: a budget must satisfy the derived inequality.

Step 4: Verify without rounded logarithms. At $k=4$, the error expression is $3/16=0.1875\gt0.1$. At $k=5$, it is $3/32=0.09375\lt0.1$. Every increase in $k$ divides it by $2$, so all earlier integers also fail and all later ones pass. This establishes the smallest budget exactly, even though the logarithm calculation was approximate.

1. Sets, Quantifiers & Logic

Every safety statement in the modules has the same grammar: a set of states or parameters, a test its points must pass, and quantifiers saying whether one point, every point or every time step must pass it.

Definition — Set, subset, set-builder notation
A set is a collection of distinct elements; $x\in A$ means that $x$ is an element of $A$, and $x\notin A$ that it is not. $A\subseteq B$ ($A$ is a subset of $B$) means that every element of $A$ lies in $B$, and $A=B$ iff $A\subseteq B$ and $B\subseteq A$; $\emptyset$ is the empty set. Set-builder notation $\{x\in X:\ P(x)\}$ denotes the elements $x$ of an ambient set $X$ for which the statement $P(x)$ is true. Read it as a filter: run through $X$ and keep $x$ if it passes the test $P$. (Some papers and modules write $\subset$ for $\subseteq$; this page writes $\subsetneq$ for a proper subset.)

Example. For $h(x)=1-x_1^2-x_2^2$ the safe set $C=\{x\in\mathbb R^2:h(x)\ge0\}$ is the closed unit disc. $(0.6,0.8)\in C$, since $h=1-0.36-0.64=0$ (it lies on the edge), while $(1,1)\notin C$, since $h=-1$. Also $C\subseteq[-1,1]^2$, because $x\in C$ forces $x_i^2\le1$; the reverse inclusion fails, as $(1,1)$ shows.

Definition — Operations on sets
For $A,B\subseteq X$: $A\cup B$ (in $A$ or $B$ or both), $A\cap B$ (in both), $A\setminus B=\{x\in A:x\notin B\}$, the complement $A^c=X\setminus A$ (it depends on the ambient set $X$), the product $A\times B=\{(a,b):a\in A,\ b\in B\}$ of ordered pairs, the cardinality $|A|$ (number of elements of a finite $A$), and the set $2^X$ of all subsets of $X$. For sets $A_i$ indexed by $i\in I$:
$$\bigcup_{i\in I}A_i=\{x:\ x\in A_i\text{ for at least one }i\},\qquad \bigcap_{i\in I}A_i=\{x:\ x\in A_i\text{ for every }i\}.$$
De Morgan's laws: $\big(\bigcup_iA_i\big)^c=\bigcap_iA_i^c$ and $\big(\bigcap_iA_i\big)^c=\bigcup_iA_i^c$. Proof. $x\notin\bigcup_iA_i$ iff no $i$ has $x\in A_i$ iff $x\in A_i^c$ for every $i$; applying this to the sets $A_i^c$ and taking complements gives the second law. $\blacksquare$

Example. With $D=\{1,\dots,6\}$, $S=\{2,3\}$, $T=\{3,4,5\}$: $S\cup T=\{2,3,4,5\}$, $S\cap T=\{3\}$, $|D\setminus S|=|\{1,4,5,6\}|=4$, and $S\times\{1,2\}$ has $4$ pairs. Several constraints form an intersection, $\bigcap_i\{a: g_i(a)\ge0\}$; "a failure at some $t\le T$" is a union, $\bigcup_{t=0}^{T}\{x_t\notin C\}$.

Where this is used
Safe sets in Module 1; seeds $S_0\subseteq D$ and indexed unions in Module 4, pairs $A\times I$ in Module 4 and Module 6; $\{a:g_i(a)\ge0\ \forall i\}$ and $|S|$ in Module 6; $X\times U$ and $X\setminus X_F$ in Module 7; intersected intervals $C_t(x)=C_{t-1}(x)\cap Q_t(x)$ in Module 5.

Statements and implications

Definition — Connectives, converse, contrapositive
For statements $P,Q$ (each true or false): $\neg P$ (not $P$), $P\wedge Q$ (and), $P\vee Q$ (or, including both), $P\Rightarrow Q$ (if $P$ then $Q$; false only when $P$ is true and $Q$ false), and $P\Leftrightarrow Q$ (both directions). The converse of $P\Rightarrow Q$ is $Q\Rightarrow P$; its contrapositive is $\neg Q\Rightarrow\neg P$. An implication is equivalent to its contrapositive and to $\neg P\vee Q$, but not to its converse. "$P$ is sufficient for $Q$" means $P\Rightarrow Q$; "$P$ is necessary for $Q$" means $Q\Rightarrow P$.

Intuition and example. An implication is a promise, broken only when $P$ holds and $Q$ fails; if $P$ never holds it is vacuously true, so a condition checked on an empty set certifies nothing. "$x\gt2\Rightarrow x^2\gt4$" is true; its converse is false ($x=-3$); its contrapositive "$x^2\le4\Rightarrow x\le2$" is true. Module 14 requires $\big(D(\xi)\le0\ \wedge\ f_{\rm cl}(\xi)\in\mathcal B\big)\vee V(\xi)\ge\rho$ for all $\xi\in\mathcal B$, with $D(\xi)\le0$ a decrease condition on $V$ (the module writes $F$). Since $P\vee Q\equiv(\neg Q\Rightarrow P)$: whenever $V(\xi)\lt\rho$, $V$ decreases and the successor $f_{\rm cl}(\xi)$ stays in $\mathcal B$.

Common mistake — reading a certificate backwards
Certificates are sufficient conditions ("the LMI is feasible $\Rightarrow$ the loop is stable"), and a failed certificate proves nothing: "infeasible $\Rightarrow$ unstable" is the inverse $\neg P\Rightarrow\neg Q$, which is equivalent to the converse, not to the statement. The S-procedure of Module 2 is special because, for one constraint (and a strictly feasible point), its sufficient condition is also necessary.

Quantifiers, negation, and why their order matters

Definition — Quantifiers and their negation
"$\forall x\in X:\ P(x)$" (for all) is true iff every element of $X$ satisfies $P$; it is vacuously true if $X=\emptyset$. "$\exists x\in X:\ P(x)$" (there exists) is true iff at least one element does. Negation swaps them:
$$\neg\big(\forall x\in X: P(x)\big)\iff\exists x\in X: \neg P(x),\qquad \neg\big(\exists x\in X: P(x)\big)\iff\forall x\in X: \neg P(x).$$
To negate a chain of quantifiers, swap every $\forall\leftrightarrow\exists$ and negate the innermost statement. In set language, "for every $i$" is an intersection and "for some $i$" a union.

Intuition. In "$\forall x\ \exists y: P(x,y)$" you may answer each $x$ with its own $y$; "$\exists y\ \forall x: P(x,y)$" forces one $y$ before seeing $x$. Committing first is harder: $\exists y\,\forall x\,P$ implies $\forall x\,\exists y\,P$, but not conversely. Over $\mathbb R$, "$\forall x\ \exists y: y\gt x$" is true (answer $y=x+1$), while "$\exists y\ \forall x: y\gt x$" claims a largest real number and is false.

Worked example — one witness for all constraints, or one per constraint (Module 6)

A parameter $a$ is certified from evaluated parameters $a'\in S$ through a Lipschitz bound $L$ on constraint functions $g_i$ (larger is safer). Module 6 compares two rules that differ only in quantifier order (the module also subtracts an accuracy $\epsilon$ and adds $S$ itself):

$$\exists a'\in S\ \forall i:\ g_i(a')-L\|a-a'\|\ge0\qquad\text{versus}\qquad \forall i\ \exists a_i'\in S:\ g_i(a_i')-L\|a-a_i'\|\ge0 .$$

Take $S=\{0,2\}$, $a=1$, $L=1$ (both witnesses at distance $1$), $g_1(0)=2$, $g_1(2)=0.5$, $g_2(0)=0.5$, $g_2(2)=2$. Witness $0$ certifies constraint $1$ ($2-1\ge0$) but not constraint $2$ ($0.5-1\lt0$), and witness $2$ the opposite. No single witness works, so $a$ fails the first rule, but $a_1'=0$, $a_2'=2$ satisfy the second. Since "$\exists\forall$" implies "$\forall\exists$", the per-constraint rule always certifies at least as much.

Worked example — negating the viability kernel (Modules 1 and 7)

With $\mathcal U$ the admissible control signals and $\varphi^u_x(t)$ the state at time $t$ from $x$ under $u$, the viability kernel of Module 7 is $X_V=\{x:\ \exists u\in\mathcal U\ \forall t\ge0:\ \varphi^u_x(t)\notin X_F\}$: some control avoids the failure set $X_F$ forever. Swap the quantifiers and negate the inside: $X\setminus X_V=\{x:\ \forall u\in\mathcal U\ \exists t\ge0:\ \varphi^u_x(t)\in X_F\}$, every control fails at some time, which is the unviability kernel $X_U$ of Module 1. The failure time $t$ may depend on $u$.

Order inside probabilities. "$\forall t:\ \mathbb P(x_t\in C)\ge1-\delta$" is much weaker than "$\mathbb P(\forall t:\ x_t\in C)\ge1-\delta$": with independent $5\%$ failure chances per step, all $20$ steps are safe only with probability $0.95^{20}\approx0.358$. The union bound $\mathbb P(\exists t\le T: x_t\notin C)\le\sum_{t=0}^{T}\delta_t$ connects the two (Primer C).

Where this is used
Both certification rules in Module 6; "$\exists$ control $\forall$ time" in Module 7 and its complement in Module 1; the alternating quantifiers $\exists\beta\ \forall a(\cdot)\ \exists s$ of a reach-avoid game in Module 10; $\mathbb P(\exists t:x_t\notin C)$ in Module 1; "for every policy some parameterised policy is within $\epsilon$" in Module 2.
Common mistake — negating only the inside
The negation of "$\forall x\in C\ \exists u\in U: f(x,u)\in C$" ($C$ is control invariant) is "$\exists x\in C\ \forall u\in U: f(x,u)\notin C$" (some state of $C$ is lost whatever you do), not "$\forall x\ \exists u: f(x,u)\notin C$".

Reading aids. "Iff" (if and only if): prove both directions. "Without loss of generality" (WLOG): a reduction that loses no cases, by symmetry or by a change of variables. For example, an equilibrium $x^\ast$ of $x_{t+1}=F(x_t)$ is moved to the origin by $z=x-x^\ast$ and $\tilde F(z)=F(z+x^\ast)-x^\ast$, which gives $\tilde F(0)=0$; hence "WLOG $x^\ast=0$", provided constraint sets and functions such as $V$ are shifted too. "s.t." means "such that", or "subject to" in optimization.

Practice: Sets, Quantifiers & Logic

Start by listing elements and reading symbols aloud. The Medium exercises ask you to translate statements; the Hard exercises combine quantifiers with constraints. If a definition feels unfamiliar, revisit this section before trying again.

Guided build-up. Start with these smaller questions to practise the tools used by the graded exercises that follow.

Exercise 0.GS1 — Easy: Separate an element from a set of elements

Let $A=\{1,2\}$ and $B=\{\{1\},2\}$. Decide whether $1\in A$, $\{1\}\subseteq A$, $\{1\}\in A$, $\{1\}\in B$, and $\emptyset\subseteq A$. Find $|A|$ and $|B|$. Explain each test in words.

Review: Sets and logic

Show hint

Membership tests one listed object. A subset test examines the elements inside the proposed subset. The number $1$ and the set $\{1\}$ are different objects.

Show worked solution

Step 1: List the objects in each set. $A$ contains the numbers $1$ and $2$. $B$ contains the singleton set $\{1\}$ as one object and the number $2$ as another. Braces create a set; they are part of the object being described.

Step 2: Test membership. $1\in A$ is true because the number $1$ is listed. $\{1\}\in A$ is false because the singleton set is not either listed number. $\{1\}\in B$ is true because that singleton set is explicitly one of $B$'s two objects.

Step 3: Test a subset. $\{1\}\subseteq A$ means that every member of $\{1\}$ belongs to $A$. Its only member is the number $1$, and $1\in A$, so this statement is true. It does not ask whether the singleton itself is listed in $A$.

Step 4: Handle the empty set. $\emptyset\subseteq A$ means that every element of the empty set belongs to $A$. There is no element that could fail this test. Formally, a failure would require an $x\in\emptyset$ with $x\notin A$, and such an $x$ does not exist. The subset statement is therefore true; this is called a vacuously true universal statement.

Step 5: Count distinct elements. Both $|A|$ and $|B|$ are $2$. The singleton in $B$ counts as one element of $B$; we do not open it and count its contents again. Vertical bars around a finite set mean cardinality, whereas vertical bars around a real number mean absolute value. The type of the object determines which meaning applies.

Exercise 0.GS2 — Easy: Build a Cartesian product and read its pairs

For $X=\{a,b\}$ and $U=\{L,R\}$, list $X\times U$. Let $S=\{(a,L),(b,L),(b,R)\}$. Find the allowed inputs at each state, a rule choosing one allowed input per state, and every input allowed at both states. Compare $(a,L)$ with $(L,a)$.

Review: Sets and logic

Show hint

A product independently chooses one element of each set. Fixing the first coordinate gives one row of the safe-pair list.

Show worked solution

Step 1: Enumerate independent choices. Pair $a$ with each input to obtain $(a,L),(a,R)$. Pair $b$ with each input to obtain $(b,L),(b,R)$. Thus

$$X\times U=\{(a,L),(a,R),(b,L),(b,R)\}.$$

There are $|X||U|=2\cdot2=4$ pairs. The two choices form a product, rather than a sum of possibilities.

Step 2: Filter the product with $S$. At state $a$, only $(a,L)$ is listed in $S$, so the allowed-input set is $U(a)=\{L\}$. At $b$, both listed pairs are allowed, so $U(b)=\{L,R\}$.

Step 3: Choose a response after seeing the state. One rule is $\pi(a)=L$, $\pi(b)=R$. Each selected pair lies in $S$, so this rule satisfies “every state has an allowed input”. Choosing $L$ at both states would also be a valid rule; the question asks for one rule, not a unique rule.

Step 4: Require a shared input. A shared input must lie in the intersection $U(a)\cap U(b)=\{L\}\cap\{L,R\}=\{L\}$. Hence $L$ works at both states and $R$ fails at $a$. In this particular example, both quantifier orders succeed; they need not do so for every safe-pair list.

Step 5: Keep the coordinate roles. $(a,L)$ is an ordered pair with a state first and an input second. $(L,a)$ reverses these roles and is not a member of $X\times U$, since $L\notin X$ and $a\notin U$. Ordered pairs cannot be rearranged like the elements inside a set.

Exercise 0.GS3 — Easy: Read an implication with a truth table

Let $P$ mean “$x\gt2$” and $Q$ mean “$x\gt0$”, for real $x$. At $x=3,1,-1$, assess $P$, $Q$, and $P\Rightarrow Q$. Complete the four-row truth table for an abstract implication. Which row refutes an implication?

Review: Sets and logic

Show hint

“If $P$, then $Q$” rules out a true premise with a false conclusion. A false premise does not demand that the conclusion be false.

Show worked solution

Step 1: Translate the promise. $P\Rightarrow Q$ promises that whenever $P$ holds, $Q$ holds too. It does not promise the reverse, and it says nothing about the value of $Q$ when $P$ fails.

$P$$Q$$P\Rightarrow Q$
TrueTrueTrue: the promise is met.
TrueFalseFalse: the promise is broken.
FalseTrueTrue: its premise was not met.
FalseFalseTrue: its premise was not met.

Step 2: Substitute the three specified inputs. At $x=3$, both $3\gt2$ and $3\gt0$ are true, so the implication is true. At $x=1$, $1\gt2$ is false while $1\gt0$ is true, giving the third row. At $x=-1$, both comparisons are false, giving the fourth row. The implication is true at all three inputs.

Step 3: Prove the statement beyond those examples. If an arbitrary real $x$ satisfies $x\gt2$, transitivity with $2\gt0$ gives $x\gt0$. Thus no real input produces the failing second row, and the implication holds for every real $x$.

Step 4: Identify a counterexample correctly. An example with $P$ false cannot refute the implication. To refute its converse $Q\Rightarrow P$, use $x=1$: this makes $Q$ true and $P$ false. Counterexamples must check the premise and the conclusion separately.

Exercise 0.GS4 — Medium: Unpack a robust statement one choice at a time

Let $X=[-1,1]$, $U=[-1,1]$, and $W=[-1/4,1/4]$. Prove $\forall x\in X\ \exists u\in U\ \forall w\in W:\ |x+u+w|\le1/4$. Write its negation and explain which variables a chosen $u$ may depend on.

Review: Sets and logic

Show hint

Choose a command that cancels the observed state. Then keep that command fixed while testing every disturbance. Negating a non-strict bound makes it strict.

Show worked solution

Step 1: Read the quantifiers from left to right. First an arbitrary $x\in[-1,1]$ is given. We must now supply one $u\in[-1,1]$. Only after that choice is fixed must the test pass for every $w\in[-1/4,1/4]$. The command can depend on $x$ but cannot depend on the later disturbance.

Step 2: Construct and check the command. Set $u=-x$. From $-1\le x\le1$, multiplying by $-1$ gives $-1\le-x\le1$, so $u$ is allowed. This domain check is part of proving an existential claim.

Step 3: Prove the final universal condition. Keep $u=-x$ and take any permitted $w$. Then $x+u+w=x-x+w=w$. Its interval bounds imply $|w|\le1/4$, so $|x+u+w|\le1/4$. The endpoints $w=\pm1/4$ give equality and are allowed. Because no extra restriction was imposed on $x$ or $w$, the complete statement is proved.

Step 4: Negate every layer. Swap each universal quantifier with an existential one, and each existential quantifier with a universal one, without changing the domains. The negation is

$$\exists x\in X\ \forall u\in U\ \exists w\in W:\ |x+u+w|\gt1/4.$$

In words, some allowed state would defeat every legal command, with an allowed disturbance showing the failure of each command. It is false here: for any proposed state, the command $-x$ already passes all disturbances. A disturbance used to refute a command may depend on that command, because its existential quantifier comes afterwards.

Exercise 0.S1 — Easy: Read a set-builder expression

Let $X=\{-2,-1,0,1,2,3\}$, $A=\{x\in X:x^2\le4\}$, and $B=\{x\in X:x\gt0\}$. List $A$ and $B$. Is $2\in A$? Is $B\subseteq A$? Give a reason for each answer.

Review: sets and logic

Show hint
Test each element of $X$ separately. A subset claim fails if you find one element of $B$ outside $A$.
Show answer

Read the three layers of the notation. $X$ gives the candidate inputs; the colon means “such that”; $x^2\le4$ is the test each candidate must pass. We do not add numbers that pass the test but lie outside $X$. To list the set, go through every candidate once.

A set-builder expression is a filter. For $A$, start with the six numbers in $X$ and keep a number precisely when its square is at most $4$. Squaring means multiplying the number by itself; a negative number times a negative number is positive.

Input $x$SquareKeep in $A$?
$-2$$(-2)(-2)=4$Yes: $4\le4$.
$-1$$(-1)(-1)=1$Yes: $1\le4$.
$0$$0(0)=0$Yes: $0\le4$.
$1$$1(1)=1$Yes: $1\le4$.
$2$$2(2)=4$Yes: $4\le4$.
$3$$3(3)=9$No: $9\gt4$.

Therefore $A=\{-2,-1,0,1,2\}$. Equality is allowed by $\le$, so both $-2$ and $2$ stay.

For $B$, use the different test $x\gt0$. The negative numbers $-2,-1$ fail, and $0$ fails because it is equal to zero, not greater. The numbers $1,2,3$ pass. Hence $B=\{1,2,3\}$.

The membership statement $2\in A$ asks about one number. It is true: $2$ is in $X$ and $2^2=4\le4$. The subset statement $B\subseteq A$ asks whether every member of $B$ belongs to $A$. Checking $1$ and $2$ succeeds, but $3\in B$ and $3\notin A$. That one counterexample proves $B\not\subseteq A$.

Connect the calculation to interval notation. Over all real inputs, $x^2\le4$ means $|x|\le2$, hence $x\in[-2,2]$. In this question $A=X\cap[-2,2]$. Similarly $B=X\cap(0,\infty)$. This explains both exclusions: $3$ fails the first test and $0$ fails the second. Notice also that $-1\in A$ but $-1\notin B$, so the reverse subset claim $A\subseteq B$ is false as well. Overlapping sets need not contain one another.

Exercise 0.S2 — Easy: Union, intersection, difference and complement

Use the universe $X=\{0,1,2,3,4,5\}$ and sets $A=\{0,2,4\}$, $B=\{2,3,4\}$. Compute $A\cup B$, $A\cap B$, $A\setminus B$, and $A^c$.

Review: sets and logic

Show hint
Union means either set; intersection means both. For $A^c$, keep the elements of the stated universe that are outside $A$.
Show answer

Keep the starting set visible. The difference starts with $A$; the complement starts with the whole universe $X$. The union starts with every member of either listed set, and the intersection keeps only common members. Using the wrong starting set changes the question.

Use the membership rule for each operation: union means “in $A$ or in $B$”; intersection means “in both”; difference means “in $A$ and outside $B$”; complement means “in the stated universe $X$ and outside $A$”.

Union. Start with $A=\{0,2,4\}$. From $B=\{2,3,4\}$, the elements $2,4$ are already present, while $3$ is new. A set lists an element only once. Thus $A\cup B=\{0,2,3,4\}$. Neither $1$ nor $5$ is in either set, so neither is added.

Intersection. Test the three members of $A$: $0$ is not in $B$, but $2$ and $4$ are. These are all the possible common members, so $A\cap B=\{2,4\}$.

Difference. Begin with $A$ again, and remove its members that are also in $B$. Remove $2$ and $4$; keep $0$. Therefore $A\setminus B=\{0\}$. The element $3$ cannot appear in this difference because it was never in $A$.

Complement. Begin with all of $X=\{0,1,2,3,4,5\}$, and remove $0,2,4$, the members of $A$. What remains is $A^c=X\setminus A=\{1,3,5\}$. Numbers outside $X$, such as $6$, are not in this complement: the universe is part of its definition.

Check the answers by reconstructing a partition. The intersection $\{2,4\}$ together with $A\setminus B=\{0\}$ reconstructs $A=\{0,2,4\}$. Separately, $B\setminus A=\{3\}$; combining these three disjoint pieces reconstructs the union $\{0,2,3,4\}$. Finally $A\cup A^c=X$ and $A\cap A^c=\emptyset$, as a complement requires. The counts give a second check: $|A\cup B|=|A|+|B|-|A\cap B|=3+3-2=4$. The subtraction removes the double counting of the common elements.

Exercise 0.S3 — Easy: True or false, with a witness

Decide whether each statement is true. Explain a true universal statement, give a witness for a true existential statement, and explain why a false statement fails.

  1. $\forall x\in\mathbb R:\ x^2\ge0$.
  2. $\exists x\in\mathbb R:\ x^2=-1$.
  3. For every real $x$ there is a real $y$ with $y=x+2$.
  4. There is one real $y$ such that $y=x+2$ for every real $x$.

Review: sets and logic

Show hint
In the third statement you may choose $y$ after seeing $x$. In the fourth, fix $y$ first and try $x=y$.
Show answer

Choose the proof method from the quantifier. To prove a universal claim, start with an arbitrary permitted input and keep the reasoning general. To prove an existential claim, exhibit one permitted witness and check it. To disprove an existential claim, show that every candidate fails; one unsuccessful guess is insufficient.

(1) Every real square is nonnegative: true. Take any real $x$. If $x=0$, then $x^2=0$. If $x\gt0$, the product $x\cdot x$ is positive. If $x\lt0$, write $x=-a$ with $a\gt0$; then $x^2=(-a)(-a)=a^2\gt0$. These cases cover every real number, so $x^2\ge0$ for every $x\in\mathbb R$.

(2) Some real square equals $-1$: false. An existential claim needs at least one permitted input. Part (1) says every permitted square is at least $0$, whereas $-1\lt0$. Thus no real input can satisfy $x^2=-1$.

(3) For every $x$ there is a $y$ with $y=x+2$: true. First take an arbitrary real $x$. We may now choose $y=x+2$. A real number plus $2$ is real, so the chosen $y$ lies in the required domain. Substituting that choice into the equation gives $x+2=x+2$, which is true. The choice may depend on the $x$ we were given.

(4) One $y$ works for every $x$: false. Suppose someone fixes a real $y$ first. The phrase “every real $x$” includes the choice $x=y$. For that input, the required equation becomes $y=y+2$. Subtract $y$ from both sides to obtain $0=2$, a contradiction. Hence no proposed fixed $y$ works. The distinction is the order of the choices: a separate answer to each input can exist even though one shared answer does not.

Trace the dependency with two inputs. In statement (3), $x=0$ permits $y=2$, and $x=1$ permits $y=3$. There is no conflict because the choices are made separately. Statement (4) would require the same $y$ to equal both $2$ and $3$. These two allowed inputs already disprove that stronger statement. This is why reversing quantifiers can change the truth even when the equation inside them is unchanged.

Exercise 0.S4 — Medium: Negate every quantifier

Negate both statements, keeping the domains unchanged. Then decide whether the original statements are true.

  1. $\forall x\in\mathbb R:\ x^2\ge1$.
  2. There exists $x\in[0,1]$ such that $x\gt y$ for every $y\in[0,1]$.

Review: sets and logic

Show hint
Swap every “for every” with “there exists”, then negate the final comparison. The negation of a strict inequality includes equality.
Show answer

Negate the entire statement, not one convenient part. For a condition $P(x)$, $\neg(\forall x\in D:P(x))$ is $\exists x\in D:\neg P(x)$, and $\neg(\exists x\in D:P(x))$ is $\forall x\in D:\neg P(x)$. Apply this rule to the outer layer, then repeat on the statement inside it. A domain restriction remains in place.

(1) Negate $\forall x\in\mathbb R:\ x^2\ge1$. A universal statement fails when at least one allowed input fails its test. Replace “for every” by “there exists”, and negate $x^2\ge1$ to $x^2\lt1$:

$$\neg(\forall x\in\mathbb R:\ x^2\ge1) \quad\Longleftrightarrow\quad \exists x\in\mathbb R:\ x^2\lt1.$$

Choose $x=0$, which is a real number. Its square is $0\cdot0=0$, and $0\lt1$. The negation is true, so the original statement is false.

(2) Negate $\exists x\in[0,1]\ \forall y\in[0,1]:x\gt y$. The outer “there exists $x$” becomes “for every $x$”. For each such $x$, the inner “for every $y$” becomes “there exists $y$”. Finally, “$x$ is greater than $y$” fails when $x$ is less than or equal to $y$. Therefore the full negation is

$$\forall x\in[0,1]\ \exists y\in[0,1]:\ x\le y.$$

To prove it, take any allowed $x$ and choose $y=x$. The choice is in $[0,1]$ because $x$ is, and $x\le x$ holds with equality. Thus the negation is true and the original is false. In the original, the same choice $y=x$ directly breaks the strict condition $x\gt y$. No endpoint exception is possible: this works at $x=0$, at $x=1$, and between them. The domains stay unchanged throughout.

Check strictness at equality. The negation of $x\gt y$ is $x\le y$, because equality also makes the original strict claim fail. Replacing it with $x\lt y$ would miss exactly the witness $y=x$ used above. Likewise the negation of $x^2\ge1$ is $x^2\lt1$, not $x^2\le1$: a square equal to $1$ satisfies the original test. The comparison and the quantifier must both be negated correctly.

Exercise 0.S5 — Medium: Converse, contrapositive and necessary conditions

For real $x$, consider $P$: “$x\gt3$” and $Q$: “$x^2\gt9$”. Write and assess $P\Rightarrow Q$, its converse, and its contrapositive. In the original implication, is $P$ necessary or sufficient for $Q$? What is $Q$ for $P$?

Review: sets and logic

Show hint
Try a negative number for the converse. “$P$ is sufficient for $Q$” means $P$ guarantees $Q$.
Show answer

Separate the three arrows before testing them. An implication only fails when its premise is true and its conclusion false. The converse swaps the two statements. The contrapositive swaps them and negates both. These are different constructions, so a counterexample to the converse need not threaten the original implication.

Original implication. Here $P$ means $x\gt3$ and $Q$ means $x^2\gt9$. To test $P\Rightarrow Q$, assume $x\gt3$. Then $x-3\gt0$, and adding $3$ gives $x+3\gt6\gt0$. The product of these two positive factors is positive:

$$x^2-9=(x-3)(x+3)\gt0.$$

Adding $9$ yields $x^2\gt9$. This proves the implication for every input satisfying its premise. For an input with $x\le3$, the implication makes no promise that $Q$ must be false.

Converse. Reverse the arrow: $x^2\gt9\Rightarrow x\gt3$. At $x=-4$, the square is $(-4)(-4)=16\gt9$, so the premise is true. But $-4\lt3$, so the conclusion is false. An implication fails at any input with a true premise and a false conclusion; therefore this converse is false.

Contrapositive. Negate each statement and reverse their order. The negation of $Q$ is $x^2\le9$; the negation of $P$ is $x\le3$. Thus the contrapositive is $x^2\le9\Rightarrow x\le3$. The square-root function preserves order between nonnegative numbers, giving $\sqrt{x^2}\le\sqrt9$, or $|x|\le3$. If $x\ge0$, this means $x\le3$. If $x\lt0$, then already $x\lt0\lt3$; also $|x|=-x\le3$ gives $x\ge-3$ after multiplying by $-1$ and reversing the inequality. Hence the premise implies $-3\le x\le3$, and in particular $x\le3$. The contrapositive is true, as equivalence with the original implication predicts.

Necessary and sufficient. $P$ is sufficient for $Q$: knowing $P$ guarantees $Q$. Equivalently, $Q$ is necessary for $P$: every input with $P$ must also have $Q$. But $P$ is not necessary for $Q$, because the input $-4$ has $Q$ without $P$. Equivalently, $Q$ is not sufficient for $P$. A necessary condition need not guarantee the conclusion on its own.

See the conditions as sets. The inputs satisfying $P$ form $(3,\infty)$. Those satisfying $Q$ form $(-\infty,-3)\cup(3,\infty)$ because $x^2\gt9$ means $|x|\gt3$. The first set is contained in the second, which is exactly $P\Rightarrow Q$. The second also has a negative branch, which prevents the reverse inclusion. “Sufficient” describes a condition whose set is contained in the desired set; “necessary” describes a condition that must contain all successful inputs.

Exercise 0.S6 — Medium: An infinite union and intersection

For each integer $k\ge1$, let $A_k=[-1/k,1/k]$. Find $\bigcup_{k\ge1}A_k$ and $\bigcap_{k\ge1}A_k$. Justify why no nonzero real number lies in the intersection.

Review: sets and logic

Show hint
$A_1$ contains every later interval. For a nonzero $x$, choose an integer $k\gt1/|x|$.
Show answer

Inspect the first few intervals. $A_1=[-1,1]$, $A_2=[-1/2,1/2]$, $A_3=[-1/3,1/3]$. The sets shrink as $k$ grows. A union needs one successful membership test; an intersection needs all of them, however large the index becomes.

Union: membership in at least one interval. At $k=1$, $A_1=[-1,1]$. For every integer $k\ge1$, the positive reciprocal satisfies $0\lt1/k\le1$. Thus any $x\in A_k$ satisfies

$$-1\le-1/k\le x\le1/k\le1.$$

Every interval is contained in $[-1,1]$, so the union has no points outside that interval. Conversely, every point of $[-1,1]$ is already in $A_1$, hence in the union. These two inclusions prove $\bigcup_{k\ge1}A_k=[-1,1]$.

Intersection: membership in every interval. For every $k\ge1$, $-1/k\le0\le1/k$, so $0$ belongs to every $A_k$ and therefore to their intersection.

Now take any $x\ne0$. Its absolute value is positive, so $1/|x|$ is a finite positive number. Integers have no finite upper bound; choose an integer $k\gt1/|x|$. Multiply by the positive number $|x|$, then divide by the positive integer $k$:

$$k\gt\frac1{|x|} \quad\Longrightarrow\quad k|x|\gt1 \quad\Longrightarrow\quad |x|\gt\frac1k.$$

A point belongs to $[-1/k,1/k]$ exactly when $|x|\le1/k$. Our strict opposite inequality shows $x\notin A_k$. Intersection membership requires every test to pass, so this one failed test excludes $x$. No nonzero real point remains, and $\bigcap_{k\ge1}A_k=\{0\}$. The intersection is not empty: all intervals still share their centre.

Make the excluding index explicit. For a given nonzero $x$, $k=\lfloor1/|x|\rfloor+1$ is an integer strictly larger than $1/|x|$. If $x=0.01$, this rule gives $k=101$, and $1/101\lt0.01$, so $x$ fails membership in $A_{101}$. It passes the first hundred intervals, showing why finitely many successful checks do not prove an infinite intersection claim. The excluding index is chosen after $x$ is given, so it may depend on $x$.

Exercise 0.S7 — Hard: Prove De Morgan’s law for an interval

In the universe $\mathbb R$, set $A=\{x:x\ge-1\}$ and $B=\{x:x\le2\}$. Find $(A\cap B)^c$. Prove that it equals $A^c\cup B^c$ by following an arbitrary real $x$ through the membership conditions.

Review: sets and logic

Show hint
Outside “both conditions hold” means “at least one condition fails”. Pay attention to whether the endpoints remain.
Show answer

Translate set membership into two scalar tests. $x\in A\cap B$ means simultaneously $x\ge-1$ and $x\le2$. Being outside the intersection means that this joint requirement fails. One failure is enough; both failures are not required.

Membership in $A$ requires $x\ge-1$, while membership in $B$ requires $x\le2$. Membership in the intersection requires both tests. Hence

$$A\cap B=\{x\in\mathbb R:-1\le x\le2\}=[-1,2].$$

The complement is taken in $\mathbb R$. A real point outside $[-1,2]$ is either less than $-1$ or greater than $2$. Therefore $(A\cap B)^c=(-\infty,-1)\cup(2,\infty)$. Both endpoints are excluded: $-1$ and $2$ pass both original non-strict tests.

For the equality proof, take an arbitrary real $x$. Apply the definitions one at a time:

$$\begin{aligned} x\in(A\cap B)^c &\iff x\notin A\cap B\\ &\iff \neg(x\in A\ \wedge\ x\in B)\\ &\iff (x\notin A)\ \vee\ (x\notin B)\\ &\iff (x\in A^c)\ \vee\ (x\in B^c)\\ &\iff x\in A^c\cup B^c. \end{aligned}$$

The middle step says that “both tests pass” fails precisely when at least one fails. Here failure of $x\ge-1$ means $x\lt-1$, and failure of $x\le2$ means $x\gt2$. A point in the middle interval fails neither condition; a point to the left fails the first, and one to the right fails the second. Thus $A^c=(-\infty,-1)$ and $B^c=(2,\infty)$, giving the same complement. The equivalences hold for every real $x$ and in both directions, so the sets have exactly the same members and are equal.

Verify the endpoint and the two sides. At $x=-1$ or $x=2$, both original conditions hold, so neither point belongs to the complement. At $x=-2$, the first condition fails and the second holds; that still puts the point in $A^c\cup B^c$. At $x=3$, the second fails and the first holds, with the same conclusion. No real point can fail both $x\ge-1$ and $x\le2$: that would require $x\lt-1$ and $x\gt2$ at once. The complement therefore uses “or”, not “and”, even in this concrete example.

Exercise 0.S8 — Hard: One input per state or one input for all states

Let $X=\{a,b,c\}$ be states and $U=\{L,R\}$ be inputs. A pair is safe exactly when it belongs to $S=\{(a,L),(b,R),(c,L),(c,R)\}$. Decide whether each statement is true:

  1. For every $x\in X$ there exists $u\in U$ with $(x,u)\in S$.
  2. There exists $u\in U$ such that $(x,u)\in S$ for every $x\in X$.

Negate statement (1) and assess its negation.

Review: sets and logic

Show hint
List the permitted inputs at each state. A single input must appear in all three lists.
Show answer

Use a row for each observed state. A state-dependent choice asks whether every row has at least one safe pair. A shared choice asks whether some input column is safe in every row. These are different tests on the same finite list.

Read the safe-pair list before changing any quantifiers. At state $a$, the list contains $(a,L)$ and not $(a,R)$, so the safe inputs are $\{L\}$. At $b$, only $(b,R)$ occurs, giving $\{R\}$. At $c$, both pairs occur, giving $\{L,R\}$.

(1) One permitted choice for each state: true. “For every $x$ there exists $u$” allows us to see the state before choosing the input. Choose $L$ at $a$, $R$ at $b$, and $L$ at $c$. The corresponding pairs $(a,L),(b,R),(c,L)$ are all explicitly in $S$. These choices cover all three states, so the universal statement is proved.

(2) One input shared by all states: false. There are only two candidate shared inputs. If we fix $L$, the test at $b$ fails because $(b,L)\notin S$. If we fix $R$, the test at $a$ fails because $(a,R)\notin S$. Every candidate is ruled out. Equivalently, the common safe-input set is $\{L\}\cap\{R\}\cap\{L,R\}=\emptyset$.

Negation of (1). Swap the outer universal quantifier for an existential one, swap the inner existential quantifier for a universal one, and negate membership:

$$\exists x\in X\ \forall u\in U:\ (x,u)\notin S.$$

This says that some state has no safe input at all. It is false: $a$ has the safe choice $L$, $b$ has $R$, and $c$ has both. At each proposed state, that permitted choice disproves “every input fails”. There can therefore be a safe response at every state while there is no single safe input for all states.

Translate both statements into set tests. With $U(a)=\{L\}$, $U(b)=\{R\}$ and $U(c)=\{L,R\}$, statement (1) is equivalent to $U(x)\ne\emptyset$ for every state $x$. Statement (2) is equivalent to $U(a)\cap U(b)\cap U(c)\ne\emptyset$. The first succeeds because each set has a member; the second fails because the first two share none. Negating (1) asks for one empty row, whereas negating (2) only asks for a failing row for each proposed shared input. The two failures have different witnesses.

Exercise 0.S9 — Hard: Find the parameter range for a quantified claim

Let $a\ge0$, $C=[-1,1]$, and $U=[-a,a]$. An input $u$ cancels a state $x$ when $x+u=0$. For which $a$ is it true that every $x\in C$ has a cancelling $u\in U$? For which $a$ can one fixed $u\in U$ cancel every $x\in C$? Prove both answers.

Review: sets and logic

Show hint
Solve for the only possible input, $u=-x$. Use $x=1$ to test the size of $U$, then compare $x=1$ and $x=-1$ for a shared input.
Show answer

Read “for which $a$” as an exact characterization. We must prove both that every parameter in the proposed range works and that every parameter outside it fails. A successful construction at one value would establish neither of these complete claims.

First solve the cancellation equation for its only possible input. Subtracting $x$ from $x+u=0$ gives $u=-x$. We must check whether this required input lies in $[-a,a]$; solving the equation alone does not establish admissibility.

A separate cancelling input for every state. For necessity, use the allowed boundary state $x=1$. Its only cancelling input is $u=-1$. Membership in $[-a,a]$ requires both $-a\le-1$ and $-1\le a$. The second holds automatically for $a\ge0$. Multiplying the first inequality by $-1$ reverses its direction and gives $a\ge1$. Thus the quantified claim cannot hold when $a\lt1$.

For sufficiency, assume $a\ge1$ and take any $-1\le x\le1$. Multiply the two bounds by $-1$, reversing their order, to obtain $-1\le-x\le1$. Choose $u=-x$. Because $a\ge1$, we have $-a\le-1$ and $1\le a$, so

$$-a\le-1\le u\le1\le a.$$

This proves $u\in U$, and substitution gives $x+u=x+(-x)=0$. It works for every allowed state. Hence the exact range is $a\in[1,\infty)$. Equality $a=1$ works, including $x=\pm1$; at $a=0$ only input $0$ is allowed, which cannot cancel $x=1$.

One fixed input for all states. If such an input existed, the allowed state $x=1$ would force $1+u=0$, hence $u=-1$. The other allowed state $x=-1$ would force $-1+u=0$, hence $u=1$. A single real number cannot equal both $-1$ and $1$. Thus no $a\ge0$, however large, makes this stronger statement true. Increasing the input interval can provide more state-dependent choices; it cannot make the uniquely required values equal.

Check a small actuator range directly. At $a=1/2$, the state $x=1/4$ can be cancelled by $u=-1/4$, which lies in $[-1/2,1/2]$. But $x=1$ needs $u=-1$, outside that interval. Thus one successful interior-state check does not prove the universal claim. At the limiting value $a=1$, every required $-x$ is available, including the endpoint commands. The parameter threshold arises from actuator feasibility, while the impossibility of a shared command arises from incompatible equations; these are separate reasons for failure.

2. Functions, Maps & Fixed Points

Controllers, networks, Bellman operators and SafeOpt's set expansion are functions, and many safety objects are their fixed points.

Definition — Function, image, preimage, composition, restriction
A function $f:X\to Y$ assigns to each $x$ in its domain $X$ exactly one value $f(x)$ in its codomain $Y$. For $A\subseteq X$ and $B\subseteq Y$, the image is $f(A)=\{f(x): x\in A\}$ and the preimage is $f^{-1}(B)=\{x\in X: f(x)\in B\}$. The composition of $f$ with $g:Y\to Z$ is $(g\circ f)(x)=g(f(x))$; the restriction $f|_A$ is $f$ with domain $A$. A function of several variables lives on a product, e.g. dynamics $f:X\times U\to\mathbb R^n$.

Intuition and example. The image collects outputs, the preimage the inputs that land in $B$. Safe sets and sublevel sets are preimages: $C=\{x:h(x)\ge0\}=h^{-1}([0,\infty))$, the zero level set is $h^{-1}(\{0\})$, and $\mathcal V(c)=\{x:V(x)\le c\}=V^{-1}((-\infty,c])$. For $f(x)=x^2$: $f([-1,2])=[0,4]$, $f^{-1}([1,4])=[-2,-1]\cup[1,2]$, $f^{-1}([-3,-1])=\emptyset$, and $f^{-1}(\{1\})=\{-1,1\}$, although $f$ has no inverse.

Fact — Preimages respect set operations; images only unions
$f^{-1}(B_1\cap B_2)=f^{-1}(B_1)\cap f^{-1}(B_2)$, likewise for $\cup$, and $f^{-1}(Y\setminus B)=X\setminus f^{-1}(B)$. Proof of the first: $x$ belongs to either side iff $f(x)\in B_1$ and $f(x)\in B_2$. $\blacksquare$ So several constraints give $C=\bigcap_ih_i^{-1}([0,\infty))$. Images respect unions, $f(A_1\cup A_2)=f(A_1)\cup f(A_2)$, but for intersections only $f(A_1\cap A_2)\subseteq f(A_1)\cap f(A_2)$ holds: for $f(x)=x^2$, $A_1=\{-1\}$ and $A_2=\{1\}$ the left side is empty and the right side is $\{1\}$. Images introduce "there exists": the projection $\pi_X(a,x)=x$ maps a set $S$ of pairs to $\pi_X(S)=\{x: \exists a,\ (a,x)\in S\}$.
Where this is used
Safe sets and equilibria $F(x^\ast)=x^\ast$ in Module 1; sublevel sets in Module 11; $h|_C$ and a domain $D\supseteq C$ in Module 10; the projection $P_X(S)$ in Module 6; slices $Q_V[x]=\{u:(x,u)\in Q_V\}$ in Module 7.

Injective, surjective, inverse. $f:X\to Y$ is injective if $f(x)=f(x')\Rightarrow x=x'$, surjective if $\forall y\ \exists x: f(x)=y$, and bijective if both; then an inverse $f^{-1}:Y\to X$ with $f^{-1}(f(x))=x$ and $f(f^{-1}(y))=y$ exists. $2x+1$ is bijective on $\mathbb R$; $x^2$ is neither on $\mathbb R$, but bijective on $[0,\infty)$ with inverse $\sqrt y$; $x\mapsto Ax$ is bijective iff $A$ is square and invertible. Strictly increasing functions are injective, which is why Module 5 can invert a continuity modulus $\phi$. Pitfall: $f^{-1}(B)$ of a set is a preimage and always exists; $f^{-1}(y)$ of a point needs a bijection.

Definition — Set-valued map, relation, operator on sets
A set-valued map $F:X\rightrightarrows Y$ assigns to each $x$ a set $F(x)\subseteq Y$, possibly empty; its graph $\{(x,y):y\in F(x)\}\subseteq X\times Y$ is a relation, and a function is the case where every $F(x)$ has one element. An operator on sets $\Phi:2^X\to2^X$ maps subsets to subsets, e.g. $\operatorname{Pre}(S)=\{x:\ \exists u\in U,\ f(x,u)\in S\}$, the states from which some input leads into $S$. A relation $R\subseteq\mathbb R\times\mathbb R$ is monotone if $(a-a')(b-b')\ge0$ for all $(a,b),(a',b')\in R$.

Examples. Admissible inputs of a safety filter, a GP confidence interval $x\mapsto[\mu_t(x)\pm\beta_t\sigma_t(x)]$, successor sets $\{f(x,u):u\in U\}$. The sign relation $\{(a,1):a\gt0\}\cup\{(0,b):|b|\le1\}\cup\{(a,-1):a\lt0\}$ is monotone but, with its vertical segment, not a function. Used in Module 10, Module 12 (activations replaced by $\Delta v\mapsto\{D\Delta v: D\text{ diagonal, entries in }[\alpha,\beta]\}$) and Module 14 (monotone relations).

Fixed points and contractions

Definition — Fixed point, fixed-point iteration, contraction
$x^\ast$ is a fixed point of $g:X\to X$ if $g(x^\ast)=x^\ast$. Fixed-point iteration picks $x_0\in X$ and sets $x_{k+1}=g(x_k)$. $g$ is a contraction with factor $L\in[0,1)$ if $\|g(x)-g(y)\|\le L\|x-y\|$ for all $x,y\in X$: a Lipschitz map with constant below $1$ (Primer B).

Intuition and example. In one dimension fixed points are where the graph of $g$ crosses the diagonal $y=x$; the iteration walks a staircase ("cobweb") between graph and diagonal, which a contraction pulls into the crossing (see the explorer). For $g(x)=0.5x+1$, solving $x=0.5x+1$ gives $x^\ast=2$. From $x_0=0$: $x_1=1$, $x_2=1.5$, $x_3=1.75$, $x_4=1.875$; the errors $2,1,0.5,0.25,0.125$ halve because $|g(x)-g(y)|=0.5|x-y|$. This is value iteration $V_{k+1}=1+\gamma V_k$ for one state with reward $1$ and $\gamma=0.5$: the iterates are the partial sums $1+\gamma+\dots+\gamma^{k-1}$ of Section 4, with limit $1/(1-\gamma)$.

Theorem — Banach fixed-point theorem (contraction mapping theorem)
Assumptions. $X\subseteq\mathbb R^n$ is nonempty and closed (it contains the limits of its convergent sequences, Section 6); $g$ maps $X$ into $X$; $g$ is a contraction with factor $L\in[0,1)$.
Conclusion. $g$ has exactly one fixed point $x^\ast\in X$, the iterates converge to it from every $x_0\in X$, and for all $k$
$$\|x_k-x^\ast\|\le L^k\,\|x_0-x^\ast\|,\qquad \|x_k-x^\ast\|\le\frac{L^k}{1-L}\,\|x_1-x_0\| .$$
In words. One fixed point, reached from anywhere at a geometric rate; the a priori bound needs only the first step, so it predicts how many iterations suffice.
Why each assumption matters. $L\lt1$: $g(x)=x+1$ ($L=1$) has no fixed point, and $g(x)=-x$ ($L=1$) makes $x_0,-x_0,x_0,\dots$ oscillate. Self-map: $g(x)=x/2+1$ contracts on $[0,1]$ but its fixed point $2$ lies outside. Closedness: $g(x)=x/2$ maps $(0,1]$ into itself, yet the iterates tend to $0\notin(0,1]$. It holds in every complete normed space (Primer A), e.g. for value functions.

Proof of uniqueness and of the first bound. If $g(x^\ast)=x^\ast$ and $g(y^\ast)=y^\ast$, then $\|x^\ast-y^\ast\|=\|g(x^\ast)-g(y^\ast)\|\le L\|x^\ast-y^\ast\|$, so $(1-L)\|x^\ast-y^\ast\|\le0$ and $x^\ast=y^\ast$. Also $\|x_k-x^\ast\|=\|g(x_{k-1})-g(x^\ast)\|\le L\|x_{k-1}-x^\ast\|$, and $k$ repetitions give $L^k\|x_0-x^\ast\|$. $\blacksquare$ Existence and the a priori bound need limits and the geometric series: walkthrough in Section 4.

Where this is used
Value iteration as a $\gamma$-contraction (Primer E); discounted safety Bellman equations with a unique fixed point in Module 10 and Module 9; the constraint-cost evaluation operator in Module 11; equilibrium layers $z=\sigma(Wz+Ux+b)$ in Primer E and Module 13. If the closed-loop map $F$ is a contraction, two trajectories satisfy $\|x_t-y_t\|\le L^t\|x_0-y_0\|$: this incremental stability (contraction) is certified in Module 2, Module 11 and Module 14.
Pitfall — convergence is not contraction
$g(x)=x/(1+x^2)$ sends every start to $0$ ($|g(x)|\lt|x|$ for $x\ne0$), but $g'(0)=1$, so no $L\lt1$ works near $0$, and convergence is slow: from $x_0=1$, $x_{10}\approx0.209$, $x_{100}\approx0.0700$, $x_{1000}\approx0.0223$, close to $1/\sqrt{2k}$. Under the strict-decrease, continuity and compactness hypotheses of Section 6, a Lyapunov function ($V=x^2$ here) proves convergence to the equilibrium; it gives no uniform geometric estimate $\|x_t-y_t\|\le q^t\|x_0-y_0\|$ with $q\lt1$ between two trajectories, and none exists here.

Monotone set operators and their limits

Fact — Monotone iteration on a finite set
An operator $\Phi:2^D\to2^D$ is monotone if $A\subseteq B\Rightarrow\Phi(A)\subseteq\Phi(B)$; $S$ is a fixed point if $\Phi(S)=S$. Let $D$ be finite and $\Phi$ monotone, and iterate $S_{k+1}=\Phi(S_k)$.
(a) If $S_0\subseteq\Phi(S_0)$, then $S_0\subseteq S_1\subseteq\cdots$ with at most $|D|-|S_0|$ strict increases, and the final set $\bar S$ is the least fixed point containing $S_0$.
(b) If $\Phi(X^0)\subseteq X^0$, then $X^0\supseteq X^1\supseteq\cdots$ with at most $|X^0|$ strict decreases, and the final set is the greatest fixed point contained in $X^0$.

Proof of (a). If $S_{k-1}\subseteq S_k$, monotonicity gives $S_k=\Phi(S_{k-1})\subseteq\Phi(S_k)=S_{k+1}$, so by induction the sets grow. Each strict increase adds one of the $|D|-|S_0|$ points outside $S_0$. Once $S_{k+1}=S_k$, all later sets are equal and $\Phi(\bar S)=\bar S$. If $T\supseteq S_0$ is a fixed point, $S_k\subseteq T$ implies $S_{k+1}=\Phi(S_k)\subseteq\Phi(T)=T$, so $\bar S\subseteq T$. (b) reverses the inclusions. $\blacksquare$

Worked example (SafeOpt's reachable set, Module 4). Grid $D=\{0,\dots,8\}$, distance $|x-x'|$, Lipschitz constant $L=1$, threshold $h=0$ (safe means $f(x)\ge0$), no estimation error. The operator $R(S)=S\cup\{x\in D:\ \exists x'\in S:\ f(x')-L|x-x'|\ge h\}$ certifies $x$ through a witness whose value exceeds the threshold by $L$ times the distance; it is monotone and $S\subseteq R(S)$. With $f=(1.8,\,2.3,\,1.4,\,2.4,\,1.4,\,2.4,\,1.4,\,0.4,\,1.4)$ (consecutive values differ by at most $1$, so $f$ is $1$-Lipschitz) and $S_0=\{0\}$:

$k$$S_k$new points (witness check)
1$\{0,1\}$$1$ from $x'=0$: $1.8-1\ge0$
2$\{0,\dots,3\}$$2,3$ from $x'=1$: $2.3-2\ge0$
3$\{0,\dots,5\}$$4,5$ from $x'=3$: $2.4-2\ge0$
4$\{0,\dots,7\}$$6,7$ from $x'=5$: $2.4-2\ge0$
5$\{0,\dots,7\}$none: the fixed point $\bar R(S_0)$

Four strict increases, well within $|D|-|S_0|=8$. Point $8$ is safe ($f(8)=1.4$) but unreachable: every witness fails, e.g. $0.4-1\lt0$ from $7$ and $2.4-3\lt0$ from $5$. This is remark (ii) of Module 4. Shrinking iterations compute viability kernels: $X^0=X\setminus X_F$, $X^{k+1}=X^k\cap\operatorname{Pre}(X^k)$ keeps the states from which some input stays in the current set; by (b) it stops at the largest $Y\subseteq X\setminus X_F$ with $Y\subseteq\operatorname{Pre}(Y)$. Game and shield papers write greatest fixed points as $\nu X.(\cdots)$, least ones as $\mu X.(\cdots)$. Reachability in a directed graph is the least fixed point of $X\mapsto S\cup\operatorname{Post}(X)$, found by breadth-first search (Module 6 adds Dijkstra's shortest paths). Caution: SafeOpt's "closure" is this fixed point, not a topological closure, and on continuous domains the iteration need not stop.

Where this is used
SafeOpt's closure $\bar R_\epsilon(S_0)$, "reached after at most $|D|$ steps", in Module 4 and its per-constraint variants in Module 6; reachability and return operators in Module 6; the viability iteration in Module 7; greatest fixed points $\nu X.\,F^g\cap\mathrm{CPre}(X)$ for safety games and shields in Module 7 and Module 10.

Practice: Functions, Maps & Fixed Points

The Easy exercises refresh function notation and substitution. Medium adds preimages and contraction estimates; Hard asks you to explain which assumptions make an argument work. If a definition feels unfamiliar, revisit this section before trying again.

Guided build-up. Start with these smaller questions to practise the tools used by the graded exercises that follow.

Exercise 0.GF1 — Easy: Evaluate a formula and check where it is defined

Let $f(x)=(2x+1)/(x-1)$ with real inputs. Find its largest real domain, calculate $f(0)$ and $f(2)$, and explain why $f(1)$ is undefined. Solve $f(x)=3$ and check whether the solution belongs to the domain.

Review: Functions and fixed points

Show hint

Division by zero is undefined. When solving the equation, retain that restriction even after multiplying by the denominator.

Show worked solution

Step 1: Determine the allowed inputs. The numerator $2x+1$ is defined for every real $x$. The denominator vanishes exactly when $x-1=0$, or $x=1$. Thus the largest real domain is $\mathbb R\setminus\{1\}$. Declaring the codomain to be $\mathbb R$ is valid because every defined quotient is real.

Step 2: Substitute into the whole fraction. At $x=0$, the numerator is $2(0)+1=1$ and the denominator is $0-1=-1$, so $f(0)=-1$. At $x=2$, they are $2(2)+1=5$ and $2-1=1$, so $f(2)=5$. At $x=1$, the numerator is $3$ and the denominator is $0$. A quotient $3/0$ cannot be a real number: any proposed value $q$ would have to satisfy $0q=3$, which is impossible.

Step 3: Solve for a specified output. Require $(2x+1)/(x-1)=3$ with $x\ne1$. Multiplying both sides by the nonzero denominator gives $2x+1=3(x-1)=3x-3$. Subtract $2x$ and add $3$ to obtain $x=4$.

Step 4: Check the domain and the original equation. The candidate $4$ is not $1$, so it is allowed. Substitution gives $f(4)=(8+1)/(4-1)=9/3=3$. We have found the preimage of the output $3$. Multiplying an equation by a nonzero quantity preserves equality regardless of its sign; unlike an inequality, an equation has no direction to reverse.

Exercise 0.GF2 — Easy: Keep the direction of an image or preimage

For $f:\mathbb R\to\mathbb R$, $f(x)=2x-1$, find $f([0,2])$ and $f^{-1}([0,2])$. Find an inverse formula and verify both compositions. Explain why the same interval appears on different sides of the two calculations.

Review: Functions and fixed points

Show hint

An image starts with an input restriction. A preimage starts with an output restriction and solves that condition for the inputs.

Show worked solution

Step 1: Push the input interval through the formula. For $0\le x\le2$, multiply by $2\gt0$ and subtract $1$ to obtain $-1\le2x-1\le3$. This proves that the image is contained in $[-1,3]$.

Step 2: Show that every proposed output is reached. Take any $y\in[-1,3]$ and choose $x=(y+1)/2$. The output bounds give $0\le(y+1)/2\le2$, so the chosen input lies in $[0,2]$. Substituting it gives $f(x)=2((y+1)/2)-1=y$. Both inclusions now prove $f([0,2])=[-1,3]$.

Step 3: Pull the required output interval back to the inputs. The preimage question asks for all real $x$ such that $0\le f(x)\le2$. Substitute the formula, add $1$, then divide by $2$:

$$0\le2x-1\le2\iff1\le2x\le3\iff\tfrac12\le x\le\tfrac32.$$

Hence $f^{-1}([0,2])=[1/2,3/2]$. These are inputs; the interval $[0,2]$ in this question specified outputs.

Step 4: Verify an inverse function. Define $q(y)=(y+1)/2$ on $\mathbb R$. Then $f(q(y))=y$, as above, and $q(f(x))=((2x-1)+1)/2=x$. These two identities verify that $q=f^{-1}$. Preimage notation also makes sense for maps without an inverse; in this example an inverse exists because every real output has exactly one input.

Exercise 0.GF3 — Easy: Read a safe set as a level-set inequality

Let $h(x)=4-x^2$ and $C=\{x\in\mathbb R:h(x)\ge0\}$. Find $C$, the zero set $\{x:h(x)=0\}$, and the strict set $\{x:h(x)\gt0\}$. Check $x=-2,0,3$. Is $h$ itself a set?

Review: Functions and fixed points

Show hint

First evaluate the function. A level set collects inputs passing a comparison on that output. Rearrange the comparison before solving it.

Show worked solution

Step 1: Separate the function from the set. $h$ is a rule assigning the real output $4-x^2$ to an input $x$. $C$ is a collection of inputs. The braces and comparison turn that function into a membership test; the function itself is not that collection.

Step 2: Solve the non-strict test. The condition $h(x)\ge0$ means $4-x^2\ge0$. Adding $x^2$ to both sides gives $x^2\le4$. By the absolute-value calculation, this is equivalent to $|x|\le2$, or $-2\le x\le2$. Thus $C=[-2,2]$.

Step 3: Find the other level sets. For the zero set, $4-x^2=0$ gives $x^2=4$, so both $x=-2$ and $x=2$ qualify. It is the set $\{-2,2\}$. For the strict set, $4-x^2\gt0$ gives $x^2\lt4$, hence $(-2,2)$. Its endpoints are excluded.

Step 4: Check actual values. $h(-2)=4-4=0$, so $-2$ is safe under the non-strict rule and lies in the zero set. $h(0)=4$, so $0$ lies in both the non-strict and strict sets. $h(3)=4-9=-5$, so $3$ lies in neither. The number $4=h(0)$ is an output value; it is not a safe input here, since $h(4)=-12$. Keeping the input and output roles separate prevents this confusion.

Exercise 0.GF4 — Medium: Compute a set of admissible commands

For a known real state $x$, define $U(x)=\{u\in[-1,1]:0\le x+u\le2\}$. Derive an interval formula, evaluate it at $x=0,1,2,3,4$, and find exactly which states have at least one admissible command. Explain why $U$ is a set-valued map.

Review: Functions and fixed points

Show hint

Subtract $x$ from the two safety bounds, then intersect with the actuator interval. An interval is empty if its lower endpoint exceeds its upper endpoint.

Show worked solution

Step 1: Solve the safety condition for the command. For a fixed observed $x$, subtracting $x$ gives $-x\le u\le2-x$. Safety alone permits $[-x,2-x]$, but the actuator permits only $[-1,1]$.

Step 2: Combine both restrictions. The lower endpoint must meet both lower bounds, hence is their maximum. The upper endpoint must meet both upper bounds, hence is their minimum:

$$U(x)=[-1,1]\cap[-x,2-x].$$

Equivalently, its endpoints are $\ell(x)=\max\{-1,-x\}$ and $r(x)=\min\{1,2-x\}$ when $\ell(x)\le r(x)$. If $\ell(x)\gt r(x)$, the set is empty. We must check that comparison rather than treating a reversed interval as nonempty.

Step 3: Evaluate the five states. At $0$, the intersection is $[-1,1]\cap[0,2]=[0,1]$. At $1$, it is $[-1,1]$. At $2$, it is $[-1,1]\cap[-2,0]=[-1,0]$. At $3$, it is $[-1,1]\cap[-3,-1]=\{-1\}$. At $4$, it is $[-1,1]\cap[-4,-2]=\emptyset$.

Step 4: Find the complete feasibility range. Two closed intervals intersect exactly when each lower endpoint is at most the other's upper endpoint. Here the nontrivial conditions are $-1\le2-x$, giving $x\le3$, and $-x\le1$, giving $x\ge-1$. Thus a command exists exactly for $x\in[-1,3]$. At the left boundary, $u=1$ yields successor $0$; at the right boundary, $u=-1$ yields successor $2$. Outside this range, even an extreme actuator command cannot reach $[0,2]$.

Step 5: Interpret the map. Each input state is assigned a set of commands, which can contain many values, one value or none. A controller selects one member when the set is nonempty. This differs from an ordinary real-valued function, which assigns a single real output to each input in its domain.

Exercise 0.F1 — Easy: Domain, codomain and actual outputs

Let $f:X\to Y$ be $f(x)=x^2$, where $X=\{-2,-1,0,1,2\}$ and $Y=\{0,1,4,9\}$. State the domain, codomain and image $f(X)$. Is $f$ injective? Is it surjective onto $Y$?

Review: functions and fixed points

Show hint
The codomain is the declared target set. The image contains only outputs actually reached. Compare $f(-1)$ and $f(1)$.
Show answer

Check that the declared function is well-defined. Each permitted input must produce exactly one output in the declared codomain. Squaring assigns one output to each input, and the calculation below puts all five outputs in $Y$. Different inputs may still share an output; that affects injectivity rather than well-definedness.

In the declaration $f:X\to Y$, the domain is the set of permitted inputs $X=\{-2,-1,0,1,2\}$, and the codomain is the declared target $Y=\{0,1,4,9\}$. These sets are part of the question, rather than something to infer from the formula alone.

The image is the set of outputs actually obtained from the permitted inputs. Evaluate them all:

$$\begin{aligned} f(-2)&=(-2)(-2)=4,& f(-1)&=(-1)(-1)=1,\\ f(0)&=0(0)=0,& f(1)&=1(1)=1,\\ f(2)&=2(2)=4. \end{aligned}$$

Repeated outputs are listed only once in a set. Thus $f(X)=\{0,1,4\}$. The codomain permits $9$, but this calculation shows that $9$ is never reached.

Injectivity would mean that equal outputs come only from equal inputs. Here $-1\ne1$, yet $f(-1)=f(1)=1$, so the map is not injective.

Surjectivity onto $Y$ would mean that every member of $Y$ has a preimage in $X$. The value $9\in Y$ has no such input, as the exhaustive five-input list shows. Inputs $\pm3$ would give $9$, but neither is in $X$, so they cannot repair the claim. The map is not surjective onto its stated codomain.

Repair each property by changing the appropriate set. Keeping $X$ but replacing the codomain by $\{0,1,4\}$ makes the function surjective, since those are exactly the attained outputs; it still has the collision $f(-1)=f(1)$. Restricting the domain to $\{0,1,2\}$ removes the negative-positive collisions. With that domain and codomain $\{0,1,4\}$, the map is bijective: the three output values are distinct and exhaust the target. The formula alone does not determine these classifications.

Exercise 0.F2 — Easy: Compute two compositions

On $\mathbb R$, let $f(x)=2x-1$ and $g(x)=x^2$. Find $(f\circ g)(2)$ and $(g\circ f)(2)$, then write a formula for each composition at a general $x$.

Review: functions and fixed points

Show hint
Apply the function on the right first: $(f\circ g)(x)=f(g(x))$.
Show answer

Use substitution rather than multiplying function names. The symbol $\circ$ means composition: the inner output becomes the outer input. It does not mean $f(x)g(x)$. In $f(g(2))$, the intermediate input to $f$ is $g(2)$, not $2$.

The definition $(f\circ g)(x)=f(g(x))$ tells us to apply the function on the right first. For $f\circ g$ at $2$, compute

$$g(2)=2^2=2\cdot2=4,\qquad f(4)=2\cdot4-1=8-1=7.$$

Therefore $(f\circ g)(2)=7$. In the opposite order, compute

$$f(2)=2\cdot2-1=4-1=3,\qquad g(3)=3^2=3\cdot3=9.$$

Therefore $(g\circ f)(2)=9$.

For a general real input, substitute the whole output of the inner function into the formula of the outer one:

$$\begin{aligned} (f\circ g)(x)&=f(x^2)=2x^2-1,\\ (g\circ f)(x)&=g(2x-1)=(2x-1)^2\\ &=(2x-1)(2x-1)\\ &=4x^2-2x-2x+1\\ &=4x^2-4x+1. \end{aligned}$$

The two middle products are each $-2x$, which is why the combined linear term is $-4x$. Both compositions are defined for every real $x$. Their values $7$ and $9$ at the same input $2$ differ, so they cannot be the same function. Composition order matters.

Check a general formula at the worked input. Substituting $x=2$ into $2x^2-1$ gives $8-1=7$; substituting it into $4x^2-4x+1$ gives $16-8+1=9$, matching the two direct calculations. The functions do agree at one input: equality of their formulas gives $2x^2-4x+2=0$, or $2(x-1)^2=0$, hence $x=1$. Both compositions give $1$ there. Agreement at a single input does not make functions equal; they must agree at every permitted input.

Exercise 0.F3 — Easy: A fixed point and three iterations

Let $g(x)=(x+3)/4$. Solve $g(x^\ast)=x^\ast$. Starting at $x_0=-1$, calculate $x_1,x_2,x_3$ using $x_{k+1}=g(x_k)$. What happens to the distance from the fixed point at each step?

Review: functions and fixed points

Show hint
Multiply the fixed-point equation by $4$. For the iteration, feed each new output back into $g$.
Show answer

Distinguish the fixed point from an iterate. $x^\ast$ solves one equation $g(x^\ast)=x^\ast$. The indexed values $x_0,x_1,\dots$ are generated from the specified start. Finding the fixed point does not set every iterate equal to it.

A fixed point is an input that comes back unchanged. Set $(x^\ast+3)/4=x^\ast$. Multiply both sides by $4$, subtract $x^\ast$, then divide by $3$:

$$x^\ast+3=4x^\ast \quad\Longrightarrow\quad3=3x^\ast \quad\Longrightarrow\quad x^\ast=1.$$

Checking the answer gives $g(1)=(1+3)/4=4/4=1$.

In the iteration, use each new output as the next input. Write integers with the needed denominator before adding fractions:

$$\begin{aligned} x_1&=\frac{-1+3}{4}=\frac2{4}=\frac12,\\ x_2&=\frac{1/2+3}{4} =\frac{1/2+6/2}{4} =\frac{7/2}{4}=\frac78,\\ x_3&=\frac{7/8+3}{4} =\frac{7/8+24/8}{4} =\frac{31/8}{4}=\frac{31}{32}. \end{aligned}$$

Dividing a fraction by $4$ multiplies its denominator by $4$. The distances from the fixed point are $|x_0-1|=|-2|=2$, $|x_1-1|=|1/2-2/2|=1/2$, $|x_2-1|=|7/8-8/8|=1/8$, and $|x_3-1|=|31/32-32/32|=1/32$.

The pattern holds at every step, not just these three. Subtract the fixed point using a common denominator:

$$g(x)-1=\frac{x+3}{4}-\frac44 =\frac{x-1}{4},\qquad |g(x)-1|=\frac14|x-1|.$$

Thus each update divides the distance by $4$. Starting from distance $2$, the exact distance after $k$ steps is $2(1/4)^k$, which tends to zero.

Derive the whole trajectory from the error update. Put $e_k=x_k-1$. The calculation gives $e_{k+1}=e_k/4$ and $e_0=-2$. Repeated substitution yields $e_1=-2/4$, $e_2=-2/4^2$, and in general $e_k=-2/4^k$. To justify the general line, use induction: it holds at $0$, and division by $4$ turns the formula at $k$ into that at $k+1$. Therefore $x_k=1-2/4^k$. At $k=3$ this is $1-2/64=31/32$, matching the fraction calculation. Every finite iterate is below $1$, even though its limit equals $1$.

Exercise 0.F4 — Medium: Images and preimages of intervals

For $f:\mathbb R\to\mathbb R$, $f(x)=x^2$, find $f([-3,1])$, $f^{-1}([1,4])$, and $f^{-1}(\{-1\})$. Explain why the preimage notation is meaningful even though this $f$ has no inverse function.

Review: functions and fixed points

Show hint
For an image, collect squares of permitted inputs. For a preimage, solve the output condition for every possible real input, including negative inputs.
Show answer

Choose the direction before manipulating a formula. For an image, start with $x\in[-3,1]$ and ask which $y=x^2$ are possible. For a preimage, start with a restriction on $y$ and solve it for all allowed real $x$. The symbol $f^{-1}$ applied to a set describes this second operation.

Image: start with the permitted inputs. The notation $f([-3,1])$ asks for all squares of numbers in $[-3,1]$. Every such input has $|x|\le3$, so $0\le x^2\le9$. This proves that no output lies outside $[0,9]$. To show that none of the values inside is missing, take any $y\in[0,9]$ and choose $x=-\sqrt y$. Then $-3\le x\le0$, so this input is permitted, and $f(x)=(-\sqrt y)^2=y$. Therefore $f([-3,1])=[0,9]$.

Preimage: start with the required outputs. Here the domain is all of $\mathbb R$, and $f^{-1}([1,4])$ asks which real inputs have square between $1$ and $4$. Taking nonnegative square roots gives

$$1\le x^2\le4\quad\Longleftrightarrow\quad1\le|x|\le2.$$

If $x\ge0$, this condition gives $1\le x\le2$. If $x\lt0$, use $|x|=-x$ to obtain $1\le-x\le2$, or $-2\le x\le-1$. Both branches are needed, so $f^{-1}([1,4])=[-2,-1]\cup[1,2]$. All four endpoints are included because the output inequalities allow equality.

Test the negative output separately. A real square is always nonnegative, so there is no real $x$ with $x^2=-1$. Consequently $f^{-1}(\{-1\})=\emptyset$.

Interpret the notation. A preimage means “collect every input whose output passes this test”; it may contain several inputs or none. It does not require an inverse function. An inverse would assign exactly one input to each output in the codomain. Squaring on $\mathbb R$ fails that requirement: $-1$ and $1$ both give $1$, and no input gives $-1$.

Check why endpoint squaring alone would fail. The endpoints $-3$ and $1$ have outputs $9$ and $1$, but the interval contains $0$, whose output is $0$. Thus the image is not $[1,9]$. On the negative part, inputs from $-3$ up to $0$ produce every output from $9$ down to $0$; on the positive part, inputs $0$ to $1$ produce $0$ to $1$. Their union is $[0,9]$. For the preimage, $x=-3/2$ is a useful negative-branch check: its square is $9/4\in[1,4]$, so omitting $[-2,-1]$ would miss an allowed input.

Exercise 0.F5 — Medium: The same formula with four choices of domain and codomain

Classify each map as injective, surjective, both, or neither. All use the formula $f(x)=x^2$.

  1. $\mathbb R\to\mathbb R$.
  2. $\mathbb R\to[0,\infty)$.
  3. $[0,\infty)\to\mathbb R$.
  4. $[0,\infty)\to[0,\infty)$.

For the bijective map, write its inverse.

Review: functions and fixed points

Show hint
Restricting inputs can remove repeated outputs. Restricting the declared target can remove unreachable outputs.
Show answer

Keep the two quantifier tests separate. Injectivity requires $\forall x,x'$ in the domain, $f(x)=f(x')\Rightarrow x=x'$. Surjectivity requires $\forall y$ in the codomain, $\exists x$ in the domain with $f(x)=y$. Shrinking a codomain changes the second test; shrinking a domain changes the available inputs in both tests.

Use two separate tests. Injectivity asks whether different permitted inputs can give the same output. Surjectivity asks whether every element of the declared codomain is actually reached. The formula is the same in all four cases, but the permitted inputs and required outputs change.

  1. $\mathbb R\to\mathbb R$: neither. The distinct inputs $-1$ and $1$ both have square $1$, so the map is not injective. The codomain contains $-1$, but every real square is nonnegative, so $-1$ is never reached. Thus it is not surjective either.

  2. $\mathbb R\to[0,\infty)$: surjective only. Given any required output $y\ge0$, the real input $x=\sqrt y$ satisfies $x^2=y$. This supplies an input for every element of this smaller codomain. The inputs $-1$ and $1$ are still permitted, so the failure of injectivity remains.

  3. $[0,\infty)\to\mathbb R$: injective only. Suppose $x,x'\ge0$ and $x^2=(x')^2$. Factoring gives $(x-x')(x+x')=0$. Either $x=x'$, or $x+x'=0$; in the second case nonnegativity forces $x=x'=0$. Thus the inputs are equal in every case. However, the codomain is still all of $\mathbb R$, and negative outputs remain impossible, so the map is not surjective.

  4. $[0,\infty)\to[0,\infty)$: both. The uniqueness argument from (3) proves injectivity, and the input $x=\sqrt y$ from (2) proves surjectivity for every $y$ in this codomain. This map is therefore bijective.

The inverse of the bijective map is $f^{-1}(y)=\sqrt y$ for $y\ge0$. Check both directions: $(\sqrt y)^2=y$, and $\sqrt{x^2}=x$ when $x\ge0$. The last identity would be $|x|$ on all of $\mathbb R$, which explains why restricting the domain matters.

Expand the zero case in the injectivity proof. For nonnegative $x,x'$, factorization gives $(x-x')(x+x')=0$. If the second factor is positive, the first must be zero, giving $x=x'$. If the second factor is zero, two nonnegative numbers can sum to zero only when both are zero, again giving equality. There is no need to divide by $x+x'$ without checking this case. For the inverse, the expression $\sqrt{x^2}$ is $|x|$; restricting to $x\ge0$ is exactly what changes it to $x$ and makes the inverse composition return its original input.

Exercise 0.F6 — Medium: An alternating contraction and an error target

Let $g(x)=-x/2+3$ on $\mathbb R$, and $x_0=0$. Find the fixed point and the first three iterates. Prove that $g$ has contraction factor $1/2$. Use the exact error to find the smallest integer $k\ge0$ for which $|x_k-x^\ast|\le1/100$.

Review: functions and fixed points

Show hint
Subtract the fixed-point equation from the iteration. The sign alternates, but the absolute error halves.
Show answer

Keep a signed error and a distance distinct. The signed error $x_k-x^\ast$ records which side of the fixed point an iterate lies on. Its absolute value records only distance. A negative slope can make the first alternate while the second decreases steadily.

Find the point that stays fixed. Set the output equal to the input and solve:

$$x^\ast=-\frac{x^\ast}{2}+3 \quad\Longrightarrow\quad\frac32x^\ast=3 \quad\Longrightarrow\quad x^\ast=2.$$

Iterate from the stated start. Each new value is obtained by putting the previous value into $g$:

$$\begin{aligned} x_1&=-0/2+3=3,\\ x_2&=-3/2+3=3/2,\\ x_3&=-(3/2)/2+3=-3/4+3=9/4. \end{aligned}$$

Check the contraction for every pair. For arbitrary real $x,y$, the constant terms cancel, giving $g(x)-g(y)=-(x-y)/2$. Taking absolute values gives $|g(x)-g(y)|=\tfrac12|x-y|$. Since $1/2\lt1$, this is a contraction on $\mathbb R$ with factor $1/2$.

Compute the exact error. Subtract the fixed-point equation from the recurrence:

$$\begin{aligned} x_{k+1}-2&=-\tfrac12(x_k-2),\\ x_k-2&=(-\tfrac12)^k(x_0-2)=-2(-\tfrac12)^k,\\ |x_k-2|&=2(1/2)^k. \end{aligned}$$

The second line follows by applying the first line $k$ times; at $k=0$ it is the initial error $-2$. The minus sign makes the signed error alternate, while its absolute size halves.

Solve the tolerance and check the first integer. The requirement $2/2^k\le1/100$ is equivalent to $2^k\ge200$, since all denominators are positive. Now $2^7=128\lt200$ and $2^8=256\ge200$. Hence the smallest qualifying iteration is $k=8$. Directly, the errors are $1/64\gt1/100$ at $7$ and $1/128\lt1/100$ at $8$. Because these exact errors decrease, every earlier iteration also fails.

Fill in the induction behind the exact error. At $k=0$, $x_0-2=-2=-2(-1/2)^0$. If $x_k-2=-2(-1/2)^k$, then multiplying the error update by $-1/2$ gives $x_{k+1}-2=-2(-1/2)^{k+1}$. Thus the formula holds for every $k$. At the certified index $8$, the sign is negative and $x_8=2-2/256=2-1/128=255/128$. Its distance is $1/128$. At index $7$, the sign is positive and $x_7=2+1/64$, giving the larger distance $1/64$. Checking distances avoids confusing an alternating signed error with a decreasing positive error.

Exercise 0.F7 — Hard: Why images do not preserve intersections

For $f(x)=x^2$, $A=\{-2\}$ and $B=\{2\}$, compare $f(A\cap B)$ with $f(A)\cap f(B)$. Then prove that for any injective function $f:X\to Y$ and any $A,B\subseteq X$, these two sets are equal.

Review: functions and fixed points

Show hint
For the general proof, show both inclusions. If an output comes from $a\in A$ and $b\in B$, injectivity forces $a=b$.
Show answer

Prove equality as two inclusions. The first direction can use the same input to witness membership in both images. In the other direction, the definitions initially give two potentially different inputs. Locate the hypothesis that lets us identify them.

Compute the counterexample. The only member of $A$ is $-2$ and the only member of $B$ is $2$. They are distinct, so $A\cap B=\emptyset$. An image needs an input: no input in the empty set can produce an output, so $f(A\cap B)=\emptyset$. Separately, $f(-2)=(-2)^2=4$ and $f(2)=2^2=4$. Hence $f(A)=f(B)=\{4\}$ and $f(A)\cap f(B)=\{4\}$. The two sets differ because a common output need not come from a common input.

First inclusion, for any function. Take any $y\in f(A\cap B)$. By the definition of image, there is an $x\in A\cap B$ with $f(x)=y$. Membership in the intersection means $x\in A$ and $x\in B$. The same input is a witness that $y\in f(A)$ and $y\in f(B)$. Thus $f(A\cap B)\subseteq f(A)\cap f(B)$.

Reverse inclusion, using injectivity. Take any $y\in f(A)\cap f(B)$. Image membership supplies an $a\in A$ with $f(a)=y$ and a $b\in B$ with $f(b)=y$. Injectivity means equal outputs force equal inputs, so $a=b$. This one input belongs to both sets and maps to $y$, proving $y\in f(A\cap B)$. Both inclusions prove equality. In the counterexample the inputs $-2,2$ have equal outputs but differ, so precisely this injectivity step is unavailable.

Check that injectivity is essential for a claim about every pair of sets. If a map is not injective, there are distinct inputs $a,b$ with $f(a)=f(b)$. Taking the singleton sets $A=\{a\}$ and $B=\{b\}$ gives $A\cap B=\emptyset$, but the two images share that common output. Hence equality of images of intersections for every $A,B$ would force the map to be injective. A particular noninjective map can still give equality for some chosen sets; the universal set-pair claim is what needs the hypothesis.

Exercise 0.F8 — Hard: Grow a set until it stops

Let $D=\{0,1,2,3,4\}$, with $F(0)=1$, $F(1)=2$, $F(2)=2$, $F(3)=4$, $F(4)=3$. Define $\Phi(S)=S\cup F(S)$ for $S\subseteq D$, where $F(S)=\{F(x):x\in S\}$. Start with $S_0=\{0\}$ and iterate $S_{k+1}=\Phi(S_k)$. Find the final set, prove $\Phi$ is monotone, and explain why $3,4$ are not added.

Review: functions and fixed points

Show hint
Use only the states already in $S_k$ to compute $F(S_k)$. For monotonicity, follow an arbitrary element from $A\subseteq B$.
Show answer

Distinguish two meanings of increase. The union in $\Phi(S)=S\cup F(S)$ means the iteration never removes old members. Monotonicity means that starting from a larger set cannot produce a smaller next set. Both are useful, but they are different properties.

Apply $F$ to each member of the current set, then retain the old members by taking a union. Starting with $S_0=\{0\}$,

$$\begin{aligned} F(S_0)&=\{F(0)\}=\{1\},&S_1&=\{0\}\cup\{1\}=\{0,1\},\\ F(S_1)&=\{F(0),F(1)\}=\{1,2\},&S_2&=\{0,1,2\},\\ F(S_2)&=\{1,2,2\}=\{1,2\},&S_3&=S_2. \end{aligned}$$

A set lists repeated elements only once. Since $\Phi(S_2)=S_2$, this is a fixed point of the same operator. Applying it again gives $S_4=\Phi(S_3)=\Phi(S_2)=S_2$, and induction gives the same value forever. The final set is $\{0,1,2\}$, after two strict increases.

To prove monotonicity, assume $A\subseteq B$ and take any $y\in\Phi(A)$. Either $y\in A$, in which case $y\in B\subseteq\Phi(B)$, or $y=F(a)$ for some $a\in A$. Then $a\in B$, so $y\in F(B)\subseteq\Phi(B)$. Every member passes, proving $\Phi(A)\subseteq\Phi(B)$.

The map sends each of $0,1,2$ back into $\{0,1,2\}$. States $3,4$ map only to each other and neither is in the initial set. Induction therefore rules out adding either one. Monotonicity preserves previously added states; it does not make every disconnected state reachable.

Verify that this is the smallest closed-under-$F$ set containing the seed. Let $T$ be any set with $0\in T$ and $F(T)\subseteq T$. Since $0\in T$, its image $F(0)=1$ must also be in $T$. Then $F(1)=2$ must be in $T$. Thus $\{0,1,2\}\subseteq T$. Our final set itself contains the seed and is closed under $F$, so no smaller set can meet those requirements. A fixed point need not be the entire domain: the separate cycle $3\leftrightarrow4$ can be included in a larger fixed point without being required by this seed.

Exercise 0.F9 — Hard: Audit the contraction theorem

In each case, say which assumption of the contraction theorem fails and whether a fixed point in $X$ exists.

  1. $X=(0,1]$, $g(x)=x/2$.
  2. $X=[0,1]$, $g(x)=x/2+1$.
  3. $X=[-1,1]$, $g(x)=-x$.
In (3), describe the iteration from $x_0=1$.

Review: functions and fixed points

Show hint
Check closedness, whether every output stays in $X$, and whether a single factor $L\lt1$ bounds all distances. Solve $g(x)=x$ separately.
Show answer

Audit hypotheses before invoking a theorem. In this scalar version, closedness keeps limits in $X$, the self-map condition keeps every iterate in $X$, and a factor below $1$ shrinks distances. After naming a failed hypothesis, solve the fixed-point equation independently to see what actually happens.

The theorem needs a nonempty closed subset of $\mathbb R$, a map into that same set, and a uniform distance factor strictly below $1$.

(1) $X=(0,1]$, $g(x)=x/2$. For $0\lt x\le1$, $0\lt x/2\le1/2\le1$, so this is a self-map. Also $|g(x)-g(y)|=|x-y|/2$. Closedness fails: the members $1,1/2,1/4,\ldots$ approach $0$, which is excluded. A fixed point would satisfy $x=x/2$, so subtracting $x/2$ gives $x/2=0$, hence $x=0$. It is outside $X$, and no fixed point exists in $X$.

(2) $X=[0,1]$, $g(x)=x/2+1$. The set is closed and the same subtraction shows contraction factor $1/2$. The self-map requirement fails: $g(1)=1/2+1=3/2\gt1$. Solving $x=x/2+1$ gives $x/2=1$, hence $x=2$, also outside $X$. No fixed point exists in the stated set.

(3) $X=[-1,1]$, $g(x)=-x$. The set is closed, and changing the sign preserves membership. But $|g(x)-g(y)|=|x-y|$. For distinct inputs, dividing by their positive distance would require $1\le L$, so no contraction factor $L\lt1$ works. The fixed-point equation $x=-x$ gives $2x=0$, hence $x=0\in X$. From $x_0=1$, repeated sign changes give $1,-1,1,-1,\ldots$. Its even and odd subsequences have different limits, so the iteration does not converge.

Each failed assumption removes the theorem's guarantee. The explicit equations and trajectories determine what actually fails in these examples; a failed hypothesis alone would not decide that.

Inspect the failure of limit retention in (1). From $x_0=1$, the iterates are $x_k=2^{-k}$. Each is positive and at most $1$, so every finite step is in $X$. Their limit is $0$, outside $X$. There is no conflict between staying in a set at every finite step and having a missing limit when the set is not closed. In (2), failure occurs earlier: starting at $1$ leaves $X$ after just one step. In (3), all steps stay in $X$, but the distances never shrink and the run from $1$ has no limit. These calculations explain the separate jobs performed by the three assumptions.

3. Reading and Writing Proofs

A proof is a chain of statements, each following from assumptions, definitions or earlier steps by a rule you can name.

Fact — A reading checklist for theorem boxes
(1) Separate assumptions from conclusion and list every quantifier: which set, all $t$ at once or each $t$, probability $1-\delta$ per run or per round? (2) Check the conclusion on the simplest instance. (3) For each assumption, find what breaks without it (the modules' "Why each assumption matters"). (4) While reading the proof, mark where each assumption is used; an unused one is redundant or signals a misreading.

Step 4 pays off in Module 5: the LoSBO safety proof uses only the Lipschitz constant, the noise bound and the seed, never $\beta_t$, the kernel or the RKHS norm, hence "for any $\beta_t$".

Direct proofs and chains of inequalities

Lemma — The Lipschitz certificate behind SafeOpt and LoSBO
If $|f(x)-f(x')|\le L|x-x'|$ for all $x,x'$ and $f(x')-L|x-x'|\ge h$, then $f(x)\ge h$. Proof (a direct proof: a chain whose links each have one reason and point the same way):
$$f(x)\ \overset{(1)}{=}\ f(x')+\big(f(x)-f(x')\big)\ \overset{(2)}{\ge}\ f(x')-L|x-x'|\ \overset{(3)}{\ge}\ h .$$
(1) adds and subtracts $f(x')$; (2) uses $f(x)-f(x')\ge-|f(x)-f(x')|\ge-L|x-x'|$, only one side of the absolute value; (3) is the hypothesis. With $f(x')=2.5$, $L=1$, $|x-x'|=1.5$, $h=0$: $f(x)\ge1\ge0$. $\blacksquare$

Tools for chains. $\|a+b\|\le\|a\|+\|b\|$ and $\big|\|a\|-\|b\|\big|\le\|a-b\|$; multiplying by $c\ge0$ keeps the direction, by $c\lt0$ flips it; increasing functions ($e^x$, $\ln x$, $\sqrt x$) keep it. One strict link makes the chain strict.

Contrapositive, contradiction, pigeonhole

To prove $P\Rightarrow Q$ one may prove the contrapositive $\neg Q\Rightarrow\neg P$. Example: "if $\|x\|\le\varepsilon$ for every $\varepsilon\gt0$, then $x=0$"; if $x\ne0$, then $\varepsilon=\|x\|/2$ violates the premise. $\blacksquare$ ("To show $a=b$, show $|a-b|\le\varepsilon$ for every $\varepsilon\gt0$" returns in every limit argument.) A proof by contradiction assumes the conclusion false and derives something impossible. The pigeonhole principle is the simplest case: $n+1$ objects in $n$ boxes put two in one box.

Fact — Deterministic loops on finite state spaces cycle
If $X$ is finite and $x_{t+1}=F(x_t)$ for a fixed $F:X\to X$ (stationary deterministic feedback and dynamics), every state the trajectory ever visits appears among $x_0,\dots,x_{|X|-1}$; so if it ever enters a failure set, it does so by time $|X|-1$.

Proof. The $|X|+1$ states $x_0,\dots,x_{|X|}$ lie in a set of size $|X|$, so $x_i=x_j$ for some $0\le i\lt j\le|X|$ (pigeonhole). Determinism gives $x_{i+m}=x_{j+m}$ for all $m\ge0$ (induction on $m$), so from time $i$ on the trajectory repeats $x_i,\dots,x_{j-1}$, and $j-1\le|X|-1$. $\blacksquare$

Induction, including induction over time

Definition — Principle of mathematical induction
If $P(0)$ is true (base case) and $P(t)\Rightarrow P(t+1)$ for every $t\in\mathbb N$ (induction step), then $P(t)$ holds for all $t\in\mathbb N$. In strong induction the step may use all of $P(0),\dots,P(t)$.

Induction over time steps proves "safe at every step": safe now, and safe now plus the certificate imply safe next. The walkthrough proves a discrete-time barrier certificate this way and shows the trap to avoid.

Counterexamples and "it suffices to show"

One counterexample disproves a "for all". "Every bounded sequence converges": $(-1)^t$ does not. "A continuous function on a bounded set attains its maximum": $x$ on $(0,1)$ does not. "If $V$ decreases along trajectories, they converge to $0$": Module 11 gives a discontinuous $F$ with $x_t=1+2^{-t}\to1$. "A barrier condition on the boundary suffices": it can fail where $\nabla h=0$ (Module 1; Section 6 below). "It suffices to show $Q$" means that $Q$ implies the goal: to show $A=B$ it suffices to show $A\subseteq B$ and $B\subseteq A$; LoSBO's proof starts "it suffices that $f\ge h$ on every $S_t$", because every query is taken from $S_t$.

Where this is used
Induction over rounds and the assumption audit in Module 5; "induction removes the circularity" in Module 14; "by induction, $X^k$ is the set of states from which failure can be avoided for $k$ steps" and finite-state cycles in Module 7; recursive feasibility of predictive safety filters in Module 10.
Common mistakes in proofs
(1) Circular reasoning: assuming the trajectory stays where a certificate holds in order to prove that it stays there. (2) Checking an example instead of the claim: one safe simulation proves nothing about all initial states. (3) Using an assumption outside its domain, e.g. a sector bound valid on a box, applied outside the box. (4) Multiplying by a quantity of unknown sign.

Practice: Reading and Writing Proofs

Write a reason beside each step. Easy exercises practise one proof move; Medium builds complete arguments; Hard combines the proof with an audit of its assumptions. If a definition feels unfamiliar, revisit this section before trying again.

Guided build-up. Start with these smaller questions to practise the tools used by the graded exercises that follow.

Exercise 0.GP1 — Easy: Prove both directions of an equivalence

Prove, for real $x$, that $x\ge2$ if and only if $3x+1\ge7$. Write one argument for each direction, and explain which direction would be enough to prove only that $x\ge2$ is sufficient.

Review: Proofs

Show hint

An “if and only if” claim contains two implications. In each direction, assume its starting condition and derive the other condition.

Show worked solution

Step 1: Name the two statements. Let $P$ be $x\ge2$ and $Q$ be $3x+1\ge7$. To prove $P\iff Q$, we need both $P\Rightarrow Q$ and $Q\Rightarrow P$.

Step 2: Prove the forward implication. Assume $x\ge2$. Multiplying by $3\gt0$ preserves order and gives $3x\ge6$. Adding $1$ gives $3x+1\ge7$. This proves $P\Rightarrow Q$: the starting condition is sufficient.

Step 3: Prove the reverse implication. Assume instead $3x+1\ge7$. Subtracting $1$ gives $3x\ge6$. Dividing by $3\gt0$ preserves order and gives $x\ge2$. This proves $Q\Rightarrow P$: the starting condition in the first direction is also necessary.

Step 4: Conclude precisely. Both implications hold for every real $x$, so the equivalence is proved. At $x=2$, both sides allow equality. A check at that endpoint confirms the bracket choice but cannot replace the two general implications. If the request were only sufficiency, Step 2 would suffice; Step 3 is what establishes necessity.

Exercise 0.GP2 — Easy: Construct the integer your proof needs

Prove that the sum of two even integers is even. Then prove that the sum of two odd integers is even. In each case give the integer that witnesses the definition of evenness; checking a few examples is not enough.

Review: Proofs

Show hint

“Even” means equal to $2q$ for some integer $q$. Replace each starting integer by its defining form and factor out $2$.

Show worked solution

Step 1: Write the hypothesis using the definition. Let $a,b$ be arbitrary even integers. There are integers $m,n$ such that $a=2m$ and $b=2n$. These two integers may differ; evenness does not require a shared witness.

Step 2: Calculate the sum and supply a witness. $a+b=2m+2n=2(m+n)$. The number $q=m+n$ is an integer because integers are closed under addition. Therefore $a+b=2q$ for an integer $q$, exactly the definition of an even number. This proves the first claim for every allowed pair, including negative numbers and zero.

Step 3: Repeat with the correct odd forms. If $a,b$ are odd, write $a=2m+1$ and $b=2n+1$ for integers $m,n$. Then

$$a+b=2m+1+2n+1=2m+2n+2=2(m+n+1).$$

Now the witness is $q=m+n+1$, also an integer. Thus the sum is even. Merely saying that the final expression “looks even” would omit the domain check on $q$.

Step 4: Compare a check with a proof. $(-3)+5=2$ checks one odd pair. The symbolic calculation covers every odd pair because $m,n$ were arbitrary. A finite list of successful examples cannot prove a statement about all integers; a definition-based witness can.

Exercise 0.GP3 — Medium: Use induction to prove an inequality

Prove $2^n\ge n+1$ for every integer $n\ge0$. State the induction hypothesis and identify where $n\ge0$ is used in the step. Check $n=0,1,2$ separately to understand the claim before proving it.

Review: Proofs

Show hint

At the next index, $2^{n+1}=2\cdot2^n$. Use the hypothesis to bound this below, then compare the resulting expression with $n+2$.

Show worked solution

Step 1: Read a few instances. At $n=0$, $2^0=1=0+1$. At $n=1$, $2^1=2=1+1$. At $n=2$, $2^2=4\ge3$. Equality at the first two indices is permitted by the non-strict comparison.

Step 2: Establish the base case. Define $P(n)$ to mean $2^n\ge n+1$. The $n=0$ calculation proves $P(0)$.

Step 3: State what may be assumed. Fix an integer $n\ge0$ and assume $P(n)$, namely $2^n\ge n+1$. The target is $P(n+1)$, namely $2^{n+1}\ge(n+1)+1=n+2$. We do not assume this target.

Step 4: Derive the next bound. The power rule and positive multiplication give $2^{n+1}=2\cdot2^n\ge2(n+1)=2n+2$. To compare with $n+2$, subtract: $(2n+2)-(n+2)=n\ge0$. Hence $2n+2\ge n+2$, so $2^{n+1}\ge n+2$. This is the desired next statement.

Step 5: Apply induction. The base case and the implication $P(n)\Rightarrow P(n+1)$ prove the inequality for every integer $n\ge0$. The nonnegativity of $n$ was needed in comparing the two linear expressions; it was not an unstated assumption about the size of $2^n$.

Exercise 0.GP4 — Medium: Combine error bounds with the triangle inequality

A true scalar value $x$, a sensor reading $y$ and a prediction $z$ satisfy $|x-y|\le0.2$ and $|y-z|\le0.1$. Prove $|x-z|\le0.3$. If $z=4.7$, can these bounds certify $x\in[0,5]$? Is the bound $0.3$ attainable?

Review: Proofs

Show hint

Insert the intermediate value: $x-z=(x-y)+(y-z)$. To certify an interval, check the extreme compatible values, including equality.

Show worked solution

Step 1: Decompose the unknown difference. Adding and subtracting $y$ changes nothing: $x-z=x-y+y-z=(x-y)+(y-z)$. This lets us connect a quantity we want to bound to the two quantities we know.

Step 2: Apply the triangle inequality. For real $a,b$, $|a+b|\le|a|+|b|$. Use $a=x-y$, $b=y-z$, then substitute the two hypotheses:

$$|x-z|\le|x-y|+|y-z|\le0.2+0.1=0.3.$$

We did not assume the errors have the same sign or cancel; the bound must cover either possibility.

Step 3: Turn the bound into an information interval. If $z=4.7$, then $-0.3\le x-4.7\le0.3$. Adding $4.7$ gives $4.4\le x\le5.0$. The whole interval $[4.4,5]$ lies in $[0,5]$, so these assumptions certify the specification. At the upper endpoint, equality $x=5$ is allowed.

Step 4: Check whether the bound could be improved from this information. Choose $z=4.7$, $y=4.8$, $x=5.0$. Then $|x-y|=0.2$, $|y-z|=0.1$, and $|x-z|=0.3$. All hypotheses hold with both signed errors pointing the same way, so the combined bound is attained. A smaller universal error bound would exclude this allowed example. Cancellation might improve a particular reading, but it cannot be guaranteed from these two absolute bounds alone.

Exercise 0.P1 — Easy: A direct proof by completing the square

Prove $x^2+2x+2\ge1$ for every real $x$. When does equality hold? Give a general argument, not just numerical checks.

Review: proof techniques

Show hint
Rewrite $x^2+2x+2$ as one square plus a constant.
Show answer

Turn the requested lower bound into a nonnegative expression. The goal $x^2+2x+2\ge1$ is equivalent to $x^2+2x+1\ge0$, after subtracting $1$. The coefficients $1,2,1$ suggest the square $(x+1)^2$. This is how we choose the useful rearrangement rather than guessing a value of $x$.

Take an arbitrary real number $x$. Expanding $(x+1)(x+1)$ gives $x^2+x+x+1=x^2+2x+1$. Thus

$$x^2+2x+2=(x+1)^2+1\ge0+1=1.$$

The inequality holds because every real square is nonnegative. Equality occurs exactly when the added square is zero, which means $x+1=0$, hence $x=-1$. Substitution checks $(-1)^2+2(-1)+2=1-2+2=1$. No restriction was placed on $x$, so this proves the bound for every real input.

Check both directions of the equality condition. If $x=-1$, the substitution above attains $1$. Conversely, if the expression equals $1$, then $(x+1)^2=0$. A square is zero only when its base is zero, so $x+1=0$ and $x=-1$. This proves the equality case is unique. The method also explains the general identity $x^2+bx+c=(x+b/2)^2+c-b^2/4$ for real $b,c$: expanding the square gives $x^2+bx+b^2/4$, and the final subtraction removes the extra constant.

Exercise 0.P2 — Easy: Prove a contrapositive about even numbers

Let $n$ be an integer. Prove: if $n^2$ is even, then $n$ is even. Use the contrapositive. Recall that an even integer has the form $2m$ and an odd integer the form $2m+1$, for an integer $m$.

Review: proof techniques

Show hint
The contrapositive says: if $n$ is odd, then $n^2$ is odd. Substitute $n=2m+1$ and expand.
Show answer

Write the logic before the algebra. Let $P$ mean “$n^2$ is even” and $Q$ mean “$n$ is even”. The target is $P\Rightarrow Q$; its contrapositive is $\neg Q\Rightarrow\neg P$. Every integer is either even or odd, so the negated statements can be expressed using oddness.

For integers, “not even” means odd. The contrapositive of “$n^2$ even implies $n$ even” is therefore “$n$ odd implies $n^2$ odd”. An implication and its contrapositive have the same truth value.

Assume $n$ is odd. By definition $n=2m+1$ for some integer $m$. Multiply out:

$$\begin{aligned} n^2&=(2m+1)(2m+1)\\ &=4m^2+2m+2m+1\\ &=4m^2+4m+1=2(2m^2+2m)+1. \end{aligned}$$

The number $q=2m^2+2m$ is an integer because sums and products of integers are integers. Hence $n^2=2q+1$ is odd. This proves the contrapositive, and therefore the requested implication. We used the integer domain: even/odd classification would not apply to arbitrary real inputs.

Explain why the contrapositive settles the original claim. Suppose the original premise holds, so $n^2$ is even. If its conclusion were false, $n$ would be odd. The calculation proves that an odd $n$ has an odd square, contradicting the even-square premise. Thus the conclusion cannot be false. We did not prove the original implication merely by squaring an even number: that would establish its converse. The starting assumption must match the direction being proved.

Exercise 0.P3 — Easy: Disprove three universal claims

Give a counterexample to each claim over real numbers, and explicitly check why it fails.

  1. For every $x$, $x^2\ge x$.
  2. If $xy=0$, then both $x=0$ and $y=0$.
  3. If $x^2=y^2$, then $x=y$.

Review: proof techniques

Show hint
Try a number between $0$ and $1$ for (1), one zero factor for (2), and opposite nonzero numbers for (3).
Show answer

Read “counterexample” as a complete failed test. We need one allowed input, or one allowed pair, at which the asserted conclusion is false. For the second and third claims, we must also check that the premise is true at our chosen pair; otherwise the implication would not be challenged.

(1) Choose the real input $x=1/2$. Then $x^2=(1/2)(1/2)=1/4$, whereas $x=1/2=2/4$. Since $1/4\lt2/4$, the claimed $x^2\ge x$ fails.

(2) Choose $x=0$, $y=1$. The premise holds: $xy=0(1)=0$. The conclusion demands both $x=0$ and $y=0$. Its second demand fails since $1\ne0$, so the implication is false at this permitted pair.

(3) Choose $x=-1$, $y=1$. Their squares are $(-1)(-1)=1$ and $1(1)=1$, so the premise holds. The conclusion $x=y$ fails because $-1\ne1$.

A universal claim requires every allowed input to pass. One allowed input with a false conclusion refutes it. For an implication the premise must hold too; an example with a false premise would not refute that implication.

Identify the nearby true statements. In (1), $x^2\ge x$ is equivalent to $x(x-1)\ge0$. It holds for $x\le0$ and $x\ge1$, but fails for $0\lt x\lt1$ because the two factors then have opposite signs. In (2), the correct zero-product conclusion is $x=0$ or $y=0$. If $x\ne0$, division by $x$ forces $y=0$; the case $x=0$ already satisfies the other branch. In (3), factoring $x^2-y^2=(x-y)(x+y)$ shows that equal squares imply $x=y$ or $x=-y$. The counterexamples expose a missing domain restriction in (1), and an overly strong conclusion in (2) and (3).

Exercise 0.P4 — Medium: Write an induction proof from start to finish

Prove that $\sum_{j=1}^{n}j=n(n+1)/2$ for every integer $n\ge0$, with the sum at $n=0$ defined to be $0$. State the base case, induction hypothesis, induction step and conclusion explicitly.

Review: proof techniques

Show hint
For the step, split the sum at $n+1$ into the old sum and the new term $n+1$.
Show answer

Distinguish the index from the summation variable. $n$ tells us how many positive integers are added. The symbol $j$ runs through those integers inside the sum. At $n=3$, the expression is $1+2+3$, not three copies of the number $3$.

Let $P(n)$ be the statement $\sum_{j=1}^n j=n(n+1)/2$.

Base case. At $n=0$ the stipulated empty sum is $0$, and the right side is $0(0+1)/2=0$. Thus $P(0)$ holds.

Induction hypothesis. Fix an integer $n\ge0$ and assume $P(n)$ is true. We must prove $P(n+1)$ from that assumption.

$$\begin{aligned} \sum_{j=1}^{n+1}j&=\sum_{j=1}^n j+(n+1)\\ &=\frac{n(n+1)}2+(n+1)\\ &=\frac{n(n+1)+2(n+1)}2\\ &=\frac{(n+1)(n+2)}2. \end{aligned}$$

The first line separates the final term; the second uses the hypothesis; the third writes the added term over denominator $2$; the fourth factors out $n+1$. The resulting numerator is $(n+1)((n+1)+1)$, exactly the formula required by $P(n+1)$.

Conclusion. The base case and step prove $P(n)$ for every integer $n\ge0$ by induction. The hypothesis concerns only index $n$; we did not assume the desired statement at $n+1$.

Replay one induction step with numbers. At $n=2$, the hypothesis says $1+2=2(3)/2=3$. The next sum appends just $n+1=3$, giving $3+3=6$. The new formula is $(n+1)(n+2)/2=3(4)/2=6$. The symbolic step performs this same append-and-factor operation for an arbitrary $n$. The base at $0$ is important: without a first verified statement, an implication from each index to the next would not establish that any statement holds.

Exercise 0.P5 — Medium: Repair a proof with a sign mistake

A proposed proof says: “If $a\le b$, multiplying by $a$ gives $a^2\le ab$, and multiplying by $b$ gives $ab\le b^2$. Hence $a^2\le b^2$.” Explain the gap, give a counterexample, and repair the argument under the additional assumption $0\le a\le b$.

Review: proof techniques

Show hint
Multiplication by a negative number reverses an inequality. Alternatively factor $b^2-a^2$.
Show answer

Audit the hypotheses of an algebraic rule. “Multiply both sides” is not a complete justification for an inequality: the sign of the multiplier determines the direction. Zero, positive and negative multipliers have different effects, and the original premise does not fix which case occurs.

Locate the unsupported step. Multiplication preserves $a\le b$ only for a nonnegative multiplier. The premise $a\le b$ does not tell us that either $a$ or $b$ is nonnegative. If a multiplier is negative, the inequality reverses.

Check a counterexample through the actual operations. Take $a=-3$ and $b=-2$. The premise $-3\le-2$ is true. Multiplying it by $a=-3$ gives $9\ge6$, and multiplying it by $b=-2$ gives $6\ge4$. The proposed proof incorrectly writes the opposite directions. Its final claim would be $a^2\le b^2$, or $9\le4$, which is false.

Repair the chain with the added hypothesis. Under $0\le a\le b$, both multipliers are now nonnegative. Multiplying $a\le b$ by $a$ gives $a^2\le ab$; multiplying the same inequality by $b$ gives $ab\le b^2$. Combining them yields $a^2\le ab\le b^2$. Zero multipliers are allowed: multiplication by zero simply gives equality.

You can check the same conclusion in one factorization: $b^2-a^2=(b-a)(b+a)$. The hypothesis gives $b-a\ge0$ and $b+a\ge0$, so their product is nonnegative. Therefore $b^2-a^2\ge0$, which is exactly $a^2\le b^2$. The sign assumption is what makes either repair valid.

See why squaring is not order-preserving everywhere. On nonnegative inputs it preserves order, as the repaired proof shows. On nonpositive inputs it reverses it: if $a\le b\le0$, then $0\le-b\le-a$, so the nonnegative result gives $b^2\le a^2$. When $a$ and $b$ have opposite signs, their squares depend on the sizes of their absolute values. For example, $-3\le2$ but $9\gt4$, while $-1\le2$ and $1\lt4$. There is no universal square comparison from $a\le b$ alone.

Exercise 0.P6 — Medium: Prove that an interval stays invariant

Let $x_{t+1}=x_t/2+1/4$ and $x_0\in C=[0,1]$. First show that any point of $C$ maps back into $C$. Then use induction to prove $x_t\in C$ for all integers $t\ge0$. Where is the assumption on $x_0$ used?

Review: proof techniques

Show hint
If $0\le x\le1$, bound $x/2+1/4$ from below and above. Use membership in $C$ as the induction statement.
Show answer

Separate a property of the rule from a property of the run. First prove that the rule sends any allowed current state to another allowed state. Then use the given starting state and induction to show that the actual run can apply this fact at each successive time.

One-step containment. Take any $x\in C=[0,1]$, so $0\le x\le1$. Dividing by the positive number $2$ preserves the order, and adding $1/4$ gives

$$0\le x/2\le1/2 \quad\Longrightarrow\quad1/4\le x/2+1/4\le1/2+1/4=3/4.$$

Since $0\le1/4$ and $3/4\le1$, the successor lies in $[0,1]$.

Induction. Let $P(t)$ mean $x_t\in C$. At $t=0$, $P(0)$ is exactly the given assumption $x_0\in C$. For the step, assume $P(t)$. The one-step argument is now applicable to $x=x_t$, and the recurrence gives $x_{t+1}=x_t/2+1/4\in C$. This proves $P(t+1)$. Induction gives membership at every integer time $t\ge0$.

The initial-state assumption supplies the base case. Without it, $x_0=2$ is permitted as a real number but outside $C$, and $x_1=2/2+1/4=5/4$ is still outside. One-step containment for points already in $C$ does not cover a start outside it.

Check the induction with an exact trajectory formula. The fixed point satisfies $x=x/2+1/4$, so $x=1/2$. Subtracting $1/2$ from the update gives $x_{t+1}-1/2=(x_t-1/2)/2$. Induction yields $x_t=1/2+2^{-t}(x_0-1/2)$. Since $x_0\in[0,1]$, its signed error lies in $[-1/2,1/2]$. Hence every time-$t$ value lies in $[1/2-2^{-(t+1)},1/2+2^{-(t+1)}]$, contained in $[0,1]$. At $t=1$ these endpoints are $1/4$ and $3/4$, exactly the one-step interval found above. This additional calculation checks the invariant and shows how the reachable interval shrinks.

Exercise 0.P7 — Hard: Prove uniqueness without assuming existence

Let $X$ be a nonempty subset of $\mathbb R$ and $g:X\to X$ satisfy $|g(x)-g(y)|\le |x-y|/3$ for all $x,y\in X$. Prove that $g$ has at most one fixed point. Does your proof also show that a fixed point exists? Give a counterexample if it does not.

Review: proof techniques

Show hint
Assume two fixed points $a,b$ and apply the contraction inequality to them. For existence, consider an interval missing its limit point.
Show answer

Read “at most one” carefully. It permits zero fixed points or one fixed point. The uniqueness proof is conditional: take any two proposed fixed points and prove that they coincide. An existence proof would instead need to produce a point or invoke a theorem whose existence hypotheses hold.

Suppose there are two fixed points $a,b\in X$: $g(a)=a$ and $g(b)=b$. We prove they are the same. Put $d=|a-b|\ge0$. The given contraction inequality implies

$$d=|g(a)-g(b)|\le d/3 \quad\Longrightarrow\quad d-d/3=2d/3\le0.$$

Multiplying by $3/2\gt0$ gives $d\le0$. Together with $d\ge0$, this forces $d=0$. Absolute value is zero only at zero, so $a-b=0$ and $a=b$. Thus there is at most one fixed point.

The proof starts by supposing fixed points exist; it does not produce one. For a counterexample to existence, take the nonempty set $X=(0,1]$ and $g(x)=x/3$. For $0\lt x\le1$, $0\lt x/3\le1/3\le1$, so this is a self-map. For all $x,y$, $|g(x)-g(y)|=|x-y|/3$, exactly the required bound. But $x=x/3$ gives $2x/3=0$, hence $x=0\notin X$. There is no fixed point. This set is not closed, so the existence part of the full contraction theorem is unavailable.

Check the zero-distance case before dividing. One alternative is to assume $a\ne b$, making $d=|a-b|\gt0$. Dividing $d\le d/3$ by this positive $d$ would give $1\le1/3$, a contradiction. This establishes $a=b$. Dividing by $d$ without first assuming it positive would be invalid when the two points are already equal. The subtraction argument above avoids division by an unknown quantity and covers that case directly. In the no-fixed-point example, iterates from $1$ approach $0$ while remaining in $(0,1]$; uniqueness cannot restore this excluded limit.

Exercise 0.P8 — Hard: Remove circular reasoning from a safety proof

Let $C=[-1,1]$ and suppose a map $F:\mathbb R\to\mathbb R$ satisfies $|F(x)|\le(4/5)|x|$ only for $x\in C$. From $x_0\in C$, define $x_{t+1}=F(x_t)$. A proposed proof says: “The trajectory is in $C$, so the bound applies at every step, so the trajectory stays in $C$.” Explain the circularity and replace it with an induction proof of $|x_t|\le(4/5)^t|x_0|$ and $x_t\in C$.

Review: proof techniques

Show hint
At time $t$, use the bound already proved at that time to establish membership in $C$ before applying the hypothesis to $F(x_t)$.
Show answer

Prove a joint induction statement. Use $P(t)$ to mean both membership in $C$ and the numerical estimate. Membership licenses the local hypothesis on $F$; the estimate then supplies membership for the next time. This order breaks the proposed circular argument.

The proposed proof assumes all-time membership in order to apply a bound that is valid only inside $C$. That assumes its own conclusion.

Prove instead, by induction, both $x_t\in C$ and $|x_t|\le(4/5)^t|x_0|$. At $t=0$, membership is given, and the estimate is equality because $(4/5)^0=1$.

Assume both statements hold at index $t$. Membership in $C$ now justifies the bound on $F$ at the current state. Thus

$$\begin{aligned} |x_{t+1}|&=|F(x_t)|\le(4/5)|x_t|\\ &\le(4/5)(4/5)^t|x_0|=(4/5)^{t+1}|x_0|\le1. \end{aligned}$$

The second inequality multiplies the induction estimate by a positive number. The last uses $|x_0|\le1$ and $0\lt(4/5)^{t+1}\le1$. The result proves both the next quantitative estimate and $x_{t+1}\in[-1,1]$. Induction gives both conclusions at all times. Future membership is derived after applying the valid current-state hypothesis.

Track a numerical start without assuming an exact map. If $x_0=1/2$, the estimate gives $|x_1|\le(4/5)(1/2)=2/5$ and $|x_2|\le(4/5)^2(1/2)=8/25$. These are upper bounds, not necessarily the actual states: the stated inequality does not determine $F$ uniquely. The map $F(x)=(4/5)x$ attains these bounds; the map $F(x)=0$ satisfies the same hypothesis and reaches zero in one step. The induction conclusion is valid for either map, and for every map meeting the local hypothesis. No behaviour outside $C$ needs to be assumed because the induction first proves the run stays inside it.

Exercise 0.P9 — Hard: When a finite simulation proves an all-time claim

A fixed deterministic map on $X=\{a,b,c,d\}$ has $F(a)=b$, $F(b)=c$, $F(c)=b$, $F(d)=d$. Start at $x_0=a$; state $d$ is failure. List the first five states. Explain why $d$ is never reached. More generally, justify why checking $x_0,\dots,x_3$ suffices for any fixed deterministic map on this four-state set. Can that conclusion fail if the map changes with time?

Review: proof techniques

Show hint
Among five states chosen from a set of four, two must repeat. A fixed deterministic map forces the same future after a repeated state.
Show answer

Write the transition graph as a calculation. The reachable arrows are $a\to b$, $b\to c$, $c\to b$; the isolated arrow is $d\to d$. Listing a trajectory means applying these arrows in order, rather than choosing a new arrow at each time.

Starting at $a$, successive substitutions give $x_0=a$, $x_1=F(a)=b$, $x_2=F(b)=c$, $x_3=F(c)=b$, and $x_4=F(b)=c$. From the repeated state $b$, the same fixed rule repeats $b,c,b,c,\ldots$. None of these states is $d$, so failure never occurs.

For a general fixed deterministic map on four states, consider the five states $x_0,\ldots,x_4$. The pigeonhole principle gives $x_i=x_j$ for some $0\le i\lt j\le4$. Applying the same function gives $x_{i+1}=F(x_i)=F(x_j)=x_{j+1}$. Induction on $m$ gives $x_{i+m}=x_{j+m}$ for every $m\ge0$.

Write the positive cycle length as $p=j-i$. From time $i$, states repeat with period $p$. For any $t\ge i$, division with remainder writes $t=i+qp+r$ with $0\le r\lt p$, so $x_t=x_{i+r}$. These cycle indices are at most $i+p-1=j-1\le3$. The initial prefix indices are smaller still. Hence every state ever visited appears among $x_0,\ldots,x_3$. Checking that prefix suffices to rule out a specified failure state.

For changing maps, let $F_t$ send every state to $a$ for $t=0,1,2$, and every state to $d$ for $t\ge3$. With $x_{t+1}=F_t(x_t)$ and $x_0=a$, the first four states are $a,a,a,a$, but $x_4=F_3(a)=d$. Equal states at different times need not have equal successors when different maps are used. The all-time conclusion needs the fixed deterministic rule.

Distinguish four checked states from four updates. $x_0,\dots,x_3$ contains four states but only three updates. The general proof temporarily considers a fifth state to force a repetition; it then shows that the fifth and every later state must equal a previously checked one. This is why it can certify the four-state prefix without testing infinitely many times. With a changing rule, the relevant input to the update includes the time as well as the state. Revisiting the same state at another time is then insufficient to force the same successor. In a finite state-and-mode model, a repetition argument would need to count the combined states instead.

4. Sequences, Limits & Series

Iterates, trajectories and learning curves are sequences; most guarantees concern their limits and rates.

Definition — Convergence, Cauchy sequences
A sequence $(a_t)_{t\in\mathbb N}$ converges to $a$, written $a_t\to a$ or $\lim_{t\to\infty}a_t=a$, if
$$\forall\varepsilon\gt0\ \ \exists T\in\mathbb N\ \ \forall t\ge T:\quad |a_t-a|\lt\varepsilon .$$
For vectors use $\|\cdot\|$ (equivalently, every coordinate converges). $a_t\to\infty$ means $\forall M\ \exists T\ \forall t\ge T: a_t\gt M$. A Cauchy sequence satisfies $\forall\varepsilon\gt0\ \exists T\ \forall s,t\ge T: |a_s-a_t|\lt\varepsilon$; in $\mathbb R^n$ a sequence converges iff it is Cauchy (completeness).

Intuition and example. Whatever tolerance $\varepsilon$ you name, the sequence is eventually within $\varepsilon$ of $a$ and stays there; $T$ may grow as $\varepsilon$ shrinks. $a_t=1/(t+1)\to0$: any integer $T\ge1/\varepsilon$ works, since $t\ge T$ gives $1/(t+1)\le1/(T+1)\lt1/T\le\varepsilon$ ($T=100$ for $\varepsilon=0.01$). $(-1)^t$ has no limit: with $\varepsilon=1$, both $1$ and $-1$ would lie within $1$ of $a$, and then $2\le|1-a|+|a+1|\lt2$.

Rules. Limits respect sums, products and quotients (nonzero denominator limit). $a_t\le b_t$ for all $t$ gives $\lim a_t\le\lim b_t$, but strict inequalities may become equalities ($1/(t+1)\gt0$, limit $0$). Squeeze: $a_t\le c_t\le b_t$ with $a_t,b_t\to\ell$ gives $c_t\to\ell$. Continuity: if $g$ is continuous at $a$ and $a_t\to a$, then $g(a_t)\to g(a)$.

Theorem — Monotone convergence for sequences
A nonincreasing sequence that is bounded below converges, to $\inf_ta_t$ (Section 5); a nondecreasing one bounded above converges to $\sup_ta_t$. Proof. Let $a=\inf_ta_t$. For $\varepsilon\gt0$, $a+\varepsilon$ is not a lower bound, so $a_T\lt a+\varepsilon$ for some $T$, and for $t\ge T$, $a\le a_t\le a_T\lt a+\varepsilon$. $\blacksquare$ Both assumptions matter: $-t$ decreases without bound, and $(-1)^t$ is bounded but not monotone.

Example (Module 11). If $V\ge0$ and $V(x_{t+1})\le V(x_t)$, then $V(x_t)\to v^\ast\ge0$, but nothing forces $v^\ast=0$ ($1+\frac1{t+1}$ decreases to $1$); that needs compactness and strict decrease (end of Section 6). For $x_{t+1}=x_t/(1+x_t^2)$, $V(x)=x^2$, $x_0=1$, the values (rounded where needed) $1,\ 0.25,\ 0.16,\ 0.119,\ 0.095,\dots$ decrease and converge. Pointwise vs uniform: $f_n\to f$ pointwise if $f_n(x)\to f(x)$ for each $x$ ($T$ may depend on $x$), uniformly if $\sup_x|f_n(x)-f(x)|\to0$; $x^n\to0$ pointwise on $[0,1)$ but not uniformly. On a finite set pointwise implies uniform (take the largest $T$).

Where this is used
"$V(x_t)$ decreases to some $v^\ast\ge0$" in Module 11; the decreasing sequence $L\ge T[L]\ge T^2[L]\ge\cdots$ in Module 11; monotone confidence endpoints $l_t\uparrow$, $u_t\downarrow$ in Module 4; "nonincreasing and bounded below, so it converges" on finitely many state-action pairs in Module 7.

Series, the geometric series and discounting

Theorem — Geometric series
A series $\sum_{t=0}^{\infty}a_t$ is the limit of its partial sums $S_T=\sum_{t=0}^{T-1}a_t$ ($T$ terms), if it exists. For $\gamma\ne1$, and for $|\gamma|\lt1$ respectively,
$$\sum_{t=0}^{T-1}\gamma^t=\frac{1-\gamma^T}{1-\gamma},\qquad \sum_{t=0}^{\infty}\gamma^t=\frac{1}{1-\gamma},\qquad \sum_{t=T}^{\infty}\gamma^t=\frac{\gamma^T}{1-\gamma}.$$
Proof. $S_T-\gamma S_T=(1+\gamma+\dots+\gamma^{T-1})-(\gamma+\dots+\gamma^{T})=1-\gamma^T$; divide by $1-\gamma$. If $|\gamma|\lt1$, then $|\gamma|^T\to0$, so $S_T\to\frac1{1-\gamma}$, and the tail is $\frac1{1-\gamma}-S_T=\frac{\gamma^T}{1-\gamma}$. $\blacksquare$
Discounting. If $|r_t|\le R_{\max}$ and $0\le\gamma\lt1$, then $\big|\sum_t\gamma^tr_t\big|\le\frac{R_{\max}}{1-\gamma}$ and the tail from $T$ on is at most $\frac{\gamma^TR_{\max}}{1-\gamma}$; $1/(1-\gamma)$ is the effective horizon ($\gamma=0.99$ counts about $100$ steps).

Example ($\gamma=0.9$). The limit is $10$. With $0.9^{10}\approx0.3487$, the first ten terms give $S_{10}\approx6.513$ and the tail is approximately $3.487$. Capturing $99\%$ needs $\gamma^T\le0.01$, i.e. $T\ge\ln0.01/\ln0.9\approx43.7$: $44$ terms. Because $\ln(1/\gamma)\ge1-\gamma$ (proved below), $T\ge\ln(1/\varepsilon)/(1-\gamma)$ always guarantees $\gamma^T\le\varepsilon$; here it asks for $47$. The explorer's lower panel computes this for any $\gamma$.

Going deeper — the matrix geometric (Neumann) series

If a square matrix has operator norm $\|A\|\lt1$ (Primer A), then $(I-A)^{-1}=\sum_{t\ge0}A^t$: indeed $(I-A)(I+A+\dots+A^{T-1})=I-A^T$ and $\|A^T\|\le\|A\|^T\to0$. For an MDP transition matrix $P_\pi$ (rows sum to $1$, so $\|\gamma P_\pi\|_\infty=\gamma$), $(I-\gamma P_\pi)^{-1}=\sum_t\gamma^tP_\pi^t$ collects the discounted visits: the "Neumann series read along trajectories" of Module 9. Module 11 uses $(I-P)^{-1}=\sum_tP^t$ for transient chains.

Telescoping. $\sum_{t=0}^{T-1}(b_{t+1}-b_t)=b_T-b_0$: intermediate terms cancel in pairs. Since $\frac1{r(r+1)}=\frac1r-\frac1{r+1}$, $\sum_{r=1}^{R}\frac1{r(r+1)}=1-\frac1{R+1}\to1$, which is why a failure probability $\delta'$ can be split into pieces $\delta'/(r(r+1))$ (Module 5). Summing a Lyapunov or dissipation inequality $V(x_{t+1})-V(x_t)\le-\varepsilon\|x_t\|^2$ over $t\lt T$ telescopes the left side, and with $V\ge0$:

$$\varepsilon\sum_{t=0}^{T-1}\|x_t\|^2\ \le\ V(x_0)-V(x_T)\ \le\ V(x_0)\qquad\text{for every }T .$$
Where this is used
Summed dissipation inequalities in Module 2, Module 12 and Module 13; the performance difference lemma in Module 9; a telescoping $\log\det$ in Module 3; $R_{\max}/(1-\gamma)$ in Module 6, $(1-\gamma^{T_f+1})/(1-\gamma)$ in Module 7 and $\frac{1}{1-\gamma}\langle\rho_\pi,r\rangle$ in Module 8.
Fact — Series with nonnegative terms
(a) If $a_t\ge0$, the partial sums are nondecreasing, so $\sum_ta_t$ converges iff they are bounded. (b) Comparison: $0\le a_t\le b_t$ and $\sum b_t\lt\infty$ give $\sum a_t\lt\infty$; and $\sum|a_t|\lt\infty$ implies that $\sum a_t$ converges. (c) If $\sum_ta_t$ converges, then $a_t=S_{t+1}-S_t\to s-s=0$. (d) The converse of (c) fails: $\sum_{t\ge1}\frac1t=\infty$, because the $2^j$ terms from $2^j+1$ to $2^{j+1}$ are each at least $2^{-(j+1)}$, adding at least $\frac12$ per block. In contrast $\sum_{t\ge1}\frac1{t^2}\le1+\sum_{t\ge2}\frac1{t(t-1)}=2$ by telescoping.

Application. For $\varepsilon\gt0$, $\varepsilon\sum_{t\lt T}\|x_t-x_\ast\|^2\le V(x_0)$ for all $T$ gives $x_t\to x_\ast$ by (a) and (c): Step D in Module 14; likewise in Module 11.

Going deeper — when may limits, sums and expectations be exchanged?

A limit and a sum cannot always be exchanged: for $a_{n,t}=1$ if $t=n$ (else $0$), $\lim_n\sum_ta_{n,t}=1$ but $\sum_t\lim_na_{n,t}=0$, although all terms are nonnegative. Two sums, or a sum and an expectation, may be exchanged when the terms are nonnegative (Tonelli), e.g. $\mathbb E\big[\sum_tX_t\big]=\sum_t\mathbb E[X_t]$ for $X_t\ge0$. A limit may be exchanged with a sum or an expectation under domination: $a_{n,t}\to a_t$ with $|a_{n,t}|\le b_t$, $\sum_tb_t\lt\infty$, gives $\sum_ta_{n,t}\to\sum_ta_t$, and $Y_n\to Y$ almost surely (Section 5) with $|Y_n|\le Z$, $\mathbb E[Z]\lt\infty$, gives $\mathbb E[Y_n]\to\mathbb E[Y]$ (dominated convergence; bounded convergence if $Z$ is constant). Nonnegative terms that increase with $n$ are another sufficient condition (monotone convergence).

For discounted sums the geometric tail suffices: if $|r_t|\le R_{\max}$, then $\big|\mathbb E\big[\sum_t\gamma^tr_t\big]-\sum_{t\lt T}\gamma^t\mathbb E[r_t]\big|\le\frac{\gamma^TR_{\max}}{1-\gamma}\to0$, so $\mathbb E\big[\sum_t\gamma^tr_t\big]=\sum_t\gamma^t\mathbb E[r_t]$: "bounded rewards and $\gamma\lt1$ kill the tail" in Module 9, the occupancy measures of Module 8. The CVaR walkthrough of Module 1 differentiates inside an expectation by bounded convergence.

Limits of functions; the exponential and the logarithm

$\lim_{x\to a}f(x)=\ell$ means $\forall\varepsilon\gt0\ \exists\delta\gt0: 0\lt|x-a|\lt\delta\Rightarrow|f(x)-\ell|\lt\varepsilon$, equivalently $f(x_t)\to\ell$ for every sequence $x_t\to a$ with $x_t\ne a$; one-sided limits $x\downarrow a$, $x\uparrow a$ use only $x\gt a$ or $x\lt a$, and $f$ is continuous at $a$ iff $\lim_{x\to a}f(x)=f(a)$.

Key equation — The exponential as a limit, and two inequalities
$$e^{x}=\lim_{n\to\infty}\Big(1+\frac xn\Big)^{n},\qquad 1+x\le e^{x}\ \ (x\in\mathbb R),\qquad \ln x\le x-1\ \ (x\gt0).$$
$(1+\frac1n)^n\approx2.5937,\ 2.7048,\ 2.7169$ for $n=10,100,1000$ ($e\approx2.71828$), and $(1-\frac1n)^n\approx0.3487,\ 0.3660,\ 0.3677$ ($1/e\approx0.3679$). Proof of the inequalities. $\phi(x)=e^x-1-x$ has $\phi'(x)=e^x-1$, negative for $x\lt0$ and positive for $x\gt0$, so $\phi\ge\phi(0)=0$. Replacing $x$ by $x-1$ gives $x\le e^{x-1}$; take logarithms. $\blacksquare$

Consequences. $(1-p)^n\le e^{-pn}$: $n$ independent trials all miss an event of probability $p$ with probability at most $e^{-pn}$ (for $p=0.01$, $n=300$: $0.99^{300}\le e^{-3}$, with $0.99^{300}\approx0.0490$ and $e^{-3}\approx0.0498$), the origin of sample sizes like $\ln(1/\beta)/\varepsilon$ in Module 15. With $x=\gamma$: $\ln(1/\gamma)\ge1-\gamma$, so $\gamma^T\le e^{-(1-\gamma)T}$. A soft maximum becomes a maximum: for $q_1,\dots,q_n$ with maximum $m$ and $\alpha\gt0$, $e^{m/\alpha}\le\sum_ie^{q_i/\alpha}\le n\,e^{m/\alpha}$, so

$$m\ \le\ \alpha\ln\sum_{i=1}^{n}e^{q_i/\alpha}\ \le\ m+\alpha\ln n\qquad\Longrightarrow\qquad \lim_{\alpha\downarrow0}\ \alpha\ln\sum_{i=1}^{n}e^{q_i/\alpha}=\max_iq_i$$

by the squeeze rule; for $q=(1,\,0.5,\,0.9)$ the soft maximum is approximately $1.921$, $1.032$ and $1.0000005$ at $\alpha=1,\ 0.1,\ 0.01$. This is the temperature limit of entropy-regularised Bellman equations (Module 7, Primer E).

Convergence rates

Definition — Linear, sublinear and quadratic convergence
Nonnegative errors $e_k\to0$ converge linearly (geometrically) with rate $q\in(0,1)$ if $e_{k+1}\le q\,e_k$, so $e_k\le q^ke_0$; sublinearly if slower than every geometric rate, for example $e_k=C/k^p$ with $C,p\gt0$ and $k\ge1$ (a polynomial upper bound alone does not rule out geometric convergence); quadratically if $e_{k+1}\le Ce_k^2$ with $C\gt0$ (scalar Newton's method near a regular root of a $C^2$ function, from a sufficiently close initial point).

For $e_0,\varepsilon\gt0$, the geometric envelope $q^ke_0$ is at most $\varepsilon$ iff $k\ge\ln(e_0/\varepsilon)/\ln(1/q)$; this cutoff suffices for any errors $e_k\le q^ke_0$, and grows like $\ln(1/\varepsilon)$ as $\varepsilon\downarrow0$ with fixed $q\in(0,1)$ and $e_0$. For the exact errors $e_k=1/\sqrt k$, $k\ge1$, reaching the tolerance is equivalent to $k\ge1/\varepsilon^2$. At $\varepsilon=10^{-6}$ and $e_0=1$, the two exact envelopes first reach the tolerance at $20$ iterations for $q=0.5$ and at $10^{12}$, respectively; faster errors can reach it earlier. On a logarithmic plot exact positive geometric errors form a straight line, while the logarithmic slope of a positive reciprocal-power curve tends to zero (see the explorer). Used for geometric Lyapunov decay and interior-point iteration counts $O(\sqrt n\log(1/\varepsilon))$ in Module 2, $O(1/\sqrt T)$ primal-dual rates in Module 8, and gradient descent in Primer B.

With limits and the geometric series, Banach's existence proof (Section 2) takes six steps.

Practice: Sequences, limits and series

Work from Easy to Medium before trying Hard. Use the review link for a missing definition, then try again with the explanation closed.

Guided build-up. Start with these smaller questions to practise the tools used by the graded exercises that follow.

Exercise 0.GL1 — Easy: Build an epsilon proof from a tolerance calculation

For $a_t=1/(t+1)$, $t=0,1,2,\dots$, calculate the first four terms and prove $a_t\to0$ from the definition of convergence. For any given $\varepsilon\gt0$, supply an explicit integer $T$ such that $|a_t|\lt\varepsilon$ for every $t\ge T$. Check your rule for $\varepsilon=1/4$.

Review: Sequences and series

Show hint

Choose $T$ after seeing the tolerance. $\lfloor r\rfloor$ is the greatest integer at most $r$, so $\lfloor r\rfloor+1\gt r$.

Show worked solution

Step 1: Evaluate the indices. Substitution gives $a_0=1$, $a_1=1/2$, $a_2=1/3$, $a_3=1/4$. The candidate limit is $0$, so its distance from $a_t$ is $|a_t-0|=1/(t+1)$.

Step 2: State the target in the correct order. Convergence to $0$ means that for every real tolerance $\varepsilon\gt0$, there is an integer $T\ge0$ such that every integer $t\ge T$ satisfies $|a_t|\lt\varepsilon$. $T$ may depend on the tolerance, but it must cover all later indices at once.

Step 3: Choose a definite integer. Given $\varepsilon\gt0$, set $T=\lfloor1/\varepsilon\rfloor+1$. It is a nonnegative integer and $T\gt1/\varepsilon$. For any $t\ge T$, the denominator satisfies $t+1\ge T+1\gt1/\varepsilon$. Taking reciprocals of positive numbers reverses order, yielding $1/(t+1)\lt\varepsilon$.

Step 4: Conclude for every tolerance. We gave a legal $T$ and verified the requested inequality for every later $t$, so the definition proves $a_t\to0$. The rule is sufficient; the definition does not require the smallest possible $T$.

Step 5: Test the distinction. At $\varepsilon=1/4$, our rule gives $T=5$, and $a_t\le1/6\lt1/4$ for all $t\ge5$. The smallest threshold is actually $4$: $a_4=1/5\lt1/4$, whereas $a_3=1/4$ fails the strict test. A sufficient convergence witness can be larger than a minimal computational budget.

Exercise 0.GL2 — Easy: Separate terms, partial sums and a tail

Let $a_t=(1/2)^t$ and $S_T=\sum_{t=0}^{T-1}a_t$, with $S_0=0$. Calculate $S_1,S_2,S_3,S_4$. Derive $S_T=2(1-2^{-T})$ and the omitted infinite tail $2^{1-T}$. Explain why $a_t\to0$ is a different statement from $S_T\to2$.

Review: Sequences and series

Show hint

Multiply a finite sum by $1/2$ and subtract; intermediate terms cancel. A tail starts at the first index you have not included.

Show worked solution

Step 1: Track how many terms are included. $S_1=1$. $S_2=1+1/2=3/2$. $S_3=3/2+1/4=7/4$. $S_4=7/4+1/8=15/8$. The subscript $T$ counts terms; the last included term is $a_{T-1}$.

Step 2: Derive the finite formula before taking a limit. For $T\ge1$, write $S_T=1+1/2+\cdots+2^{-(T-1)}$ and $(1/2)S_T=1/2+1/4+\cdots+2^{-T}$. Subtracting cancels all shared terms:

$$S_T-\tfrac12S_T=1-2^{-T}.$$

Thus $(1/2)S_T=1-2^{-T}$, and multiplying by $2$ gives $S_T=2(1-2^{-T})$. It also holds at $T=0$, since $2(1-1)=0=S_0$.

Step 3: Define the infinite sum through its partial sums. Because $2^{-T}\to0$, the finite-sum formula gives $S_T\to2$. This limit is what we mean by $\sum_{t=0}^{\infty}a_t=2$.

Step 4: Subtract the included portion. The omitted tail after $T$ terms is $2-S_T=2-2(1-2^{-T})=2\cdot2^{-T}=2^{1-T}$. At $T=4$, it is $2-15/8=1/8$; its first term is $a_4=1/16$, and the remaining terms supply the other $1/16$.

Step 5: Distinguish two sequences. $a_t$ is one term at a time, and its limit is zero. $S_T$ is the accumulation of the first $T$ terms, and its limit is two. Terms tending to zero is necessary for a series to converge, but is not sufficient: $1/(t+1)$ tends to zero while its harmonic series diverges. The geometric calculation establishes convergence here rather than assuming it from the term limit.

Exercise 0.GL3 — Medium: Watch a telescoping sum cancel

Define $b_t=1/(t+1)-1/(t+2)$ for $t\ge0$. Calculate $b_0,b_1,b_2$ and expand $\sum_{t=0}^{2}b_t$ before simplifying. Derive the $T$-term partial sum and the infinite sum. Can all the terms be positive while the sum stays finite?

Review: Sequences and series

Show hint

The second fraction of one term cancels the first fraction of the next. Keep the first and last uncancelled fractions.

Show worked solution

Step 1: Evaluate individual terms. $b_0=1-1/2=1/2$. $b_1=1/2-1/3=(3-2)/6=1/6$. $b_2=1/3-1/4=(4-3)/12=1/12$. More generally, a common denominator gives $b_t=1/((t+1)(t+2))\gt0$.

Step 2: Write the cancellation explicitly.

$$\begin{aligned} \sum_{t=0}^{2}b_t &=(1-\tfrac12)+(\tfrac12-\tfrac13)+(\tfrac13-\tfrac14)\\ &=1-\tfrac14=\tfrac34. \end{aligned}$$

The $-1/2$ cancels $+1/2$, and $-1/3$ cancels $+1/3$. As an independent arithmetic check, $1/2+1/6+1/12=(6+2+1)/12=3/4$.

Step 3: Identify the last index. A $T$-term sum starting at $0$ ends at $T-1$, whose second fraction is $1/(T+1)$. Every intermediate fraction appears with both signs, so $\sum_{t=0}^{T-1}b_t=1-1/(T+1)$. At $T=0$, both the empty sum and this expression are zero.

Step 4: Take the limit of partial sums. As $T\to\infty$, $1/(T+1)\to0$, giving the infinite sum $1$. The omitted tail is exactly $1/(T+1)$. All terms are positive, so the partial sums increase, but the formula keeps them below $1$. Positivity implies increase, not unbounded growth. This cancellation pattern later turns many one-step energy inequalities into finite total budgets.

Exercise 0.4a — Easy: Turn a tolerance into an index

Let $a_t=3/(t+1)$ for integers $t\ge0$. Write the first four terms, state the limit, and find the smallest $T$ such that $|a_t|\lt0.1$ for every $t\ge T$.

Review: Sequences, limits and series

Show hint

Solve $3/(t+1)\lt0.1$ first, then remember that $t$ is an integer and the inequality is strict.

Show worked solution

Translate “for every later time” into a permanent bound. Finding one small term is not generally enough. Here the positive denominator increases with $t$, so the terms decrease; once the inequality is true, it stays true. We still need to check the first qualifying integer.

Substitute $t=0,1,2,3$ into $a_t=3/(t+1)$: the first four terms are $3/1=3$, $3/2$, $3/3=1$, and $3/4$. Since $t+1$ grows without bound while the numerator stays $3$, the limit is $0$.

For $t\ge0$, $a_t\gt0$, so $|a_t|=a_t$. Both $t+1$ and $0.1$ are positive. Therefore

$$\frac3{t+1}\lt0.1 \iff3\lt0.1(t+1) \iff30\lt t+1 \iff29\lt t.$$

An integer greater than $29$ is at least $30$. For every $t\ge30$, $a_t\le3/31\lt1/10=0.1$; the strict comparison follows by cross-multiplying positive denominators: $30\lt31$. Thus $T=30$ works. At $t=29$, $a_{29}=3/30=0.1$, so the strict inequality fails. Any smaller threshold includes this failing index. Hence $30$ is the smallest threshold valid for every later term.

Supply the limit proof behind the informal denominator argument. For an arbitrary tolerance $\varepsilon\gt0$, choose $T=\lfloor3/\varepsilon\rfloor$. If $t\ge T$, then $t+1\ge T+1\gt3/\varepsilon$, so $|a_t|=3/(t+1)\lt\varepsilon$. This proves the definition of convergence to $0$. At $\varepsilon=0.1$, it gives $T=30$, matching the exact cutoff. For a non-strict tolerance at $0.1$, the endpoint $t=29$ would pass; the difference between $\lt$ and $\le$ changes the smallest budget by one here.

Exercise 0.4b — Medium: Bound the part of a return you have not summed

With discount $\gamma=1/2$ and rewards $|r_t|\le2$, bound the absolute infinite return. Compute the first four terms and the omitted tail when $r_t=2$ always. What is the smallest number $T$ of terms guaranteeing a tail at most $0.01$ for every permitted reward sequence?

Review: Sequences, limits and series

Show hint

The first $T$ terms have indices $0,\dots,T-1$; the tail bound is $2\gamma^T/(1-\gamma)$.

Show worked solution

Name the object being bounded. The return is a sum of signed discounted rewards. Its absolute value is not the same as the sum of the absolute values, but the triangle inequality bounds the first by the second. The latter is easier to control because its terms are nonnegative.

Bound the return before computing any particular sequence. Since $|r_t|\le2$ and the discount is $\gamma=1/2$, each discounted reward satisfies $|2^{-t}r_t|\le2\cdot2^{-t}$. The geometric series on the right converges, so the return converges absolutely. Applying the triangle inequality and summing gives

$$\left|\sum_{t=0}^{\infty}2^{-t}r_t\right| \le\sum_{t=0}^{\infty}2^{-t}|r_t| \le2\sum_{t=0}^{\infty}(1/2)^t =\frac{2}{1-1/2}=4.$$

Compute the four-term example. With $r_t=2$ at every time, the terms at $t=0,1,2,3$ are $2,1,1/2,1/4$. Their sum is $2+1+1/2+1/4=15/4=3.75$. The infinite sum is exactly $4$, so the omitted tail is $4-15/4=1/4$. Its first omitted term is at $t=4$, not at $t=3$.

Keep the unknown rewards in the tail bound. After $T$ terms, the tail starts at $t=T$. For every allowed sequence,

$$\left|\sum_{t=T}^{\infty}2^{-t}r_t\right| \le2\sum_{t=T}^{\infty}(1/2)^t =\frac{2(1/2)^T}{1-1/2} =4\cdot2^{-T}.$$

To guarantee a tail at most $0.01=1/100$, solve $4/2^T\le1/100$, equivalently $2^T\ge400$. The neighbouring powers are $2^8=256$ and $2^9=512$, so $T=9$ is sufficient. The corresponding bounds are $4/256=0.015625$ at $8$ and $4/512=0.0078125$ at $9$.

These checks also prove minimality for a guarantee about every reward sequence: the permitted sequence $r_t=2$ attains the tail bound. It therefore really has too much omitted return at $T=8$, and at every smaller $T$. The tolerance is an absolute return error, not a percentage of the infinite return.

Check the two extremes and the indexing. The constant sequence $r_t=2$ attains return $4$; the constant sequence $r_t=-2$ attains $-4$. Thus the possible returns lie in $[-4,4]$, and the absolute bound $4$ cannot be improved from the stated data. Mixed signs can cancel, but a guarantee for every permitted sequence cannot assume that cancellation. At the sufficient budget $T=9$, the included rewards have indices $0,1,\dots,8$ and the omitted tail begins at $9$. Using an endpoint $T$ in the included sum would silently use ten terms rather than nine.

Exercise 0.4c — Hard: Extract convergence from a telescoping inequality

Suppose $V_t\ge0$, $V_0=3$, and $V_{t+1}-V_t\le-\tfrac12\|x_t\|^2$ for every $t\ge0$. Prove $x_t\to0$. Bound the total number of indices with $\|x_t\|\ge0.2$. Does this give a time after which all such indices have disappeared?

Review: Sequences, limits and series

Show hint

Sum through $t=T-1$. Every index above the threshold contributes at least $0.2^2$ to the sum of squared norms.

Show worked solution

Start with a finite horizon. We first add only $T$ inequalities, so all cancellation and rearrangement involve finite sums. The all-time conclusion follows after we prove one bound that works for every finite $T$; we need not manipulate an infinite sum before establishing convergence.

Sum the one-step inequality. Add it for $t=0,\ldots,T-1$. The left side is

$$(V_1-V_0)+(V_2-V_1)+\cdots+(V_T-V_{T-1})=V_T-V_0,$$

because each intermediate value appears once with each sign. Thus $V_T-V_0\le-\tfrac12\sum_{t=0}^{T-1}\|x_t\|^2$. Rearranging and using $V_T\ge0$, $V_0=3$, gives

$$\frac12\sum_{t=0}^{T-1}\|x_t\|^2 \le V_0-V_T\le3, \qquad \sum_{t=0}^{T-1}\|x_t\|^2\le6.$$

Turn the energy budget into convergence. These partial sums increase because every squared norm is nonnegative, and they are bounded above by $6$. They therefore converge to a finite limit. If $S_T$ denotes the partial sum, then $\|x_T\|^2=S_{T+1}-S_T\to0$. Since the norms are nonnegative, taking square roots gives $\|x_T\|\to0$, which is the definition of $x_T\to0$.

Count all excursions, not just an initial block. Whenever $\|x_t\|\ge0.2$, its squared norm is at least $(0.2)^2=0.04$. If $N$ such indices occur before a horizon $T$, then $0.04N\le\sum_{t=0}^{T-1}\|x_t\|^2\le6$, so $N\le150$. If there were $151$ excursions over all time, some finite horizon would contain all of the first $151$, contradicting that bound. There are therefore at most $150$ altogether.

Distinguish existence of a last excursion from knowing its time. A finite set of excursion indices has a last member, so the stated assumptions imply an eventual absence of excursions. They do not supply a numerical time valid for every compatible sequence. For example, choose any large index $M$ and, in the scalar case, set $x_M=0.2$ and all other $x_t=0$. Keep $V_t=3$ through $t=M$, and set $V_t=2.98$ afterwards. At $M$, the decrease is $-0.02=-\tfrac12(0.2)^2$; at other times it is $0$. All assumptions hold, but the single excursion can occur as late as we choose. A time estimate requires additional information.

Prove convergence through the definition, without assuming a rate. Given any $\varepsilon\gt0$, each index with $\|x_t\|\ge\varepsilon$ spends at least $\varepsilon^2$ of the total squared-norm budget $6$. There can therefore be at most $\lfloor6/\varepsilon^2\rfloor$ such indices. This set of indices is finite. If it is nonempty, choose $T$ one larger than its largest member; if it is empty, choose $T=0$. Then every $t\ge T$ has $\|x_t\|\lt\varepsilon$, exactly the definition of convergence to zero. This $T$ depends on the actual locations of the excursions. The energy inequality controls how many there are, but does not reveal those locations, which explains the lack of a uniform numerical time estimate.

5. Supremum, Infimum & Bounds

Worst cases over infinite sets (largest gradient, worst disturbance, best policy) are suprema; unlike maxima they always exist, possibly as $\pm\infty$.

Definition — Upper bound, supremum, maximum
For a nonempty $A\subseteq\mathbb R$, $u$ is an upper bound if $a\le u$ for all $a\in A$, and $A$ is bounded above if it has one. When $A$ is bounded above, its supremum $\sup A$ is the least upper bound: (i) $a\le\sup A$ for all $a\in A$, and (ii) for every $\varepsilon\gt0$ some $a\in A$ has $a\gt\sup A-\varepsilon$ (if $A$ is not bounded above, $\sup A=+\infty$, see the next box). If $\sup A\in A$ it is the maximum. Infimum (greatest lower bound) and minimum are symmetric, $\inf A=-\sup(-A)$, and $\sup_{x\in X}f(x):=\sup f(X)$. Completeness of $\mathbb R$: every nonempty set that is bounded above has a supremum in $\mathbb R$.

Intuition and examples. A supremum is a ceiling you can approach but may never touch: $[0,1)$ has supremum $1$ and no maximum. $\sup_{r\ge0}(1-e^{-r})=1$ is not attained (a bounded continuity modulus in Module 5), while $\sup_xe^{-x^2}=1$ is a maximum. The Lipschitz constant $L^\star(f)=\sup_{x\ne y}|f(x)-f(y)|/|x-y|$ of $\sin$ is $1$, approached as $x,y\to0$ but never attained. To prove $\sup A=s$, show that $s$ is an upper bound and find $a_n\in A$ with $a_n\to s$.

Definition — Extended reals and optimal values
$\overline{\mathbb R}=\mathbb R\cup\{-\infty,+\infty\}$; $\sup A=+\infty$ if $A$ is unbounded above, and by convention $\sup\emptyset=-\infty$, $\inf\emptyset=+\infty$ (every number bounds $\emptyset$). $a+\infty=\infty$ for $a\ne-\infty$, while $\infty-\infty$ is undefined. The value $\inf\{f(x):x\in S\}$ of a minimization is $+\infty$ if it is infeasible ($S=\emptyset$) and $-\infty$ if it is unbounded below. A function with values in $\overline{\mathbb R}$ is proper if it never equals $-\infty$ and is finite somewhere.

Example. SafeOpt starts from $C_0(x)=[h,\infty)$ on the seed, so $l_0(x)=h$ and $u_0(x)=+\infty$, and from $C_0(x)=\mathbb R$ elsewhere ($l_0=-\infty$). If data contradict an earlier band, $C_t(x)=\emptyset$, and the conventions would give $l_t=+\infty\gt u_t=-\infty$; Module 4 treats this as a failed confidence event or numerical error, not as a certificate; one empty intersection alone does not prove that the assumptions are false.

Fact — Rules for suprema and infima
For nonempty bounded $A,B\subseteq\mathbb R$, $c\gt0$ and functions $f,g,\phi$: (1) $\sup(cA)=c\sup A$ and $\sup(-A)=-\inf A$; (2) $\sup(A+B)=\sup A+\sup B$, where $A+B=\{a+b\}$; (3) $\sup_x(f+g)\le\sup_xf+\sup_xg$ and $\inf_x(f+g)\ge\inf_xf+\inf_xg$, possibly strictly; (4) $A\subseteq B\Rightarrow\sup A\le\sup B$ and $\inf A\ge\inf B$: optimizing over a larger set (relaxing constraints) raises a maximum and lowers a minimum; (5) the max-min inequality $\sup_y\inf_x\phi(x,y)\le\inf_x\sup_y\phi(x,y)$.

Proofs. (2) "$\le$": $a+b\le\sup A+\sup B$. "$\ge$": pick $a\gt\sup A-\frac\varepsilon2$, $b\gt\sup B-\frac\varepsilon2$, so $\sup(A+B)\gt\sup A+\sup B-\varepsilon$ for every $\varepsilon\gt0$. (1) is similar. (3): $f(x)+g(x)\le\sup f+\sup g$ for every $x$; it is strict for $f(x)=x$, $g(x)=-x$ on $[0,1]$ ($0\lt1$). (5): $\inf_x\phi(x,y)\le\phi(x',y)\le\sup_{y'}\phi(x',y')$ for all $x',y$; take $\sup_y$ on the left and $\inf_{x'}$ on the right. $\blacksquare$ For $\phi(x,y)=(x-y)^2$ on $\{0,1\}^2$: $\inf_x\sup_y\phi=1$ but $\sup_y\inf_x\phi=0$.

Where this is used
$L^\star(f)=\sup_x\|J_f(x)\|$ in Module 12; "the infimum of a sum is at least the sum of the infima", optimal values $\pm\infty$ and weak duality via rule (5) in Module 2 and Module 8; $\ell_t=\inf C_t$, $u_t=\sup C_t$ in Module 5; argmax sets and min-max problems in Primer B.
Pitfall — writing max where only sup is known
"$\max_{x\in D}f(x)$" presumes a maximizer: fine for nonempty finite $D$, or nonempty compact $D$ and continuous $f$ (Section 6). On $(0,1)$, $\max x$ does not exist although $\sup x=1$. A step "pick $x_t\in\operatorname*{arg\,max}$" needs that existence, or an explicit approximate choice.

Limit superior and limit inferior

$\limsup_ta_t:=\lim_{T\to\infty}\sup_{t\ge T}a_t$ and $\liminf_ta_t:=\lim_{T\to\infty}\inf_{t\ge T}a_t$ always exist in $\overline{\mathbb R}$, because $\sup_{t\ge T}a_t$ is nonincreasing and $\inf_{t\ge T}a_t$ nondecreasing in $T$; a sequence converges iff they are equal and finite. Example. Let $r_t=1$ if $4^k\le t\lt2\cdot4^k$ for some integer $k\ge0$, else $r_t=0$ ($t\ge1$). The average $\frac1T\sum_{t=1}^{T}r_t$ approaches $\frac23$ at the end of each block of ones and $\frac13$ at the end of each block of zeros: $\liminf=\frac13$, $\limsup=\frac23$, no limit. A long-run constraint $\liminf_T\frac1T\sum_{t\lt T}r_t\ge c$ says that for every $\varepsilon\gt0$ the average is at least $c-\varepsilon$ for all large $T$ (it may stay slightly below $c$ forever, like $c-\frac1T$), whether or not the average settles (Module 8).

Preview: almost everywhere and almost surely

Definition — Measure zero, a.e., a.s., essential supremum
$N\subseteq\mathbb R^n$ has measure zero (zero volume) if for every $\varepsilon\gt0$ it can be covered by countably many boxes of total volume below $\varepsilon$, e.g. finite sets in positive dimension, lines in $\mathbb R^2$, hyperplanes $\{x:w^\top x+b=0\}$ with $w\ne0$, and finite unions of these. A property holds almost everywhere (a.e.) if it fails only on a measure-zero set, and an event holds almost surely (a.s.) if its probability is $1$. The essential supremum is the smallest almost-sure upper bound, $\operatorname*{ess\,sup}Z=\inf\{c:\mathbb P(Z\le c)=1\}$.

Intuition and example. A ReLU network is differentiable except at the kinks where a hidden unit switches: finitely many pieces of hyperplanes $w^\top x+b=0$ (whole hyperplanes for one hidden layer), a measure-zero set. Every Lipschitz function on $\mathbb R^n$ is differentiable a.e. (Rademacher). If $U$ is uniform on $[0,1]$ and $Z=U$ except $Z=10$ when $U=\frac12$, then $\operatorname*{ess\,sup}Z=1$, although the supremum over all outcomes is $10$. Almost-sure safety tolerates failures on a probability-zero set of disturbances; robust safety tolerates none (Primer C). Used in Module 1 (a.s. safety, $\operatorname*{ess\,sup}$), Module 12 and Module 10 (differentiable a.e.), Module 13 (gradient norm $1$ almost everywhere) and Module 8 (a.s. convergence).

Pitfall — "probability zero" is not "impossible"
A statement for almost every $x$ says nothing about a particular $x$, and the exceptions may sit exactly where it matters (a boundary, a ReLU kink). Upgrading needs structure such as continuity: a continuous function that is $\ge0$ almost everywhere is $\ge0$ everywhere.

Practice: Suprema, infima and bounds

Work from Easy to Medium before trying Hard. Use the review link for a missing definition, then try again with the explanation closed.

Guided build-up. Start with these smaller questions to practise the tools used by the graded exercises that follow.

Exercise 0.GB1 — Easy: Compute bounds and extrema on a finite set

Let $A=\{-3,1,1,2\}$. Write it without repetitions, find its cardinality, infimum, supremum, minimum and maximum, and decide whether $-4$ is a lower bound and $5$ is an upper bound. Why are these latter bounds not the tightest ones?

Review: Bounds and extrema

Show hint

A set does not retain repeated entries. A lower bound must be below every member; the infimum is the greatest of all such lower bounds.

Show worked solution

Step 1: Remove the repeated listing. $A=\{-3,1,2\}$, so $|A|=3$. Listing $1$ twice does not create a fourth distinct element.

Step 2: Find the tight lower bound. Every member is at least $-3$, so $-3$ is a lower bound. A proposed larger lower bound would exceed the actual member $-3$, and would fail its test. Thus $\inf A=-3$. It is a member of $A$, so $\min A=-3$ too.

Step 3: Find the tight upper bound. Every member is at most $2$, so $2$ is an upper bound. A proposed smaller upper bound would fail at the member $2$. Thus $\sup A=2$, and because it belongs to the set, $\max A=2$.

Step 4: Check looser bounds. $-4$ is indeed a lower bound: $-4\le-3$, $-4\le1$, $-4\le2$. But the larger lower bound $-3$ works, so $-4$ is not the greatest lower bound. Likewise $5$ is an upper bound, but $2$ is a smaller upper bound, so $5$ is not the least upper bound.

Step 5: State the distinction. Lower and upper bounds need not be members. Minimum and maximum must be members. Every nonempty finite subset of $\mathbb R$ has a smallest and a largest member; infinite sets require a separate attainment check.

Exercise 0.GB3 — Easy: Separate a minimum value from a minimizer

On $D=\{-1,0,1,2\}$, let $f(x)=(x-1)^2$. Find $f(D)$, $\min_{x\in D}f(x)$ and $\operatorname*{arg\,min}_{x\in D}f(x)$. Repeat the last two calculations on $D'=\{0,2\}$. Explain the type of each answer.

Review: Bounds and extrema

Show hint

Make a table of input-output pairs. The minimum is an output value; argmin is the set of inputs attaining it.

Show worked solution

Step 1: Evaluate every permitted input. $f(-1)=(-2)^2=4$, $f(0)=(-1)^2=1$, $f(1)=0^2=0$, and $f(2)=1^2=1$. Thus the output set is $f(D)=\{0,1,4\}$; its repeated value $1$ is listed once.

Step 2: Find the smallest output. The smallest of those output values is $0$. Hence $\min_{x\in D}f(x)=0$. This answer is a real number measured on the output side.

Step 3: Collect all attaining inputs. Only $x=1$ has output $0$, so $\operatorname*{arg\,min}_{x\in D}f(x)=\{1\}$. The answer is a set of inputs, even when it has just one member. The input $1$ and the minimum value $0$ play different roles.

Step 4: Change the permitted inputs. On $D'=\{0,2\}$, both outputs equal $1$. The minimum value is now $1$, and the argmin set is $\{0,2\}$. A well-defined minimum value need not have a unique minimizer.

Step 5: State the general test. An input $x$ belongs to argmin exactly when it is permitted and $f(x)$ equals the minimum value. Changing a domain can change that value and the attaining set, even while the function formula stays the same.

Exercise 0.GB2 — Medium: Prove a supremum with an arbitrary gap

For $A=\{2-1/n:n=1,2,\dots\}$, prove that $\sup A=2$ using an arbitrary gap $\varepsilon\gt0$. Find the minimum, explain why there is no maximum, and exhibit a member larger than $1.99$.

Review: Bounds and extrema

Show hint

Show first that $2$ bounds every element, then that each smaller candidate ceiling is exceeded. For the latter, choose $n\gt1/\varepsilon$.

Show worked solution

Step 1: Establish an upper bound. Every index $n\ge1$ is finite and positive, so $1/n\gt0$. Therefore $2-1/n\lt2$ for every member, and $2$ is an upper bound.

Step 2: Rule out every smaller upper bound. Take any $\varepsilon\gt0$, so the proposed smaller bound is $2-\varepsilon$. Choose an integer $n\gt1/\varepsilon$, possible because integers are unbounded. Taking positive reciprocals gives $1/n\lt\varepsilon$, hence $2-1/n\gt2-\varepsilon$. We have found a member exceeding that proposed bound. Every number below $2$ has this form for some positive gap, so no smaller upper bound exists. Thus $\sup A=2$.

Step 3: Check attainment separately. No member equals $2$, since that would require $1/n=0$. There is also a direct larger member after each one: $1/(n+1)\lt1/n$, so $2-1/(n+1)\gt2-1/n$. Consequently no maximum exists.

Step 4: Find the bottom of the set. Since $1/n\le1$, every member is at least $1$. At $n=1$, it equals $1$. Therefore $\min A=\inf A=1$.

Step 5: Make the gap argument concrete. To exceed $1.99=2-0.01$, require $n\gt100$. Choosing $n=101$ gives $2-1/101\gt1.99$. At $n=100$ the value is exactly $1.99$, so that index would fail the strict request. The general proof and this numerical instance use the same reasoning.

Exercise 0.5a — Easy: A bound need not belong to the set

For $A=(-2,3]$, find $\inf A$, $\sup A$, the minimum and the maximum. Repeat for $B=\{1-1/n:n=1,2,\dots\}$. Explain any missing extrema.

Review: Suprema, infima and bounds

Show hint

First identify the floor and ceiling; then ask whether each is actually an element.

Show worked solution

Use two obligations for a tight bound. First show the candidate bounds every member. Then show no tighter candidate works. Only afterwards ask whether a member attains that bound. This keeps the bound and the extremum tests separate.

Separate two questions. An infimum or supremum is the tightest lower or upper bound. A minimum or maximum also has to belong to the set. We first find the bounds, then check whether they are attained.

For $A=(-2,3]$. Every member satisfies $-2\lt x\le3$, so $-2$ is a lower bound and $3$ an upper bound. The values $-2+1/n$ belong to $A$ and tend to $-2$: any proposed lower bound larger than $-2$ eventually exceeds one of them and fails. Hence $\inf A=-2$. This value is excluded by the round bracket, so there is no minimum. Indeed, for any $x\in A$, the midpoint $(x-2)/2$ between $-2$ and $x$ is a smaller member of $A$.

The value $3$ belongs to $A$ and bounds every other member, so both $\sup A$ and $\max A$ equal $3$.

For $B=\{1-1/n:n=1,2,\ldots\}$. Its first values are $0,1/2,2/3,3/4,\ldots$. For every $n\ge1$, we have $1/n\le1$, so $1-1/n\ge0$. At $n=1$ this value is $0$. Therefore $\inf B=\min B=0$.

Each $1-1/n$ is strictly less than $1$, so $1$ is an upper bound. To show it is the least one, take any $\varepsilon\gt0$ and choose an integer $n\gt1/\varepsilon$. Then $1/n\lt\varepsilon$ and $1-1/n\gt1-\varepsilon$: elements approach the proposed ceiling arbitrarily closely. Thus $\sup B=1$. No finite $n$ gives $1$, and $1-1/(n+1)\gt1-1/n$ always supplies a larger member. Consequently $B$ has no maximum.

Expand the midpoint argument for the missing minimum. Given $x\in(-2,3]$, put $z=(-2+x)/2$. Since $x\gt-2$, the difference $z-(-2)=(x+2)/2$ is positive, so $z\gt-2$. Also $x-z=(x+2)/2\gt0$, so $z\lt x\le3$. Thus $z$ is another allowed member strictly smaller than $x$. This works for every proposed minimum, including $x=3$, so no member can be the smallest. In $B$, the corresponding strict-improvement calculation is $(1-1/(n+1))-(1-1/n)=1/(n(n+1))\gt0$, excluding every proposed maximum.

Exercise 0.5b — Medium: Separate a supremum from a limit superior

For $a_t=(-1)^t+1/(t+1)$, $t\ge0$, compute $\sup_ta_t$, $\inf_ta_t$, $\limsup_ta_t$ and $\liminf_ta_t$. Which bounds are attained, and does the sequence converge?

Review: Suprema, infima and bounds

Show hint

Split into even and odd indices. A limit superior ignores any fixed finite beginning.

Show worked solution

Keep the location of the parentheses visible. Here only $(-1)^t$ alternates sign; the positive fraction is added afterwards. Thus an odd term is $-1+1/(t+1)$, not $-(1+1/(t+1))$. That difference changes the infimum.

Split the indices by parity. The sign $(-1)^t$ is $1$ for even $t$ and $-1$ for odd $t$. Hence

$$a_{2k}=1+\frac1{2k+1}, \qquad a_{2k+1}=-1+\frac1{2k+2}, \qquad k=0,1,2,\ldots.$$

The even terms decrease from $a_0=2$ towards $1$. None exceeds $2$, and the odd terms are negative, so $\sup_ta_t=2$. It is attained at $t=0$ and is also the maximum.

The odd terms begin at $a_1=-1/2$ and decrease towards $-1$, staying strictly above $-1$ because their added fraction is positive. Even terms exceed $1$, so $-1$ bounds the whole sequence from below. Odd terms get arbitrarily close to it, proving $\inf_ta_t=-1$. No term equals $-1$, so no minimum exists.

Now discard the finite beginning. For any index $T$, its tail still contains both parities. The largest tail value is the first even term whose index is at least $T$: later even terms are smaller, and all odd terms are negative. As $T$ increases, this largest tail value tends to $1$. By the definition $\limsup_ta_t=\lim_{T\to\infty}\sup_{t\ge T}a_t$, we obtain $\limsup_ta_t=1$.

The infimum of every tail is $-1$, since the remaining odd terms still approach $-1$ from above. Therefore $\liminf_ta_t=-1$. These two tail limits differ, so the sequence does not converge. The initial value $2$ changes the supremum over the entire sequence but disappears from sufficiently late tails; this is why the supremum and limit superior are different.

Compute one tail before taking its limit. For a tail beginning at $T=5$, the first even index is $6$ and its value is $a_6=1+1/7=8/7$. It is the largest value in that tail. The odd terms beginning at $5$ are $-1+1/6,-1+1/8,\dots$; their infimum is still $-1$, not their first term. For $T=7$, the tail supremum drops to $a_8=1+1/9=10/9$. As the first even index grows, these ceilings approach $1$. The finite beginning controls the global maximum, while arbitrarily late behaviour controls limsup and liminf.

Exercise 0.5c — Hard: Compute both orders of a minimax problem

Let $x,y\in\{0,1\}$ and let $\phi(0,0)=0$, $\phi(0,1)=2$, $\phi(1,0)=1$, $\phi(1,1)=0$. Compute $\min_x\max_y\phi(x,y)$ and $\max_y\min_x\phi(x,y)$. Explain why changing the order changes the result.

Review: Suprema, infima and bounds

Show hint

Treat $x$ as a row and $y$ as a column. For min-max take row maxima first; for max-min take column minima first.

Show worked solution

Step 1: Put the four values in a table. The first coordinate $x$ chooses the row; the second coordinate $y$ chooses the column. The player choosing $x$ wants a small value, and the player choosing $y$ wants a large one.

$\phi(x,y)$$y=0$$y=1$
$x=0$$0$$2$
$x=1$$1$$0$

Step 2: Compute the inner maximum with $x$ held fixed. If $x=0$, the maximizing response chooses $y=1$ and obtains $\max\{0,2\}=2$. If $x=1$, it chooses $y=0$ and obtains $\max\{1,0\}=1$. We have reduced the inner problem to two row values, $2$ and $1$.

Step 3: Compute the outer minimum. The minimizing player chooses between those row values, taking $x=1$ because $1\lt2$. Thus $\min_x\max_y\phi(x,y)=\min\{2,1\}=1$. This is the smallest worst-case value when $x$ must be chosen first.

Step 4: Reverse the choice order and recompute the inner problem. Now hold $y$ fixed and minimize over $x$. If $y=0$, the column entries are $0,1$, and choosing $x=0$ gives the minimum $0$. If $y=1$, the column entries are $2,0$, and choosing $x=1$ gives the minimum $0$. Both column minima are zero.

Step 5: Compute the outer maximum. The maximizing player chooses between those two column minima, so $\max_y\min_x\phi(x,y)=\max\{0,0\}=0$.

Step 6: Explain the gap using the permitted response. When $y$ is revealed first, the minimizing player can choose $x=0$ for $y=0$ and $x=1$ for $y=1$, always obtaining zero. When $x$ is committed first, the maximizing player can instead select the damaging column: value $2$ against $x=0$ or value $1$ against $x=1$. No single row secures zero against both columns. Consequently changing the order changes the value, with $0\le1$ as the max-min inequality predicts. The finite domain permits us to check all choices; it does not force equality of the two orders.

6. Open, Closed & Compact Sets; Continuity

Safety is decided at the boundary of the safe set; optimizers and positive margins exist thanks to compactness. We work in $\mathbb R^n$ with the Euclidean distance (other norms give the same open, closed and compact sets, Primer A).

Definition — Balls, interior, open, closed, closure, boundary, neighbourhood
$B_r(x)=\{y:\|y-x\|\lt r\}$ is the open ball, $\bar B_r(x)=\{y:\|y-x\|\le r\}$ the closed ball. $x$ is an interior point of $A$ if $B_r(x)\subseteq A$ for some $r\gt0$; $\operatorname{Int}A$ collects them. $A$ is open if $A=\operatorname{Int}A$, and closed if its complement is open, equivalently if every convergent sequence in $A$ has its limit in $A$. The closure $\operatorname{cl}A$ adds all such limits, and the boundary $\partial A=\operatorname{cl}A\setminus\operatorname{Int}A$ consists of the points every ball around which meets both $A$ and its complement. A neighbourhood of $x$ contains a ball around $x$; "locally" means "on some neighbourhood". Example: $[0,1)$ has interior $(0,1)$, closure $[0,1]$, boundary $\{0,1\}$, and is neither open nor closed.
Fact — Sets defined by a continuous function
If $h:\mathbb R^n\to\mathbb R$ is continuous and $C=\{h\ge0\}$, then $C$ and $\{h=0\}$ are closed, $\{h\gt0\}$ is open, $\{h\gt0\}\subseteq\operatorname{Int}C$ and $\partial C\subseteq\{h=0\}$. Proof. If $x_t\to x$ with $h(x_t)\ge0$, then $h(x)=\lim h(x_t)\ge0$; likewise for $\{h\le0\}$ and $\{h=0\}$. The complement $\{h\gt0\}$ of $\{h\le0\}$ is open and inside $C$, hence inside $\operatorname{Int}C$, and $\partial C=C\setminus\operatorname{Int}C\subseteq\{h=0\}$. $\blacksquare$

When is the boundary the zero level set? If $h$ is continuously differentiable (the partial derivatives in $\nabla h=(\partial h/\partial x_1,\dots,\partial h/\partial x_n)$ exist and are continuous) and $\nabla h(x)\ne0$ wherever $h(x)=0$ ($0$ is a regular value), then $\partial C=\{h=0\}$ and $\operatorname{Int}C=\{h\gt0\}$. Reason: take $x_0$ with $h(x_0)=0$ and follow the gradient, $\varphi(s)=h(x_0+s\nabla h(x_0))$. By the chain rule (Primer B), $\varphi(0)=0$ and $\varphi'(0)=\|\nabla h(x_0)\|^2\gt0$, so $\varphi\lt0$ for small $s\lt0$: every ball around $x_0$ contains points with $h\lt0$, hence $x_0\notin\operatorname{Int}C$, and $x_0\in\partial C$ because $C$ is closed. Without regularity this fails: $h(x)=x^2$ gives $C=\mathbb R$ and $\partial C=\emptyset$ although $h(0)=0$; and $h(x)=-x^3$ with $\dot x=1$ passes the boundary check $\dot h=-3x^2\dot x=0\ge0$ at $0$, yet the state leaves $C=(-\infty,0]$ at once. Why the boundary matters: a continuous trajectory that starts in $C$ and ends outside must cross $\partial C$ (intermediate value theorem for $t\mapsto h(x(t))$), so, for $\dot x=f(x)$ with $f:\mathbb R^n\to\mathbb R^n$ locally Lipschitz, forward invariance on each maximal solution interval can be checked on a regular boundary alone (Nagumo, Module 10).

Going deeper — tangent cones and the Hausdorff distance

With $\operatorname{dist}(y,C)=\inf_{c\in C}\|y-c\|$, the tangent cone of a closed $C$ at $x$ is $T_C(x)=\{v:\liminf_{\tau\downarrow0}\operatorname{dist}(x+\tau v,C)/\tau=0\}$, which equals $\{v:\nabla h(x)^\top v\ge0\}$ at a regular boundary point; Nagumo: $C$ is forward invariant iff $f(x)\in T_C(x)$ on $\partial C$ (unique solutions). The Hausdorff distance $d_H(A,B)=\max\{\sup_{a\in A}\operatorname{dist}(a,B),\sup_{b\in B}\operatorname{dist}(b,A)\}$ of nonempty compact sets ($d_H([0,1],[0,1.5])=0.5$) measures the convergence of reachable sets in Module 10.

Compact sets and the extreme value theorem

Definition and theorem — Compactness (Heine–Borel, Bolzano–Weierstrass)
$A\subseteq\mathbb R^n$ is bounded if $A\subseteq B_R(0)$ for some $R$, and compact if every sequence in $A$ has a subsequence ($a_{t_1},a_{t_2},\dots$ with $t_1\lt t_2\lt\cdots$) converging to a point of $A$. In $\mathbb R^n$: compact $\iff$ closed and bounded, every bounded sequence has a convergent subsequence, and a compact set is covered by finitely many balls of any radius $\tau\gt0$. Proof idea: halve a box containing the sequence repeatedly, keeping a half with infinitely many terms; the boxes shrink to the limit of a subsequence, and closedness keeps it in the set.

Examples. $[0,1]^d$, closed balls and ellipsoids $\{x:x^\top Px\le c\}$ with $P\succ0$ (bounded since $x^\top Px\ge\lambda_{\min}(P)\|x\|^2$, Primer A) are compact; $\mathbb R^n$ for $n\ge1$, $(0,1]$ and $\{x:x_1^2-x_2^2\le1\}$ (closed, unbounded) are not. Sublevel sets need care: $V(x)=x^2/(1+x^2)$ is positive away from $0$, and $\{V\le0.5\}=[-1,1]$, but $\{V\le c\}=\mathbb R$ for every $c\ge1$.

Theorem — Weierstrass extreme value theorem
A continuous $f:K\to\mathbb R$ on a nonempty compact $K\subseteq\mathbb R^n$ attains its maximum and minimum. Proof. Let $M=\sup_Kf\in\overline{\mathbb R}$ and $x_t\in K$ with $f(x_t)\to M$. A subsequence converges to some $\bar x\in K$, and continuity gives $f(\bar x)=M$, so $M$ is finite and attained; use $-f$ for the minimum. $\blacksquare$ Why each assumption matters: $x$ on $(0,1]$ never attains $\inf=0$ (not closed); $e^{-x}$ on $[0,\infty)$ neither (unbounded); $f(x)=x$ on $[0,1)$ with $f(1)=0$ never attains $\sup=1$ (discontinuous).

Coercivity. If $S$ is closed and nonempty, $f$ continuous and $f(x)\to\infty$ as $\|x\|\to\infty$, then $f$ has a minimizer on $S$ (Weierstrass on the compact set $\{x\in S:f(x)\le f(x_0)\}$). So the safety filter $\min_u\|u-u_{\rm nom}\|^2$ subject to $a+b^\top u\ge0$ has a solution on an unbounded feasible set, whereas $\max_{u\in\mathbb R^m}b^\top u$ ($b\ne0$) has none. Positive margins: if $V$ is continuous, $V(0)=0$ and $V\gt0$ elsewhere, then $\min_KV\gt0$ on every nonempty compact $K$ with $0\notin K$.

Proof — strict decrease on a compact sublevel set forces convergence (the argument of Module 11)

Claim. Let $F$ be continuous with $F(0)=0$, $V$ continuous with $V(0)=0$ and $V(x)\gt0$ for $x\ne0$, $\mathcal V(c)=\{V\le c\}$ compact, and $V(F(x))\lt V(x)$ on $\mathcal V(c)\setminus\{0\}$. Then trajectories of $x_{t+1}=F(x_t)$ from $x_0\in\mathcal V(c)$ stay in $\mathcal V(c)$ and converge to $0$.

(1) Induction: $x_t\in\mathcal V(c)$ gives $V(x_{t+1})\le V(x_t)\le c$ ($F(0)=0$ covers $x_t=0$). (2) Monotone convergence: $v_t=V(x_t)\downarrow v^\ast\ge0$. (3) Contradiction and compactness: if $v^\ast\gt0$, all $x_t$ lie in the compact $K=\{v^\ast\le V\le c\}$, which excludes $0$; the continuous $\Delta V(x)=V(F(x))-V(x)$ is negative there, so $\max_K\Delta V=-\eta\lt0$ and $v_t\le v_0-t\eta\to-\infty$, impossible. (4) For $\varepsilon\gt0$, $m_\varepsilon=\min\{V(x):x\in\mathcal V(c),\|x\|\ge\varepsilon\}\gt0$ (if that compact set is nonempty), and $v_t\lt m_\varepsilon$ forces $\|x_t\|\lt\varepsilon$. $\blacksquare$

Audit. Induction, monotone convergence, suprema, Weierstrass (twice) and contradiction all appear. Without continuity of $F$ step (3) fails (Module 11: $x_t=1+2^{-t}\to1$). The argument gives no rate: for $F(x)=x/(1+x^2)$, $V=x^2$, one finds $\eta=v^\ast\big(1-(1+v^\ast)^{-2}\big)\to0$ as $v^\ast\to0$, matching the sublinear $1/\sqrt{2t}$ of Section 2.

Uniform continuity, nets, and gridding with a Lipschitz margin

$f$ is uniformly continuous on $X$ if $\forall\varepsilon\gt0\ \exists\delta\gt0\ \forall x,y\in X:\|x-y\|\lt\delta\Rightarrow|f(x)-f(y)|\lt\varepsilon$: one $\delta$ for all points (for continuity $\delta$ may depend on the point). Continuous functions on compact sets are uniformly continuous (Heine–Cantor), and $L$-Lipschitz ones are too, with $\delta=\varepsilon/L$ for $L\gt0$ (any $\delta$ works if $L=0$: $f$ is constant); $1/x$ on $(0,1]$ and $x^2$ on $\mathbb R$ are continuous but not uniformly so.

Definition and fact — $\tau$-nets, covering numbers, a Lipschitz margin
For $\tau\gt0$, a finite $Z\subseteq X$ is a $\tau$-net if every $x\in X$ has some $z\in Z$ with $\|x-z\|\le\tau$; the covering number $M(\tau,X)$ is the smallest size of one. For $d\ge1$, cubes of side $2\tau/\sqrt d$ have half-diagonal $\tau$, so $M(\tau,[0,1]^d)\le\lceil\sqrt d/(2\tau)\rceil^d$: for $\tau=0.1$, $64$ points in $d=2$ but $16^{10}\approx1.1\cdot10^{12}$ in $d=10$. Fact: if $h$ is $L$-Lipschitz, $Z$ is a $\tau$-net of $X$ and $h(z)\ge L\tau$ on $Z$, then $h\ge0$ on $X$, because $h(x)\ge h(z)-L\|x-z\|\ge L\tau-L\tau=0$. $\blacksquare$

Example. $h(x)=1-x^2$ on $X=[-0.95,0.95]$ has $L=\max_X|h'|=1.9$. The $20$ points $-0.95,-0.85,\dots,0.95$ form a $0.05$-net; the margin $L\tau=0.095$ is cleared by the smallest grid value $h(\pm0.95)=0.0975$, so $h\ge0$ on $X$ is certified. Spacing $0.2$ ($\tau=0.1$, margin $0.19$) fails although $h\ge0$ is true: finer grids certify more, at a cost growing like $\tau^{-d}$ (Section 7).

Where this is used
Open domains, $\operatorname{Int}C$, $\partial C$ in Module 10; regular values in Module 1 and Module 7; closed failure sets in Module 7; compact sublevel sets in Module 11 and Module 14; compact domains in Module 3; attained optima in Module 7 and Module 10, and attainment failing in Module 8; covering numbers in Module 3; $\epsilon$-nets in Module 10; grids in Module 5.

Connectedness, semicontinuity and density

Connectedness. $A$ is path-connected if any two points are joined by a continuous path inside $A$; path components are the maximal path-connected subsets (for open sets they coincide with the usual connected components, in general not). Continuous images of path-connected sets are path-connected, so a continuous parameterisation from $\mathbb R^N$ reaches only one path component of a set that has several. A finite grid in Euclidean space has no continuous path joining distinct points; its connectivity depends on an adjacency rule, and certified reachability is a third notion (Module 6, Module 4, Module 13, Module 11).

Semicontinuity. $f$ is lower semicontinuous if $f(x)\le\liminf_tf(x_t)$ whenever $x_t\to x$, equivalently if every $\{f\le c\}$ is closed; the Weierstrass argument still yields minima on nonempty compact sets. Example: $f=0$ on $(-\infty,0]$, $f=1$ on $(0,\infty)$ (Module 8).

Density. A class $\mathcal G$ is dense in $\mathcal F$ in the sup norm on a compact $X$ if $\forall f\in\mathcal F\ \forall\varepsilon\gt0\ \exists g\in\mathcal G:\sup_X|f-g|\le\varepsilon$: arbitrarily good approximation, not exact representation (Module 13).

Practice: Topology, existence and grid certificates

Work from Easy to Medium before trying Hard. Use the review link for a missing definition, then try again with the explanation closed.

Guided build-up. Start with these smaller questions to practise the tools used by the graded exercises that follow.

Exercise 0.GT1 — Easy: Check open and closed as separate properties

Working in the ambient space $\mathbb R$, classify $[0,1)$, $\mathbb R$, and $\emptyset$ as open or closed. Explain why “not open” does not mean “closed”. For $[0,1)$, exhibit a member without an interior neighbourhood and a convergent sequence whose limit is missing.

Review: Continuity and topology

Show hint

Open means each member has a small interval around it contained in the set. Closed means all limits of convergent sequences of members are retained, or equivalently the complement is open.

Show worked solution

Step 1: Test openness of $[0,1)$. The number $0$ is a member. For any radius $r\gt0$, the neighbourhood $(-r,r)$ contains $-r/2$, which is outside $[0,1)$. Thus $0$ has no neighbourhood contained in the set, and the set is not open.

Step 2: Test closedness independently. For integers $n\ge1$, the numbers $x_n=1-1/n$ all lie in $[0,1)$. They converge to $1$, since $|x_n-1|=1/n\to0$. But $1$ is excluded, so the set is not closed either. It is therefore neither open nor closed; the two properties are not logical opposites.

Step 3: Check the entire ambient space. For any $x\in\mathbb R$, the interval $(x-1,x+1)$ stays in $\mathbb R$, so $\mathbb R$ is open. It is also closed: every real limit belongs to $\mathbb R$, or its complement $\emptyset$ is open.

Step 4: Check the empty set. Openness asks for a neighbourhood around each member. There are no members for which that requirement can fail, so $\emptyset$ is open. Its complement is $\mathbb R$, already proved open, so $\emptyset$ is closed too. A set may be both open and closed. These statements refer to the ambient space specified in the question; a different ambient space can change the classification.

Exercise 0.GT2 — Medium: Choose delta in a continuity proof

For $f(x)=2x+1$, prove continuity at an arbitrary real point $a$ using the epsilon-delta definition. State how $\delta$ depends on a given $\varepsilon\gt0$. At $a=1$ and $\varepsilon=0.1$, give a concrete input interval and its output interval.

Review: Continuity and topology

Show hint

Subtract $f(a)$ before estimating. Continuity at $a$ asks for $|f(x)-f(a)|\lt\varepsilon$ whenever $|x-a|\lt\delta$.

Show worked solution

Step 1: State the goal and its choice order. Fix any point $a\in\mathbb R$. For each tolerance $\varepsilon\gt0$, we must find $\delta\gt0$ so that every input within distance $\delta$ of $a$ has its output within distance $\varepsilon$ of $f(a)$. The output tolerance is given first; the input tolerance is chosen in response.

Step 2: Simplify the exact output difference. Subtracting the two formulas cancels the constant:

$$|f(x)-f(a)|=|(2x+1)-(2a+1)|=|2(x-a)|=2|x-a|.$$

Step 3: Choose and verify a radius. Set $\delta=\varepsilon/2$, which is positive. If $|x-a|\lt\delta$, multiplying by $2$ gives $|f(x)-f(a)|=2|x-a|\lt2\delta=\varepsilon$. This proves continuity at $a$. Because $a$ was arbitrary, the function is continuous on all of $\mathbb R$.

Step 4: Substitute the numerical tolerance. At $a=1$, $f(a)=3$. For $\varepsilon=0.1$, our radius is $\delta=0.05$. Inputs satisfying $|x-1|\lt0.05$ lie in $(0.95,1.05)$; applying $2x+1$ gives outputs in $(2.9,3.1)$, exactly the required distance less than $0.1$ from $3$.

Step 5: Track the endpoints. Inputs equal to $0.95$ or $1.05$ give output distance exactly $0.1$, so they are excluded by this strict version of the definition. A smaller positive $\delta$ would also work; existence of a suitable radius is the requirement, not uniqueness.

Exercise 0.GT3 — Medium: Derive a Lipschitz constant on a stated domain

Prove that $f(x)=x^2$ is $4$-Lipschitz on $[0,2]$ using the factorization of $x^2-y^2$. Show why no finite Lipschitz constant works on all of $\mathbb R$. Does this prevent the function from being continuous?

Review: Continuity and topology

Show hint

On a bounded domain you can bound $|x+y|$. On the whole real line, test the pair $x=n+1,y=n$ and let $n$ grow.

Show worked solution

Step 1: State what must hold for every pair. A Lipschitz constant $L$ on a domain requires $|f(x)-f(y)|\le L|x-y|$ for every pair of points in that domain. A few successful pairs do not prove the universal requirement.

Step 2: Factor the output difference. For real $x,y$, $x^2-y^2=(x-y)(x+y)$, so $|x^2-y^2|=|x-y||x+y|$. For $x,y\in[0,2]$, their sum lies in $[0,4]$, giving $|x+y|\le4$. Therefore $|x^2-y^2|\le4|x-y|$, as required. The same inequality holds when $x=y$, with both sides zero.

Step 3: Test a proposed global constant. Suppose a finite $L\ge0$ worked on $\mathbb R$. For any nonnegative integer $n$, choose $x=n+1$ and $y=n$. Their input distance is $1$, but their output distance is $(n+1)^2-n^2=2n+1$. The Lipschitz requirement would give $2n+1\le L$ for every such $n$. Choosing an integer larger than $L$ contradicts this. Thus no finite global constant exists.

Step 4: Keep continuity distinct. The function is nevertheless continuous at each real $a$. For example, choose $\delta=\min\{1,\varepsilon/(2|a|+1)\}$ for any $\varepsilon\gt0$. If $|x-a|\lt\delta$, then $|x+a|\le|x-a|+2|a|\lt1+2|a|$, so $|x^2-a^2|=|x-a||x+a|\lt\delta(1+2|a|)\le\varepsilon$. The permitted radius can depend on $a$; a global Lipschitz constant would have to control every pair with one finite number.

Exercise 0.6a — Easy: Describe an interval all the way to its boundary

Working in $\mathbb R$, find the interior, closure and boundary of $A=(-1,1]$. Is $A$ open, closed, bounded or compact? Is $B=\{0,1\}$ compact?

Review: Topology, existence and grid certificates

Show hint

An interior point needs a small interval around it inside the set. A closed set keeps every limit of its convergent sequences.

Show worked solution

Choose a neighbourhood using the nearer endpoint. For an interior point $x$, its distances to $-1$ and $1$ are $x+1$ and $1-x$. Both are positive. Half the smaller distance leaves room on both sides without touching an excluded point.

Interior: find room on both sides. If $-1\lt x\lt1$, the positive radius $r=\tfrac12\min\{x+1,1-x\}$ makes $(x-r,x+r)$ lie inside $(-1,1]$. Thus every such $x$ is interior. The point $1$ is in $A$, but every interval around it contains a number greater than $1$, outside $A$. It is not interior. No point outside $A$ is interior either, so $\operatorname{Int}A=(-1,1)$.

Closure: include the possible limits. The missing endpoint $-1$ is a limit of members: $x_n=-1+1/n\in A$ and $x_n\to-1$. The other endpoint $1$ is already included. There are no limits outside $[-1,1]$, because every member is between these two bounds and inequalities persist under limits. Therefore $\operatorname{cl}A=[-1,1]$.

Boundary: remove the interior from the closure. This gives $\partial A=[-1,1]\setminus(-1,1)=\{-1,1\}$. Every neighbourhood of either endpoint meets both $A$ and its complement. Only $1$ belongs to $A$, showing that a boundary point need not be a member of the original set.

Classify $A$. It is not open, since its member $1$ is not interior. It is not closed, since the sequence above converges to the excluded point $-1$. It is bounded, for example by $|x|\le1$. In $\mathbb R$, the compact sets are exactly those that are closed and bounded. Hence $A$ is not compact.

Check $B=\{0,1\}$ separately. It is bounded. It is closed: if $x$ is outside $B$, the radius $\tfrac12\min\{|x|,|x-1|\}\gt0$ gives an interval around $x$ avoiding both members, so the complement of $B$ is open. Thus $B$ is closed and bounded, and therefore compact. Neither $0$ nor $1$ has an interval around it inside $B$, so compactness here does not require interior points.

Check that the stated radius really works. With $r=\frac12\min\{x+1,1-x\}$, we have $r\le(x+1)/2\lt x+1$, so $x-r\gt-1$. Also $r\le(1-x)/2\lt1-x$, so $x+r\lt1$. Every point of $(x-r,x+r)$ therefore lies in $A$. At $x=1/2$, for example, the smaller endpoint distance is $1/2$, and $r=1/4$ gives neighbourhood $(1/4,3/4)$. At $x=1$, the right-hand distance is zero, so this construction cannot give a positive radius; every positive radius really does reach outside. The compactness test “closed and bounded” used here is specific to finite-dimensional Euclidean space.

Exercise 0.6b — Medium: Decide whether a smallest value is attained

For $f(x)=x^2$, decide whether a minimum exists on each of $(0,1]$, $[0,1]$ and $\mathbb R$. State which cases follow directly from the extreme value theorem and explain the remaining cases.

Review: Topology, existence and grid certificates

Show hint

Find the infimum first. Compactness is sufficient for a continuous function to attain it, but not necessary.

Show worked solution

Step 1: State the theorem's assumptions. The extreme value theorem guarantees an attained minimum for a continuous real-valued function on a nonempty compact domain. In $\mathbb R$, compactness means closed and bounded. The polynomial $f(x)=x^2$ is continuous on every domain in this question; the domains have different compactness properties.

Step 2: Analyze $(0,1]$ directly. Every permitted input is positive, so its square is strictly positive. Yet the inputs $x_n=1/n$ lie in the domain and have squares $1/n^2\to0$. Therefore $0$ is the infimum: it bounds all outputs from below, and outputs approach it arbitrarily closely.

No input in this domain attains $0$. More directly, if $x$ were a minimizing input, then $x/2$ would still belong to $(0,1]$ and would have value $(x/2)^2=x^2/4\lt x^2$. Every candidate can be improved, so there is no minimum. The domain is bounded but excludes the limit $0$, so it is not closed and the theorem does not apply.

Step 3: Analyze $[0,1]$. The domain is nonempty, closed and bounded, so the extreme value theorem guarantees existence. To compute the minimum, use $x^2\ge0$ and the permitted input $x=0$, where equality holds. The minimum value is $0$ and the unique minimizing input is $0$, since $x^2=0$ forces $x=0$.

Step 4: Analyze all of $\mathbb R$. This domain is unbounded, hence not compact, so the compact-domain theorem alone gives no conclusion. Nevertheless the same direct calculation applies: all squares are at least zero, and $0\in\mathbb R$ attains zero uniquely. A minimum exists despite failure of that sufficient theorem hypothesis.

Step 5: Compare the conclusions. Continuity holds in all three cases. The first case has a missing limiting input and no minimum; the second meets the theorem and attains one; the third fails compactness yet attains one by a direct argument. Failure of a sufficient condition removes a guarantee, but it does not prove failure of the desired outcome.

Exercise 0.6c — Hard: Certify the space between measurements

An unknown $3$-Lipschitz function $h:[0,1]\to\mathbb R$ satisfies $h(g)\ge0.35$ at $G=\{0,0.2,0.4,0.6,0.8,1\}$. Prove a uniform lower bound. Would measurements at $\{0,0.4,0.8,1\}$ with the same lower bound suffice? Give a counterexample if not.

Review: Topology, existence and grid certificates

Show hint

Use half the largest gap as the covering radius. For the counterexample try $h(x)=0.35-3\operatorname{dist}(x,G)$.

Show worked solution

Use distance to the nearest measured point, not just grid spacing. A point in a gap can use either endpoint. If the gap has length $d$, its distance to the nearer endpoint is at most $d/2$. The certificate spends the Lipschitz constant times that distance from the measured safety margin.

Locate an arbitrary point relative to the fine grid. Adjacent points of $G=\{0,0.2,0.4,0.6,0.8,1\}$ are separated by $0.2$. Every $x\in[0,1]$ lies between two adjacent grid points or equals one. In a gap of length $0.2$, at least one endpoint is at distance at most $0.1$: the largest nearest-endpoint distance occurs at its midpoint. Choose such a grid point $g$.

Transfer the measured lower bound. The Lipschitz assumption says $|h(x)-h(g)|\le3|x-g|$. Its lower side gives $h(x)-h(g)\ge-3|x-g|$, so

$$h(x)\ge h(g)-3|x-g| \ge0.35-3(0.1) =0.05.$$

Since $x$ was arbitrary, $0.05$ is a uniform positive margin on the entire interval, including points that were not measured.

Recompute coverage for the coarse grid. For $G_c=\{0,0.4,0.8,1\}$, the gaps are $0.4,0.4,0.2$. The largest nearest-grid distance is therefore $0.2$. The same reasoning now yields only $h(x)\ge0.35-3(0.2)=-0.25$. A negative lower bound does not itself prove a negative true value, so this calculation alone is not a counterexample.

Construct one function showing failure is possible. Define $d_c(x)=\operatorname{dist}(x,G_c)=\min_{g\in G_c}|x-g|$, and set $h_c(x)=0.35-3d_c(x)$. A minimum exists because this grid is finite and nonempty. To check the required Lipschitz property, choose a nearest grid point $g_y$ for $y$. The triangle inequality gives

$$d_c(x)\le|x-g_y| \le|x-y|+|y-g_y| =|x-y|+d_c(y).$$

Thus $d_c(x)-d_c(y)\le|x-y|$. Swapping $x,y$ gives the reverse bound, so $|d_c(x)-d_c(y)|\le|x-y|$. Consequently $|h_c(x)-h_c(y)|=3|d_c(x)-d_c(y)|\le3|x-y|$.

At every grid point, $d_c(g)=0$ and $h_c(g)=0.35$, so all measurements meet the hypothesis. At the midpoint $x=0.2$, the nearest grid distance is $0.2$, giving $h_c(0.2)=0.35-0.6=-0.25$. The coarse measurements therefore cannot guarantee nonnegativity between them.

Derive the general spacing requirement. If every grid value is at least $m\ge0$, the function is $L$-Lipschitz, and the largest gap is $d$ with the domain endpoints included, the same calculation gives $h(x)\ge m-Ld/2$. For this bound to certify nonnegativity, require $d\le2m/L$ when $L\gt0$. Here $2m/L=0.7/3\approx0.2333$, so gaps of $0.2$ pass and gaps of $0.4$ do not. To certify a specified positive margin $q\le m$, require instead $d\le2(m-q)/L$. This is a sufficient design condition under the stated global Lipschitz assumption; measurements alone do not prove that assumption.

7. Asymptotic Notation & Rates

Rates and costs are stated up to constants ("$\gamma_T=O((\log T)^{d+1})$" for the information gain of a GP, Module 3, where $\gamma_T$ is not a discount factor; "an $O(t^3)$ determinant"); here is what that promises.

Definition — $O$, $\Omega$, $\Theta$, $o$, $\tilde O$
For $f,g\ge0$ as $n\to\infty$: $f=O(g)$ if $\exists C\gt0,n_0$ with $f(n)\le Cg(n)$ for all $n\ge n_0$; $f=\Omega(g)$ if $\exists c\gt0,n_0$ with $f(n)\ge cg(n)$ for $n\ge n_0$; $f=\Theta(g)$ if both; $f=o(g)$ if $\forall\varepsilon\gt0\ \exists n_0\ \forall n\ge n_0:\ f(n)\le\varepsilon g(n)$, equivalently $f(n)/g(n)\to0$ when $g$ is eventually positive; $f=\tilde O(g)$ if $f(n)=O\big(g(n)\,(\log n)^k\big)$ for some constant $k\ge0$ (so $\log n=\tilde O(1)$; with several parameters, papers differ in which logarithms they hide). For a small parameter, "$f(x)=O(g(x))$ as $x\to0$" means $|f(x)|\le C|g(x)|$ for all small $|x|$, e.g. $e^x=1+x+O(x^2)$. Always ask which variable tends where, what is held fixed, and what the constant may depend on (dimension, $\delta$, $\gamma$, a norm bound).

Examples. $3n^2+10n+5=\Theta(n^2)$: for $n\ge10$, $10n\le n^2$ and $5\le n^2$, so $3n^2\le3n^2+10n+5\le5n^2$. $\ln n=o(n^a)$ and $n^k=o(e^{an})$ for all $a\gt0$, $k$. Module 12 writes $\log\det(N+\varepsilon E)=\log\det N+\varepsilon\operatorname{tr}(N^{-1}E)+O(\varepsilon^2)$ as $\varepsilon\to0$, and Module 2 an error "within $O(\eta)$", i.e. at most $C\eta$ for small step sizes $\eta$.

$T$$10^2$$10^4$$10^6$$10^8$$10^{10}$
$\sqrt T$$10$$100$$1000$$10^4$$10^5$
$T^{2/3}$$\approx 21.5$$\approx 464$$10^4$$\approx 2.15\cdot10^5$$\approx 4.64\cdot10^6$
$(\ln T)^3$$\approx 97.7$$\approx 781$$\approx 2637$$\approx 6251$$\approx 12208$

Comparing rates. $(\ln T)^3=o(\sqrt T)$ and $\sqrt T=o(T^{2/3})$, yet $(\ln T)^3$ exceeds $\sqrt T$ for every $T$ from $4$ to about $2.4\cdot10^7$: an $o$-statement says nothing about a particular $T$.

Operation counts. A dense Cholesky factorisation, determinant or solve of a $t\times t$ matrix costs $O(t^3)$ operations (about $t^3/3$ for Cholesky), a matrix-vector product $O(t^2)$; doubling $t$ multiplies $O(t^3)$ by about $8$. Total cost is iterations times cost per iteration: interior-point SDP solvers need $O(\sqrt n\log(1/\varepsilon))$ iterations of $O(mn^3+m^2n^2+m^3)$ each. $O$ predicts growth, not seconds. Grids explode with dimension: $m$ points per axis give $m^d$ points, e.g. $100^3=10^6$ but $100^6=10^{12}$.

Definition — Polynomial time, P, NP, NP-hard (working version)
A decision problem asks a yes/no question about an input of $n$ bits; it is in P if one algorithm answers every instance in $O(n^k)$ steps for a fixed $k$. NP contains the problems whose "yes" answers have certificates checkable in polynomial time (a claimed counterexample to robustness is checked by one forward pass). A problem is NP-hard if every NP problem reduces to it in polynomial time, and NP-complete if it is also in NP. Whether P $=$ NP is open; if P $\ne$ NP, no polynomial-time algorithm solves all instances of an NP-hard problem. It is a worst-case statement about growing sizes, not a claim that every instance is hard; it is why the modules use relaxations (LipSDP) and branch-and-bound verifiers.
Definition — Sample complexity, cumulative and simple regret
The sample complexity $n(\varepsilon,\delta)$ is the number of samples that guarantees accuracy $\varepsilon$ with probability at least $1-\delta$. For queries $x_1,\dots,x_T$ and a comparator $x^\ast$ (e.g. a maximizer of $f$), the cumulative regret is $R_T=\sum_{t=1}^{T}\big(f(x^\ast)-f(x_t)\big)$, and the simple regret of a recommendation $\hat x_T$ is $f(x^\ast)-f(\hat x_T)$. Regret is sublinear if $R_T=o(T)$, i.e. $R_T/T\to0$ ("no regret"); then $\min_{t\le T}\big(f(x^\ast)-f(x_t)\big)\le R_T/T$.

Examples. By Hoeffding's inequality (Primer C), the mean of $n$ independent $[0,1]$-valued samples is within $\varepsilon$ of its expectation with probability $1-\delta$ once $n\ge\ln(2/\delta)/(2\varepsilon^2)$, a sample complexity $O(\varepsilon^{-2}\log(1/\delta))$: $738$ samples for $\varepsilon=\delta=0.05$. $R_T\le4\sqrt{T\gamma_T}$ with $\gamma_T=(\ln T)^2$ gives $R_T/T\le4\ln T/\sqrt T\to0$ (sublinear), yet this bound is $0.37$ at $T=10^4$ and reaches $0.1$ only at $T=246{,}639$. Check products as a whole: Module 6 needs $\beta_N^2\gamma_N=o(N)$, and $\sqrt N\cdot\sqrt N=N$ although each factor is $o(N)$. Bandits and regret are developed in Primer E.

Where this is used
Information-gain rates and $\tilde O$ regret in Module 3 and Module 3; $\gamma_t=O((\log t)^{d+1})$ and sample complexity in Module 4; $O(t^3)$ and hopeless grids in Module 5 and Module 5; $O(s)$ per backup in Module 6; $O(1/\sqrt T)$ in Module 8; $O(\sqrt\delta)$ in Module 9; solver costs in Module 2, Module 12 and Module 14; NP-hardness in Module 12 and Module 15; $O(n^2c^3)$ in Module 13; $O(m^2n^3)$ in Module 15.
Pitfall — a rate is not a certificate
"$R_T=O(\sqrt T)$" hides a constant and a threshold $n_0$; a guarantee at a specific $T$ needs explicit constants. And the symbol has two uses: $O(\varepsilon^2)$ as $\varepsilon\to0$ (a small remainder) and $O(n^2)$ as $n\to\infty$ (a growing cost).

Practice: Rates, constants and computational budgets

Work from Easy to Medium before trying Hard. Use the review link for a missing definition, then try again with the explanation closed.

Guided build-up. Start with these smaller questions to practise the tools used by the graded exercises that follow.

Exercise 0.GR1 — Easy: Read the quantifiers behind big-O

Let $f(n)=3n+4$ for integers $n\ge1$. Prove $f(n)=O(n)$ with an explicit constant $C$ and threshold $n_0$. Would $C=3$ work at any finite threshold? Would $C=4$ work, and from which threshold?

Review: Rates and work budgets

Show hint

$O(n)$ requires $f(n)\le Cn$ for every integer $n\ge n_0$, for some fixed $C\gt0$ and $n_0$. Divide by positive $n$ to inspect $3+4/n$.

Show worked solution

Step 1: State the required witness. We need one constant $C\gt0$ and one integer $n_0\ge1$ such that $3n+4\le Cn$ for every $n\ge n_0$. The constant cannot change with $n$ after it is chosen.

Step 2: Give an easy pair of witnesses. For $n\ge1$, $4\le4n$. Hence $3n+4\le3n+4n=7n$. Choosing $C=7$ and $n_0=1$ proves $f(n)=O(n)$.

Step 3: Check the tempting smaller constant. If $C=3$, the inequality would require $3n+4\le3n$, or $4\le0$, at every permitted $n$. It fails even at arbitrarily large finite indices. The limiting ratio $f(n)/n\to3$ does not make $3$ a valid upper-bound constant.

Step 4: Trade a smaller constant for a later threshold. For $C=4$, the condition becomes $3n+4\le4n$, equivalently $n\ge4$. Thus $C=4$ works with $n_0=4$. At $n=3$, $f(3)=13\gt12=4(3)$, so any smaller threshold would include a failing index.

Step 5: Interpret the notation. Big-O records the existence of some working constant and threshold; it does not specify their smallest values or assert an exact equality $f(n)=Cn$. Different valid witnesses can describe the same growth class.

Exercise 0.GR2 — Easy: Divide cumulative growth by the number of trials

For $T\ge1$, compare cumulative quantities $A_T=100\sqrt T$, $B_T=100T$, and $C_T=100$. Find their averages after $T$ trials, their values at $T=10^4$, and decide which cumulative quantities are $o(T)$. Can a cumulative quantity increase without bound while its average tends to zero?

Review: Rates and work budgets

Show hint

An average divides the total by $T$. Little-o of $T$ means that this ratio tends to zero, not that the total tends to zero.

Show worked solution

Step 1: Form the three ratios. Division by $T\gt0$ gives $A_T/T=100/\sqrt T$, $B_T/T=100$, and $C_T/T=100/T$. In the first ratio, $\sqrt T/T=1/\sqrt T$ because $T=(\sqrt T)^2$.

Step 2: Substitute a finite budget. At $T=10^4=10{,}000$, $\sqrt T=100$. The totals are $A_T=10{,}000$, $B_T=1{,}000{,}000$, and $C_T=100$. The respective averages are $1$, $100$, and $0.01$.

Step 3: Test the limiting ratios. As $T\to\infty$, $100/\sqrt T\to0$ and $100/T\to0$, so $A_T=o(T)$ and $C_T=o(T)$. The middle ratio remains $100$, so $B_T$ is not $o(T)$; it is proportional to $T$.

Step 4: Explain what sublinear means. $A_T=100\sqrt T$ grows without bound, yet it grows more slowly than the number of trials. Its average tends to zero. The vanishing average therefore does not mean that accumulated error or regret disappears, nor that every individual trial has a vanishing value. It compares a total with a growing horizon.

Exercise 0.GR3 — Medium: Find the accuracy where a better rate becomes cheaper

Two sufficient error bounds are $E_A(T)\le1000/T$ and $E_B(T)\le1/\sqrt T$ for integer budgets $T\ge1$. Compare the bounds at $T=10^4$ and $T=10^8$. Find where the two formulas cross, then compute the smallest sufficient budgets for tolerances $0.01$ and $0.0001$. Assume equal work per iteration.

Review: Rates and work budgets

Show hint

Solve each error-bound inequality separately. The constants matter at finite budgets even though $1/T$ decays faster than $1/\sqrt T$.

Show worked solution

Step 1: Compare actual bound values. At $T=10^4$, algorithm A's bound is $1000/10{,}000=0.1$, while B's is $1/100=0.01$, so B has the smaller bound. At $T=10^8$, A's is $10^{-5}$, while B's is $10^{-4}$, so A has the smaller bound.

Step 2: Solve the crossover exactly. Equality $1000/T=1/\sqrt T$ is equivalent to $1000=\sqrt T$, after multiplying by $T\gt0$. Squaring gives $T=10^6$. Before this budget B's formula is smaller; afterwards A's is smaller. This compares the guarantees, not necessarily the observed errors.

Step 3: Solve for a requested positive tolerance. To certify error at most $\varepsilon$, A needs $1000/T\le\varepsilon$, hence $T\ge1000/\varepsilon$. B needs $1/\sqrt T\le\varepsilon$, hence $T\ge1/\varepsilon^2$. For a general tolerance, round each lower bound up to the next integer and enforce $T\ge1$.

Step 4: Substitute both tolerances. At $\varepsilon=0.01$, A needs $100{,}000$ iterations and B needs $10{,}000$, so B uses one tenth of the work under equal per-iteration cost. At $\varepsilon=0.0001$, A needs $10{,}000{,}000$ and B needs $100{,}000{,}000$, so A now uses one tenth.

Step 5: Explain the change. The ratio of the formulas is $(1000/T)/(1/\sqrt T)=1000/\sqrt T\to0$, so A has the faster asymptotic decay. Its larger constant delays the benefit. A rate comparison must retain constants and the requested accuracy to justify a finite work budget.

Exercise 0.7a — Easy: Prove a growth class with actual constants

For $f(n)=2n^2+3n+1$, $n\ge1$, prove $f(n)=\Theta(n^2)$ using explicit constants. Is $f(n)=o(n^2)$?

Review: Rates, constants and computational budgets

Show hint

For $n\ge1$, both $n$ and $1$ are at most $n^2$. Little-$o$ asks for a ratio tending to zero.

Show worked solution

Step 1: State the two-sided target. For positive $n$, $f(n)=\Theta(n^2)$ means there are constants $c,C\gt0$ and a threshold $n_0$ such that $cn^2\le f(n)\le Cn^2$ for every integer $n\ge n_0$. We must choose fixed constants and justify both comparisons.

Step 2: Obtain the lower bound. For $n\ge1$, both $3n$ and $1$ are nonnegative. Adding them to $2n^2$ cannot decrease the value, so $f(n)=2n^2+3n+1\ge2n^2$. Choose $c=2$ and $n_0=1$. This proves the lower growth bound, written $\Omega(n^2)$.

Step 3: Bound each extra term at the same scale. Since $n\ge1$, multiplying $1\le n$ by $n\gt0$ gives $n\le n^2$. Hence $3n\le3n^2$. Also $1\le n^2$. Adding these bounds gives

$$2n^2+3n+1\le2n^2+3n^2+n^2=6n^2.$$

Choose $C=6$ at the same threshold. This proves $O(n^2)$. At $n=1$, $f(1)=6=6(1)^2$, so the proposed upper bound handles the endpoint as well.

Step 4: Combine the two directions. We have $2n^2\le f(n)\le6n^2$ for every $n\ge1$. Thus the function is both $\Omega(n^2)$ and $O(n^2)$, which is exactly $\Theta(n^2)$.

Step 5: Test little-o separately. Dividing the formula by the positive $n^2$ gives $f(n)/n^2=2+3/n+1/n^2$. The last two fractions tend to zero while the constant remains $2$, so the ratio tends to $2$, not $0$. Therefore $f(n)$ is not $o(n^2)$. Being bounded by a fixed multiple of $n^2$ does not make a function negligible relative to $n^2$.

Exercise 0.7b — Medium: Translate accuracy into work

Algorithm A guarantees error at most $4/\sqrt T$ after $T\ge1$ iterations, each costing $100$ operations. Algorithm B guarantees error at most $8/T$, each iteration costing $1000$ operations. Find sufficient iteration and operation budgets for error at most $0.1$. Which is cheaper under these bounds?

Review: Rates, constants and computational budgets

Show hint

Solve each explicit inequality for $T$, round upward, then multiply by the cost per iteration.

Show worked solution

Step 1: Decide what the budgets certify. The given error expressions are upper bounds after $T$ iterations. Making an upper bound at most $0.1$ supplies a sufficient guarantee about actual error. Actual errors may already be smaller, so we are finding the smallest budgets that these formulas certify, rather than the actual stopping times of unknown runs.

Step 2: Solve algorithm A's bound. Require $4/\sqrt T\le0.1=1/10$. Since $T\ge1$, its square root is positive. Multiply by $10\sqrt T$ to get $40\le\sqrt T$. Both sides are nonnegative, so squaring preserves order and gives $1600\le T$. The first integer budget certified by this expression is $1600$.

Step 3: Translate iterations into work. At $100$ operations per iteration, A's sufficient work is $1600\cdot100=160{,}000$ operations. Checking the error expression at that budget gives $4/40=0.1$ exactly. At $1599$, the square root is less than $40$, making its upper-bound expression larger than $0.1$.

Step 4: Solve algorithm B's bound. Require $8/T\le1/10$. Multiplying by positive $10T$ gives $80\le T$. The first certified integer is $80$, and $8/80=0.1$. At $79$, $8/79\gt8/80$, so the bound does not certify the target. At $1000$ operations per iteration, the sufficient work is $80\cdot1000=80{,}000$ operations.

Step 5: Compare total work under the supplied model. B requires twenty times fewer iterations, but each costs ten times as much. Its resulting operation count is half A's. Thus B is cheaper for this tolerance under these sufficient bounds. Faster decay alone would not settle a finite comparison: the constants, tolerance and per-iteration work all enter it. Both budgets assume the stated guarantees hold and the supplied operation costs model the relevant work.

Exercise 0.7c — Hard: Combine two rates without losing their meaning

Suppose $0\le R_T\le5\sqrt T\log T$ for $T\ge2$, where $R_T$ is cumulative regret and $\log$ is natural. Prove the average regret tends to zero and give the resulting upper bound at $T=10^4$. Separately, show why $a_T=o(T)$ and $b_T=o(T)$ do not imply $a_Tb_T=o(T)$.

Review: Rates, constants and computational budgets

Show hint

Divide cumulative regret by $T$. For the second claim use two square-root sequences.

Show worked solution

Define the average before discussing its limit. Cumulative regret is $R_T$, and average regret is $R_T/T$. The given lower bound is useful: after the upper bound tends to zero, it traps the average between two quantities with the same limit.

Convert a cumulative quantity into an average. Since $T\ge2$ is positive, divide the stated inequality by $T$ without changing its direction:

$$0\le\frac{R_T}{T} \le\frac{5\sqrt T\log T}{T} =\frac{5\log T}{\sqrt T}.$$

The last expression tends to zero. For example, regarding $T$ as a real variable, the ratio $\log T/\sqrt T$ has the form $\infty/\infty$. L'Hôpital's rule differentiates numerator and denominator:

$$\lim_{T\to\infty}\frac{\log T}{\sqrt T} =\lim_{T\to\infty}\frac{1/T}{1/(2\sqrt T)} =\lim_{T\to\infty}\frac{2}{\sqrt T}=0.$$

The same limit holds at integer iteration counts. The squeeze theorem now gives $R_T/T\to0$, equivalently $R_T=o(T)$: cumulative regret is sublinear. This is a statement about averages, not a claim that every individual trial's regret tends to zero.

Evaluate the actual finite bound. At $T=10^4$, $\sqrt T=100$ and $\log T=4\log10\approx9.21034$. Therefore

$$\frac{R_{10^4}}{10^4} \le\frac{5(9.21034)}{100} \approx0.46052.$$

This is an upper bound, not the observed average regret. Its fairly large size at this budget is consistent with its eventual limit being zero.

Test the product assertion independently. Take $a_T=b_T=\sqrt T$. Each satisfies $a_T/T=b_T/T=1/\sqrt T\to0$, so both are $o(T)$. Their product is $a_Tb_T=(\sqrt T)^2=T$. Dividing that product by $T$ gives $1$ at every index, not a quantity tending to zero. Hence $a_Tb_T$ is not $o(T)$. To assess a product, multiply the complete expressions and test the resulting ratio to the specified comparison scale.

Expand the derivative calculation used for the limit. The derivative of $\log T$ is $1/T$. Writing $\sqrt T=T^{1/2}$ gives derivative $(1/2)T^{-1/2}=1/(2\sqrt T)$. Dividing these derivatives multiplies by the reciprocal: $(1/T)/(1/(2\sqrt T))=2\sqrt T/T=2/\sqrt T$. This tends to zero because its denominator grows. L'Hôpital's rule is applicable on the positive real tail: both original functions tend to infinity, are differentiable, and the denominator's derivative is nonzero. This calculus justification is used in Section 7; the earlier set, logic and proof exercises require no differentiation.

Interactive: Fixed-Point Iteration & Geometric Series

Iterate $x_{k+1}=g(x_k)$ for several maps (cobweb and log-scale error against Banach's a priori bound) and sum the discounted series $\sum_t\gamma^t$.

Fixed-Point Iteration & Geometric Series
Map

Cobweb: $g$ (blue), $y=x$ (grey), staircase $(x_0,x_0)\to(x_0,x_1)\to(x_1,x_1)\to\cdots$ (orange), fixed point (green). Errors: $|x_k-x^\ast|$ (dots) and, if a factor $L\lt1$ is known, the bound $L^{k-k_0}|x_{k_0+1}-x_{k_0}|/(1-L)$ (dashed).

Blue: fraction $1-\gamma^t$ of the limit collected by $t$ terms; teal: the remaining fraction $\gamma^t$; orange: horizon $T$; purple: first $T$ with $\gamma^T\le0.01$.

What to look for. (1) Affine, $a=0.5$: the dots lie on the (exact) bound; $a=0.99$ needs $1833$ iterations; $a\lt0$ spirals; $|a|\ge1$ breaks the theorem ($a=1$: no fixed point; $a=-1$: nonfixed starts alternate; $|a|\gt1$: nonfixed starts run away; for $a\ne1$, a start at $x^\ast=1/(1-a)$ stays fixed). (2) Cosine from $x_0=1$: the bound asks for $87$ iterations, $32$ suffice (slope $0.674$ near $x^\ast$ versus $L=0.841$). (3) Logistic: $r=2.8$ converges without a global contraction, $r=2$ quadratically, $r=3.2,\ 3.5,\ 3.56$ end on (approximate) cycles of period $2,4,8$, and at $r=3.9$ the orbit is chaotic: no short cycle shows up. (4) Slow map: the dots bend, sublinear convergence. (5) The button's iterates $V_k$ are the partial sums below.

From the mathematics to a real decision

A useful mathematical answer changes what someone can responsibly do. A temperature reading may support accepting a chamber, choosing a cooling command, or waiting for another solver iteration. Those are different decisions, and they require different statements. This chapter follows a constructed thermal-chamber model from a single reading to a claim about every future step. The numbers are teaching choices, not measurements from a particular machine. Their purpose is to make the order of the reasoning visible.

Learning objectives
  • Translate an acceptance rule into containment of sets and explain what a failed test means.
  • Place control choices and unknown disturbances in the correct quantifier order.
  • Build an all-time conclusion from a one-step bound without assuming the conclusion.
  • Turn an error recurrence into a finite iteration budget, including its unavoidable error floor.

Begin with the decision and its units

Let $x$ be temperature above a chosen reference, measured in degrees Celsius, and let the allowed interval be $C=[0,5]$. This is a specification: for this hypothetical task a temperature deviation in that interval is acceptable. It is not a claim that the interval is physically appropriate for any actual chamber. A sensor reading $y$ comes with a deterministic error bound $|x-y|\le\varepsilon$. The word deterministic means that every error in the interval is permitted; no probability distribution has been assumed.

The possible true values form $I(y)=[y-\varepsilon,y+\varepsilon]$. Acceptance follows when $I(y)\subseteq C$. Notice the change from a statement about one number to a statement about all numbers compatible with the information. Checking only $y\in C$ answers whether the displayed reading is acceptable. It does not answer whether the unknown temperature is acceptable. If containment fails, the information allows an unacceptable temperature; it may also allow acceptable temperatures. The correct conclusion is that this acceptance test has not certified the chamber.

This distinction is useful whenever a calculation is an upper or lower bound rather than an exact observation. Write down what the bound encloses before deciding what its sign proves. A positive upper bound on an error does not mean that this error occurred. A negative lower bound on a safety margin does not mean the actual margin is negative. Both statements describe the limits of the information.

Choose before the disturbance arrives

Now consider one minute between commands. The constructed update is $x^+=1.1x+u+w$, where $x^+$ is the next temperature deviation, $u\in[-1,0]$ is a commanded cooling contribution in degrees Celsius per step, and $w\in[0,0.4]$ is an unknown warming contribution in the same units. The coefficient $1.1$ is dimensionless. This simplified model assumes that the current $x$ is known exactly, the command is realized exactly, and the stated disturbance interval contains the actual disturbance. Sensor uncertainty would require another universal quantifier over the possible current temperatures.

The command is selected after observing $x$ and before observing $w$. Therefore the desired one-step statement is:

$$\forall x\in C\ \exists u\in[-1,0]\ \forall w\in[0,0.4]:\quad 1.1x+u+w\in C.$$

Read this aloud as a sequence of information: show me an allowed temperature; I choose a command; any allowed disturbance may then occur. If $u$ were allowed to depend on $w$, the calculation would describe a different device with information available before the action. Mathematical punctuation is recording a physical timing assumption.

Worked example — A command interval at one measured temperature

Decision. At $x=4.5$ degrees Celsius, find every command that keeps the next step in $C$, whatever allowed warming occurs. Since the update increases with $w$, its complete range is $[4.95+u,5.35+u]$. There is no need to test infinitely many disturbances separately: the two endpoints bound every intermediate value.

Translate containment. The lower endpoint must be at least zero and the upper endpoint at most five. Thus $u\ge-4.95$ and $u\le-0.35$. Intersect these conditions with the actuator interval $[-1,0]$ to obtain $u\in[-1,-0.35]$. The intersection matters: a mathematically useful command is irrelevant if the actuator cannot issue it.

Select and check. Choose $u=-0.5$. The successor interval is $[4.45,4.85]$, contained in $[0,5]$. The nominal disturbance $w=0$ would predict $4.45$; accounting for every allowed disturbance raises the upper prediction to $4.85$. This verifies one step from the stated temperature. It has not yet verified a whole trajectory or a chamber with unmodeled delays.

To cover every $x\in C$, one explicit choice is $u(x)=-0.18x$. This command lies in $[-0.9,0]\subseteq[-1,0]$, and the resulting successor interval is $[0.92x,0.92x+0.4]$. Its lower endpoint is nonnegative; its upper endpoint is at most $0.92(5)+0.4=5$. We have supplied a witness for the existential quantifier at every state, using one formula rather than infinitely many separate calculations.

No single fixed command works for the entire interval. At $x=0$, allowing $w=0$ forces $u\ge0$, hence $u=0$. At $x=5$, allowing $w=0.4$ forces $u\le-0.9$. These requirements conflict. Feedback changes the available decision because the command may depend on the observed temperature. This conclusion follows from the two boundary states, not from how many points were simulated.

Extend the claim one step at a time

Suppose the same update and disturbance bounds apply at every integer time $t\ge0$, and apply the feedback $u_t=-0.18x_t$. To prove $x_t\in C$ for all time, first state the base case $x_0\in C$. Next assume only that the current $x_t$ lies in $C$. The one-step calculation then shows $x_{t+1}\in C$ for every permitted $w_t$. Induction completes the argument. It permits disturbances to change arbitrarily from step to step, because the one-step result did not require them to be constant or independent.

The proof is conditional. If a disturbance exceeds $0.4$, if the command arrives late, or if the temperature is not known as assumed, a hypothesis has changed. The proof remains mathematically valid while its applicability to that modified situation needs new work. Keeping hypotheses beside the step where they are used makes that limitation understandable rather than an unexplained disclaimer at the end.

A limit does not automatically give a stopping time

A controller may run a numerical calculation before issuing its command. Let $e_k$ be a nonnegative temperature prediction error bound after iteration $k$. An error recurrence describes how an earlier error is reduced and how new approximation error is introduced. The geometric factor explains the improvement; the additive term explains why unlimited iteration can still leave a nonzero bound.

Worked example — Transfer from a recurrence to a computation deadline

Model and goal. Suppose $e_0=0.8$ degrees Celsius and $e_{k+1}\le0.6e_k+0.02$. Each iteration costs $2$ milliseconds and initialization costs $5$ milliseconds. We require a certified error at most $0.06$ degrees Celsius before issuing a command. The recurrence and timings are stipulated teaching assumptions.

Unroll the recurrence. The first bounds are $e_1\le0.5$ and $e_2\le0.32$. Repeating substitution gives $e_k\le0.8(0.6)^k+0.02\sum_{j=0}^{k-1}(0.6)^j$. Multiplying the finite sum by $1-0.6$ cancels adjacent powers, so the sum is $(1-0.6^k)/0.4$. Therefore:

$$e_k\le0.05+0.75(0.6)^k.$$

Solve the actual tolerance. We need $0.75(0.6)^k\le0.01$, equivalently $(0.6)^k\le1/75$. Taking logarithms gives $k\ge\log(1/75)/\log(0.6)$; division reverses the inequality because $\log(0.6)$ is negative. Check the neighboring integers: at $k=8$ the bound is $0.06259712$, and at $k=9$ it is $0.057558272$. Nine iterations suffice, costing $5+9(2)=23$ milliseconds. Eight are not certified by this bound.

Interpret the limit. The bound approaches $0.05$, so a demand of $0.04$ cannot be established from this recurrence. A demand of exactly $0.05$ is also not reached by this finite bound. Actual errors might be smaller, but this information alone cannot certify them. Improving the additive approximation term could be more useful than buying more iterations.

Common mistake — proving the nominal problem

Using $w=0$ in the chamber or dropping $0.02$ from the error recurrence makes the arithmetic easier while changing the claim. Repair the argument by writing the range of every unknown contribution and retaining it through each inequality. A successful nominal trajectory and a convergent geometric term are both useful calculations; each becomes a robust conclusion only after every remaining term is accounted for.

Application practice: information, action and guarantees

Exercise 0.B1 — Easy: Accept a reading with a bounded error

A chamber must have $x\in[0,5]$ degrees Celsius above reference. A sensor satisfies $|x-y|\le0.2$. Assess readings $y=4.7$ and $y=4.9$. Derive the complete interval of readings this rule can accept, and explain whether rejecting a reading proves physical failure.

Review the relevant tools

Show hint

Write the possible true-temperature interval and require both its endpoints to satisfy the specification.

Show worked solution

Separate what is observed from what must be safe. $y$ is the known reading; $x$ is the unknown true temperature. The assumption supplies a set of possible $x$ values for that reading. Certification requires all members of this set to satisfy the temperature specification.

Translate the sensor statement into information about the true temperature. The inequality $|x-y|\le0.2$ is equivalent to $-0.2\le x-y\le0.2$. Adding $y$ gives $y-0.2\le x\le y+0.2$. Thus the possible true temperatures are the entire interval $I(y)=[y-0.2,y+0.2]$, in degrees Celsius above reference.

To accept a reading under this rule, every compatible value must satisfy the specification $C=[0,5]$. For intervals this means checking the two extreme values: $I(y)\subseteq C$ exactly when $y-0.2\ge0$ and $y+0.2\le5$.

Reading $y=4.7$. The information interval is $[4.7-0.2,4.7+0.2]=[4.5,4.9]$. Its lower endpoint is at least $0$ and its upper endpoint at most $5$, so every compatible temperature is acceptable. This reading is certified.

Reading $y=4.9$. The interval is $[4.7,5.1]$. The lower endpoint is acceptable, but $5.1\gt5$, so the upper endpoint breaks containment. This reading is not certified. It allows both a safe true temperature, such as $x=4.8$, and an unsafe one, such as $x=5.1$; each differs from the reading by at most $0.2$.

Find all accepted readings. Solving the endpoint conditions gives $y\ge0.2$ and $y\le4.8$, so the complete acceptance interval is $[0.2,4.8]$. At either endpoint, a possible true temperature equals a boundary of $C$ and is permitted, which explains the closed brackets. Rejection means that this information is insufficient to certify the specification; it does not establish physical failure. Certification itself remains conditional on the sensor error bound holding for this reading.

Check necessity of both acceptance endpoints. If $y\lt0.2$, the allowed value $x=y-0.2$ is negative and breaks the lower temperature bound. If $y\gt4.8$, the allowed value $x=y+0.2$ exceeds $5$ and breaks the upper bound. Thus no reading outside $[0.2,4.8]$ can pass this information-set test. At $y=0.2$, the interval is $[0,0.4]$; at $y=4.8$, it is $[4.6,5]$. Both limiting readings pass. For $y=4.9$, the simultaneous compatibility of a safe and an unsafe value explains why rejection is an information conclusion rather than an observed physical failure.

Exercise 0.B2 — Medium: Keep the decision ahead of the unknown warming

Use $x^+=1.1x+u+w$, $u\in[-1,0]$, $w\in[0,0.4]$, and $C=[0,5]$. At $x=4.8$, find every robustly allowed command and verify $u=-0.8$. A colleague chooses $u=-0.28-w$. Explain why that calculation uses different information, even if its numerical values lie in the actuator interval.

Review the relevant tools

Show hint

First fix one u and range over w. Then ask when the colleague learns w.

Show worked solution

Specify when each value is known. The state $4.8$ is observed before the command is chosen. The command must be fixed before the disturbance is known. Consequently the interval of successors is calculated with one fixed $u$, rather than a different command at each disturbance endpoint.

Fix a command before ranging over the disturbance. At the known state $x=4.8$, the deterministic term is $1.1x=1.1(4.8)=5.28$. For one fixed $u$, the unknown $w\in[0,0.4]$ therefore gives every successor between $5.28+u$ and $5.68+u$:

$$x^+\in[5.28+u,\;5.68+u].$$

Because $w$ enters with positive coefficient $1$, checking these endpoints checks all allowed intermediate disturbances.

Solve containment and enforce the actuator limit. Keeping this entire interval in $[0,5]$ requires

$$\begin{aligned} 5.28+u&\ge0 &&\Longleftrightarrow& u&\ge-5.28,\\ 5.68+u&\le5 &&\Longleftrightarrow& u&\le-0.68. \end{aligned}$$

Those two inequalities give $u\in[-5.28,-0.68]$, but the actuator additionally requires $u\in[-1,0]$. Their intersection is $[-1,-0.68]$, the complete set of robustly allowed commands.

Verify $u=-0.8$. It lies in this intersection, and substitution gives $x^+=5.28-0.8+w=4.48+w$. Thus $x^+\in[4.48,4.88]\subseteq[0,5]$ for every allowed warming contribution. All contributions to this temperature update have the stated degrees-Celsius units.

Audit the colleague's information. Their choice gives $x^+=5.28+(-0.28-w)+w=5$. For $0\le w\le0.4$, it ranges from $-0.28$ down to $-0.68$, so its values really are within $[-1,0]$. The problem is the dependency: choosing that value requires knowing the particular $w$ first. It proves $\forall w\ \exists u$, whereas the stated device must supply one $u$ before $w$ arrives, requiring $\exists u\ \forall w$. For example, choosing $-0.28$ as if $w=0$ and then receiving $w=0.4$ would give $x^+=5.4$. The robust command interval avoids this dependence and supplies the required single command.

Check the edges of the complete command interval. At $u=-1$, the possible successors are $[4.28,4.68]$. At $u=-0.68$, they are $[4.60,5.00]$. Both edges pass. Any legal command larger than $-0.68$ fails for $w=0.4$, since $5.68+u\gt5$. A command smaller than $-1$ might satisfy the safety inequalities but is unavailable to the actuator. The final admissible set must satisfy the model test and the command restriction simultaneously. The robust quantifier here is “there exists one $u$ such that every $w$ passes”; testing separately optimized endpoint commands would not prove it.

Exercise 0.B3 — Medium: Recognize an attainable tolerance

An iterative predictor satisfies $e_0=0.70$ and $e_{k+1}\le0.5e_k+0.03$, in degrees Celsius. Derive a bound for every $k$. Can it certify $e_k\le0.04$? Find the smallest iteration budget certified for $e_k\le0.07$ and explain how the answer changes for the strict requirement $e_k\lt0.07$.

Review the relevant tools

Show hint

The steady value of the equality recurrence solves b=0.5b+0.03. Subtract it before taking powers.

Show worked solution

Build an upper comparison sequence, not an equality for the actual errors. The assumption uses $\le$, so actual errors are allowed to lie below the recurrence envelope. We derive that envelope by an equality calculation and use positive multiplication to propagate its upper-bound property.

Remove the constant term before iterating. The equality recurrence has a steady value $b$ satisfying $b=0.5b+0.03$. Subtracting $0.5b$ gives $0.5b=0.03$, so $b=0.06$ degrees Celsius. Using this identity in the stated inequality gives

$$e_{k+1}-0.06 \le0.5e_k+0.03-0.06 =0.5(e_k-0.06).$$

Set $z_k=e_k-0.06$. Its initial value is $z_0=0.70-0.06=0.64$. We claim $z_k\le0.64(0.5)^k$. At $k=0$ this is equality. If it holds at $k$, multiply it by the positive number $0.5$ and use the recurrence to obtain $z_{k+1}\le0.5z_k\le0.64(0.5)^{k+1}$. Induction therefore proves

$$e_k\le0.06+0.64(0.5)^k =0.06+\frac{0.64}{2^k}$$

for every integer $k\ge0$, with the bound measured in degrees Celsius.

Assess the demand $0.04$. This upper envelope decreases towards $0.06$, which is above $0.04$. It cannot certify the requested tolerance. This does not assert that every actual error is at least $0.06$: actual errors may be smaller than an upper bound. It establishes lack of a universal guarantee because the equality sequence $e_k=0.06+0.64/2^k$ satisfies all the given information and stays above $0.04$.

Find the non-strict budget for $0.07$. Requiring the envelope to be at most $0.07$ gives

$$0.06+\frac{0.64}{2^k}\le0.07 \ \Longleftrightarrow\ \frac{0.64}{2^k}\le0.01 \ \Longleftrightarrow\ 2^k\ge64.$$

Since $2^6=64$, the smallest certified budget is $k=6$, where the bound is exactly $0.07$. At $k=5$ it is $0.06+0.64/32=0.08$, so that smaller budget fails.

Account for a strict demand. For $e_k\lt0.07$, the envelope must be strictly below $0.07$, requiring $2^k\gt64$. The first integer is now $k=7$, giving $0.06+0.64/128=0.065$. Equality is an allowed recurrence, so $k=6$ cannot guarantee the strict condition even though it guarantees the non-strict one.

Check the first envelope values. Its equality recurrence gives $0.70$, $0.38$, $0.22$, $0.14$, $0.10$, $0.08$, $0.07$, $0.065$ at indices $0$ through $7$. For instance, $0.5(0.38)+0.03=0.22$. The closed form gives the same value at $k=2$: $0.06+0.64/4=0.22$. This trace makes the two stopping decisions visible. At $k=6$ the non-strict target is met exactly; at $k=7$ the strict target is met. The limiting envelope $0.06$ is never attained at a finite index because $0.64/2^k$ remains positive. A target equal to that limit would therefore also lack a finite universal certificate under these assumptions.

Exercise 0.B4 — Hard: Find exactly how much disturbance the actuator can cover

Replace the warming bound by $w\in[0,d]$, with $d\ge0$, in the chamber model. For which $d$ does $\forall x\in[0,5]\ \exists u\in[-1,0]\ \forall w\in[0,d]:x^+\in[0,5]$ hold? Prove necessity with a boundary state and sufficiency with an explicit feedback. Then state the all-time consequence and its initial-state assumption.

Review the relevant tools

Show hint

At x=5 test the largest warming and strongest available cooling. For sufficiency try u=-0.2x.

Show worked solution

Use separate proofs for “only if” and “if”. Necessity may use one difficult state and disturbance, because a universal claim must handle them. Sufficiency must instead give an allowed command for an arbitrary state and check an arbitrary disturbance. This is why one boundary test can rule out a parameter but cannot by itself certify every state.

Find a necessary disturbance limit. A claim about every $x\in[0,5]$ must in particular work at $x=5$, and a robust command must handle $w=d$. For any legal command $u\ge-1$,

$$x^+=1.1(5)+u+d \ge5.5-1+d=4.5+d.$$

If $d\gt0.5$, this lower bound already exceeds $5$. Even the strongest permitted cooling cannot help, so no command works at that state and the quantified claim is false. Because $d\ge0$ was stipulated, the only possible range is $0\le d\le0.5$.

Supply a command throughout that range. Assume $0\le d\le0.5$ and take an arbitrary observed $x\in[0,5]$. Choose the feedback $u(x)=-0.2x$. Multiplying the state bounds by $-0.2$ reverses them and gives $-1\le u(x)\le0$, so the actuator can issue it. The choice depends on $x$, as permitted, and not on the unknown $w$.

Check every disturbance. With this feedback,

$$x^+=1.1x-0.2x+w=0.9x+w.$$

For arbitrary $0\le w\le d$, both terms are nonnegative, so $x^+\ge0$. Also $x^+\le0.9(5)+d=4.5+d\le5$. Therefore every allowed successor lies in $[0,5]$. This proves sufficiency, including the limiting case $d=0.5$, and establishes the exact parameter range $[0,0.5]$.

Extend one step to all time. Assume $x_0\in[0,5]$, that the stated update holds at every step, and that every disturbance satisfies $w_t\in[0,d]$. Apply $u_t=-0.2x_t$. The initial-state assumption is the induction base. If $x_t$ is in the interval, the calculation above shows the command is legal and $x_{t+1}$ is in the interval for every allowed $w_t$. Induction gives $x_t\in[0,5]$ for all $t\ge0$, even if disturbances vary arbitrarily over time.

Starting outside the interval is not covered by that base case. The earlier feedback for $d=0.4$ was a valid choice for that disturbance range; this feedback additionally handles the exact limiting range $d=0.5$ under the same model and timing assumptions.

Check the exact limiting disturbance budget. At $d=0.5$, the proposed feedback uses $u=-1$ at $x=5$ and gives $x^+=4.5+w\in[4.5,5]$. At $x=0$, it uses $u=0$ and gives $x^+=w\in[0,0.5]$. Both boundary states remain feasible. At an intermediate state $x=2.5$, the command is $-0.5$ and the successor interval is $[2.25,2.75]$. If $d$ exceeds $0.5$ by any positive amount, the state $5$ with disturbance $d$ already violates the upper limit even at command $-1$. These substitutions check the endpoint inclusion and the exact threshold, while the arbitrary-state inequalities above prove the whole range.

Reconstruct the argument before moving on

Close the examples and reconstruct the chain in your own words: specification, information set, command timing, one-step containment, induction, and computation budget. At each link, name a hypothesis that could break its application. Explain why a failed sufficient test differs from a counterexample, and why a limiting value differs from a finite stopping guarantee. These distinctions let you read later safety statements without silently strengthening what they prove.

For recall, write the negation of the robust chamber claim; identify which variable may depend on which earlier variables; and explain where the initial condition enters the induction. Then derive the error floor for a general recurrence $e_{k+1}\le ae_k+b$ with $0\le a\lt1$ and $b\ge0$. The answer $b/(1-a)$ should follow from the same finite geometric sum, rather than from memory alone.

The next bridge is geometric. Primer A's vectors and norms describe information sets when several temperatures or positions are uncertain together. Primer B's constrained optimization selects a good command from the admissible set. The logic here continues to determine what either calculation is allowed to conclude.

Exercises

For gradual practice on the opening material, use the graded sets on sets & logic, functions & fixed points, and proofs. The exercises below bring together ideas from across the primer.

Exercise 0.1 — Negation and quantifier order: feedback versus one fixed input

Let $C=U=[-1,1]$ and $f(x,u)=2x+u$. (a) Negate "$\forall x\in C\ \exists u\in U: f(x,u)\in C$". (b) Prove that statement. (c) Prove that "$\exists u\in U\ \forall x\in C: f(x,u)\in C$" is false. (d) Interpret the difference.

Show answer

Write the admissible command set for a fixed state. The condition $-1\le2x+u\le1$ is equivalent to $-1-2x\le u\le1-2x$. Intersecting with the actuator range gives $U(x)=[-1,1]\cap[-1-2x,1-2x]$. This lets us compare a command chosen after $x$ with one shared across every such set.

(a) Negate the whole quantified statement. To make “every state has a successful input” false, there must be one state for which every input fails. Swapping both quantifiers and negating membership gives

$$\exists x\in C\ \forall u\in U:\quad f(x,u)\notin C.$$

The domains stay $C=U=[-1,1]$. Since $f(x,u)=2x+u$, the final failure condition means $2x+u\lt-1$ or $2x+u\gt1$; equality at either boundary is not failure.

(b) Prove the original statement with a witness. Let an arbitrary $x\in[-1,1]$ be given. Choose $u=-x$. The inequalities $-1\le x\le1$ imply $-1\le-x\le1$, so this input belongs to $U$. Substitution gives $f(x,-x)=2x-x=x$, which belongs to $C$. Thus every allowed state has a successful input, and the negation in (a) is false.

(c) Test a command that must work for all states. Suppose a single $u\in U$ worked for every $x$. At the allowed state $x=1$, keeping $2+u$ in $C$ requires $2+u\le1$, hence $u\le-1$. At the allowed state $x=-1$, keeping $-2+u$ in $C$ requires $-2+u\ge-1$, hence $u\ge1$. No real number can satisfy both conditions. Therefore $\exists u\in U\ \forall x\in C:\ f(x,u)\in C$ is false.

(d) Interpret the information order. In $\forall x\ \exists u$, the state is known before the input is chosen, so the formula $u=-x$ is a feedback rule. Under it the closed-loop successor equals the current state, so an initial state in $C$ remains there at every step. In $\exists u\ \forall x$, the input has to be fixed before knowing which state will occur. The conflicting endpoint requirements show why this stronger request fails, despite the existence of a valid input at each separate state.

Inspect the sets at three states. At $x=1$, $U(1)=[-1,1]\cap[-3,-1]=\{-1\}$. At $x=-1$, $U(-1)=[-1,1]\cap[1,3]=\{1\}$. At $x=0$, $U(0)=[-1,1]$. Every state can have a nonempty command set while the intersection of all command sets is empty; these two endpoint singletons already force the empty intersection. The feedback $-x$ is one allowed selection at each state, not a claim that the allowed set always contains only that command. This set calculation makes the quantifier distinction concrete.

Exercise 0.2 — A monotone set operator: reachability is fragile

Redo the worked example of Section 2 ($D=\{0,\dots,8\}$, $L=1$, $h=0$, $f=(1.8,\,2.3,\,1.4,\,2.4,\,1.4,\,2.4,\,1.4,\,0.4,\,1.4)$, $S_0=\{0\}$) with estimation error $\epsilon=0.5$: $R_\epsilon(S)=S\cup\{x:\exists x'\in S: f(x')-\epsilon-|x-x'|\ge0\}$. (a) Compute the iterates and $\bar R_\epsilon(S_0)$. (b) Compare the number of strict increases with the Fact's bound. (c) Why does the closure shrink from $8$ points to $3$?

Show answer

Read the operator as repeated certification. $R_\epsilon$ retains $S$ and adds grid points justified by a witness already in $S$. The function values are indexed by grid position: $f(0)=1.8$, $f(1)=2.3$, and so on. The parameter $\epsilon$ reduces each witness's usable margin before distance is paid for.

(a) Convert each witness value into its permitted radius. Here $L=1$, $h=0$ and $\epsilon=0.5$. A witness $x'\in S$ can add $x$ exactly when $|x-x'|\le f(x')-0.5$. The operator also retains every point already in $S$. At each round, use only witnesses in the preceding set; a newly added point can become a witness at the next round.

From $S_0=\{0\}$, the only radius is $f(0)-0.5=1.8-0.5=1.3$. Among the integer grid points, $|x|\le1.3$ selects $0,1$. Thus $S_1=\{0,1\}$.

For the next round, witness $0$ still reaches $0,1$. The new witness $1$ has radius $2.3-0.5=1.8$, selecting $0,1,2$ because their distances from $1$ are $1,0,1$. Point $3$ is at distance $2\gt1.8$ and is not selected. Therefore $S_2=\{0,1,2\}$.

At round three, witness $2$ has radius $1.4-0.5=0.9$, smaller than the distance $1$ to either neighbouring integer, so it certifies only itself. Witnesses $0,1$ reach the sets already listed. Their union adds no point, and $S_3=S_2$. Hence $S_2$ is a fixed point: applying the same operator again gives the same set. Every later iterate is equal to it, so $\bar R_{0.5}(S_0)=\{0,1,2\}$.

(b) Count strict increases. The grid has $9$ points and the seed has $1$, so there can be at most $|D|-|S_0|=8$ strict increases: each would add at least one previously absent point. Here only $S_0\subsetneq S_1$ and $S_1\subsetneq S_2$ are strict. There are two increases, followed by stabilization.

(c) Explain the loss of the gateway. Without estimation error, witness $1$ could certify point $3$ with margin $f(1)-|3-1|=2.3-2=0.3$. Subtracting the new error budget $0.5$ turns this margin into $-0.2$, so that link fails. The alternative witness $2$ also fails: $f(2)-0.5-|3-2|=1.4-0.5-1=-0.1$. Witness $0$ is still farther away. Thus no point in the final three-point set can add $3$ or a more distant point.

The zero-error closure in the worked example was $\{0,\ldots,7\}$, containing eight points. With this error allowance it has only three. Error subtracts from a witness's safety margin before that margin can pay for distance; losing a gateway then loses the points that would have relied on it as a later witness. This describes reachability under the stated certificate, not an absolute impossibility for methods using additional information.

Check every possible gateway out of the final set. To add the next point $x=3$, witnesses $0,1,2$ give margins $1.8-0.5-3=-1.7$, $2.3-0.5-2=-0.2$, and $1.4-0.5-1=-0.1$. All are negative. For any grid point $x\ge3$, its distance from each of these witnesses is at least the distance at $3$, so its margin is no larger. Thus none of $3,4,\dots,8$ can enter from the final set. This proves stabilization by checking every outside candidate through a monotone distance comparison, rather than only observing that one attempted witness failed.

Exercise 0.3 — Induction and discounted sums

(a) Prove by induction that $\sum_{t=0}^{T-1}\gamma^t=\frac{1-\gamma^T}{1-\gamma}$ for $\gamma\ne1$. (b) For $0\le\gamma\lt1$, show $\sum_{t\ge0}t\gamma^t=\frac{\gamma}{(1-\gamma)^2}$ by writing $t=\sum_{s=1}^{t}1$ and exchanging the order of summation; why is that allowed? (c) Evaluate for $\gamma=0.9$ and interpret $(1-\gamma)\sum_tt\gamma^t$.

Show answer

Keep the horizon and discount conventions explicit. $T$ is a nonnegative integer counting terms; $\gamma$ is fixed throughout each sum. Discount weights use $\gamma^0=1$, including the convention that the time-zero weight is $1$ when $\gamma=0$. For positive indices and $\gamma=0$, every weight is zero. The finite identity needs $\gamma\ne1$; the infinite calculation additionally needs $0\le\gamma\lt1$.

(a) Prove the finite formula by induction on the number of terms. Let $S_T=\sum_{t=0}^{T-1}\gamma^t$, with $S_0=0$. At $T=0$, the proposed expression is $(1-\gamma^0)/(1-\gamma)=0$, since $\gamma^0=1$ and $\gamma\ne1$.

For the induction step, assume $S_T=(1-\gamma^T)/(1-\gamma)$. The sum with $T+1$ terms adds the term $\gamma^T$, so

$$\begin{aligned} S_{T+1} &=S_T+\gamma^T\\ &=\frac{1-\gamma^T}{1-\gamma}+\gamma^T\\ &=\frac{1-\gamma^T+\gamma^T(1-\gamma)}{1-\gamma}\\ &=\frac{1-\gamma^{T+1}}{1-\gamma}. \end{aligned}$$

The third line uses a common denominator, and the fourth cancels $-\gamma^T+\gamma^T$. This is the desired formula at $T+1$. Induction proves it for every integer $T\ge0$.

(b) Count each discounted term by its time index. For $t\ge1$, the identity $t=\sum_{s=1}^{t}1$ expresses $t$ as $t$ copies of $1$. The term at $t=0$ is zero. Consequently

$$\begin{aligned} \sum_{t=0}^{\infty}t\gamma^t &=\sum_{t=0}^{\infty}\sum_{s=1}^{t}\gamma^t\\ &=\sum_{s=1}^{\infty}\sum_{t=s}^{\infty}\gamma^t\\ &=\sum_{s=1}^{\infty}\frac{\gamma^s}{1-\gamma}\\ &=\frac1{1-\gamma}\,\frac{\gamma}{1-\gamma} =\frac{\gamma}{(1-\gamma)^2}. \end{aligned}$$

In the second line, the same pairs of indices are counted: $1\le s\le t$. For a finite horizon, these pairs form a finite triangular region, and either order adds exactly the same terms. As the region grows, every term is nonnegative because $0\le\gamma\lt1$. Thus enlarging it can only increase the partial sum, and the two orders have the same supremum; no cancellation or conditional convergence obstructs the exchange. The third line uses the geometric tail formula; the fourth uses $\sum_{s=1}^{\infty}\gamma^s=\gamma/(1-\gamma)$. At $\gamma=0$ the sum and the resulting formula are both zero.

(c) Substitute and interpret. For $\gamma=0.9$, the weighted sum is $0.9/(0.1)^2=0.9/0.01=90$. Multiplying by $1-\gamma=0.1$ gives $9$.

Define probabilities $p_t=(1-\gamma)\gamma^t$ for $t=0,1,\ldots$. They are nonnegative and sum to $(1-\gamma)/(1-\gamma)=1$, so they describe a random time $\tau$ with $\mathbb P(\tau=t)=p_t$. Its mean is $\mathbb E[\tau]=\sum_ttp_t=(1-\gamma)\sum_tt\gamma^t=\gamma/(1-\gamma)=9$. In this precise sense discounting weights time as a random horizon with mean time index $9$ steps.

See the order exchange on a small triangular array. Up to time $3$, the weighted terms are $\gamma+2\gamma^2+3\gamma^3$. Writing each coefficient as copies of $1$ gives $(\gamma)+(\gamma^2+\gamma^2)+(\gamma^3+\gamma^3+\gamma^3)$. Grouping instead by $s$ yields $(\gamma+\gamma^2+\gamma^3)+(\gamma^2+\gamma^3)+(\gamma^3)$. Each group for a fixed $s$ contains exactly the terms with $t\ge s$. The infinite argument uses this same indexing region and nonnegativity to pass to growing sums. At $\gamma=0.9$, the probabilities $p_t=0.1(0.9)^t$ sum to $1$; the mean $9$ is a mean time index, not a statement that the random time is always $9$ or that a fixed nine-step truncation has zero tail.

Exercise 0.4 — Suprema, limsup and the max-min inequality

(a) Find $\inf$, $\min$, $\sup$, $\max$ of $A=\{x/(1+x):x\ge0\}$ where they exist. (b) For $a_t=(-1)^t\big(1+\frac1{t+1}\big)$ find $\sup$, $\inf$, $\limsup$, $\liminf$. (c) Compare $\sup_x(\sin x+\cos x)$ with $\sup\sin+\sup\cos$. (d) For $\phi(x,y)=xy$ on $[-1,1]^2$, compute $\inf_x\sup_y\phi$ and $\sup_y\inf_x\phi$.

Show answer

Work with the specified domain in each part. Part (a) produces a set of output values; part (b) studies one indexed sequence; part (c) requires one common input for a sum; part (d) fixes one coordinate while optimizing the other. These are related bound questions, but their witnesses have different roles.

(a) Identify the actual output set. For $x\ge0$,

$$\frac{x}{1+x}=1-\frac1{1+x}.$$

The denominator is positive, so these values are nonnegative and strictly below $1$. The value $0$ is attained at $x=0$. As $x\to\infty$, the fraction $1/(1+x)$ tends to zero, and the outputs approach $1$. Hence $\inf A=\min A=0$ and $\sup A=1$. There is no maximum, because no finite $x$ gives $1$; increasing $x$ gives a larger output.

(b) Separate the two parity subsequences. Here the factor $(-1)^t$ multiplies the whole bracket. Thus $a_{2k}=1+1/(2k+1)$ decreases from $2$ to $1$, while $a_{2k+1}=-1-1/(2k+2)$ increases from $-3/2$ to $-1$. The first values are $2,-3/2,4/3,-5/4,\ldots$.

Every term is between $-3/2$ and $2$, and both bounds are attained: $\sup=\max=2$ at $t=0$, and $\inf=\min=-3/2$ at $t=1$. Every late tail still has both parities; its upper limiting value is $1$ and its lower limiting value is $-1$. Therefore $\limsup a_t=1$ and $\liminf a_t=-1$. The sequence does not converge, despite having a largest and a smallest term.

(c) Optimize the sum at one common input. The angle-addition identity gives

$$\sin(x+\pi/4) =\frac{\sin x+\cos x}{\sqrt2}, \qquad \sin x+\cos x=\sqrt2\sin(x+\pi/4).$$

Since $\sin$ never exceeds $1$, the sum never exceeds $\sqrt2$, and at $x=\pi/4$ it equals $\sqrt2$. Thus $\sup_x(\sin x+\cos x)=\sqrt2\approx1.414$. Separately, $\sup_x\sin x=1$ and $\sup_x\cos x=1$, so their sum is $2$. Those separate optima occur at different inputs: $\sin$ is $1$ at $\pi/2$ and $\cos$ is $1$ at $0$, and they cannot both equal $1$ at a common input. This explains the strict inequality $\sqrt2\lt2$.

(d) Choose the inner optimizing response first. Fix $x\in[-1,1]$. If $x\ge0$, the largest $xy$ occurs at $y=1$ and is $x$. If $x\lt0$, it occurs at $y=-1$ and is $-x$. In both cases $\sup_{y\in[-1,1]}xy=|x|$. Minimizing this over $x$ gives $0$, attained at $x=0$.

In the other order, fix $y$. If $y\ge0$, the smallest $xy$ occurs at $x=-1$; if $y\lt0$, it occurs at $x=1$. Thus $\inf_{x\in[-1,1]}xy=-|y|$. Its largest value over $y$ is $0$, at $y=0$. We conclude

$$\inf_x\sup_y\phi(x,y)=0 =\sup_y\inf_x\phi(x,y).$$

There is no minimax gap in this example. At $(0,0)$, both $\phi(0,y)$ and $\phi(x,0)$ are zero for every allowed opponent's choice, so neither player can improve its outcome by changing only its own coordinate; $(0,0)$ is a saddle point.

Verify that the output set in (a) has no gaps. Given any $y\in[0,1)$, solve $y=x/(1+x)$: multiply by $1+x$, giving $y+yx=x$, hence $y=x(1-y)$. Since $1-y\gt0$, choose $x=y/(1-y)\ge0$. Substitution returns $y$, so the output set is exactly $[0,1)$.

Expand one inner minimax calculation. At $x=-1/2$, the values $xy$ range from $-1/2$ at $y=1$ to $1/2$ at $y=-1$; the maximizing response depends on the sign of $x$. At $x=0$, every $y$ gives zero. The outer minimizer can therefore secure zero by choosing this latter input. In the reverse order, fixing $y=0$ makes every minimizing response give zero. These witnesses explain equality here. They do not imply that the two orders can be exchanged for every function or domain, as the finite local practice example shows.

Exercise 0.5 — Does a minimizer exist?

Decide with a reason, and compute where possible: (a) $\min_{x\ge0}e^{-x}$; (b) $\min_{x\in[0,1]}(x^2-x)$; (c) $\min\|u\|^2$ subject to $u_1+u_2\ge1$ in $\mathbb R^2$; (d) $\max_{u\in\mathbb R^2}(u_1+u_2)$; (e) for which $c$ is $\{x\in\mathbb R:x^2/(1+x^2)\le c\}$ compact?

Show answer

Separate an existence theorem from a direct calculation. A continuous objective on a nonempty compact set has an attained minimum. When that sufficient theorem does not apply, solve the particular problem: it may still attain a minimum, or may only approach an infimum. For $u=(u_1,u_2)$, the squared norm means $\|u\|^2=u_1^2+u_2^2$.

(a) $e^{-x}$ on $x\ge0$. Every finite $x$ gives $e^{-x}\gt0$, so $0$ is a lower bound. Taking $x=n$ and sending $n\to\infty$ gives $e^{-n}\to0$, showing that no larger number is a lower bound. Thus the infimum is $0$, but it is never attained, and a minimum does not exist. The domain is unbounded, so the compact-domain extreme value theorem does not apply.

(b) $x^2-x$ on $[0,1]$. This polynomial is continuous and the interval is nonempty and compact, so a minimum exists. To locate it and verify that it is global, complete the square:

$$x^2-x=(x-\tfrac12)^2-\tfrac14\ge-\tfrac14.$$

Equality occurs only at $x=1/2$, which is in the domain. The unique minimum is $-1/4$. The calculus calculation $f'(x)=2x-1=0$ gives the same point; the square verifies that neither an endpoint nor any other input has a smaller value.

(c) The constrained squared norm. Write $s=u_1+u_2$ and note that feasibility means $s\ge1$. Expanding squares gives

$$\begin{aligned} \|u\|^2=u_1^2+u_2^2 &=\frac{(u_1+u_2)^2+(u_1-u_2)^2}{2}\\ &\ge\frac{s^2}{2}\ge\frac12. \end{aligned}$$

The first inequality drops a nonnegative square; the second uses $s\ge1$. At $u^\ast=(1/2,1/2)$, the constraint holds with equality and the objective is $1/4+1/4=1/2$. Hence a minimum exists and equals $1/2$. Equality requires $u_1-u_2=0$ and $s=1$, so this minimizer is unique. Although the feasible half-space is unbounded, it is closed and nonempty and the objective is coercive; the explicit lower-bound-and-witness calculation here establishes the result directly.

(d) The unconstrained linear maximum. Choose $u=(s,s)$. Its objective is $u_1+u_2=2s$, which grows without bound as $s\to\infty$. Any proposed maximum can be exceeded by a larger $s$. Thus there is no maximum; the supremum is $+\infty$.

(e) Split the parameter cases before rearranging. Since $1+x^2\gt0$, we always have $0\le x^2/(1+x^2)\lt1$.

  • If $c\lt0$, no value meets the inequality, so the sublevel set is empty. The empty set is compact.
  • If $0\le c\lt1$, multiplying by the positive denominator and rearranging gives $x^2\le c(1+x^2)$, hence $(1-c)x^2\le c$. Because $1-c\gt0$, division preserves the inequality and gives $x^2\le c/(1-c)$. The set is the closed bounded interval $[-\sqrt{c/(1-c)},\sqrt{c/(1-c)}]$, so it is compact. At $c=0$, this interval is the singleton $\{0\}$.
  • If $c\ge1$, every real $x$ satisfies the inequality, so the set is all of $\mathbb R$ and is not compact because it is unbounded.

Therefore the sublevel set is compact exactly when $c\lt1$, including negative $c$. Its emptiness in the negative case does not imply that a minimizer exists there: the extreme value theorem also requires a nonempty domain.

Expand the two-square identity in (c). $(u_1+u_2)^2=u_1^2+2u_1u_2+u_2^2$, while $(u_1-u_2)^2=u_1^2-2u_1u_2+u_2^2$. Adding cancels the cross terms and dividing by $2$ gives $u_1^2+u_2^2$. To attain the lower bound $1/2$, both inequalities in the chain must be equalities: $u_1-u_2=0$ and $(u_1+u_2)^2=1$. Since feasibility requires $u_1+u_2\ge1$, the latter forces the sum to be $1$, not $-1$. Solving equal coordinates with sum $1$ gives $u_1=u_2=1/2$.

Check why the parameter split in (e) comes first. At $c=1$, the inequality $(1-c)x^2\le c$ becomes $0\le1$ and permits every real $x$; division by $1-c$ would be division by zero. At $c\gt1$, that factor is negative and division would reverse order. The simple range $0\le x^2/(1+x^2)\lt1$ already settles these cases correctly. Empty, bounded nonempty and unbounded sublevel sets have distinct existence consequences.

Exercise 0.6 — Reading rates and costs

(a) Order $(\ln T)^3$, $\sqrt T$, $T^{2/3}$, $T/\ln T$ by growth and justify two comparisons. (b) Is $0\le R_T\le4\sqrt T\ln T$ sublinear, and from which $T$ on is the average-regret bound at most $0.1$? (c) A Cholesky factorisation takes $0.05$ s at size $1000$; estimate size $4000$. (d) How many points has a grid with $20$ points per axis in $d=6$?

Show answer

Plan of attack. The four parts ask four different kinds of question, so each gets its own tool: (a) limits of ratios, (b) a squeeze argument followed by a finite inequality solved with a monotonicity check, (c) a cubic scaling model, (d) counting independent choices.

Step 1 — Fix what “grows more slowly” means. For positive functions $f,g$ of $T$, write $f\ll g$ when $f(T)/g(T)\to0$ as $T\to\infty$. We will show

$$(\ln T)^3\ll\sqrt T\ll T^{2/3}\ll\frac{T}{\ln T}.$$

This is a statement about the eventual behaviour of ratios, not an ordering of the values at every small $T$. For example, at $T=10$ we have $(\ln10)^3\approx12.2$ while $\sqrt{10}\approx3.16$, so the first function is still larger there.

Step 2 — Compare $(\ln T)^3$ with $\sqrt T$ by a change of variable. Put $s=\ln T$, so $T=e^s$ and $\sqrt T=e^{s/2}$. As $T\to\infty$, also $s\to\infty$. The ratio becomes

$$\frac{(\ln T)^3}{\sqrt T}=\frac{s^3}{e^{s/2}}.$$

Both numerator and denominator tend to $\infty$, both are differentiable, and the denominator's derivative $\tfrac12e^{s/2}$ is never zero. Those are the assumptions of L'Hôpital's rule for the form $\infty/\infty$, so we may replace the ratio by the ratio of derivatives, provided the new limit exists. Applying the rule three times (each new ratio is again of the form $\infty/\infty$ until the numerator becomes a constant):

$$\begin{aligned} \frac{s^3}{e^{s/2}} &\;\to\;\frac{3s^2}{\tfrac12e^{s/2}}=\frac{6s^2}{e^{s/2}}\\ &\;\to\;\frac{12s}{\tfrac12e^{s/2}}=\frac{24s}{e^{s/2}}\\ &\;\to\;\frac{24}{\tfrac12e^{s/2}}=\frac{48}{e^{s/2}}\;\longrightarrow\;0. \end{aligned}$$

Here “$\to$” between lines means “has the same limit as”. The last expression tends to zero because its denominator grows without bound while the numerator stays $48$. Hence $(\ln T)^3/\sqrt T\to0$.

Step 3 — Compare the two powers. Subtracting exponents (both bases are the same positive $T$):

$$\frac{\sqrt T}{T^{2/3}}=T^{1/2-2/3}=T^{-1/6}=\frac1{T^{1/6}}\longrightarrow0.$$

Step 4 — Compare $T^{2/3}$ with $T/\ln T$. Dividing by a fraction multiplies by its reciprocal:

$$\frac{T^{2/3}}{T/\ln T}=\frac{T^{2/3}\ln T}{T}=\frac{\ln T}{T^{1/3}}.$$

Again both parts tend to $\infty$ and the denominator's derivative $\tfrac13T^{-2/3}$ is positive, so one application of L'Hôpital's rule gives

$$\frac{1/T}{\tfrac13T^{-2/3}}=\frac{3T^{2/3}}{T}=\frac{3}{T^{1/3}}\longrightarrow0.$$

Steps 2–4 justify all three links of the chain (the question asked for two). Since $\ll$ is transitive (multiply two ratios that tend to zero), the full order follows.

Step 5 — Turn the regret bound into an average-regret bound. Divide $0\le R_T\le4\sqrt T\ln T$ by the positive number $T$; division by a positive number keeps both inequalities:

$$0\le\frac{R_T}{T}\le b(T):=\frac{4\sqrt T\ln T}{T}=\frac{4\ln T}{\sqrt T}.$$

The last equality uses $T=\sqrt T\cdot\sqrt T$. By the same single L'Hôpital step as in Step 4, $\ln T/\sqrt T$ has the same limit as $(1/T)/(1/(2\sqrt T))=2/\sqrt T$, which tends to $0$. So $b(T)\to0$, and the squeeze theorem (lower bound $0$, upper bound tending to $0$) gives $R_T/T\to0$. The regret is sublinear.

Step 6 — Find where $b$ is decreasing. A “from which $T$ on” answer needs the bound to stay below $0.1$ for every later $T$, so we need monotonicity, not just one good value. Write $b(T)=4(\ln T)\,T^{-1/2}$ and use the product rule:

$$\begin{aligned} b'(T)&=4\Big[\frac1T\,T^{-1/2}+(\ln T)\big(-\tfrac12T^{-3/2}\big)\Big]\\ &=4T^{-3/2}\Big(1-\tfrac12\ln T\Big). \end{aligned}$$

The factor $4T^{-3/2}$ is positive, so the sign of $b'$ is the sign of $1-\tfrac12\ln T$. This is $\le0$ exactly when $\ln T\ge2$, i.e. $T\ge e^2\approx7.39$. So $b$ increases up to $e^2$, where it peaks at $b(e^2)=4\cdot2/e=8/e\approx2.94$, and decreases for all larger $T$. Once $b(T)\le0.1$ at some $T\ge e^2$, it stays $\le0.1$ for every larger $T$.

Step 7 — Rewrite the target without fractions. For $T\gt0$, multiplying $4\ln T/\sqrt T\le0.1$ by $10\sqrt T\gt0$ gives the equivalent test

$$b(T)\le0.1\iff40\ln T\le\sqrt T.$$

Step 8 — Bracket the crossing and narrow it. Evaluate $b$ at a few budgets, keeping the decreasing branch $T\ge e^2$ in mind:

$T$$b(T)=4\ln T/\sqrt T$$\le0.1$?
$10^4$$\approx0.36841$No
$10^5$$\approx0.14563$No
$240{,}000$$\approx0.101151$No
$250{,}000$$\approx0.099434$Yes
$246{,}600$$\approx0.1000066$No
$246{,}700$$\approx0.0999895$Yes
$246{,}630$$\approx0.10000145$No
$246{,}640$$\approx0.09999975$Yes
$246{,}638$$0.1000000922$ (approximately)No
$246{,}639$$0.0999999221$ (approximately)Yes

Each failing–passing pair of rows shrinks the interval known to contain the crossing; reading the table this way is legitimate because $b$ is decreasing on this whole range (Step 6). The last two rows are so close to $0.1$ that it is worth checking them in the fraction-free form of Step 7:

$$\begin{aligned} T=246{,}638:\quad40\ln T&\approx496.62708,\\ \sqrt T&\approx496.62662;\\[4pt] T=246{,}639:\quad40\ln T&\approx496.62724,\\ \sqrt T&\approx496.62763. \end{aligned}$$

At $246{,}638$ the left side is larger, so the test fails; at $246{,}639$ the right side is larger, so it passes. Hence $T=246{,}639$ is the first integer from which the average-regret bound stays at most $0.1$.

Step 9 — Check that no smaller cutoff works. Any cutoff $T_0\le246{,}638$ would have to cover the index $246{,}638$, where the bound is above $0.1$. Note that very small budgets can also satisfy the inequality (at $T=1$, $b(1)=0$), but $b$ then rises above $0.1$ again, so such isolated values do not give a permanent cutoff. These numbers describe the upper bound; the actual regret may be smaller.

Step 10 — Scale the Cholesky time. Cholesky factorisation of an $n\times n$ matrix costs about $n^3/3$ operations, i.e. it scales like $n^3$. The size ratio is $4000/1000=4$, so the work ratio is

$$\Big(\frac{4000}{1000}\Big)^3=4^3=64,\qquad 0.05\ \text{s}\times64=3.2\ \text{s}.$$

This assumes the same implementation and roughly constant time per operation (no change in cache or parallel efficiency); big-$O$ gives the scaling model, not an exact wall-clock guarantee.

Step 11 — Count the grid points. A grid point is chosen by picking one of $20$ positions on axis $1$, one of $20$ on axis $2$, and so on, independently on all $6$ axes. Independent choices multiply:

$$20^6=(20^3)^2=8000^2=64{,}000{,}000=6.4\times10^7.$$

Building it up axis by axis: $20$, then $20\cdot20=400$, then $8000$, $160{,}000$, $3{,}200{,}000$, $64{,}000{,}000$. It is a product of choices, not $20\times6$.

Check. At $T=246{,}639$: $\ln T\approx12.41568$, so $4\ln T\approx49.6627$, and $\sqrt T\approx496.628$; their ratio is $0.09999992\le0.1$, consistent with the table. The cubic estimate passes a sanity check in the other direction: halving $n$ from $1000$ to $500$ would predict $0.05/8\approx0.006$ s. With $10$ axes the grid would have $20^{10}=1.024\times10^{13}$ points.

Interpretation. A sublinear rate guarantees that average regret eventually falls below any tolerance, but the constants ($4$ and the $\ln T$ factor) push the certified budget for $0.1$ to about a quarter of a million rounds. The cubic matrix cost and the exponential grid cost respond to different size variables: multiplying the matrix dimension by $4$ costs a factor $64$, whereas each extra grid axis multiplies the cost by $20$.

Exercise 0.7 — Banach's theorem for $\cos x$: the bound versus reality

(a) Show that $g(x)=\cos x$ maps $J=[\cos1,1]$ into itself and is a contraction there with $L=\sin1$. (b) From $x_0=1$, how many iterations does the a priori bound guarantee for $|x_k-x^\ast|\le10^{-6}$? (c) In fact $32$ suffice; explain the gap. (d) Evaluate the a posteriori bound at $k=10$, where $x_9\approx0.731404$, $x_{10}\approx0.744237$.

Show answer

List the three distinct certificates. The self-map calculation checks that the iteration stays in $J$. The a priori error estimate uses the first step and a global contraction constant before running further iterations. The a posteriori estimate uses a recent observed step. The actual error additionally involves the fixed point, which is not known exactly from the update rule alone.

(a) Check that the interval is preserved. Write $c=\cos1$ and $J=[c,1]$, with $c\approx0.5403$. The interval lies in $[0,\pi/2]$, where $\cos$ is decreasing. Hence its image is $g(J)=[\cos1,\cos(\cos1)]=[c,\cos c]$. The upper endpoint satisfies $\cos c\le1$, and $\cos c\ge\cos1=c$ because $c\le1$. Therefore $g(J)\subseteq J$; the image endpoints are approximately $0.5403$ and $0.8576$.

Check contraction, not just preservation. For distinct $x,y\in J$, the mean value theorem supplies $\xi$ between them such that $\cos x-\cos y=-\sin\xi\,(x-y)$. Since $0\le\xi\le1$ and $\sin$ increases on this interval, $|\sin\xi|\le\sin1$. Thus

$$|\cos x-\cos y|\le L|x-y|, \qquad L=\sin1\approx0.8415\lt1.$$

The inequality also holds when $x=y$. The interval is nonempty and closed, and we verified the self-map and strict-contraction properties. Banach's theorem therefore gives one fixed point in $J$, $x^\ast\approx0.739085$, and convergence from every start in $J$.

(b) Use the bound that needs only the first step. At $x_0=1$, the next value is $x_1=\cos1$, so $|x_1-x_0|=1-\cos1\approx0.4597$. The a priori bound is

$$|x_k-x^\ast| \le\frac{L^k}{1-L}(1-\cos1).$$

To guarantee the target, require $L^k\le(1-L)10^{-6}/(1-\cos1)$. Both sides are positive, so logarithms preserve their order. Dividing by $\ln L\lt0$ then reverses the inequality:

$$k\ge \frac{\ln\big((1-\cos1)/((1-\sin1)10^{-6})\big)} {\ln(1/\sin1)} \approx86.2098.$$

The first integer meeting this certificate is $87$. As a rough arithmetic check, $1-L\approx0.1585$, the numerator is approximately $14.88$ and the denominator approximately $0.1726$. The integer decision uses the original sine and cosine values, rather than treating their rounded displays as exact.

(c) Explain why the actual run is faster. The constant $L$ bounds the slope everywhere in $J$. Once the iterates are near $x^\ast$, the slope magnitude is about $\sin x^\ast\approx0.674$, substantially smaller. A geometric estimate using this local factor and the starting error $1-x^\ast\approx0.261$ gives $\ln(0.261\cdot10^6)/\ln(1/0.674)\approx31.6$, suggesting $32$ iterations. This explains the gap but is not itself a uniform guarantee.

A certified interval calculation can check the actual conclusion. The fixed point lies between $0.7390851331$ and $0.7390851333$, and the thirty-second iterate lies between $0.73908599959$ and $0.73908599970$. These intervals place the iterate above the fixed point and bound its error by $0.73908599970-0.7390851331=0.0000008666\lt10^{-6}$. Such enclosures track rounding error; simply comparing rounded iterates with a rounded fixed point is not a certificate. The global a priori bound must also cover starts elsewhere in $J$.

(d) Use the observed last step to bound all remaining movement. Let $d_k=|x_k-x_{k-1}|$. Contraction gives $|x_{k+1}-x_k|\le Ld_k$, the next step is at most $L^2d_k$, and so on. The total remaining distance to the limit is at most the sum of these step lengths:

$$|x^\ast-x_k| \le(L+L^2+L^3+\cdots)d_k =\frac{L}{1-L}d_k.$$

At $k=10$, the supplied rounded values give $d_{10}\approx|0.744237-0.731404|=0.012833$. Also $L/(1-L)\approx5.31$, so the a posteriori bound is approximately $5.31(0.012833)\approx0.068$. The true error is about $0.0052$, and the a priori bound at this index is about $0.52$. The recent-step bound improves the certificate, but still uses the worst slope and a triangle-inequality sum, so it remains larger than the actual error.

Expand the sign change in the logarithm calculation. Starting with $L^k(1-\cos1)/(1-L)\le10^{-6}$, multiply by the positive $(1-L)/(1-\cos1)$ to isolate $L^k$. Taking logarithms gives $k\ln L\le\ln((1-L)10^{-6}/(1-\cos1))$. Since $\ln L\lt0$, division reverses the comparison. Multiplying numerator and denominator by $-1$ then gives the positive ratio displayed above. The ceiling operation is applied after this real lower bound on $k$.

Explain the a posteriori indexing. The observed step $d_k$ ends at the current value $x_k$ and is already completed. The uncompleted movement begins with $x_{k+1}-x_k$, bounded by $Ld_k$, not by $d_k$. The next movement is bounded by $L^2d_k$. Summing from power $1$ gives $L/(1-L)$; starting at power $0$ would yield a valid but larger estimate. Rounded values make the reported $k=10$ number an approximation. To certify a sharp tolerance numerically, one must also bound rounding and function-evaluation errors, as the interval comparison in part (c) does.

Ready to move on?

You are ready for Primer A when you can read and negate a quantified statement, compose two functions, and explain the difference between a bound and an attained optimum. Check these without opening a solution:

If one task stalls, revisit its review link and attempt the local Easy exercise again. You can continue once Easy and Medium work is independent; the Hard exercises are useful return visits as later modules give the ideas context. Next: Primer A: vectors and matrix tools.

Further Reading

ResourceEditionCoversWhy read it
Book of Proof (R. Hammack)3rd ed. 2018, freeSets, logic, proof techniques, induction, functionsThe gentlest complete route through Sections 1–3.
How to Prove It: A Structured Approach (D. J. Velleman)3rd ed., CUP 2019Quantifiers, proof strategies, inductionHow the logical form of a statement dictates its proof.
Mathematics for Computer Science (E. Lehman, F. T. Leighton, A. R. Meyer)MIT 6.042J, 2015, freeLogic, induction and state-machine invariants, sums, asymptotic notationInvariants are induction over time steps; its "Sums and Asymptotics" matches Sections 4 and 7.
Understanding Analysis (S. Abbott)2nd ed., Springer 2015Suprema, sequences, series, compactness, continuityThe most readable treatment of Sections 4–6.
Basic Analysis I (J. Lebl)v6.3, 2026, freelimsup, series, extreme values, uniform continuity, metric spacesFree and complete; Section 7.6 proves the contraction fixed-point theorem.
Convex Optimization, App. A (S. Boyd, L. Vandenberghe)CUP 2004, free PDFNorms, open and closed sets, sup and infA compact reference in the optimization modules' conventions.
Computational Complexity: A Modern Approach (S. Arora, B. Barak)CUP 2009, free draftP, NP, reductions (Chapter 2)The precise meaning of "NP-hard" in Modules 12 and 15.
Reinforcement Learning: An Introduction (R. S. Sutton, A. G. Barto)2nd ed., MIT Press 2018, freeDiscounted returns, value iterationWhere the geometric series and fixed points meet RL.

Flashcards