← First Pair Library

Counting Arnold's Meanders with Verified Algorithms

Alexy Khrabrov

2026-10-08

Abstract

In 1988 V. I. Arnold asked in how many ways a river can cross a straight road nn times. No closed formula for these meander numbers is known, and the values are known only by computer enumeration. We formalize the problem in the Lean 4 proof assistant and give two counting algorithms that are proved, for every nn, to return exactly the number defined by the specification. The first is a depth-first search over crossing orders with a pruning rule based on a parity argument. The second is a transfer matrix that scans the road from west to east, tracks how the open strands of the river connect, merges equal states, and discards states that can no longer be completed. Its correctness proof is a bijection between the action sequences it accepts and meanders, established through a decorated version of the machine that carries the actual pieces of river. Along the way we prove that closed meanders of order nn are equinumerous with open meanders with 2n−12n-1 crossings, and that there are at most Cn2C_n^2 closed meanders, where CnC_n is the nn-th Catalan number. The verified transfer matrix computes the meander numbers up to n=30n=30 in about half a minute; values up to n=13n=13 are checked by the Lean kernel alone. Unverified parallel implementations of the same machine in Rust and OxCaml, with each state packed into one machine word, reproduce the published values up to n=50n = 50, and companion notebooks implement the algorithms in Lean, Python and OCaml. The development is about 5,000 lines of Lean and is available at https://github.com/querygraph/meander.

1. Introduction

A meander is a non-self-intersecting curve in the plane that crosses a fixed straight line a prescribed number of times. In a short note on the topology of real algebraic curves, Arnold [2] posed the enumeration question in its most vivid form: in how many ways can a river cross a straight road nn times? Two rivers are considered the same if one can be deformed into the other without changing the order of the crossings along the road and along the river. The resulting numbers, 1,1,1,2,3,8,14,42,81,262,538,1828,3926,13820,…1,\ 1,\ 1,\ 2,\ 3,\ 8,\ 14,\ 42,\ 81,\ 262,\ 538,\ 1828,\ 3926,\ 13820,\ \dots form sequence A005316 of the OEIS [11]. The closely related count of closed curves crossing the line 2n2n times is A005315 [12]. Meanders appeared earlier in work on folding a strip of stamps [14], were studied systematically by Lando and Zvonkin [8], and became a test bed for exact enumeration and statistical physics [4, 5, 6].

Despite this attention there is no closed formula. Di Francesco, Golinelli and Guitter conjectured from a conformal field theory argument that the number of closed meanders of order nn grows like CR2nn−αC\,R^{2n} n^{-\alpha} with R2≈12.26R^2 \approx 12.26 and α=(29+145)/12\alpha = (29+\sqrt{145})/12 [5]. Rigorous bounds on the growth rate are far apart: Albert and Paterson proved that the exponential growth constant R2R^2 lies between about 11.3811.38 and 12.9012.90 [1]. Every known value of the sequence comes from a computer program, and the best of these are intricate transfer-matrix codes [6].

This paper asks a narrower question: can we compute meander numbers with programs whose correctness is machine-checked against the plain definition? We answer it in the Lean 4 proof assistant [9] with the mathlib library [10]. Our contributions are:

  1. A formal specification of open meanders as permutations of the bridges satisfying a non-crossing condition, and of closed meanders (Section 2).

  2. Structural theorems: open meanders exist for every nn; there are at most n!n!; closed meanders of order nn correspond bijectively to open meanders with 2n−12n-1 crossings; and there are at most Cn2C_n^2 closed meanders (Section 3).

  3. A depth-first search with a pruning rule derived from a parity argument, proved equal to the specification (Section 4).

  4. A transfer matrix with state merging and a capacity-based pruning rule, proved equal to the specification by a bijection between accepted action sequences and meanders (Section 5).

  5. Certified values: kernel-checked for n≤13n \le 13, and computed by the verified transfer matrix up to n=32n = 32, matching the OEIS (Section 6).

  6. Parallel implementations of the same machine in Rust and OxCaml, unverified but checked against the certified values and the OEIS, which reach n=50n = 50; teaching implementations in Python and OCaml; and a comparison of all of them (Section 6.1).

