The shortest proof: EQP’s twelve equations#

In The Robbins problem we told the story of the Robbins problem: the three equations

\[ x + y = y + x, \qquad x + y + z = x + (y + z), \qquad n(n(x + y) + n(x + n(y))) = x \]

(commutativity A1, associativity A2 and the Robbins equation R) are enough to build a Boolean algebra. The proof was found in 1996 by William McCune’s program EQP. Now we look at the proof itself as an object: how many steps it has, what it is made of, and how to write it down compactly, so that our kernel from lecture 3 checks every detail of it.

How many steps does a proof have?#

The question “how many steps” has no single answer: everything depends on what counts as a step. After the first success McCune came back to the problem and ran several new searches. In the paper Solution of the Robbins Problem (Journal of Automated Reasoning, 1997, Table I) he gives the lengths of the proofs found, in EQP steps. One EQP step is one new equation: one equation substituted into another (paramodulation) together with simplifications.

Search

Condition 2 (Winker)

Condition 1 (Winker)

Huntington’s equation

m5-70 (October 1996, the first proof)

15 steps, 7.85 days

—

—

m5-60a, m5-60b

15

17

194

m5-50, m5-50b

8

12

86

Winker’s conditions are \(\exists C, D\colon n(C + D) = n(C)\) (condition 2) and \(\exists C, D\colon C + D = C\) (condition 1). Each of them suffices for a Robbins algebra to be Boolean, but that part — Winker’s lemmas — still has to be proved separately. McCune writes that in all searches the first proof found and the shortest one were of condition 2; condition 1 appeared a few steps later. We know of no shorter published computer proof, so we say it carefully: this is the shortest published proof known to us.

McCune published the files with the EQP proofs on his web page. The script obce/pobierz.py fetches them together with other proofs of this theorem (licences and sources are in obce/ZRODLO.md). The files have no licence, so we do not copy them here — we only read them and count. A line of an EQP proof has a number, a weight, a justification and an equation; the justification para(a,b) means “substitute equation no. a into equation no. b”.

import re

def eqp_parents(justification):
    """Numbers of the equations a new one comes from: para(a,b), demod([c,d]), back_demod(e)."""
    numbers = []
    for a, b in re.findall(r"para\((\d+),(\d+)\)", justification):
        numbers += [int(a), int(b)]
    for listed in re.findall(r"demod\(\[([\d,]+)\]\)", justification):
        numbers += [int(x) for x in listed.split(",")]
    numbers += [int(x) for x in re.findall(r"back_demod\((\d+)\)", justification)]
    return numbers


def read_eqp(file):
    """Lines of an EQP proof: number -> (numbers of the parents, equation as text, derived or not)."""
    lines = {}
    for row in (FOREIGN / "mccune" / file).read_text().splitlines():
        m = re.match(r"(\d+) \(wt=\d+\) \[(.*?)\] (.*)\.$", row.strip())
        if m:
            justification = m.group(2)
            lines[int(m.group(1))] = (eqp_parents(justification), m.group(3), bool(justification))
    return lines


proofs = {"October 1996 (condition 2)": "eqp-theorem.proof.txt",
          "November 1996, m5-50 (condition 1)": "eqp-lemma3.proof.txt",
          "November 1996, m5-50 (Huntington's equation)": "eqp-hunt.proof.txt"}
eqp_steps = {}
for verdict, file in proofs.items():
    lines = read_eqp(file)
    eqp_steps[file] = [n for n, (_, _, derived) in lines.items() if derived]
    print(f"{verdict}: {len(eqp_steps[file])} derived equations")
