Module contents
Lesson 4 of 23Advanced 105 min

Reading and verifying the mathematics of a paper

Read a paper's theoretical section by reconstructing notation, drawing lemma and theorem dependencies, auditing assumptions, and checking statements numerically on small instances. The central case is Adam's convergence proof and the online convex optimization counterexample by Reddi, Kale, and Kumar, together with the AMSGrad correction.

After this lesson you can

  • Build a notation table and dependency graph for a paper's theoretical section.
  • Audit theorem assumptions and identify which are essential by seeking counterexamples when removed.
  • Numerically reproduce the Reddi et al. counterexample to Adam's convergence and measure regret.
  • Locate an incorrect step in a published proof and explain why it fails.
  • Numerically check inequalities and rates claimed by a paper before building on them.

Before you start

A result can work despite a flawed proof

Adam is a widely used practical optimization method. Its paper also presented a regret guarantee for online convex optimization. Reddi, Kale, and Kumar showed a counterexample and identified problems in the proof. This case teaches us to separate three things: an algorithm can be empirically useful, a proof can have an invalid step, and a general claim can be false under certain assumptions. None of these observations implies that Adam fails on every neural-network problem.

Reconstructing notation comes before checking the result. Copy definitions, types, indices, and update conventions. A hat may indicate bias correction in one paper and a historical maximum in another. In Reddi’s case, vtv_t is the uncorrected exponential second moment, while v^t\hat v_t in AMSGrad is the running maximum of vsv_s. In the original Adam paper, hatted symbols denote bias-corrected moments. Do not mix the formulas of the two variants when comparing a proof with an implementation.

SymbolType and meaning
xtx_tScalar point in [−1,1][-1,1] before observing loss ftf_t.
gtg_tGradient ft′(xt)f_t'(x_t); in the example it is CC or −1-1.
mt,vtm_t,v_tExponential averages of gradient and squared gradient, initialized to zero.
αt\alpha_tBase step α/t\alpha/\sqrt t; the effective rate also depends on vtv_t.
v^t\hat v_tFor AMSGrad, maximum of v1,…,vtv_1,\ldots,v_t.
Γt+1\Gamma_{t+1}Change in inverse rate: vt+1/αt+1−vt/αt\sqrt{v_{t+1}}/\alpha_{t+1}-\sqrt{v_t}/\alpha_t.
RTR_TSum of the algorithm’s losses minus that of the best fixed point in hindsight.

In multiple dimensions vtv_t and Γt\Gamma_t are diagonal and the positive-semidefinite condition requires a nonnegative sign in each coordinate. Reddi’s general algorithm uses a weighted-metric projection; in one dimension on an interval, this reduces to clipping to the interval. That detail does not automatically transfer to a Euclidean projection onto an arbitrary multidimensional set.

Read an equation as a contract

For each formula, note what is given and what is calculated. In online optimization, xtx_t is chosen before evaluating ftf_t; a gradient is then observed and xt+1x_{t+1} is produced. If you update first and then evaluate ftf_t, you have given the algorithm future information. The difference is easy to hide in a loop updating a variable where losses are accumulated. Write the order explicitly and compare it with the pseudocode.

Also note what changes with the horizon. The best fixed comparator is defined after seeing losses through TT, but it is not a sequence of the best decision at each instant. If the sum of gradients is positive, the interval comparator is -1; if negative, it is +1; if zero, every point ties. Regret can be negative on a finite sequence because the adaptive algorithm can outperform the best fixed point in hindsight. An upper bound on regret does not claim that every individual term is positive.

Coordinate indices matter when moving from scalar to vector. An elementwise maximum in AMSGrad is not the maximum of the global norm; each coordinate keeps its own history. For a diagonal matrix, positive semidefiniteness is equivalent to checking each diagonal entry. For a general matrix diagonal entries alone are insufficient: consider eigenvalues or the quadratic form. Writing each object’s type prevents applying a scalar rule to a matrix without justification.