We do not claim new values of the sequence; larger values are known [6]. What is new is that the values we report come from programs proved correct for all nn, and that the proofs expose the combinatorial facts that make the fast algorithms work.

2. The specification

2.1. From a picture to a permutation

Label the bridges 0,1,…,n−10,1,\dots,n-1 from west to east. Following Arnold, the river enters from the south and leaves to the east. Between consecutive crossings it runs along an arc in one of the two half-planes, alternately: the first arc, from the south, lies below the road, the next above, and so on. A river is therefore determined up to deformation by its crossing order, the permutation τ\tau with τ(i)\tau(i) the bridge crossed ii-th.

Not every permutation is realized. To state the condition, compactify each half-plane to a disk whose boundary consists of the road and one point at infinity, and record the two ends of the river as two boundary points east of every bridge: the east end E=nE = n and the south end S=n+1S = n+1. (Going around the lower disk counterclockwise, one meets the bridges, then east, then south.) The river’s path is the sequence of boundary points P0=S,P1=τ(0),…,Pn=τ(n−1),Pn+1=E,P_0 = S,\quad P_1 = \tau(0),\ \dots,\ P_n = \tau(n-1),\quad P_{n+1} = E, and arc kk joins PkP_k and Pk+1P_{k+1} in the lower half-plane if kk is even and the upper one if kk is odd. By the Jordan curve theorem the river is simple exactly when no two arcs on the same side cross, and two chords of a disk cross exactly when their endpoints alternate around the boundary. Because all endpoints are now points of a line, alternation is an elementary condition.

Definition 2.1. Chords {a,b}\{a,b\} and {c,d}\{c,d\} interleave if exactly one of c,dc,d lies strictly between min⁡(a,b)\min(a,b) and max⁡(a,b)\max(a,b). A point sequence PP has no crossing among its first LL arcs if for all j<k<Lj<k<L with j≡k(mod⁡2)j \equiv k \pmod 2, the arcs {Pj,Pj+1}\{P_j,P_{j+1}\} and {Pk,Pk+1}\{P_k,P_{k+1}\} do not interleave. A permutation τ\tau of {0,…,n−1}\{0,\dots,n-1\} is an open meander if its path has no crossing among its n+1n+1 arcs. We write Mn\mathrm{M}_n for the number of open meanders.

Figure 1 gives the specification in Lean. Figure 2 shows the three open meanders with four crossings, and Figure 3 shows all eight with five.

def Interleave (a b c d : Nat) : Prop :=
  ¬ ((min a b < c ∧ c < max a b) ↔ (min a b < d ∧ d < max a b))

def NoCross (P : Nat → Nat) (L : Nat) : Prop :=
  ∀ k < L, ∀ j < k, j % 2 = k % 2 →
    ¬ Interleave (P j) (P (j + 1)) (P k) (P (k + 1))

def IsMeander {n : ℕ} (σ : Equiv.Perm (Fin n)) : Prop :=
  NoCross (pathPt σ) (n + 1)