October 1996 (condition 2): 15 derived equations
November 1996, m5-50 (condition 1): 12 derived equations
November 1996, m5-50 (Huntington's equation): 87 derived equations

The numbers agree with the table: 15 steps in the first proof and 12 in the proof of condition 1. In the proof of Huntington’s equation one of the derived equations is the negation of the goal, which EQP drives to a contradiction — so there are 86 equations, as in the table.

Where do the “8 steps” for condition 2 come from? McCune notes that one of the equations in the proof of condition 1 already satisfies condition 2. Let us count how many derived equations it uses — directly or through other equations:

lines = read_eqp("eqp-lemma3.proof.txt")

def ancestors(number):
    """Derived equations that equation `number` uses (itself included)."""
    parents, _, derived = lines[number]
    result = {number} if derived else set()
    for r in parents:
        result |= ancestors(r)
    return result

print(sorted(ancestors(8855)), len(ancestors(8855)))
[10, 11, 29, 54, 217, 674, 6736, 8855] 8

Eight equations, the last of which, no. 8855, is \(n(q + 5x) = n(3x)\) for \(q = n(n(3x) + x)\): condition 2 for \(C = 3x\) and \(D = q + 2x\). Four more equations lead to condition 1.

The twelve equations are Mann’s lemmas#

EQP proofs are hard to read: the program itself chooses what to combine with what, and it applies associativity and commutativity invisibly. Allen L. Mann rewrote McCune’s proof for people (A Complete Proof of the Robbins Conjecture, 2003). His lemmas 44–54 then went into the formalizations in Isabelle (M. Wampler-Doty, 2010) and in Lean’s mathlib library (J. Tan, 2026, file Archive/Robbins.lean, Apache 2.0 licence). The same statements, in our notation (\(n\) is the complement, a + a + a is \(3a\)), are in the module robbins_proof:

from robbins_proof import STATEMENTS

for name, formula in STATEMENTS.items():
    print(f"{name:8} {formula}")
mann_44  n(n(n(a + b) + n(a) + b) + b) = n(a + b)
mann_45  n(n(n(n(a) + b) + a + b) + b) = n(n(a) + b)
mann_46  n(n(n(n(a) + b) + a + b + b) + n(n(a) + b)) = b
mann_47  n(n(n(n(n(a) + b) + a + b + b) + n(n(a) + b) + c) + n(b + c)) = c
mann_48  n(n(n(n(n(a) + b) + a + b + b) + n(n(a) + b) + n(b + c) + c) + c) = n(b + c)
mann_49  n(n(n(n(n(n(a) + b) + a + b + b) + n(n(a) + b) + n(b + c) + c) + c + d) + n(n(b + c) + d)) = d
mann_50  n(n(n(n(a + a + a) + a) + n(a + a + a)) + n(n(n(a + a + a) + a) + (a + a + a + a + a))) = n(n(a + a + a) + a)
mann_51  n(n(n(a + a + a) + a) + (a + a + a + a + a)) = n(a + a + a)
mann_52  n(n(n(n(a + a + a) + a) + n(a + a + a) + (a + a)) + n(a + a + a)) = n(n(a + a + a) + a) + (a + a)
mann_53  n(n(n(a + a + a) + a) + n(a + a + a)) = a
mann_54  n(n(n(n(a + a + a) + a) + n(a + a + a) + b) + n(a + b)) = b
winker   n(n(a + a + a) + a) + (a + a) = a + a

Let us check that these are exactly the twelve equations from the EQP file. We count two equations as the same if, after renaming the variables (EQP writes \(x, y, z, u\), Mann \(a, b, c, d\)), they have the same normal form with respect to A1 and A2 — the normal form is the subject of the next part; for now it is enough that the function normal sorts the summands of sums.

from itertools import permutations
from kernel import subst, term_vars
from syntax import term, equation
from ac import normal

def te_same(r1, r2):
    """The same equations up to the names of variables, A1 and A2 (also with the sides swapped)."""
    (l1, p1), (l2, p2) = r1, r2
    z1 = sorted(term_vars(l1) | term_vars(p1))
    z2 = sorted(term_vars(l2) | term_vars(p2))
    if len(z1) != len(z2):
        return False
    goal = (normal(l2), normal(p2))
    for z in permutations(z2):
        s = dict(zip(z1, z))
        pair = (normal(subst(l1, s)), normal(subst(p1, s)))
        if pair == goal or pair[::-1] == goal:
            return True
    return False

counterparts = {}
for number in eqp_steps["eqp-lemma3.proof.txt"]:
    r_eqp = equation(lines[number][1])
    names = [name for name, formula in STATEMENTS.items() if te_same(r_eqp, equation(formula))]
    counterparts[number] = names
    print(number, "->", ", ".join(names) or "?", "  parents:", lines[number][0])
10 -> mann_44   parents: [7, 7]
11 -> mann_45   parents: [7, 7]
29 -> mann_46   parents: [11, 7]
54 -> mann_47   parents: [29, 7]
217 -> mann_48   parents: [54, 7]
674 -> mann_49   parents: [217, 7]
6736 -> mann_50   parents: [10, 674]
8855 -> mann_51   parents: [6736, 7, 54]
8865 -> mann_52   parents: [8855, 7]
8866 -> mann_53   parents: [8855, 7, 11]
8870 -> mann_54   parents: [8866, 7]
8871 -> winker   parents: [8870, 8865]

Every EQP equation has its lemma, and the order agrees: Mann’s proof is EQP’s proof written out as lemmas. EQP writes the Robbins equation as \(n(n(n(x) + y) + n(x + y)) = y\) — our R after swapping \(x \leftrightarrow y\) and reordering the summands:

r_eqp = equation(lines[7][1])
print(lines[7][1], "  the same as R:", te_same(r_eqp, equation("n(n(x + y) + n(x + n(y))) = x")))
n(n(n(x)+y)+n(x+y)) = y   the same as R: True

An EQP step in our kernel#

The first equation, para(7,7), is the Robbins equation substituted into itself. In mathlib the same lemma has a proof of three Lean tactics:

lemma mann_44 : -(-(-(a + b) + -a + b) + b) = -(a + b) := by
  nth_rw 2 [← robbins (-(a + b)) (-a + b)]
  nth_rw 3 [← robbins b a]
  congr 2 <;> ac_rfl

(Excerpt from Archive/Robbins.lean, © 2026 Jeremy Tan, Apache 2.0 licence.) The first two lines are the creative part: twice we “expand” an expression with the Robbins equation from right to left — we replace \(x\) by \(n(n(x + y) + n(x + n(y)))\) — and we have to choose well where and with which \(y\). The third line is bookkeeping: both sides are already equal up to the order of summands, and ac_rfl checks it. Our module robbins has the same tactics — except that each of them leaves behind an ordinary proof made of the five kernel rules:

from robbins import theory, Goal, nodes
from syntax import show_equation

K = theory()
g = Goal(K, STATEMENTS["mann_44"])
g.nth_rw(2, "← R (n(a + b)) (n(a) + b)")
print("after the 1st expansion:", g)
g.nth_rw(3, "← R b a")
print("after the 2nd expansion:", g)
g.ac()
proof = g.qed()
print("the kernel accepts:", show_equation(K.conclusion(proof)), "| proof nodes:", nodes(proof))
after the 1st expansion: n(n(n(a + b) + n(a) + b) + b) = n(n(n(a + b) + (n(a) + b)) + n(n(a + b) + n(n(a) + b)))
after the 2nd expansion: n(n(n(a + b) + n(a) + b) + n(n(b + a) + n(b + n(a)))) = n(n(n(a + b) + (n(a) + b)) + n(n(a + b) + n(n(a) + b)))
the kernel accepts: n(n(n(a + b) + n(a) + b) + b) = n(a + b) | proof nodes: 48

The script has three tactics, and the proof the kernel gets has 48 nodes (rule applications). Most of them are the work of ac: swaps of neighbouring summands, each written as an Inst of axiom A1 or A2, put into the context by CongrArg and joined by Trans. In EQP this bookkeeping is not visible at all — the program has associativity and commutativity built into unification.

The whole stage 1 of the proof — twelve lemmas, from mann_44 to Winker’s condition — is written in the function winker_by_hand. Each lemma is a few tactic calls, just as in mathlib:

from robbins_proof import winker_by_hand
import inspect

print(inspect.getsource(winker_by_hand))
def winker_by_hand(K):
    """Stage 1 as in mathlib: every creative step written out."""
    def prove(name, *script):
        lemma(K, name, STATEMENTS[name],
              lambda g: [step(g) for step in script])

    prove("mann_44", lambda g: g.nth_rw(2, "← R (n(a + b)) (n(a) + b)"),
          lambda g: g.nth_rw(3, "← R b a"), lambda g: g.ac())
    prove("mann_45", lambda g: g.nth_rw(2, "← R (n(n(a) + b)) (a + b)"),
          lambda g: g.nth_rw(3, "← R b a"), lambda g: g.ac())
    prove("mann_46",
          lambda g: g.rw("← R b (n(n(a) + b) + a + b)", side="rhs"),
          lambda g: g.nth_rw(2, "← mann_45 a b"), lambda g: g.ac())
    prove("mann_47", lambda g: g.nth_rw(3, f"← R c ({W})"),
          lambda g: g.rw("mann_46 a b"), lambda g: g.ac())
    prove("mann_48",
          lambda g: g.rw(f"← R (n(b + c)) ({W} + c)", side="rhs"),
          lambda g: g.rw_ac("mann_47 a b c"), lambda g: g.ac())
    prove("mann_49", lambda g: g.nth_rw(3, f"← R d ({W2})"),
          lambda g: g.rw("mann_48 a b c"), lambda g: g.ac())
    winker_rest(K)

Running it adds twelve theorems to the kernel. For each we show how many nodes the proof checked by the kernel has (a use of an earlier lemma counts once) and which assumptions it uses.

from robbins import lemma
import time

K = theory()
start = time.perf_counter()
winker_by_hand(K)
elapsed = time.perf_counter() - start
for name in STATEMENTS:
    print(f"{name:8} {nodes(K.proofs[name]):5} nodes   assumptions: {sorted(K.assumptions[name])}")
sum_term = sum(nodes(K.proofs[n]) for n in STATEMENTS)
print(f"together {sum_term} nodes, {elapsed:.2f} s")
mann_44     48 nodes   assumptions: ['A1', 'A2', 'R']
mann_45     51 nodes   assumptions: ['A1', 'A2', 'R']
mann_46     94 nodes   assumptions: ['A1', 'A2', 'R']
mann_47     97 nodes   assumptions: ['A1', 'A2', 'R']
mann_48    231 nodes   assumptions: ['A1', 'A2', 'R']
mann_49    175 nodes   assumptions: ['A1', 'A2', 'R']
mann_50    437 nodes   assumptions: ['A1', 'A2', 'R']
mann_51    316 nodes   assumptions: ['A1', 'A2', 'R']
mann_52    203 nodes   assumptions: ['A1', 'A2', 'R']
mann_53    241 nodes   assumptions: ['A1', 'A2', 'R']
mann_54     45 nodes   assumptions: ['A1', 'A2', 'R']
winker     101 nodes   assumptions: ['A1', 'A2', 'R']
together 2039 nodes, 0.05 s

EQP’s twelve equations are twelve theorems of our kernel, each checked from the axioms A1, A2 and R only. The last one, winker, is condition 1: \(q + 2a = 2a\), that is \(C + D = C\) for \(C = 2a\) and \(D = q = n(n(3a) + a)\).

The same proof without built-in associativity#

EQP could not write its proof in a form another program could check. So McCune reproduced the proofs with the program Otter, in which associativity and commutativity are ordinary axioms. Otter prints the length of the proof at the top of the file; let us also count how many steps use the commutativity and associativity axioms directly (in Otter’s files these are the input lines x+y=y+x and (x+y)+z=x+y+z):

def read_otter(file):
    """(length according to Otter, steps with a justification, steps that use A1 or A2)."""
    content = (FOREIGN / "mccune" / file).read_text()
    length = int(re.search(r"Length of proof is (\d+)", content).group(1))
    lines = re.findall(r"^(\d+) \[(.*?)\] (.*)\.$", content, re.M)
    ac = {int(n) for n, uz, r in lines if not uz and r.replace(" ", "") in ("x+y=y+x", "(x+y)+z=x+y+z")}
    steps = [uz for n, uz, r in lines if uz]
    z_ac = [uz for uz in steps
            if ac & {int(x.split(".")[0]) for x in uz.split(",") if x[:1].isdigit()}]
    return length, len(steps), len(z_ac)


for file in ["otter-lemma3.proof.txt", "otter-theorem.proof.txt"]:
    length, steps, z_ac = read_otter(file)
    print(f"{file}: length {length}, steps with a justification {steps}, of these with A1 or A2: {z_ac}")
otter-lemma3.proof.txt: length 40, steps with a justification 41, of these with A1 or A2: 28
otter-theorem.proof.txt: length 34, steps with a justification 35, of these with A1 or A2: 20

The same condition 1 that EQP proves in 12 steps takes Otter 40, and 28 of the 41 lines with a justification use commutativity or associativity directly. The difference is exactly the bookkeeping: in EQP it sits in the unification algorithm, in Otter — in explicit steps, and with us — in the tactic ac.

This is the first lesson about compression. The shortest proof is short because the prover has well-chosen tools. EQP had a built-in “tactic” for associativity and commutativity, so its proof consists of creative steps only. Our kernel has no such tactic and does not need one: it is enough that the script has it, and the kernel checks everything this tactic wrote. In the next part we will see how to build such a tactic.

References and places worth a visit#

  • W. McCune, Solution of the Robbins Problem, Journal of Automated Reasoning 19(3), 263–276 (1997), DOI; Table I in §5. The EQP and Otter proofs: McCune’s page and the paper’s page.

  • A. L. Mann, A Complete Proof of the Robbins Conjecture (2003) — the original disappeared from the author’s page; copy in the Internet Archive.

  • J. Tan, Archive/Robbins.lean in the mathlib library (2026, Apache 2.0) — a formalization in Lean 4, following the Isabelle version of M. Wampler-Doty (2010, BSD licence).

  • S. Winker, Robbins algebra: Conditions that make a near-Boolean algebra Boolean, Journal of Automated Reasoning 6(4), 465–489 (1990), DOI.