The program that computed A000104(41) to A000104(50), taken apart into its phases. Each bay runs the real algorithm in this page, ported from rust/src/tm.rs, rust/src/search.rs and python/a000104.py, at sizes a browser handles in a second; the values at n = 41 to 50 come from data/components-50.txt. Notes on the left cite tex/a000104-v2.pdf by section heading.
BAY 01
Pipeline
Five counts, two engines, one sum
Five counts
Burnside's lemma counts orbits as the average number of elements each group element fixes. The eight symmetries of the square act on the fixed hole-free n-ominoes, and the orbits are the free ones, so A000104(n) = (F + R2 + 2 R4 + 2 M + 2 D) / 8.
F counts every fixed hole-free n-omino (A006724). R2, R4, M and D count those with a half-turn, a quarter-turn, a vertical mirror and a diagonal mirror symmetry. At n = 50 the largest of the four is about 2 × 10⁻¹⁴ of F.
A transfer matrix over self-avoiding polygons gives F, and a test at each polygon's center inside the same sweep gives R2. A Redelmeier search over the orbits of each symmetry gives R4, M and D, and R2 again as a check.
The sweep counts in 64-bit words, once modulo 2⁶⁴ and once modulo the prime 2⁶¹ − 1, and the Chinese remainder theorem rebuilds each count from the two residues.
Mimic diagram · the program's phasesclick a box to open its bay
Cyan pipe: R2 from the sweep checked against R2 from the search. Amber outline: the box under the pointer.
Register · where each phase livesbay · manuscript section · code
Phase
Bay
TEX · a000104-v2.pdf
RUST · rust/
BAY 02
Symmetry
Unholey polyominoes, their images and their cores
Hole-free means one polygon
A polyomino has no holes exactly when its boundary is a single self-avoiding polygon. A pinch, a vertex where only two diagonally opposite cells are present, always encloses a hole: the path of cells joining the two, closed through the pinch, cuts off one of the empty cells there.
So F(n) is A006724, the self-avoiding polygons of area n, and the transfer matrix can count polygons in place of polyominoes.
For a connected union of closed cells, χ = V − E + F is 1 minus the number of holes, where V, E and F count its distinct corners, edges and cells. The search keeps χ as it adds cells.
A rotation that maps a hole-free polyomino onto itself has its center in the interior, so the one, two or four cells around the center belong to it. A mirror line meets it in one segment, so the cells on the axis form one unbroken run.
ON THE PANELClick or drag on the grid to place cells. The eight images light cyan where the symmetry maps the shape onto a translate of itself; the Burnside row adds up to the number of symmetries that fix it.
Polyomino drawing gridclick toggles · drag paints
Eight imagescyan · a translate of the shape
Symmetries that give back the drawn polyominoup to a shift · one term of the Burnside sum each
Symmetry
Term
Shape given back
BAY 03
The cut
One polygon through the transfer matrix, vertex by vertex
The state
The polygon sits in a strip of W cell rows. The sweep visits vertices bottom to top within a column and columns left to right, and after each vertex the cut between visited and unvisited vertices crosses W + 2 edges.
For each crossed edge the state holds 0 if the polygon does not use it, and 1 or 2 if it carries the lower or upper end of an arc drawn so far. Arcs cannot cross, so the 1s and 2s nest like parentheses. A state is a 64-bit word, 2 bits per edge.
A vertex uses 0 or 2 of its 4 edges. Two are crossed before it is visited, the edge from below and the edge from the left, and two after, so the step starts an arc, extends one, or joins two ends. Joining two lower ends turns the partner of the upper one into a lower end, and joining two upper ends does the reverse. Joining the two ends of one arc closes the polygon, allowed only when no other arc is open.
A cell is inside when an odd number of used edges lies below it in its column, and the state gives that parity as the sweep passes the cell. Each state carries one count per area.
The interactive panels
ON THE PANELDraw a hole-free polyomino in the strip, then scrub the vertex rail or press ← →. The amber ring is the next vertex; the dashed line is the cut. The full sweep follows every successor; here the polygon picks one at each vertex.
Strip · the cut after each vertex
W4
State at the cuttop of the strip first, as in the picture
Vertex rules(edge from below, edge from left)
In
Step
Successors
BAY 04
Sweep
Every state at once: layers, pruning, the mirror merge, shards
Layers and state-steps
The states at one point of the sweep form a layer. Each state is a word and a window of counts by area, and the unit of work is the state-step, one state processed at one vertex. State-steps and peak states are exact and the same on every machine.
Every column of a polygon holds a cell, and the strip of W rows only needs polygons of length at least W. So after column c a state is dropped once its least area passes N − (W − 1 − c).
The mirror merge
The strip is symmetric top to bottom, so at a column boundary a state and its mirror image, positions reversed and labels 1 and 2 swapped, have the same completions. The two merge into one. At N = 24 this removes 44% of the states at column boundaries.
A layer of 16,384 states or more splits into four shards per thread by a multiplicative hash of the word. A step runs in two passes: each shard maps its states to successors and routes them to their new shard, then each shard adds up what it received.
While the sweep works on one window of rows, states that differ in the occupancy outside the window never combine. Under a memory limit these groups go to bucket files on disk, and each bucket is stepped in memory.
Bars: states after each vertex, one group per column. Click a bar, or use ← →, to open that layer below. Amber: the vertex you picked.
The layer at the picked vertex
Each row: a state as parentheses, bottom slot first; its partial polygons; its counts by area, from the least area at the left.
Shardskey × 0x9E3779B97F4A7C15 ≫ 32, mod shards
Threads
Occupancy groupsone window of rows
Work by strip
The widest strip, of ⌈N/2⌉ rows, does about half the work and holds the memory peak. Each odd N adds a new widest strip, which the even N after it reuses.
Growthstate-steps by N, every strip
N
State-steps
Ratio
Peak states
Ratio
The rows at N = 42 to 46 and 50 are the program's runs, one modulus each.
BAY 05
Strips
From placements to exact heights by second differences
Each polygon once
A run in a strip of W rows counts a polygon of height h ≤ W once for each of its W − h + 1 vertical placements. With TW that strip's count at one area and length, the polygons of height exactly h number Th − 2 Th−1 + Th−2.
A quarter-turn swaps height and length L, so only h ≤ L is needed, counted twice when h < L. Since h + L − 1 ≤ N, the strips stop at ⌈N/2⌉ rows.
It is taken at each length L separately. For h ≤ L it needs strips h, h − 1 and h − 2 only at lengths L ≥ h, and the strip of W rows keeps every polygon of length at least W.
One run per N
A run to N truncates every count at area N, so it cannot later be extended to N + 1: each N chosen costs a full run, and a run gives every term up to N.
The interactive panels
ON THE PANELPick an area with the stepper, then click a cell of the lower map to see its second difference spelled out.
N12
area12
Placements TW(area, L)rows W = 1 … ⌈N/2⌉ · columns L
Faint: h > L, left to the quarter-turn. Cells with L > h carry ×2.
The picked cell
F at this areaΣ over h of e(h, h) + 2 ΣL>h e(h, L)
0A006724
h
L = h
2 × L > h
Sum
BAY 06
Half-turn
R2 from the same sweep, by a test at the center
Half a polygon is enough
A polygon with 180-degree symmetry is its left half plus the half-turned copy of that half. The sweep for F already carries every left half, since the copy is one possible completion, so R2 needs only a test on states the sweep already has, made where it reaches the center.
A state passes if its occupancy, which edges are used, is symmetric under the half-turn (a bit reversal of the word), no used edge touches the center, and its arcs with their half-turned copies form a single loop. Only the few states that pass the bit reversal reach the loop walk.
The center sits on the strip's middle line, at height W/2. Odd L puts it in a column of cells: a cell center for odd h, a horizontal edge's midpoint for even h, tested after the column's last vertex. Even L puts it on a vertex column: a vertex for even h, a vertical edge's midpoint for odd h, tested partway up the column.
The swept cells and their images overlap in the cells the cut splits, so the area is 2a − i (odd L) or 2a − 2i (even L).
The interactive panels
ON THE PANELPick a center and paint: each click places a cell and its half-turned image. Shift-click places one cell alone, to break the symmetry and watch the test reject it.
Painter · symmetric about the centershift-click: one cell
In the strip, at the test
W3
Ink: the swept part. Cyan: its half-turned copy and the center.
Occupancy and its reversalslots bottom to top
Loop walk→ an arc of the state · ⇢ through the half-turned copy
R2 by center, sweep against searchcomputed here, n ≤ 16
n
Cell
H-edge
Vertex
V-edge
R2 sweep
R2 search
BAY 07
Search
Redelmeier's recursion over orbits of a symmetry
Add or exclude
Redelmeier's algorithm lists every connected set of cells that contains a start set, each once. It keeps a list of untried neighbors; each untried cell is either added, and its new neighbors join the list, or excluded for the rest of that branch.
Run on the orbits of a symmetry g in place of single cells, from a forced core, the recursion lists the polyominoes that contain the core and are symmetric under g. An orbit adds 1, 2 or 4 cells, one at a time, to keep χ.
Adding a cell changes χ by its corners not yet present plus its neighbors already present, minus 3. A set is counted when χ = 1.
A run more than 11 orbits deep splits at depth 8 into 4d − 11 parts, at most 1,024; part i of p continues only every p-th branch. The split depends on the run alone, so the units are the same on every machine and thread count.
ON THE PANELPick a job and n, then step or run. Ink: the set. Dashed: untried orbits. ×: excluded on this branch. Cyan: the orbit just added, and the symmetry's center or axis.
Search · one job
n8
Steps a second
Counted so far, by cellslog scale
Jobs and their forced coresclick to pick
Every job at oncecomputed here
n18
Job
×
Count at n
Search nodes
Share of nodes
BAY 08
Residues
Counting on counters that wrap around, then rebuilding the count
The counts are too big for one counter
The sweep keeps its counts in 64-bit words. A word wraps around after 2⁶⁴ − 1, a 20-digit number, the way a car's odometer rolls over to 0. F(50) has 28 digits, so a single word cannot hold it.
Two counters are enough
The program runs the sweep twice, with counters that wrap at two different points: once at 2⁶⁴, once at 2⁶¹ − 1. Each run on its own loses the top of the number. Together they pin it down, because only one number below the two wrap points multiplied together leaves both readings.
The example on the right shows the same thing with counters that wrap at 100 and at 97.
The sweep can also use 16-bit counters, which wrap near 65,536 and take about a third of the memory. Then it needs more runs, one counter each, until the wrap points multiplied together pass the largest the count can be.
This works for every count from 0 to 9,699, one less than 100 × 97. The counters share no factor, which is what makes the match unique.
The real counters · two runs of the sweepwrap at 2⁶⁴ and at 2⁶¹ − 1
n50
Sixteen-bit counters
BAY 09
Checks
Subgroup sums, data checks, independent pieces
Subgroup sums
Burnside's lemma holds for every subgroup of the symmetry group, and each subgroup's sum must be a multiple of its order. An error e in F or R2 escapes the full sum only when 8 divides e, and the subgroup sums narrow down which count is wrong.
Above n = 41 the checks that use none of the sweep's code reach F only modulo 8: R2 from the search checks the sweep's R2, and the Burnside sums catch an error in F only when 8 does not divide it.
ON THE PANELStep n to see every check at that n, or run the whole computation here for small n.
n50
Annunciator
holdsfailsno data at this n
Burnside sums, one per group of symmetries
Each group of the square's symmetries gives its own Burnside sum: add up, over the group's symmetries, how many fixed polyominoes each one fixes. The sum must divide evenly by the group's size, so each tile shows its remainder, which must be 0.
The counts against other sources
Compute here · every phase, end to endsweep, search, brute force, Burnside
N20
The lamps in the Checks column · cyan when the check holds, dark when there is no data to check against
BA000104(n) equals its OEIS b-file
FF equals the A006724 b-file
RR2 from the sweep equals R2 from the search
Xall five counts and A000104(n) equal a brute force over every fixed polyomino, for n ≤ 10
n
F
R2 sweep
R2 search
R4
M
D
A000104(n)
Checks
Independent piecesevery split recombines exactly
Split
Pieces
Recombined by
Checked in each run
Checked in the tests
symmetry
F, R2, R4, M, D
Burnside sum
sum is a multiple of 8
all five against a brute force at small n
modulus
residues modulo each modulus
Chinese remainder theorem
none of its own
exact F against A006724 to n = 20; 16-bit counts against 64-bit