def openMeanderCount (n : ℕ) : ℕ :=
  Fintype.card {σ : Equiv.Perm (Fin n) // IsMeander σ}
Figure 1. The specification in Lean 4. pathPt σ is the point sequence P of the river with crossing order σ.

image image image

Figure 2. The three open meanders with n = 4 crossings. The river enters from the south and leaves to the east; bridges are numbered 0 to 3 from west to east. Their crossing orders are 0123, 0321 and 2103.

2.2. Closed meanders

A closed meander of order nn is a simple closed curve crossing the road 2n2n times. To count each curve once we fix where it starts and in which direction it runs: it starts at the westmost bridge and leaves it into the upper half-plane. It is then a permutation σ\sigma of {0,…,2n−1}\{0,\dots,2n-1\} with σ(0)=0\sigma(0)=0 whose cyclic path has no crossing among its 2n2n arcs. We write M¯n\overline{\mathrm{M}}_n for their number.

image image
01234 01432
image image
03214 21034
image image
23410 41230
image image
43012 43210
Figure 3. All eight open meanders with n = 5 crossings, each labelled with its crossing order (the bridges crossed, in river order, numbered from west to east). The river enters from the south; since n is odd, its last arc lies above the road and it leaves to the east above every other upper arc.

3. Structural results

Theorem 3.1. For every nn, 0<Mn≤n!0 < \mathrm{M}_n \le n!.

Proof sketch. The upper bound is the cardinality of a subtype of the permutations. For the lower bound, the identity permutation is a meander: all its arcs except the first join neighbouring bridges, so nothing lies strictly between their ends, and the first arc, from S=n+1S=n+1 to bridge 00, encloses every other lower arc. ◻

Theorem 3.2. For every n≥1n \ge 1, M¯n=M2n−1\overline{\mathrm{M}}_n = \mathrm{M}_{2n-1}.

Proof sketch. Delete the westmost bridge of a closed meander and rotate the picture by 180∘180^\circ. The two arcs at the deleted bridge now run off to infinity: one in the lower half-plane, from which the river enters, and one to the east, where it leaves. The result is an open meander with 2n−12n-1 crossings, and the construction can be reversed. In coordinates the map sends an open crossing order τ\tau on 2n−12n-1 bridges to the closed order 0,2n−1−τ(0),2n−1−τ(1),…0,\,2n-1-\tau(0),\,2n-1-\tau(1),\dots, which in Lean is 𝚍𝚎𝚌𝚘𝚖𝚙𝚘𝚜𝚎𝙵𝚒𝚗.𝚜𝚢𝚖𝚖(0,τ⋅𝚛𝚎𝚟𝙿𝚎𝚛𝚖)\texttt{decomposeFin.symm}\,(0, \tau \cdot \texttt{revPerm}). Reflection x↦2n−1−xx \mapsto 2n-1-x reverses the order on the bridges, so it preserves interleaving. The only subtlety is the south end 2n2n, which truncated subtraction sends to the new bridge 00; it is an endpoint of a single lower arc, and every other lower arc has both endpoints among the bridges, so interleaving is unaffected. All of this reduces to omega once the values of the path are pinned down. ◻

Theorem 3.3. For every nn, M¯n≤Cn2\overline{\mathrm{M}}_n \le C_n^2, where Cn=1n+1(2nn)C_n = \frac{1}{n+1}\binom{2n}{n}.

Proof sketch. By Theorem 3.2 it suffices to inject open meanders with 2n+12n+1 crossings into pairs of Dyck words of semilength n+1n+1; mathlib already proves that there are Cn+1C_{n+1} such words. Treat the two ends of the river as extra points east of every bridge. Each half-plane then carries a non-crossing perfect matching of 2n+22n+2 points, and the river is recovered by walking from the south end and taking, at each point, the partner on the side where the river currently is. A non-crossing matching is determined by its pattern, the word recording whether each point opens (UU) or closes (DD) its arc. To see this, let si=±1s_i = \pm 1 according to the pattern and let B(x,z)=∑x<i<zsiB(x,z) = \sum_{x<i<z} s_i. For an opener xx with partner yy, every arc starting strictly inside (x,y)(x,y) also ends inside it, so B(x,y)=0B(x,y) = 0 and B(x,z)≥0B(x,z) \ge 0 for x<z≤yx < z \le y. These two facts locate yy from the pattern alone: if a second matching with the same pattern paired xx with y′>yy' > y, then B(x,y+1)=−1<0B(x,y+1) = -1 < 0, a contradiction. Closers are handled symmetrically. The pattern is a Dyck word because every closer in a prefix is matched to an opener in the same prefix. ◻

4. A verified search with parity pruning

The specification counts permutations, so evaluating it directly costs n!n! steps. The first algorithm builds the crossing order one bridge at a time. It abandons a branch as soon as the newest arc crosses an earlier arc on the same side, or as soon as the following test fails.

Lemma 4.1 (Parity). Let qq be a prefix of a meander, with t=|q|t = |q| arcs already drawn, and let j<tj < t be one of them, on side s=jmod⁡2s = j \bmod 2, with ends a<ba<b. Count the arc ends still to come on side ss that lie strictly between aa and bb: every unused bridge in (a,b)(a,b); the current point, if the next arc is on side ss; and the east end, if the last arc is on side ss. This number is even.

Proof. Each later arc on side ss has both ends inside (a,b)(a,b) or neither, since it may not cross arc jj. Each point listed is the end of exactly one later arc on side ss, and no other point is. Formally, an induction along the remainder of the river shows that the running count of such ends inside (a,b)(a,b) changes by 00 or 22 with each later arc on side ss. ◻

The correctness theorem openMeanderCount_eq_meanderCount has two parts. First, the search equals the number of complete orderings, generated by the same recursion, that satisfy the specification; this holds because a pruned branch contains no meanders (for crossings, by monotonicity of NoCross; for parity, by Lemma 4.1). Second, permutations of Finn\mathrm{Fin}\,n correspond bijectively to members of that list of orderings.

Measured in a prototype, parity pruning reduces the number of search nodes at n=11n=11 from 322,080322{,}080 to 14,47114{,}471. A further rule, that every remaining bridge be reachable from the current point through the regions cut out by the drawn arcs, reduces this to 9,8359{,}835. For n≤10n \le 10 the reduced search visits exactly the prefixes of actual meanders, so no further pruning rule of this kind can help (Table 1). In the compiled search the reachability test cost more than it saved, so we did not adopt it; the transfer matrix of the next section enforces connectivity by construction.

Table 1. Nodes visited by the depth-first search under successive pruning rules, and the number of prefixes that can actually be completed (a lower bound for any search that builds the river bridge by bridge).
nn Mn\mathrm{M}_n crossing test ++ parity ++ reachability completable prefixes
8 81 6,077 522 404 404
9 262 22,452 1,746 1,336 1,336
10 538 84,419 4,115 2,854 2,854
11 1,828 322,080 14,471 9,835 —

5. A verified transfer matrix

5.1. The machine

Scan the points of the road from west to east: the bridges, then EE (one arc, on side nmod⁡2n \bmod 2), then SS (one arc, below). Each point opens or closes its arc on each of its sides. Arcs on one side never cross, so the arcs still open at a cut form a stack on each side, and a closing point always closes the top of its stack.

To the west of the cut the river is broken into pieces. Each piece joins two open arcs, or an open arc and the east end. The state records, for every open arc in stack order, a reference to where its piece leads:

inductive Ref where
  | E                         -- the east end
  | s (σ : Bool) (i : Nat)    -- position i in the stack of side σ

structure St where
  up : List Ref
  dn : List Ref

There are four transitions at a bridge. Opening both sides creates a new piece whose two ends are the two new arcs. Opening one side and closing the other continues the closed arc’s piece along the new arc. Closing both sides joins two pieces, unless the two arcs being closed are the two ends of the same piece; that would close a loop, so the machine rejects it. At EE the top arc on its side is closed and its piece now ends at EE, or a new arc is opened towards SS. A sequence is accepted when, after EE, exactly one arc is open, below the road, leading to EE, so that SS can close it.

5.2. Counting with merging and pruning

The machine is run on all action sequences at once, layer by layer. Each layer is a list of states with multiplicities, and equal states are merged by sorting and adding adjacent counts. Any merge procedure is admissible if it preserves weighted sums ∑(s,c)c⋅g(s)\sum_{(s,c)} c\cdot g(s) for every weight function gg; the counting theorem tmCountWith_eq_countP is proved for an arbitrary such procedure. We instantiate it twice: with a sort-based merge for compiled execution, and with a structurally recursive insertion merge that the Lean kernel can evaluate.

Each layer also drops states that cannot be finished. Every remaining point closes at most one arc on each of its sides, and the accepting state has no open arc above the road and one below, so a state with more open arcs than the remaining points can close has no accepted continuation. In a prototype this viability test reduces the total number of states over all layers at n=17n=17 from 512,350512{,}350 to 3,1353{,}135. Its soundness is an induction showing that a single step lowers each stack by at most one, and only on the sides the point has.

5.3. Correctness

The counting theorem reduces correctness of the transfer matrix to the following statement.

Theorem 5.1. The action sequences accepted by the machine are in bijection with open meanders. Consequently tmCount m = openMeanderCount m for every mm.

The bijection is given explicitly. A meander τ\tau is encoded by letting point yy open its arc on side σ\sigma exactly when the other end of that arc lies east of yy. An accepted sequence is decoded by running a decorated machine, described next, and reading off the river it has built. We prove that decoding an accepted sequence yields a meander whose encoding is the sequence, and that encoding a meander yields an accepted sequence that decodes back to the meander.

Decoding.

The decorated machine stores, for every open arc, the point where it opened and its actual piece of river: the list of points from its origin, through scanned points, to the origin of its partner or to EE. It also records the closed arcs. Forgetting the decorations gives back the transfer matrix exactly (lemma step_abs), so decorated runs and plain runs accept the same sequences. The heart of the proof is an invariant with twenty conjuncts, preserved by each of the five kinds of step (open–open, open–close for either side, close–close, and the two moves at EE). It states, among other things, that partners point to each other; that a piece is duplicate-free, begins at its arc’s origin, and is the reverse of its partner’s piece; that consecutive points of a piece are joined by recorded arcs; that pieces of different components are disjoint and together cover every scanned point; that recorded arcs on one side do not interleave and do not straddle the origin of an open arc on that side; that each point is an arc end at most once per side; and that the recorded arcs agree with the actions read. At acceptance only one piece remains. Prefixing the south end gives a duplicate-free list of all m+2m+2 points in which consecutive points are joined by arcs. Because each point is an arc end at most once per side, the sides of consecutive arcs must alternate, and the non-interleaving of recorded arcs then yields the meander condition.

Encoding.

Along the run of a meander’s own sequence we maintain a second, simpler invariant: every recorded arc is an arc of the meander, and the stack on each side consists exactly of the scanned points whose arc on that side crosses the cut, in increasing order. The non-crossing property implies that a closing point’s partner is the largest such point, hence the top of the stack. The only remaining danger is the loop check. Suppose a bridge closes both sides and the two arcs being closed are the ends of one piece. That piece is a duplicate-free chain of meander arcs from one path-neighbour of the bridge to the other, and every step changes the position along the river by exactly one. A discrete intermediate-value argument shows the chain passes through the position of the bridge itself, which is impossible because the bridge has not been scanned yet. Finally, after EE the stacks are forced: nothing is open above, and below only the first bridge on the path is open, joined to SS. Its piece is the whole river, so decoding returns the original meander.

5.4. The proof in numbers

The transfer-matrix development is about 3,650 lines of Lean. The project as a whole, including the specification, the structural theorems and the search, is about 4,960 lines and 171 theorems. All main theorems depend only on Lean’s standard axioms (propext, Classical.choice and Quot.sound).

6. Certified values and performance

Table 2 compares the algorithms. Times are wall-clock on an Apple-silicon laptop for computing all values up to the given nn. The specification itself is evaluable only for very small nn.

Table 2. Running times.
Algorithm largest nn time
search, crossing test only (compiled) 15 72 s
search with parity pruning (compiled) 15 5 s
17 62 s
transfer matrix (compiled) 24 1.3 s
28 11 s
30 32 s
32 93 s
search, kernel evaluation 9 30 s for n=9n=9 alone
transfer matrix, kernel evaluation 13 68 s for n=13n=13 alone

The repository certifies values at two levels of trust. The statement (M0,…,M13)=(1,1,1,2,3,8,14,42,81,262,538,1828,3926,13820)(\mathrm{M}_0,\dots,\mathrm{M}_{13}) = (1,1,1,2,3,8,14,42,81,262,538,1828,3926,13820) is proved by evaluation in the Lean kernel, through Theorem 5.1 applied to the insertion-merge variant, and the corresponding closed values (M¯1,…,M¯7)=(1,2,8,42,262,1828,13820)(\overline{\mathrm{M}}_1,\dots,\overline{\mathrm{M}}_7) = (1,2,8,42,262,1828,13820) follow by Theorem 3.2. Values up to n=24n = 24 are proved with native_decide, which additionally trusts the Lean compiler. The compiled transfer matrix produces M30=1,503,962,954,930,M32=15,012,865,733,351,\mathrm{M}_{30} = 1{,}503{,}962{,}954{,}930, \qquad \mathrm{M}_{32} = 15{,}012{,}865{,}733{,}351, and all values for n≤32n \le 32 agree with the OEIS b-file. The executable is the same function that the correctness theorem is about, so these values carry the guarantee of Theorem 5.1 up to the correctness of compilation.

Figure 4. One of the 262 open meanders with n = 9 crossings; its crossing order is 456783210.

6.1. All implementations

The repository contains the algorithms in five languages. Only the Lean programs are verified; the others run the same machine and are checked against the certified values and the OEIS.

Table 3 times the parallel programs on a workstation with an 18-core Intel Xeon W-2191B (36 threads) and 128 GB of memory, one value per run on all threads; on the same machine the verified meanders computes all values up to n=32n=32 in 160 s. Every count equals the OEIS term; in particular M49=8,499,066,628,515,413,229,282,M50=22,206,891,674,746,169,557,410.\mathrm{M}_{49} = 8{,}499{,}066{,}628{,}515{,}413{,}229{,}282, \qquad \mathrm{M}_{50} = 22{,}206{,}891{,}674{,}746{,}169{,}557{,}410. Memory is the limit: the largest layer for n=50n = 50 holds 2.25×1092.25 \times 10^9 states, and n=50n = 50 is the largest value that fits in 128 GB, at about 35 bytes per state. Table 4 shows that the programs scale to the physical cores and no further, as expected for work dominated by random memory access.

The OxCaml program is faster than the Rust program in its default mode, and the difference is one design choice. By default Rust grows each shard’s table by half when it is 80% full, so every state is moved several times as its table grows; OxCaml predicts each layer’s size from the growth of the previous layers and allocates every table once. With the same prediction (Rust’s pre-sizing option), Rust is 20–28% faster at every thread count, including one, so the saving is the rehashing work itself rather than time spent waiting on locks. Pre-sized Rust is then the fastest program for n≥44n \ge 44 and on a single thread; OxCaml keeps an edge for small nn on many threads, plausibly because it keeps one pool of workers and their buffers for the whole run, while Rust starts its threads and allocates their batch buffers for every point. Pre-sizing costs memory, since each table is allocated at its final size while the previous layer is still draining (17.0 against 12.6 GiB at n=46n = 46); OxCaml needs more still (20.5 GiB), because its freed tables are returned only after a major garbage collection. Rust grows on demand by default, so that the largest nn fits in memory. The teaching implementations are far slower: interpreted Python computes all values up to n=30n = 30 in about twelve seconds on the laptop, and the OCaml notebook’s transfer matrix, run as bytecode on ten domains, takes about half a second for n=28n = 28.

Table 3. The parallel programs on 36 threads of an 18-core Xeon with 128 GB, interleaved runs (Rust with tables grown on demand, Rust with pre-sized tables, OxCaml). From n=44n = 44 a value takes two sweeps. Peak memory at n=46n = 46: 12.6, 17.0 and 20.5 GiB; at n=50n = 50: 74 GiB (Rust).
nn Mn\mathrm{M}_n largest layer Rust pre-sized OxCaml
40 1.66×10171.66 \times 10^{17} 2.2×1072.2 \times 10^{7} 3.6 s 2.9 s 2.2 s
42 1.73×10181.73 \times 10^{18} 5.7×1075.7 \times 10^{7} 6.1 s 5.3 s 5.3 s
44 1.83×10191.83 \times 10^{19} 1.4×1081.4 \times 10^{8} 30 s 22 s 25 s
46 1.94×10201.94 \times 10^{20} 3.5×1083.5 \times 10^{8} 80 s 57 s 65 s
49 8.50×10218.50 \times 10^{21} 1.4×1091.4 \times 10^{9} 516 s
50 2.22×10222.22 \times 10^{22} 2.3×1092.3 \times 10^{9} 1052 s
Table 4. Scaling with threads for n=40n = 40 on the same machine.
threads 1 4 9 18 36
Rust 21.3 s 6.1 s 3.5 s 3.0 s 3.3 s
Rust, pre-sized 17.0 s 4.8 s 2.8 s 2.4 s 2.9 s
OxCaml 20.4 s 5.6 s 2.8 s 2.2 s 2.3 s

7. Discussion

7.1. What the proofs say about the algorithms

The two pruning rules are the computational shadows of the Jordan curve theorem. Parity (Lemma 4.1) says that arcs pair up inside every region; viability says that a point can close at most one arc per side. Neither rule needs any topology beyond the interleaving of chords, which is why both proofs reduce to linear arithmetic.

The transfer-matrix proof is longer, mostly because the machine’s state records connectivity abstractly, by reference, while correctness needs to know what is connected to what. The decorated machine bridges the gap: it carries explicit pieces of river, so the connectivity argument becomes reasoning about lists. Making the abstract machine literally the decorated one with decorations forgotten (step_abs) means no separate refinement proof is needed.

7.2. Meandric permutations and the conjectured scaling limit

The specification is a statement about permutations, and the same permutations appear in recent probability. Borga, Gwynne and Sun [3] attach to a closed meander its meandric permutation: number the crossings from west to east, and again in the order in which the river meets them; the permutation relates the two orders. Up to inversion and the choice of where and in which direction the river is started, this is the permutation σ\sigma of IsClosedMeander, and Rosenstiehl [13] had studied the same objects as planar permutations. The formalization therefore counts meandric permutations exactly, and Theorem 3.2 is a bijection between meandric permutations of size 2n2n and open meanders with 2n−12n-1 crossings.

Borga, Gwynne and Sun conjecture that a uniform random meander, viewed as a planar map with two Hamiltonian paths (the road and the river), converges to a Liouville quantum gravity surface with matter central charge −4-4, that is γ=(17−145)/3≈1.29\gamma = \sqrt{(17-\sqrt{145})/3} \approx 1.29, decorated by two independent space-filling SLE8_8 curves, and that the plots of uniform meandric permutations converge to the corresponding meandric permuton. They prove, among other things, that the longest increasing subsequence of permutations sampled from the permuton is sublinear. The conjecture is the probabilistic counterpart of the asymptotic formula of Di Francesco, Golinelli and Guitter [5], M¯n∼CAnn−α,α=29+14512≈3.4201,\overline{\mathrm{M}}_n \sim C\, A^n\, n^{-\alpha}, \qquad \alpha = \frac{29+\sqrt{145}}{12} \approx 3.4201, for the number M¯n\overline{\mathrm{M}}_n of closed meanders of order nn, with A≈12.2629A \approx 12.2629 estimated by Jensen and Guttmann [6, 7].

Exact counts test the exponent directly. With AA fixed at that estimate, αn=−log⁡(M¯n+1/(AM¯n))log⁡(1+1/n)\alpha_n = -\frac{\log\bigl(\overline{\mathrm{M}}_{n+1}/(A \overline{\mathrm{M}}_n)\bigr)}{\log(1 + 1/n)} estimates α\alpha, with an error of order 1/n1/n; extrapolating linearly in 1/n1/n from αn−2\alpha_{n-2} and αn\alpha_n removes most of it. Table 5 uses M¯n=M2n−1\overline{\mathrm{M}}_n = \mathrm{M}_{2n-1} (Theorem 3.2) with open counts up to 4949 crossings, computed by the parallel programs of Section 6.1. The extrapolated values increase steadily towards 3.42013.4201. This is numerical evidence for the conjectured exponent, not a proof, and it assumes the estimate of AA.

Table 5. Estimates of the meander exponent α\alpha from exact counts of closed meanders, with the growth constant fixed at A=12.2629A = 12.2629.
nn M¯n+1/M¯n\overline{\mathrm{M}}_{n+1}/\overline{\mathrm{M}}_n αn\alpha_n extrapolated
12 9.4415 3.2665 3.4053
14 9.7747 3.2870 3.4100
16 10.0377 3.3027 3.4129
18 10.2506 3.3152 3.4149
20 10.4263 3.3253 3.4163
22 10.5739 3.3337 3.4172
24 10.6996 3.3407 3.4180
conjecture [5] 3.4201

7.3. Limitations and further work

Our verified transfer matrix is far from the state of the art. Jensen’s algorithm [6] encodes states more compactly and enumerates well beyond n=32n=32. The unverified Rust and OxCaml programs of Section 6.1 pack each state into one machine word and reach n=50n = 50. Verifying such an encoding is a natural next step, and the generic counting theorem already accepts any merge procedure that preserves weighted sums. A second direction is to formalize the rigorous growth-rate bounds of Albert and Paterson [1], which would make our Catalan bound one instance of a more general framework. Finally, the question that motivated the work, a closed formula for the meander numbers, remains open; the conjectured critical exponent α=(29+145)/12\alpha = (29+\sqrt{145})/12 suggests that if a formula exists it is not of an elementary kind.

Acknowledgements

The formalization and this paper were developed with the assistance of Claude Code (Anthropic).

References

M. H. Albert and M. S. Paterson, Bounds for the growth rate of meander numbers, J. Combin. Theory Ser. A 112 (2005), 250–262.

V. I. Arnold, The branched covering ℂℙ2→S4\mathbb{CP}^2 \to S^4, hyperbolicity and projective topology, Siberian Math. J. 29 (1988), 717–726.

J. Borga, E. Gwynne and X. Sun, Permutons, meanders, and SLE-decorated Liouville quantum gravity, J. Eur. Math. Soc. 28 (2026), 4893–4949; arXiv:2207.02319.

P. Di Francesco, O. Golinelli and E. Guitter, Meander, folding, and arch statistics, Math. Comput. Modelling 26 (1997), 97–147.

P. Di Francesco, O. Golinelli and E. Guitter, Meanders: exact asymptotics, Nuclear Phys. B 570 (2000), 699–712.

I. Jensen, A transfer matrix approach to the enumeration of plane meanders, J. Phys. A 33 (2000), 5953–5963.

I. Jensen and A. J. Guttmann, Critical exponents of plane meanders, J. Phys. A 33 (2000), L187–L192.

S. K. Lando and A. K. Zvonkin, Plane and projective meanders, Theoret. Comput. Sci. 117 (1993), 227–241.

L. de Moura and S. Ullrich, The Lean 4 theorem prover and programming language, in Automated Deduction – CADE 28, Lecture Notes in Comput. Sci. 12699, Springer, 2021, 625–635.

The mathlib Community, The Lean mathematical library, in Proceedings of the 9th ACM SIGPLAN International Conference on Certified Programs and Proofs (CPP 2020), 367–381.

OEIS Foundation, Sequence A005316: Meandric numbers, The On-Line Encyclopedia of Integer Sequences, https://oeis.org/A005316.

OEIS Foundation, Sequence A005315: Closed meandric numbers, The On-Line Encyclopedia of Integer Sequences, https://oeis.org/A005315.

P. Rosenstiehl, Planar permutations defined by two intersecting Jordan curves, in Graph Theory and Combinatorics (Cambridge, 1983), Academic Press, London, 1984, 259–271.

J. Touchard, Contributions à l’étude du problème des timbres-poste, Canad. J. Math. 2 (1950), 385–398.