Draw dependencies and audit assumptions

A dependency graph connects definitions, lemmas, and theorems. In the Adam appendix, lemma 10.2 is the convexity inequality; 10.3 is used in 10.4, and the proof of theorem 10.5, corresponding to the main guarantee 4.1, uses the lemmas. The corollary on average regret depends on that guarantee. Reddi and colleagues point to both the assumed sign of Γ\Gamma and problems in lemmas 10.3 and 10.4. The diagram summarizes these dependencies; it does not reproduce every inequality.

InteractiveProof dependencies

Dependencies: convexity → theorem; 10.3 → 10.4 → theorem; telescoping → theorem → corollary.

Telescoping step: The proof needs to control the sign of the change in the preconditioner. Γ can be negative for Adam.

An unsupported step invalidates that proof; by itself it does not show that every related result is false.

Selected nodeTelescoping step
Select a node to examine its role. A questioned step leaves results depending on that proof unjustified.

An assumption audit asks where each hypothesis is used and what kind of object it permits: convex losses, bounded gradients and domain, momentum parameters, and step schedule. If an assumption does not appear in a particular proof, the proof may admit a more general conclusion, but check dependencies and versions before removing it. A counterexample after removing it shows that the expanded statement fails; it does not show that the assumption is the only possible condition.

InteractiveExamine assumptions

Claim: x² ≤ 1 for |x| ≤ 1. Closed grid of 401 points.

Worst explored point: x = -1.00; excess = 0.00. No violation was found on this grid; this does not prove the statement over the full continuum.

Statusrestricted case
Largest excess on grid0.00
The grid looks for violations of two auxiliary bounds as the domain expands; absence of a violation on a grid is not a proof.

A technical assumption can be hard to check in an application. A bounded gradient over an entire domain does not follow merely from observing small values over ten iterations. A bound on the diameter of iterates differs from a bound on the entire domain. Note quantifiers: “for all tt and xx” is stronger than “for observed points”. In a proof, assign a line to each use; when an inequality reverses upon multiplication by a negative quantity, check the sign before telescoping.

Review a long proof

Start from the final result and follow one dependency at a time. For the regret bound, identify where convexity turns a loss difference into a gradient-displacement product. Then find the expansion of the update and sums of squared distances. Ask which terms cancel exactly and which retain changing coefficients. Telescoping with variable weights is not the same identity as with a constant weight.

If you write at=(xt−x∗)2a_t=(x_t-x^*)^2 and wt=vt/αtw_t=\sqrt{v_t}/\alpha_t, a sum such as ∑twt(at−at+1)\sum_t w_t(a_t-a_{t+1}) rearranges into boundary terms and differences wt−wt−1w_t-w_{t-1}. A uniform bound at≤D2a_t\leq D^2 can directly control a positive contribution, but if the weight difference is negative you must preserve its sign and handle it with a valid inequality. Assuming all differences are positive simplifies the calculation, but that property must follow from the update and schedule.

The graph is a navigation aid, not a formal proof. If lemma A is used in B, a problem in A’s proof removes that support for B; another proof of A or B might exist. Likewise, a failed step does not automatically prove the final result false. Reddi’s counterexample adds another piece: it describes a concrete problem contradicting the convergence guarantee attributed to Adam in that setting. Keeping the observations separate avoids overstating a proof inspection.

An assumption audit must also follow definitions across papers. The original Adam analysis and Reddi’s simplified presentation use different notation for normalized moments. Reddi also distinguishes the example with constant momentum from the decreasing form used in the original analysis and explains how to extend the phenomenon. When reproducing the case, state which variant you run; do not present matching names as exact code identity.

The online counterexample

For each block of three steps, take ft(x)=Cxf_t(x)=Cx if t mod 3=1t\bmod 3=1 and ft(x)=−xf_t(x)=-x on the other two, with C>2C>2. In a complete block the cumulative loss of a fixed point is (C−2)x(C-2)x; the best in [−1,1][-1,1] is x∗=−1x^*=-1 and the worst is +1+1. The large positive gradient is rare; the two negative gradients push right. Adam normalizes by a moment that falls after the large gradient, so those two updates can dominate.

