We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
Cumul
Cumul is an esoteric programming language invented in 2026 by User:Zhil, in which a program is a square matrix of integers. The only operation is adding rows to a running total, and the only control flow is the choice of rows: those whose entry in the total is currently zero. Despite this, Cumul is Turing-complete.
Language description
Picture a grid of whole numbers with as many rows as columns, and a scoreboard with one score for each column. All scores start at zero. In each round, look for the scores that are exactly zero. If the third score is zero, pick the third row, and so on. Then add all the picked rows to the scoreboard at once, number by number. Keep playing rounds until no score is zero. The grid is the whole program, and the final scoreboard is its answer.
Formal definition
A program is an n × n matrix M of integers of unbounded size. Rows and columns are numbered from 0. The state is a vector v of n integers, called the total, which starts as all zeroes.
Execution repeats the following step:
- Let Z be the set of indices i such that v[i] = 0.
- If Z is empty, halt.
- Otherwise, add to v the sum of all rows M[i] with i in Z.
Z is determined before any row is added, so all selected rows are applied simultaneously.
The first step always adds every row, since the total starts at zero.
Syntax
Each line of source code is one row, written as integers separated by whitespace. The number of integers on each line must equal the number of lines.
Input and output
Cumul has no input or output instructions. Input is encoded in the program, and the result is the total at the moment of halting.
Examples
Smallest programs
This program halts after one step with total 1:
1
This one runs forever:
0
Addition
Computes 3 + 2:
1 0 1 4 0 2 0 1 -1 -1 0 0 0 0 1 0 -1 0 0 0 0 1 1 0 0 -1 0 0 1 1 0 0 0 0 0 0
It halts after 12 steps with total 1 1 1 1 1 6. The last entry is the result plus one.
Multiplication
Computes 6 × 7:
1 0 1 0 1 2 0 1 7 1 7 1 0 7 7 0 0 0 1 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 -1 0 1 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 0 -1 1 0 0 0 1 0 0 0 1 0 0 0 0 -1 0 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 -1 0 0 0 0 0 1 0 0 0 0 -1 0 0 0 0 0 1 0 -1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 -1 0 0 0 0 1 0 0 0 0 -1 0 -1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
It halts after 333 steps. Column 15 of the total is then 43, that is, 42 plus one. To multiply other non-negative integers a and b, replace the 7s in columns 8 and 13 of row 0 with a + 1, and those in columns 10 and 14 with b.
Fibonacci numbers
This program runs forever:
1 1 0 2 0 1 2 0 1 0 1 1 1 -1 0 1 -1 0 1 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 -1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 0 1 -1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 -1 0 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 0 -1 1 0 0 0 1 0 0 0 1 0 0 0 -1 0 0 0 0 0 1 0 0 0 0 0 -1 0 0 0 0 1 -1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 -1 0 0 0 0 0 1 0 0 0 0 -1 0 0 0 0 0 1 0 -1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 -1 0 0 0 0 1 0 0 0 -1 0 -1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Each time column 1 of the total is zero, look at column 14 and subtract one. Ignoring repeated zeroes, the new peaks are successive Fibonacci numbers: each countdown starts at 1, 1, 2, 3, 5, 8, 13, and so on.
Long-running programs
Since entries are unbounded, the size of a program is measured here by both its width n and its largest absolute entry k. A champion halts after more steps than every halting program that is smaller in at least one measure and no larger in the other.
No limit from width 3
Width alone does not limit the running time. For every positive integer m, this program halts after exactly 8m + 2 steps:
-2m 2m m 1 0 0 -2m -2m -2m
The first step gives the total (1−4m, 0, −m). Row 1 is then added until step 4m, giving (0, 0, −m). Rows 0 and 1 give (1−2m, 2m, 0), and row 2 gives (1−4m, 0, −2m). Row 1 is again added until step 8m + 1, giving (0, 0, −2m). Finally rows 0 and 1 give (1−2m, 2m, −m), which has no zeroes.
Best known larger programs
n = 4, k = 2: 52 steps
1 2 1 2 1 1 -1 2 1 -1 0 -1 -1 2 0 0
n = 4, k = 9: 998 steps
0 9 -1 -6 1 9 9 0 -9 8 8 6 0 -1 9 0
n = 5, k = 3: 18077 steps
-1 -3 2 1 -3 1 0 0 -1 2 1 -3 -2 0 -3 -3 0 0 0 1 -1 1 0 0 -3
Computational class
Cumul is Turing-complete, because it can simulate any two-counter Minsky machine. Such a machine has registers A and B holding non-negative integers, and instructions numbered 0 to k − 1, each of one of two forms:
INC r, a: increment register r and go to a.DEC r, a, b: if r > 0, decrement it and go to a; otherwise go to b.
Going to instruction k halts the machine.
Construction
Create the following columns, and for each column the row with the same index:
- boot, used once;
- Si for each instruction i;
- Mi and Ti for each
DECinstruction i; - A and B for the registers.
The copies of a register r are column r together with every Ti whose instruction tests r.
Rows are zero except for the following contributions, which are summed if they fall in the same column. References to the nonexistent Sk are omitted.
| Instruction | Row | +1 in columns | −1 in columns |
|---|---|---|---|
INC r, a |
Si | Si, copies of r | Sa |
DEC r, a, b |
Si | Si | Mi, Ti |
| Mi | Mi, Ti | Sa, copies of r | |
| Ti | Sa, copies of r | Sb |
Rows A and B are zero. (The same construction works for any number of registers, as in some of the examples above.) Finally, the boot row has 1 in the boot column, and its other entries are chosen so that the sum of all rows is the initial configuration described below.
Proof
Between instructions, with the machine at instruction i, the total satisfies this invariant:
- Si is 0;
- the boot column, every other S column and every M column are 1;
- every copy of register r equals r + 1.
Start. The first step adds all rows, establishing the invariant for instruction 0. Since only the boot row is nonzero in the boot column, that column stays 1 and the boot row is never used again.
Increment. Only Si is zero. Its row sets Si to 1, increments every copy of r, and sets Sa to 0. (If a = i, the two changes to Si cancel.)
Decrement. Only Si is zero. Its row sets Si to 1, Mi to 0, and Ti to r. Hence Ti is now zero exactly when register r is.
- If r > 0, only row Mi is added. It restores Mi to 1, decrements every copy of r (its extra +1 leaves Ti equal to the new value plus one), and sets Sa to 0.
- If r = 0, rows Mi and Ti are added together. Their changes to the copies of r cancel, as do their changes to Sa. What remains restores Mi and Ti to 1 and sets Sb to 0.
In every case the invariant holds for the next instruction.
Halting. Going to instruction k sets no S column to zero, and every other entry is positive, so the program halts. Before that, some entry is always zero. Therefore the Cumul program halts if and only if the Minsky machine does, with registers A and B stored, plus one, in columns A and B. ∎
Every row except the boot row uses only the entries −1, 0 and 1.
Interpreter
A Python interpreter, reading the program from standard input and printing the final total:
import sys
# Read the program: one row of integers per non-blank line.
program = [list(map(int, line.split())) for line in sys.stdin if line.strip()]
# The running total has one entry per column, all starting at zero.
total = [0] * len(program)
# Keep going for as long as some entry of the total is zero.
while 0 in total:
# Choose every row whose matching entry in the total is zero.
# All rows are chosen before any of them is added.
selected_rows = [row for row, value in zip(program, total) if value == 0]
# zip(total, *selected_rows) walks through the columns, pairing each
# current value with the numbers to be added to it.
total = [sum(column) for column in zip(total, *selected_rows)]
# No zeroes remain, so the program has halted.
print(*total)