Visual paradoxes like the Penrose staircase present a fundamental tension: locally coherent geometric relationships that cannot be realized globally.
On the roof of M. C. Escher’s Ascending and Descending, monks walk a staircase on which every step goes up, yet one lap of the courtyard brings them back to where they started. Inspect any flight and it is an honest flight of stairs. So where is the mistake? Not on any step. It lives in the loop, in the courtyard the stairs go round — and finding mistakes of that kind, which are invisible everywhere you look and fatal as a whole, is what cohomology is for.
Part III was about places. A chain was an inventory of pieces of a shape — these edges, those triangles, each with a multiplicity — and homology asked which inventories go around holes. Now we turn the telescope around and measure the pieces instead: write a number on every vertex, or on every edge, the way a hiker writes elevations on a trail map or an engineer writes voltages on a circuit diagram. Then we ask one innocent question: when do numbers on the edges come from numbers on the vertices? The answer, “exactly when every loop adds up to zero”, sounds like accounting. It unmasks the staircase, explains why a ring of gears can jam and finds free money on the currency markets. And it leads straight back to the holes: homology counted them, and cohomology tells you what each one forbids.
Places and measurements
Here is a trail map of a small mountain. The dots are junctions, the lines are trails. In the language of §2.5 Simplicial Complexes this is a simplicial complex of dimension one — a graph. Next to each junction is its elevation above sea level, in metres.
A hiker does not really care about elevations; she cares about climbs. How much does the trail from the Spring to the Ridge go up? That is the elevation at the Ridge minus the elevation at the Spring: metres. So the elevations on the junctions automatically produce a number on every trail. Play with this in the figure: drag a junction up or down and watch the numbers on the trails next to it change.
Let us write this down carefully, because every symbol in it will stay with us for the rest of the book.
The arrow on each edge matters. Walk the trail from the Spring to the Ridge and you climb metres; walk it the other way and you “climb” metres. A number on an edge only makes sense once we have agreed which way the edge points. In this book every edge of a simplicial complex points from its lower-numbered vertex to its higher-numbered one (the convention of §3.2 Chains and the Boundary Operator), and in the figures the arrows are drawn. Tap a trail in Figure 4.1.1 to flip its arrow: the number on it changes sign, and nothing else changes. This is the same orientation bookkeeping that gave chains their signs.
A second model: voltages
Exactly the same arithmetic describes an electrical circuit. The vertices are the connection points, is the voltage (the electric potential) at and is the voltage across the component sitting on the edge — the thing a voltmeter clipped to its two ends would read. John Baez puts it in the language we are building: “It’s good to think of as a 1-cochain, which assigns to each edge the voltage across that edge” (Baez 2010). The word cochain is coming in a moment; for now, read it as “a number on every edge”.
Walking a path: the climbs telescope
Suppose you walk from the Trailhead to the Summit by way of the Spring and the Ridge. Adding up the climbs along the way gives
Every intermediate height appears once with a plus sign and once with a minus sign, and cancels. Only the two ends survive. A sum that collapses like this is called telescoping, after the old folding telescope whose segments slide inside each other. In general, if a walk visits the vertices in order, then
(If the walk uses an edge against its arrow, the climb counts with a minus sign, which is exactly what the formula needs.) This is the discrete fundamental theorem of calculus: adding up the changes along a route gives the total change, and the total change depends only on where you start and where you finish — not on the route. The other route in the figure, Trailhead → Meadow → Lake → Hut → Summit, gives as well.
And here is the consequence that will drive the whole chapter. If the walk is a closed loop, so that it ends where it began, then and the total is The climbs around any closed loop add up to zero: you cannot walk in a circle and end up higher than you started. In circuit language this is Kirchhoff’s voltage law: the voltages around any closed loop of a circuit sum to zero.
The gradient puzzle
Now run the story backwards. A hiker has kept a notebook: for every trail she walked, she wrote down how much it climbed. She never wrote down a single elevation. Can we reconstruct the elevations from her notebook?
In symbols: we are handed a number on every edge (the letter is psi), and we ask whether there is a potential with If there is, we call a gradient. Sometimes the answer is yes and sometimes no, and the difference between the two is the first glimpse of cohomology. Try it yourself before reading on.
Every step is +1, so the loop sum is 4: an impossible staircase.
On a tree, it always works
If the graph is a tree — connected, with no loops at all — the puzzle always has a solution, and here is a recipe. Pick any vertex (the root) and give it height Every other vertex is joined to by exactly one path, because a tree has no loops to provide a second route. Walk that path and add up the numbers on its edges (with a minus sign for edges walked against their arrows); call the result Then every edge is satisfied: if an edge goes from to the path to is the path to followed by that edge, so This recipe, like much of this chapter, comes from the four pages Allen Hatcher calls “The Idea of Cohomology” (Hatcher 2002, pp. 186–189). There the root is a base vertex and each value is fixed “by induction along the unique path from to in the tree.” (Hatcher writes for the potential where we write
On a loop, the numbers must add up to zero
The square puzzle “A loop that does not” in Figure 4.1.2 has on each of its four edges, all pointing the same way around. Say the bottom-left vertex has height Following the arrows, the next vertex must be at the next at the next at — and the last edge leads back to the start, which would then have to be at But it is at Since there is no solution, whatever you choose.
The culprit is the loop. We showed in the last section that any gradient sums to around every loop; here the sum is So a non-zero loop sum is a certificate of impossibility: one number that proves no potential can exist. The surprise is that the converse holds too: if every loop sums to zero, a potential exists.
How many loops must we check?
A graph can have a great many loops, but we do not have to test them all. Recall from §3.1 Cycles and Boundaries how a spanning tree organises the loops of a graph: the edges outside the tree are the troublemakers, and each one closes exactly one fundamental loop with the tree. Every loop of the graph is a combination of fundamental loops, and loop sums add up the same way, so it is enough to check the fundamental ones. That is exactly what “Integrate” does in Figure 4.1.2: it builds heights along a spanning tree (the tree edges are automatically satisfied) and then tests each leftover edge. The mismatch on a leftover edge, is precisely the sum of around that edge’s fundamental loop.
For a graph with vertices, edges and connected pieces, a spanning forest has edges, so the number of leftover edges — the number of independent checks — is
You have seen this number before: it is the first Betti number of the graph, the number of independent holes, from §3.1 Cycles and Boundaries. The trail map of Figure 4.1.1 has of them, which is why “Next loop” cycles through three loops.
What never changes:
When the puzzle has a solution, how many solutions are there? If and then subtracting, So the question is really: which potentials have — no climb on any edge at all?
means across every edge, so neighbours have equal heights. Walking along edges, the height never changes, so is constant on each connected piece of the graph. But different pieces are free to sit at different heights: nothing connects them, so nothing forces them to agree. Such a function is called locally constant.
The space of locally constant functions has one dimension for each connected piece: choose one height per island. It is the first of the cohomology groups, and it gets the name
and its dimension is the number of connected pieces:
So the solutions of the gradient puzzle, when they exist, are unique up to adding a locally constant function — exactly like the “ you add to an antiderivative in calculus, one constant per island. Hatcher makes the same comparison: solving is “rather like the calculus problem of finding a function having a specified derivative, with the difference operator playing the role of differentiation.”
Local tests, global obstructions
So far our shapes have been graphs. Now fill in some triangles. Picture the trail map again, but where three trails enclose a small meadow you can walk straight across, we fill the triangle in: it is now a 2-dimensional simplex of our complex. What does a filled triangle say about measurements on the edges?
If the edge numbers come from heights, then walking once around the triangle must return you to your starting height. For a triangle with vertices and edges pointing and walking uses the last edge against its arrow, so the test reads
The left-hand side is called the circulation of around the triangle — or, borrowing a word from vector calculus, its curl. For a gradient the curl of every filled triangle is every term cancels. That is the discrete version of a fact you may remember from calculus, “the curl of a gradient is zero”.
The curl test is local: it looks at only three edges at a time. That makes it cheap, and it is a genuine necessary condition. The question is whether it is also sufficient: if a labelling passes the curl test on every filled triangle, must it be a gradient?
When there are no holes, local is enough
Suppose the complex is a filled-in disk, triangulated. Take any loop in it. As we saw in §3.1 Cycles and Boundaries, a loop in a disk is a boundary: it is the boundary of the union of the triangles it encloses. Add up the curls of all those triangles. Every edge inside the region is shared by two of them and is walked once in each direction, so it cancels; only the edges on the loop survive. So the loop sum equals the sum of the curls inside it. If every curl is every loop sum is and by the gradient test is a gradient. In a region without holes, passing every local test is the same as being a gradient.
When there is a hole, it is not
Now make a hole. The complex in the next figure is a triangulated annulus — a ring — with an inner triangle an outer triangle and six filled triangles between them. The labelling has a on the three edges and and everywhere else: a little “fence” of ones running from the hole out to the edge.
Check the triangle by hand: its edges carry and and walking around it gives The triangle gives and the other four triangles see only zeros. Every local test passes. But walk around the hole along the inner triangle: So is not a gradient. The loop around the hole is a cycle that is not a boundary — the very definition of a hole in §3.1 Cycles and Boundaries — and that is why no collection of triangle tests can reach it.
Hatcher describes this situation with two phrases worth memorising (Hatcher 2002, p. 188). The curl of — in his notation which we will justify shortly — is a local obstruction:
We can think of as a local obstruction to solving since it depends only on the values of within individual 2 simplices of … This class in is thus the global obstruction to solving
The “class in is what is left of once we stop caring about bumps. Adding a bump at a vertex — that is, adding the gradient of a function that is at that vertex and elsewhere — changes the edge numbers but cannot change any loop sum, because the loop sum of a gradient is For the annulus, the only thing that survives is a single number, the loop sum around the hole.
Impossible staircases and other paradoxes
The pattern we have found — data that is perfectly consistent everywhere you look closely, yet impossible as a whole — turns up all over the place once you know its shape. Here are four instances: one from art, one from geometry, one from engineering and one from finance.
The staircase that climbs forever
The Penrose staircase is a flight of stairs that goes around the four sides of a square courtyard, climbing at every step, and arrives back where it started. Look at any short stretch and it is an ordinary staircase; look at the whole and it is impossible. The geneticist Lionel Penrose and his son, the mathematician Roger Penrose, published it in 1958 in a short note on “impossible objects” (Penrose & Penrose 1958), and two years later M. C. Escher put it on the roof of Ascending and Descending, the lithograph this chapter opened with.
In our language the staircase is an edge labelling. Make a graph with one vertex per step and one edge from each step to the next; the edges form a single loop. “Each step goes up by one” labels every edge If the staircase could exist, there would be a height function on the steps with these differences — but the loop sum is the number of steps, not so by the gradient test no height function exists. The staircase is the “loop that does not close” from Figure 4.1.2, drawn by an artist.
The real object in Figure 4.1.6 does have a height function: step sits at height Its differences are on every edge except the one that closes the loop, where it drops by — the cliff, hidden behind the camera angle. Compare that with the impossible labelling that is everywhere: the two differ only on the cliff edge, by exactly the loop sum. You may put the cliff wherever you like (that is adding a bump, changing but you cannot get rid of it, because the loop sum does not change. The cliff is the obstruction, made of stone — or of plywood: between 1955 and 1959 the Penroses built small models of exactly this kind, meant to be photographed from the one angle at which they look impossible, and London’s Science Museum keeps them (Penrose & Penrose 1955–59).
The tribar
The Penrose triangle, or tribar, is three square beams joined at right angles into a triangle. Each corner is a perfectly good right-angled joint; the three together are impossible. (The Swedish artist Oscar Reutersvärd had drawn an impossible triangle made of cubes as early as 1934; Lionel and Roger Penrose published theirs in 1958.) Decades later Roger Penrose wrote a short paper, On the cohomology of impossible figures, explaining the tribar in exactly our terms (Penrose 1992). Cut the drawing into three overlapping pieces, each of which can be built. A drawing fixes each piece only up to its distance from your eye, so on each overlap the two pieces must be rescaled to match, by some positive factor. The figure can be built exactly when these factors come from one scale per piece — when they are “differences” — and that happens exactly when their product around the triangle is For the tribar it is not. This is our gradient test again, with one change: the numbers on the edges are multiplied around the loop instead of added, because scale factors combine by multiplication. We will meet Penrose’s argument properly in §4.7 Sheaves and Čech Cohomology.
A ring of gears
Arrange identical gears in a ring, each meshing with its two neighbours. When two gears mesh, they turn in opposite directions. Lewis Ghrist and Robert Ghrist describe what happens: “If is even, alternating spins around the loop satisfies all opposition constraints, and the system spins freely. If is odd, no such alternation exists – the final gear must simultaneously agree and oppose its neighbor. The system locks: a mechanical paradox that we will identify as a nontrivial class” (Ghrist & Ghrist 2026, §2.2).
Let us identify it. Record the spin of each gear as an element of — the integers mod 2, also written — with for clockwise and for anticlockwise. Each mesh says “the spins differ”, which in reads So the meshes put the label on every edge of the ring, and the gears can turn exactly when this labelling is a gradient: when it comes from spins on the gears. Around the ring the labels add up to and in that is exactly when is even.
Nothing in the gradient test used the fact that our numbers were real numbers; all we needed was to be able to add and subtract. So measurements may take values in any abelian group: heights in counts in spins in scale factors in the positive real numbers under multiplication. The choice is called the coefficients, and changing it changes what the obstruction can see. Over a loop of length is impossible only when is odd.
Free money
Our last example is about currencies. Suppose dollars, euros, pounds and yen trade only around a square: dollars for euros, euros for pounds, pounds for yen, yen for dollars. Each edge carries an exchange rate meaning one unit of the first currency buys units of the second. Start with \$1000 and go once around. If you come back with more than \$1000, you have found an arbitrage: free money, from nothing but the rates.
Rates multiply around a loop, but logarithms turn multiplication into addition ( so label each edge with instead. A market is fair if every currency has a “value” (in some common unit) and every rate is the ratio of values, Taking logarithms, the log-rates are exactly the differences of the potential So fair market = gradient, and the gradient test says: a market is fair if and only if no loop of trades makes money. In Figure 4.1.8 the log loop sum is zero only at the fair rate
A trader who checks every three-currency triangle is running the local curl test. If all six pairs of currencies trade, every triangle is filled, every loop of trades is a boundary, and the local test is enough: no triangular arbitrage means no arbitrage at all (the last exercise of this chapter asks you to prove it). But in our square market there are no triangles to check, so a perfectly real arbitrage hides from every local inspection. Arbitrage can only hide in the holes.
The coboundary operator
It is time to give our objects their proper names. Nothing new will happen mathematically; we only need to notice that the two operations of this chapter — “differences of heights” and “circulation around a triangle” — are one operation, and that it is the mirror image of the boundary operator of Part III.
Now look again at our two operations, side by side with the boundary formulas of §3.2 Chains and the Boundary Operator:
In both cases the new cochain is computed by evaluating the old cochain on the boundary. That is the definition in every degree.
The discrete Stokes theorem
Since for each simplex, adding up over a chain gives the same identity for every chain
In words: measuring the change of over a region is the same as measuring on the region’s edge. In degree this is telescoping: because the boundary of a path is its end minus its start. In degree it is the argument we used for the disk: the sum of the curls over a region equals the loop sum around its boundary. In calculus the same statement is Stokes’ theorem, and there it takes real work. Here it costs nothing, because we defined the coboundary to make it true.
The coboundary of a coboundary is zero
We saw that the curl of a gradient vanishes. Here is the one-line reason, valid in every degree:
using the fundamental fact from §3.2 Chains and the Boundary Operator. So “the curl of a gradient is zero” is the shadow, in the world of measurements, of “the boundary of a boundary is zero” in the world of places.
A matrix picture: is a transpose
Take the hollow triangle with vertices and edges The boundary matrix from §3.2 Chains and the Boundary Operator has a row for each vertex and a column for each edge, and the column of an edge lists its boundary. The coboundary has a row for each edge and a column for each vertex, and the row of an edge lists how on that edge depends on the heights:
The second matrix is the first one flipped across its diagonal — its transpose, from §1.5 Linear Algebra. That is not a coincidence of this example: the entry of in row column is the coefficient of in and the entry of in row column is the change in on when is at and elsewhere — which is the same coefficient. In every degree, Keenan Crane, comparing the two theories in his notes on discrete geometry, sums it up: “the only difference is a matrix transpose!” (Crane 2025, p. 138) We will make full use of this in §4.2 Cohomology Groups.
The new vocabulary
Everything we have discovered now has a name, built by putting “co-” in front of a word from homology. (The prefix means “dual”; the names are due to Hassler Whitney in the late 1930s, as we will see in the next chapter (Whitney 1938).)
| Homology: places | Cohomology: measurements | In this chapter |
|---|---|---|
| chain | cochain | heights, edge labellings |
| boundary operator (lowers degree) | coboundary operator (raises degree) | gradient, curl |
| cycle: | cocycle: | passes every local test |
| boundary: | coboundary: | comes from a potential |
| curl of a gradient is zero | ||
| = cycles / boundaries | = cocycles / coboundaries | the global obstructions |
The last row is a preview. In the language of §1.4 Abelian Groups and Formal Sums, the cocycles form a group, the coboundaries form a subgroup inside it, and the cohomology group is the quotient: cocycles, with two of them counted as the same when they differ by a coboundary. That is exactly the move we made when we decided that “adding a bump” should not count as a change. For the annulus, the cocycles modulo coboundaries form a single copy of (or with whole-number labels), and the number that identifies a class is its loop sum around the hole. Lek-Heng Lim calls the general recipe — two matrices and with and the quotient — “cohomology on a bumper sticker” (Lim 2020, §2.1). The precise definitions, and many computations, are the subject of §4.2 Cohomology Groups.
Gradient, curl and harmonic: the Hodge decomposition
Real data is never exactly a gradient. Suppose sports teams play each other and each match produces a number on an edge — how many points the winner won by. If there were a “true strength” for each team, the margins would be differences of strengths, a gradient. In practice the data is noisy and inconsistent: A beats B, B beats C, and C beats A. What is the best we can do?
The answer sounds too good to be true. Every edge labelling (call it a flow when you think of the numbers as amounts flowing along the arrows) splits in exactly one way into three pieces,
and the three pieces are perpendicular to each other, in the sense that for any two of them. This is the discrete Hodge decomposition, named after W. V. D. Hodge, who developed its smooth version, for differential forms, in the 1930s.
Look at the example in Figure 4.1.10, the flow on the edges
- The gradient part comes from the heights on vertices It is the gradient closest to — the one that minimises the total squared error, the “least squares” fit. Read as a ranking, it says Finding means solving one equation per vertex. The matrix is the graph Laplacian: each vertex’s number of edges on the diagonal, and in row column whenever an edge joins and Here and the heights above solve the equations.
- The curl part is one unit of swirl around the filled triangle: along and and along so it goes once around It lives entirely on triangles that are filled, and it is what the local curl test detects.
- The harmonic part is what is left. It passes every local test (its curl on the filled triangle is and it is balanced: at every vertex, what flows in equals what flows out. Yet its sum around the hole is It is the global obstruction, standing on its own.
Check the energies: while the parts have and and Because the pieces are perpendicular, their squared lengths add, just as for the sides of a right-angled triangle.
This is not a toy. In a 2011 paper Xiaoye Jiang, Lek-Heng Lim, Yuan Yao and Yinyu Ye proposed HodgeRank, which ranks items from pairwise comparisons — teams from match results, films from viewers’ preferences — in exactly this way: the gradient part is the ranking, the curl part records local three-way inconsistencies, and the harmonic part records inconsistencies that are, in their words, “locally acyclic but globally cyclic” (Jiang et al. 2011). Those are the ones no amount of local checking will find.
Exercises
Summary
Further reading
- The model for this chapter: trails on a mountain, voltages in a circuit, fences on surfaces, and the local and global obstructions, in four pages. The rest of the chapter is graduate level.
- Cohomology and Hodge theory with nothing but matrices and graphs. Section 2, “Cohomology and Hodge theory for pedestrians”, opens with “cohomology on a bumper sticker” and is the best next read after this chapter; the rest is advanced undergraduate.
- Discrete differential forms as “integrated” measurements on meshes, the discrete exterior derivative, and a chapter (8) on Hodge decomposition of vector fields on surfaces. Undergraduate level, written for graphics programmers, with many pictures.
- Statistical ranking and combinatorial Hodge theory — Xiaoye Jiang, Lek-Heng Lim, Yuan Yao, Yinyu Ye (Math. Programming 127, 2011) freeHodgeRank: turning pairwise comparisons into a ranking (the gradient part) plus local and global inconsistencies (curl and harmonic parts). Sections 1–2 are readable after this chapter; the statistics comes later.
- A gallery of impossible staircases on cylinders, Möbius bands, tori and Klein bottles, analysed with exactly the ideas of this chapter.
- Impossible by Degrees: Cohomology & Bistable Visual Paradox — Lewis Ghrist & Robert Ghrist (2026) freeGears, Necker cubes and rhombic tilings with ℤ/2 coefficients, from H⁰ up to H², with a companion YouTube playlist of animations linked in the introduction. The source of our gear ring.
- On the cohomology of impossible figures — Roger Penrose (Leonardo 25, 1992; first published in Structural Topology)Penrose’s own three-page essay explaining the tribar as a cohomology class with coefficients in the positive reals. For a gentle walk-through, read Phillips’s column below first.
- A friendly, illustrated explanation of Penrose’s argument with depth ratios on overlapping pieces.
- Electrical circuits through the eyes of homology: currents as chains, voltages as cochains, power as their pairing.