The concrete construction in Reddi’s appendix A uses x1=1x_1=1, β1=0\beta_1=0, β2=1/(1+C2)\beta_2=1/(1+C^2), and αt=α/t\alpha_t=\alpha/\sqrt t with α<1−β2\alpha<\sqrt{1-\beta_2}. This presentation does not correct bias. For C=3C=3, β2=0.1\beta_2=0.1 and α=0.2\alpha=0.2 satisfy those conditions. The proof establishes that block-start iterates return to +1+1 and mean regret does not vanish; the numerical calculation below illustrates finite horizons, not the limit. For different parameters, the interactive runs another instance without assuming the same behavior.

InteractiveAdam and AMSGrad in the periodic example
0.70.0step 3000

Blue: Adam; orange: AMSGrad. Every 30th step is shown; Γ can also be negative between samples. Regret is calculated against the best fixed point over the observed horizon, not a per-step optimum.

3
0.0
0.1
Show
Adam: average regret0.670
AMSGrad: average regret0.126
Change the parameter, momentum, and displayed variable. The default reproduces the configuration described in the text; points are sampled every 30 steps.

AMSGrad maintains v^t=max⁡(v^t−1,vt)\hat v_t=\max(\hat v_{t-1},v_t) and uses that maximum in the denominator. With nonincreasing αt\alpha_t, v^t/αt\sqrt{\hat v_t}/\alpha_t does not decrease and Γ\Gamma is nonnegative. This removes the sign problem, but alone is insufficient to prove every convergence claim. Reddi’s regret bound requires additional conditions, including an appropriate momentum schedule; it does not promise convergence of all practical variants or non-convex problems.

Why normalization changes the balance

Without adaptive normalization, the cumulative gradient of a block is positive when C>2C>2, so aggregate descent tends to move left if steps are comparable. With Adam, the denominator depends on history: after the large gradient, vtv_t is large but decays when small gradients arrive. Negative updates can have a higher effective rate. This explanation is intuition for the construction, not a rule for deducing behavior for arbitrary CC, β1\beta_1, and β2\beta_2.

AMSGrad’s running maximum remembers the largest second moment observed. With β1=0\beta_1=0, the example’s two negative updates are normalized by that maximum, and the block’s positive contribution can move the trajectory toward the minimum. The code applies the maximum to the uncorrected value and projects after each update. Another library may correct bias, add epsilon, or define the step differently; its curves need not coincide at the start. To verify an implementation, print moments and points for the first three steps before comparing long-term results.

The graph samples every 30 steps to keep the trajectory legible. This can hide oscillations within each block and signs of Γ\Gamma between displayed points. The cell stores values at specific horizons, and a simple modification can log every step if you want to examine alternation. Never infer that Γ\Gamma is always nonnegative merely because sparse samples show no negative values; for AMSGrad the property follows from monotonicity of the maximum and base step.

Locate the sign

A telescoping sum contains a weight proportional to the difference between consecutive inverse rates, multiplied by a squared distance. Bounding that term using an upper bound on distance requires handling its sign correctly. For g1=3g_1=3, g2=−1g_2=-1, v0=0v_0=0, and β2=0.1\beta_2=0.1, we obtain v1=8.1v_1=8.1 and v2=1.71v_2=1.71. With αt=0.2/t\alpha_t=0.2/\sqrt t, Γ2=(2v2−v1)/0.2<0\Gamma_2=(\sqrt{2v_2}-\sqrt{v_1})/0.2<0. Thus nonnegativity does not follow from the example’s conditions. A sign change alone does not identify which other lemma fails; Reddi examines both issues.

