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, is the uncorrected exponential second moment, while in AMSGrad is the running maximum of . 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.
| Symbol | Type and meaning |
|---|---|
| Scalar point in before observing loss . | |
| Gradient ; in the example it is or . | |
| Exponential averages of gradient and squared gradient, initialized to zero. | |
| Base step ; the effective rate also depends on . | |
| For AMSGrad, maximum of . | |
| Change in inverse rate: . | |
| Sum of the algorithm’s losses minus that of the best fixed point in hindsight. |
In multiple dimensions and 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, is chosen before evaluating ; a gradient is then observed and is produced. If you update first and then evaluate , 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 , 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 and problems in lemmas 10.3 and 10.4. The diagram summarizes these dependencies; it does not reproduce every inequality.
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.
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 and ” 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 and , a sum such as rearranges into boundary terms and differences . A uniform bound 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 if and on the other two, with . In a complete block the cumulative loss of a fixed point is ; the best in is and the worst is . 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 , , , and with . This presentation does not correct bias. For , and satisfy those conditions. The proof establishes that block-start iterates return to 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.
AMSGrad maintains and uses that maximum in the denominator. With nonincreasing , does not decrease and 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 , so aggregate descent tends to move left if steps are comparable. With Adam, the denominator depends on history: after the large gradient, 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 , , and .
AMSGrad’s running maximum remembers the largest second moment observed. With , 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 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 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 , , , and , we obtain and . With , . 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 . For linear losses with gradient sum , the minimum is , so . 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 .
Lab: projected Adam and AMSGrad
The cell runs 30,000 steps using the same conventions as the example and records , average regret, and . The running maximum is applied to 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.
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 for the claim . It combines a grid, seeded sampling, and differential evolution. On , has no positive excess; the proof is . On 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.
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 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 before an update from 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 , one valid case with positive excess refutes that specific statement. First identify which claim you are checking.
Exercises
Step 1 of 2. What are v1 and v2?
def step(x,m,v,vmax,g,t,beta1,beta2,alpha,ams):
pass
def regret(T, ams):
passSummary
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.