Most three-dimensional spaces that topologists study can be built in two steps. First, start from a simpler "parent" space that has tube-shaped ends, called cusps. Second, cap each cusp with a solid donut, choosing how to glue it by a pair of coprime integers p/q called a slope. This operation is Dehn filling, or Dehn surgery. It is computationally hard to go backwards: given a scrambled list of glued tetrahedra describing some 3-manifold, find a parent and slopes that produce it. We propose a neural decoder that answers this inverse question. It reads a triangulation and emits a surgery description, writing each slope one step at a time as a path down the Farey (Stern–Brocot) tree, the binary tree that lists every fraction exactly once. Every proposal is checked by the topology packages SnapPy and Regina, and a failed check is repaired locally rather than regenerated from scratch.
The bet is that this tree-shaped output fits the problem itself. The slope p/q is not an arbitrary integer pair. It is a continued fraction, and when a cusp is filled by stacking tetrahedra in layers, each layer corresponds to one step along a Farey path. A decoder that emits the slope step by step can therefore attend to one layer of the input at a time. A flat decoder that emits the string "p/q" cannot. We are most interested in the case where the result of surgery is not hyperbolic, the so-called exceptional surgeries. There, geometric shortcuts fail and no practical general method exists.
Where this sits
There is a deep combinatorial bridge between ideal polyhedral decompositions and surgery. Word hyperbolic Dehn surgery proves that slopes of normalized length above 6, or combinatorial length above 2π on an angled ideal triangulation, give hyperbolic results. The maximal number of exceptional Dehn surgeries shows that a one-cusped hyperbolic manifold has at most 10 exceptional slopes, pairwise intersecting at most 8 times. Exceptional surgery curves in triangulated 3-manifolds gives an algorithm that builds exceptional surgery curves by inserting tangles from a finite catalogue into each tetrahedron. It needs the slope to meet the meridian more than once (Δ(σ, μ) > 1), it admits infinite families at Δ = 1, and it is described as "fairly lengthy" with no practical implementation.
These papers motivate the problem and limit what we can promise. They tell us exceptional slopes are few and short, which keeps the target space small. They also tell us that the Δ = 1 regime is where finiteness breaks, so it must be evaluated separately rather than averaged away. The continued-fraction formula for lens-space triangulation complexity in The triangulation complexity of fibred 3-manifolds is our main supporting evidence that Farey steps track combinatorial size.
The only machine-learning work in this area is Learning 3-Manifold Triangulations. It trains feed-forward networks and BERT on flat isomorphism-signature strings, which are canonical text encodings of how tetrahedra are glued. It found that BERT did worse than plain feed-forward networks. It reported about 0.74 accuracy separating the lens spaces L(7,1) and L(7,2), and accuracy rising from about 0.63 to over 0.97 on unknot versus trefoil once the knot complements were Dehn-filled. Its brute-force search over Pachner-move graphs ran out of 200 GB of memory at depth 5. That work is purely discriminative and flat. Ours is generative, tree-structured, and verified, and it targets surgery descriptions rather than class labels.
The decoding method comes from the tree-decoding literature. A Goal-Driven Tree-Structured Neural Model for Math Word Problems decomposes goals top-down and embeds finished subtrees bottom-up. Tree-Based Representation and Generation of Natural and Mathematical Language contributes tree-position embeddings and grammar masks. Decompose, Structure, and Repair maps compiler errors back onto subtrees and repairs only those subtrees. We borrow the repair loop from the last of these, with SnapPy and Regina playing the role of the compiler.
The third input direction, stable extendability, plays a smaller role. On slope genera of knotted tori in 4-space shows that a Dehn twist along a slope on a knotted torus extends stably across 4-space exactly when that slope has singular genus zero. The same Farey-tree slope decoder could propose such slopes. However, there is no verifier for commutator length in those knot groups, so we treat this only as a stated extension and not as an evaluated claim.
Core Claim
The claim is narrow. When the output is a surgery description, decoding each slope as a Farey-tree path conditioned on the input triangulation does two things a flat decoder cannot. It extrapolates to slopes deeper than any seen in training, and it recovers verified descriptions of exceptional fillings, where geometric drilling has nothing to work with.
The extrapolation half has a mechanism behind it. A continued fraction is
$$p/q = a_0 + \cfrac{1}{a_1 + \cfrac{1}{\ddots + \cfrac{1}{a_k}}}.$$
Here the $a_i$ are positive integers (with $a_0 \ge 0$), and the Farey path to p/q runs $a_0$ steps one way, then $a_1$ steps the other way, and so on. Each step is a local, repeated operation. A decoder that has learned one step should keep working for longer paths, much as a tree decoder that has learned an operator keeps working on deeper expressions.
Research Program
We build a supervised and self-improving dataset from the SnapPy orientable cusped census. We use the 4,815-manifold subset with fewer than 8 tetrahedra that was used in Learning 3-Manifold Triangulations. There are two tasks.
In the closed task, a one-cusped parent is filled along a slope and the input is a triangulation of the resulting closed manifold. In the cusp-reduction task, one cusp of a two-cusped parent is filled and the input is the resulting one-cusped manifold. We draw slopes up to a chosen Farey depth. We label each example as hyperbolic or exceptional using SnapPy, plus Regina recognition where it succeeds. We then scramble each triangulation with random Pachner moves followed by Regina simplification, so that the input does not trivially display the parent.
The model has three parts. A graph encoder reads the face-pairing structure of the input triangulation: tetrahedra are nodes and face gluings are edges labelled by permutations. A pointer head selects a parent from the census. A tree decoder then emits, for each cusp being filled, a Farey path. At each node of the Farey tree it chooses left, right, or stop, using tree-position embeddings in the style of MathGPT and bottom-up embeddings of the path so far in the style of GTS.
Many different surgery descriptions can produce the same manifold, so any description that passes verification counts as correct. For hyperbolic targets, verification is a SnapPy isometry check. For non-hyperbolic targets, we count a success only when Regina certifies a homeomorphism, either through matching simplified signatures or through recognition of the space as Seifert-fibered. Proposals that match all invariants but are not certified are reported separately and never counted as successes.
When verification fails, the repair step backs up the slope path to the deepest node whose invariant shadow still matches. Concretely, the homology of the filled manifold is a function of p/q that we can compute exactly at every prefix of the path, so we can locate where the path went wrong and re-decode only from there. After supervised pretraining, we add verified self-generated descriptions back into the training set.
Baselines
The naive reference is uniform proposal. It samples a census parent and a slope uniformly from those within the length bound given by the 6-theorem, and checks each sample with the same verifier. It gets exactly the same number of verifier calls as our method. Beating it shows that the model learned something beyond the geometric prior that exceptional slopes are short.
The strongest non-learned competitor for hyperbolic targets is SnapPy's drilling of the shortest closed geodesic. Removing that geodesic produces a cusped manifold whose meridian slope is a valid surgery description. We run it on the same inputs. We expect it to be close to perfect when the target is hyperbolic and to be inapplicable when the target is exceptional. We found no reported result on Lacuna for drilling success rates on this task. We will therefore report drilling ourselves and claim a win only on targets where drilling is undefined, or where the drilled cusped manifold falls outside the census.
The strongest in-distribution competitor is invariant-hash retrieval. We precompute every census filling up to the training slope depth, index the results by cheap invariants such as homology and simplified signature, and verify the candidates that match. Retrieval gets the same compute budget as our training plus inference. Beating it means a higher verified recovery rate on unseen parents, or on slopes deeper than the precomputed table, at matched verifier calls.
The closest learned baseline is a flat transformer over isomorphism signatures that emits the parent's signature and the string "p/q", following the representation of Learning 3-Manifold Triangulations. That paper reports about 0.74 accuracy separating L(7,1) from L(7,2) with feed-forward networks, with BERT doing worse. It reports no generative recovery number, so no reported result was found on Lacuna for flat surgery-description decoding.
The key ablation keeps our graph encoder and the parent pointer but replaces the Farey decoder with a head that predicts p and q directly as integers. A second ablation removes the repair loop, isolating the contribution borrowed from Decompose, Structure, and Repair. All learned models share the same data, parameter count within ten percent, and hyperparameter search budget.
Why not just…?
Why not just drill the shortest geodesic? For hyperbolic targets this probably works and is cheap, and we expect it to win there. We will report that honestly rather than hide it. It gives nothing for Seifert-fibered, toroidal, or reducible results, which have no hyperbolic metric to drill. That is exactly the regime that The maximal number of exceptional Dehn surgeries shows to be small but non-empty, and the regime the proposal targets.
Why not just precompute all fillings and look them up? This is the real threat for small, in-distribution slopes. If retrieval matches our method on held-out parents and deeper slopes at equal compute, we will conclude that learning is unnecessary at census scale. The experiment that settles this is the extrapolation split. For two-cusped parents, the table grows exponentially with Farey depth, because the number of fractions at depth d doubles with each level. A learned local step does not grow this way.
Why not just write a combinatorial peeler that detects layered solid tori in the simplified input and reads off the slope? When simplification leaves the layered chain intact, this hand-written peeler may be as good as our decoder. We include it as a further baseline, built from Regina simplification plus layered-solid-torus detection and a signature lookup of the remainder. We measure how often Pachner scrambling destroys the chain. If the peeler succeeds on most inputs, the learned decoder adds value only on the residue, and we will report the result that way.
Why not just use a graph network with an integer head? That is our main ablation. If it matches the Farey decoder on deeper-slope extrapolation, then the tree structure of the output is not doing any work, and the core claim fails.
Decisive Experiments
The primary metric is verified recovery rate at a fixed budget of verifier calls. We report it separately for hyperbolic and exceptional targets, for Δ(σ, μ) = 1 versus Δ > 1, and for slopes inside versus beyond the training Farey depth. Recovery is defined as producing at least one certified surgery description.
The claim is supported if the Farey decoder beats both uniform proposal and retrieval on exceptional targets with unseen parents, and if its recovery rate degrades much more slowly with Farey depth than the integer-head ablation. We also check the mechanism by perturbing single tetrahedra in the input and seeing which decoding steps change. If the claim is right, successive Farey steps should depend on successive layers of tetrahedra in the input.
The claim is refuted if the integer-head ablation extrapolates equally well, or if the peeler explains nearly all successes. The claim is limited in scope if all gains vanish in the Δ = 1 regime. That outcome would itself be informative, because Exceptional surgery curves in triangulated 3-manifolds predicts the regime is structurally different.
As a secondary sanity check, a frozen encoder from the trained model should improve the L(7,1)-versus-L(7,2) classification beyond the roughly 0.74 reported in Learning 3-Manifold Triangulations. We would not count this as the main result.
References
- Word hyperbolic Dehn surgery
- The maximal number of exceptional Dehn surgeries
- Exceptional surgery curves in triangulated 3-manifolds
- The triangulation complexity of fibred3–manifolds
- Learning 3-manifold triangulations
- A Goal-Driven Tree-Structured Neural Model for Math Word Problems
- Tree-Based Representation and Generation of Natural and Mathematical Language
- Decompose, Structure, and Repair: A Neuro-Symbolic Framework for Autoformalization via Operator Trees
- On slope genera of knotted tori in 4-space