Regret uses RT=∑t=1Tft(xt)−min⁡x∈[−1,1]∑t=1Tft(x)R_T=\sum_{t=1}^T f_t(x_t)-\min_{x\in[-1,1]}\sum_{t=1}^T f_t(x). For linear losses with gradient sum STS_T, the minimum is −∣ST∣-|S_T|, so RT=∑tgtxt+∣ST∣R_T=\sum_t g_tx_t+|S_T|. The retrospectively chosen point is fixed for the whole horizon. On horizons not ending at a complete block, compute the comparator from the actual sum; do not assume without checking that it remains −1-1.

Lab: projected Adam and AMSGrad

The cell runs 30,000 steps using the same conventions as the example and records xt+1x_{t+1}, average regret, and Γt\Gamma_t. The running maximum is applied to vtv_t without bias correction. Finite values can be checked and modified: by default Adam has average regret about 0.6677 and AMSGrad 0.0135 at the end. For the latter, the decrease observed at this horizon is not an asymptotic proof. Consult the source for the theoretical guarantee under its assumptions.

[ ]Projected counterexampleBrowser
from math import sqrt
import numpy as np

def run(T=30000,C=3.,beta1=0.,beta2=.1,alpha=.2,ams=False):
    x=1.;m=v=vmax=0.;loss=0.;gsum=0.;history=[];prev=None
    for t in range(1,T+1):
        g=C if t%3==1 else -1.
        loss+=g*x;gsum+=g
        m=beta1*m+(1-beta1)*g;v=beta2*v+(1-beta2)*g*g
        vmax=max(vmax,v);used=vmax if ams else v
        inverse=sqrt(used)*sqrt(t)/alpha;gamma=None if prev is None else inverse-prev
        x=max(-1.,min(1.,x-alpha/sqrt(t)*m/sqrt(used)));prev=inverse
        if t in (3,300,3000,30000,T):history.append((t,x,(loss+abs(gsum))/t,gamma))
    return history
for mode in (False,True):print('AMSGrad' if mode else 'Adam',run(ams=mode))

Search for counterexamples carefully

Numerical verification compares an inequality, its assumptions, and a tolerance. A grid can discover extremes, random sampling explores broad regions, and adversarial optimization tries to maximize violation. None proves a universal inequality on a continuum. A point with positive excess, however, can refute it if inputs satisfy the assumptions and the excess exceeds numerical error.

The following searcher takes h(x)h(x) for the claim h(x)≤0h(x)\leq0. It combines a grid, seeded sampling, and differential evolution. On [−1,1][-1,1], h(x)=x2−1h(x)=x^2-1 has no positive excess; the proof is ∣x∣≤1⇒x2≤1|x|\leq1\Rightarrow x^2\leq1. On [−2,2][-2,2] the search finds excess 3 at an endpoint. This auxiliary bound shows how removing a condition changes the problem; it does not establish the necessity of each assumption of the AMSGrad theorem.

[ ]Search for inequality violationsBrowser
import numpy as np
from scipy.optimize import differential_evolution

def hunt(gap, bounds, grid_points=101, samples=1000, seed=31):
    """Busca exceso positivo de una desigualdad gap(x)<=0; no prueba ausencia."""
    if len(bounds)!=1: raise ValueError('esta versión admite una dimensión')
    lo,hi=bounds[0]
    if not lo<hi: raise ValueError('intervalo inválido')
    grid=np.linspace(lo,hi,grid_points);rng=np.random.default_rng(seed)
    random=rng.uniform(lo,hi,samples)
    candidates=np.concatenate((grid,random))
    values=np.array([float(gap(x)) for x in candidates])
    best=int(np.argmax(values))
    result=differential_evolution(lambda x:-float(gap(x[0])),bounds,seed=seed,polish=True)
    points=[(float(candidates[best]),float(values[best])),(float(result.x[0]),float(-result.fun))]
    return max(points,key=lambda pair:pair[1])

for bounds in [[(-1,1)],[(-2,2)]]:
    x,excess=hunt(lambda x:x*x-1,bounds)
    print('dominio',bounds,'peor x',round(x,4),'exceso',round(excess,4))

Design a search that can fail informatively

A uniform grid covers exactly its points, but need not detect a narrow violation between them. Random sampling adds diversity but can leave small regions unvisited; fix seed and distribution to repeat the result. Differential evolution explores the objective on a bounded region but can stop at a local maximum or nonfinite evaluation. Check the output, evaluate boundaries too, and keep the best point from all methods. If the domain is discrete or has nonrectangular constraints, adapt the generator and check that each candidate is admissible.

An excess function must have a clear convention: positive means violation, zero equality, and negative that the inequality holds at that point. Before trusting it, test it on an inequality with a known answer. When excess is small, evaluate the same candidate at greater precision or with an alternative algebraic form. A result of 10−1410^{-14} in double precision may reflect cancellation; an exact excess of 3 in the expanded-domain example does not depend on a delicate tolerance.

The included searcher is deliberately one-dimensional and accepts only an interval. It is a starting point for experimenting with parameters, not a formal verifier or universal optimizer. When extending it, add validation of shapes, constraints, and nonfinite values, and record the number of evaluations. Even an exhaustive search on a finite grid needs an additional argument, such as a Lipschitz bound, to control points between nodes.

From a numerical failure to a verifiable critique

Detecting a gap starts by checking types, units, indices, initialization, tolerances, and the statement version. First reproduce a simple case with an analytical answer; verify that your code uses the same normalization, projection, and update rule. In optimization, distinguishing xtx_t before an update from xt+1x_{t+1} avoids comparing a loss with the wrong point. Save the minimal case, inputs, and output with enough precision for another person to run it.

Then check that the case satisfies every assumption and that the discrepancy is not due to rounding, underflow, or a condition omitted in an appendix. A numerical test can suggest a false inequality, but a mathematical refutation must explain why the concrete point violates it exactly or in a controlled way. Look for corrections and later versions; state the critique respectfully, contact the authors when appropriate, and give the problem’s precise scope. Do not turn a local mistake into a judgment about intent or every result in the work.

An inequality may contain hidden constants, an asymptotic condition, or a failure probability. If the result says “with probability at least 0.95”, one realization outside the favorable event is not itself a contradiction. If the bound is asymptotic, a small case may fall outside the claimed range. If it is deterministic and holds for every T≥1T\geq1, one valid case with positive excess refutes that specific statement. First identify which claim you are checking.

Exercises

ProofA change of sign
Prove: With beta2 = 0.1, alpha_t = 0.2/sqrt(t), v0 = 0, and gradients 3 and -1, show that Gamma_2 is negative.
0
First update the two moments and compare their inverse rates.

Step 1 of 2. What are v1 and v2?

Numeric
For C = 3, what is the average gradient of a three-step block?
Code
Implement step(x,m,v,vmax,g,t,beta1,beta2,alpha,ams) for the scalar variant without bias correction: update moments, keep the running maximum, use vmax if ams and v otherwise, apply alpha/sqrt(t), and project onto [-1,1]. Return (new_x,new_m,new_v,new_vmax). Assume t >= 1 and new_v > 0. Also implement regret(T, ams): use initial x 1, C=3, beta1=0, beta2=0.1, alpha=0.2; calculate average regret against the horizon's best fixed point.
def step(x,m,v,vmax,g,t,beta1,beta2,alpha,ams):
  pass

def regret(T, ams):
  pass
Shift+Enter to run
Quiz
A proof of x² ≤ 1 uses only |x| ≤ 1, although the statement also assumes x is rational. What can be concluded from this proof?
Quiz
An implementation appears to violate a published bound. What do you do first?

Summary

Reconstruct symbols and dependencies before auditing assumptions. In Reddi’s example, Adam can exhibit nonzero average regret and a negative difference of inverse rates; AMSGrad keeps a maximum and corrects that property under the stated schedule. Finite experiments help find and understand errors, while universal claims require proof or a valid counterexample.