3.5. Deep dives#

In the lecture several topics were only announced — on the slides marked 🤿. Here we develop them. The longest part is about the Robbins problem: we will find all small Robbins algebras and then run the proof that the program EQP found in 1996 through our kernel. The shorter parts are about bound variables and de Bruijn indices, completeness of equational logic and truth tables, associativity from Huntington’s axioms, and Lean’s kernel. The exercises are at the end; the marks ★, ★★ and ★★★ have the same meaning as in the lab problem sets.

We use the same files as the previous sections: kernel.py, syntax.py, tactics.py and boolean.py. The part on the Robbins problem also uses the code of the Boole Lab (lab.py, library.py, solver.py). To run this notebook yourself, save the files from the Boole Lab code page in the same folder as the notebook.

3.5.1. The Robbins problem#

In §3.4 the Robbins problem was an example of a division of roles: a large program searches for a proof, and a small one checks it. Here we look at the mathematics itself: what exactly Robbins asked, what EQP proved, and which steps make up the whole proof. Then we find all Robbins algebras with at most nine elements, check Winker’s conditions in them, and see how to write a step of a computer-found proof with the five rules of our kernel.

3.5.1.1. Huntington’s axioms of 1933#

In the lecture, Boolean algebra was described by the eight axioms H1–H8 that E. V. Huntington gave in 1904. In 1933 Huntington showed that three equations suffice, for one binary operation \(+\) and one unary operation \(n\) (the complement):

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

The third equation is called the Huntington equation. We write it as McCune does; our parser uses the same notation. The product and the constants need not be taken as primitive operations, because they can be defined: \(x \cdot y = n(n(x) + n(y))\) (De Morgan’s law), \(1 = x + n(x)\) and \(0 = n(1)\). Along the way one has to prove that \(x + n(x)\) does not depend on \(x\).

Where does such an equation come from? In a Boolean algebra \(n(n(x) + y) = x \cdot n(y)\) and \(n(n(x) + n(y)) = x \cdot y\), so the Huntington equation says that \(x = x \cdot n(y) + x \cdot y\): the element \(x\) splits into the part lying outside \(y\) and the part lying inside \(y\).

3.5.1.2. Robbins’s question#

Soon afterwards Herbert Robbins asked whether the Huntington equation can be replaced by the Robbins equation

\[ n(n(x + y) + n(x + n(y))) = x. \]

A set with operations \(+\) and \(n\) in which \(+\) is commutative and associative and the Robbins equation holds is called a Robbins algebra. The Robbins problem reads: is every Robbins algebra a Boolean algebra? Equivalently: does the Huntington equation follow from commutativity, associativity and the Robbins equation?

The Robbins equation also has a simple interpretation in a Boolean algebra. We have \(n(x + y) = n(x) \cdot n(y)\) and \(n(x + n(y)) = n(x) \cdot y\), so inside there is \(n(x) \cdot n(y) + n(x) \cdot y = n(x)\), and outside \(n(n(x)) = x\). It is the same splitting as Huntington’s, only applied to \(n(x)\). The two equations differ only in where the complements stand, and yet the answer took more than sixty years.

3.5.1.3. The easy direction#

Every Boolean algebra is a Robbins algebra and satisfies the Huntington equation; this follows from the computation above. Let us check both equations in the algebras of subsets of sets with 1, 2 and 3 elements (we write subsets as bit masks, as in §3.4). This time we write the functions more generally: a model is a dictionary that assigns operations and elements to the symbols +, *, n, 0 and 1. For comparison we add an equation in which one complement has been moved.

from itertools import product

from kernel import term_vars
from syntax import equation, show, show_equation


def value(t, v, model):
    """The value of t under the valuation v in a model (dict of operations)."""
    if isinstance(t, str):
        return model[t] if t in model else v[t]
    return model[t[0]](*(value(a, v, model) for a in t[1:]))


def counterexample(text, model, elements):
    """A valuation under which the equation fails, or None."""
    l, r = equation(text)
    xs = sorted(term_vars(l) | term_vars(r))
    for values in product(elements, repeat=len(xs)):
        v = dict(zip(xs, values))
        if value(l, v, model) != value(r, v, model):
            return v
    return None


def subsets(k):
    """The algebra of subsets of a k-element set (subsets as bit masks)."""
    full = 2**k - 1
    return {"+": lambda a, b: a | b, "*": lambda a, b: a & b,
            "n": lambda a: full & ~a, "0": 0, "1": full}


HUNTINGTON = "n(n(x) + y) + n(n(x) + n(y)) = x"
ROBBINS = "n(n(x + y) + n(x + n(y))) = x"
OTHER = "n(n(x + y) + n(n(x) + y)) = x"

def verdict(v):
    """None -> “holds”, a valuation -> a counterexample."""
    if v is None:
        return "holds"
    return "no: " + ", ".join(f"{z} = {w}" for z, w in v.items())


results_a = {}
for text in [HUNTINGTON, ROBBINS, OTHER]:
    results_a[text] = [counterexample(text, subsets(k), range(2**k))
                       for k in (1, 2, 3)]
    print(text)
    print("   k = 1, 2, 3:", " | ".join(map(verdict, results_a[text])))
n(n(x) + y) + n(n(x) + n(y)) = x
   k = 1, 2, 3: holds | holds | holds
n(n(x + y) + n(x + n(y))) = x
   k = 1, 2, 3: holds | holds | holds
n(n(x + y) + n(n(x) + y)) = x
   k = 1, 2, 3: no: x = 0, y = 1 | no: x = 0, y = 1 | no: x = 0, y = 1

Both equations hold, and the third one fails already in the algebra \(\{0, 1\}\): for \(x = 0\) and \(y = 1\) its left-hand side equals \(y\), not \(x\). Indeed, in a Boolean algebra \(n(x + y) + n(n(x) + y) = n(x) \cdot n(y) + x \cdot n(y) = n(y)\), so the left-hand side is always \(y\).

In Boolean algebras both equations can also be proved from the axioms H1–H8, and in our kernel at that. The library of the lab Boole Lab contains both theorems with full proofs — tactic scripts that the kernel checks every time the lab starts:

from lab import Session
from syntax import show_equation, size

lab = Session("en")      # a kernel with H1–H8 and the whole Boole Lab library
for name in ("huntington", "robbins"):
    _, l, r = lab.kernel.facts[name]
    assumed = " ".join(sorted(lab.kernel.assumptions[name]))
    print(f"{name:11} {show_equation((l, r))}")
    print(f"{'':11} proof tree: {size(lab.proofs[name])} nodes, assumptions: {assumed}")
huntington  n(n(x) + y) + n(n(x) + n(y)) = x
            proof tree: 19 nodes, assumptions: H1 H2 H3 H4 H5 H6 H7 H8
robbins     n(n(x + y) + n(x + n(y))) = x
            proof tree: 15 nodes, assumptions: H1 H2 H3 H4 H5 H6 H7 H8

For Boolean algebras such a check in models is decisive: an equation true in the algebra \(\{0, 1\}\) holds in every Boolean algebra (see Completeness and truth tables). For Robbins algebras there is no such shortcut — we do not know in advance what their models look like. That was the whole difficulty.

3.5.1.4. History: from Huntington to EQP#

  • The 1930s. Robbins and Huntington could not settle the question. Later Alfred Tarski and his students worked on it; the problem made its way into the monograph Cylindric Algebras (1971) by L. Henkin, J. D. Monk and A. Tarski.

  • 1979. Steve Winker learned of the problem from his advisor, J. Berman. Larry Wos of Argonne National Laboratory suggested that he look for additional conditions that turn a Robbins algebra into a Boolean algebra. Argonne’s programs easily showed that it suffices, for example, that \(n(n(x)) = x\) for all \(x\), that a zero exists (\(x + 0 = x\) for all \(x\)), or that \(x + x = x\) for all \(x\).

  • The 1980s. Winker proved by hand, using hints from computer searches, that much weaker conditions suffice, conditions that require the existence of one pair of elements:

    \[\begin{split} \begin{aligned} &\exists C\, \exists D\colon\ C + D = C && \text{(the first Winker condition)},\\ &\exists C\, \exists D\colon\ n(C + D) = n(C) && \text{(the second Winker condition)}. \end{aligned} \end{split}\]

    The papers appeared in 1990 and 1992. It remained to show that one of these conditions holds in every Robbins algebra.

  • October 10, 1996. The program EQP by William McCune of Argonne National Laboratory found a proof that every Robbins algebra satisfies the second Winker condition. EQP is a program for automated theorem proving in equational logic that treats commutativity and associativity in a special way (unification modulo AC). It argued by contradiction: to the Robbins equation it added the negation of the condition, that is, \(n(x + y) \ne n(x)\) for all \(x, y\), and derived new equations until it reached a contradiction. The search took about 8 days on an RS/6000 processor and used about 30 MB of memory.

  • Checking. EQP could not write the proof as an object that can be checked independently. EQP’s proof therefore served as a hint for another of McCune’s programs, Otter, in which commutativity and associativity were ordinary axioms. Otter built a proof object, and this object was checked by a separate, very simple program (running it required the Nqthm system); Winker’s lemmas were checked in the same way. According to the New York Times, the proof was also checked independently by Mark Stickel of SRI with his own program, and Stanley Burris checked it by hand and rewrote it as three pages of ordinary mathematics.

  • December 10, 1996. The news was reported by the New York Times (G. Kolata, Computer Math Proof Shows Reasoning Power). McCune phoned the 81-year-old Robbins, who replied: “Isn’t that marvelous. I’m glad I lived long enough to see it” (quoted from the NYT).

  • 1997. McCune’s article Solution of the Robbins Problem in the Journal of Automated Reasoning takes a shorter route: a second EQP search, started on November 15, 1996, gave a proof that every Robbins algebra satisfies the first Winker condition directly.

  • Later. B. I. Dahn (1998) published a revision of McCune’s computer proof in the Journal of Algebra, and A. L. Mann (2003) a complete proof in one notation, from the Robbins axioms to the axioms of Boolean algebra. The proof was formalized in proof assistants: in Mizar (A. Grabowski, University of Białystok, 2001), in Isabelle (M. Wampler-Doty, 2010, following Mann’s version) and in Lean 4 (J. Tan, the file Archive/Robbins.lean in Mathlib, 2026).

3.5.1.5. How the proof is built#

The whole proof is a chain of four steps and Huntington’s theorem. All the concrete elements (\(C\), \(D\), …) come from the Otter proofs that McCune published on his web page (see the literature at the end of this part).

  1. EQP (1996). In every Robbins algebra, for any element \(x\) the elements

    \[ C = n(n(x) + x) + x + x + x, \qquad D = n(n(x) + x) + x \]

    satisfy \(n(C + D) = n(C)\), that is, the second Winker condition.

  2. Winker’s lemma (from the second condition to the first). If \(n(C + D) = n(C)\), then the elements \(C' = n(n(C) + n(C))\) and \(D' = D + n(D + n(C))\) satisfy \(C' + D' = C'\), that is, the first Winker condition.

  3. Winker’s lemma (from the first condition to an idempotent element). If \(C + D = C\), then the element \(e = n(C + n(C))\) satisfies \(e + e = e\).

  4. Winker’s lemma (from an idempotent element to the Huntington equation). If some element of a Robbins algebra satisfies \(e + e = e\), then the Huntington equation holds (along the way, Otter’s proof derives \(n(n(x)) = x\)).

  5. Huntington’s theorem (1933). Commutativity, associativity and the Huntington equation give a Boolean algebra.

On McCune’s web page, steps 2, 3 and 4 are lemmas 2, 1 and 0: the numbering runs from the end of the chain.

In a Boolean algebra all these steps are trivial: \(n(n(x) + x) = n(1) = 0\), so \(C = x\) and \(D = x\). The whole difficulty is that the proof may not use the laws of Boolean algebra. About a Robbins algebra we know only what follows from the three equations.

3.5.1.6. Finite Robbins algebras#

Before we get to the proof, let us look for counterexamples: perhaps some small Robbins algebra is not a Boolean algebra? On the set \(A = \{0, 1, \dots, k-1\}\) we will systematically go through all possible tables of the operations.

First a simple observation that greatly reduces the search space. By the Robbins equation with \(y = x\), every element is a value of the function \(n\): \(x = n(n(x + x) + n(x + n(x)))\). So \(n\) is onto, and on a finite set an onto function is a bijection: \(n\) is a permutation of the set \(A\). If we renumber the elements by a bijection \(g\), the permutation \(n\) changes into \(g \circ n \circ g^{-1}\), that is, into a permutation of the same cycle type. Up to isomorphism it is therefore enough to consider one permutation of each type; for \(k = 4\) these are the types \((4)\), \((3, 1)\), \((2, 2)\), \((2, 1, 1)\) and \((1, 1, 1, 1)\).

For a fixed \(n\) we fill in the table of the operation \(+\) by backtracking: we write a value into the first empty cell and then add everything that follows from it. Commutativity makes the table symmetric. Associativity says that when we know \(a + b\), \(b + c\) and one side of the equation \((a + b) + c = a + (b + c)\), we know the other. The Robbins equation rewritten as \(n(x + y) + n(x + n(y)) = n^{-1}(x)\) determines one cell of the table when we know \(x + y\) and \(x + n(y)\). A contradiction ends the branch, and we undo its entries.

from itertools import permutations
from math import factorial


def cycle_types(k, largest=None):
    """Partitions of k (non-increasing parts): cycle types of permutations."""
    largest = largest or k
    if k == 0:
        yield ()
        return
    for c in range(min(k, largest), 0, -1):
        for rest in cycle_types(k - c, c):
            yield (c,) + rest


def permutation(cycle_type):
    """A permutation of the given type: cycles on 0, 1, 2, ... in turn."""
    sigma, first = [], 0
    for c in cycle_type:
        sigma += [first + (i + 1) % c for i in range(c)]
        first += c
    return sigma


def num_permutations(cycle_type):
    """The number of permutations of the type: k! / (product of c^m * m!)."""
    denominator = 1
    for c in set(cycle_type):
        m = cycle_type.count(c)
        denominator *= c**m * factorial(m)
    return factorial(sum(cycle_type)) // denominator


def robbins_tables(n):
    """All tables of + that give a Robbins algebra with the permutation n."""
    k = len(n)
    n_inv = [0] * k
    for i, ni in enumerate(n):
        n_inv[ni] = i
    T = [[-1] * k for _ in range(k)]           # -1: the cell is still empty
    results = []

    def put(a, b, v, trail):
        """T[a][b] = T[b][a] = v (commutativity); False on a contradiction."""
        if T[a][b] < 0:
            T[a][b] = T[b][a] = v
            trail.append((a, b))
            return True
        return T[a][b] == v

    def propagate(trail):
        """Fills in what the equations imply; False on a contradiction."""
        while True:
            before = len(trail)
            for x, y in product(range(k), repeat=2):
                s, t = T[x][y], T[x][n[y]]        # s = x + y, t = x + n(y)
                if s >= 0 and t >= 0:             # n(s) + n(t) = n⁻¹(x)
                    if not put(n[s], n[t], n_inv[x], trail):
                        return False
            for a, b in product(range(k), repeat=2):
                ab = T[a][b]
                if ab < 0:
                    continue
                for c in range(k):                # (a + b) + c = a + (b + c)
                    bc = T[b][c]
                    if bc < 0:
                        continue
                    if T[ab][c] >= 0 and not put(a, bc, T[ab][c], trail):
                        return False
                    if T[a][bc] >= 0 and not put(ab, c, T[a][bc], trail):
                        return False
            if len(trail) == before:
                return True

    def search():
        for a in range(k):
            for b in range(a, k):
                if T[a][b] < 0:                   # the first empty cell
                    for v in range(k):
                        trail = []
                        if put(a, b, v, trail) and propagate(trail):
                            search()
                        for p, q in trail:        # undo this branch
                            T[p][q] = T[q][p] = -1
                    return
        results.append(tuple(map(tuple, T)))      # the table is full

    search()
    return results


def iso_classes(tables, n):
    """The number of tables up to permutations g commuting with n."""
    k = len(n)
    centralizer = [g for g in permutations(range(k))
                   if all(g[n[i]] == n[g[i]] for i in range(k))]
    forms = set()
    for T in tables:
        variants = []
        for g in centralizer:
            T2 = [[0] * k for _ in range(k)]
            for a, b in product(range(k), repeat=2):
                T2[g[a]][g[b]] = g[T[a][b]]
            variants.append(tuple(map(tuple, T2)))
        forms.add(min(variants))
    return len(forms)


def model_from_table(T, n):
    """A model with Huntington's operations: x * y = n(n(x) + n(y)),
    1 = x + n(x) (if it does not depend on x) and 0 = n(1)."""
    ones = {T[x][n[x]] for x in range(len(n))}
    if len(ones) != 1:
        return None
    (one,) = ones
    return {"+": lambda a, b: T[a][b], "*": lambda a, b: n[T[n[a]][n[b]]],
            "n": lambda a: n[a], "0": n[one], "1": one}

The number of algebras on the set \(\{0, \dots, k-1\}\) (that is, with numbered elements) is a sum over types: the number of tables for the chosen permutation times the number of permutations of this type. Up to isomorphism we count tables that cannot be carried into one another by a permutation commuting with \(n\). In every algebra found we check the Robbins equation (a check of the search), the Huntington equation and the axioms H1–H8 from the file boolean.py for the operations defined as Huntington did.

import time

from boolean import AXIOMS

EQUATIONS = [ROBBINS, HUNTINGTON] + [text for _, text in AXIOMS]
counts, classes, examples, consistent = {}, {}, {}, {}
print(" k  types of n            algebras classes  Robbins, Huntington, H1–H8   "
      "time")
for k in range(1, 10):
    start = time.perf_counter()
    counts[k], classes[k], types, consistent[k] = 0, 0, [], True
    for cycle_type in cycle_types(k):
        n = permutation(cycle_type)
        tables = robbins_tables(n)
        if not tables:
            continue
        types.append(cycle_type)
        counts[k] += len(tables) * num_permutations(cycle_type)
        classes[k] += iso_classes(tables, n)
        examples[k] = (tables[0], n)
        for T in tables:
            model = model_from_table(T, n)
            consistent[k] = consistent[k] and model is not None and all(
                counterexample(text, model, range(k)) is None
                for text in EQUATIONS)
    elapsed = time.perf_counter() - start
    verdict = ("yes" if consistent[k] else "NO") if types else "—"
    print(f"{k:2}  {', '.join(map(str, types)) or '—':20} {counts[k]:9} "
          f"{classes[k]:7}  {verdict:28} {elapsed:.2f} s")
 k  types of n            algebras classes  Robbins, Huntington, H1–H8   time
 1  (1,)                         1       1  yes                          0.00 s
 2  (2,)                         2       1  yes                          0.00 s
 3  —                            0       0  —                            0.00 s
 4  (2, 2)                      12       1  yes                          0.00 s
 5  —                            0       0  —                            0.00 s
 6  —                            0       0  —                            0.02 s
 7  —                            0       0  —                            0.08 s
 8  (2, 2, 2, 2)              6720       1  yes                          1.02 s
 9  —                            0       0  —                            2.90 s

Robbins algebras with at most nine elements exist only for \(k = 1, 2, 4, 8\), and each of them is a Boolean algebra: with the operations defined as Huntington did, it satisfies the axioms H1–H8. For each such \(k\) there is one algebra up to isomorphism. The numbers of algebras with numbered elements are \((2^m)!/m!\) for \(k = 2^m\): for example \(6720 = 8!/3!\), because the elements of the algebra of subsets of a 3-element set can be numbered in \(8!\) ways, and each table is obtained exactly \(3!\) times (numberings that differ by an automorphism, that is, by a permutation of the three atoms). For \(k = 3, 5, 6, 7, 9\) there are no Robbins algebras at all.

3.5.1.7. Winker’s conditions in finite models#

In the algebras we found, Winker’s conditions hold with a wide margin. For each \(k\), let us count in one algebra the idempotent elements (\(x + x = x\)) and the pairs satisfying the first and the second Winker condition:

print(" k    idempotent  C + D = C  n(C + D) = n(C)")
winker = {}
for k, (T, n) in examples.items():
    E = range(k)
    idempotent = sum(T[x][x] == x for x in E)
    first_one = sum(T[c][d] == c for c in E for d in E)
    second_one = sum(n[T[c][d]] == n[c] for c in E for d in E)
    winker[k] = (idempotent, first_one, second_one)
    print(f"{k:2} {idempotent:13} {first_one:10} {second_one:16}")
 k    idempotent  C + D = C  n(C + D) = n(C)
 1             1          1                1
 2             2          3                3
 4             4          9                9
 8             8         27               27

In a Boolean algebra with \(2^m\) elements every element is idempotent, and there are \(3^m\) pairs with \(C + D = C\): these are the pairs \(D \subseteq C\), in which each of the \(m\) atoms lies in both sets, only in \(C\), or in neither. The two numbers of pairs are equal because \(n\) is one-to-one, so \(n(C + D) = n(C)\) simply means \(C + D = C\).

More important is that in every finite Robbins algebra an idempotent element exists — without any search.

Corollary

Every finite Robbins algebra is a Boolean algebra.

Proof. Take any element \(x\) and its multiples \(x\), \(2x = x + x\), \(3x\), … The set is finite, so \(ix = jx\) for some \(i < j\); let \(p = j - i\). Then \((i + p)x = jx = ix\), and after adding \((m - i)x\) to both sides, \((m + p)x = mx\) for every \(m > i\), so altogether for every \(m \ge i\). For \(m = ip\) (a number at least \(i\)) we have \(2m = m + ip\), so applying this equation \(i\) times we get \(mx + mx = (m + ip)x = mx\). The element \(e = mx\) is idempotent, so by Winker’s lemma (step 4) the algebra satisfies the Huntington equation, and by Huntington’s theorem (step 5) it is a Boolean algebra. \(\square\)

Therefore no search of finite models — neither ours nor a much larger one — could find a counterexample: if there were a Robbins algebra that is not a Boolean algebra, it would have to be infinite. The whole difficulty of the Robbins problem lay in infinite algebras.

3.5.1.8. A step of a computer proof in our kernel#

McCune published Otter proofs for EQP’s theorem and for the three Winker lemmas, that is, for steps 1–4. Each line of such a proof is one new equation with a justification, for example (a line from the proof of EQP’s theorem):

130 [para_into,93.1.1.1.2,73.1.1] n(n(n(n(x)+y)+x+y)+y)=n(n(x)+y).

This line says: equation no. 130 was obtained by paramodulation into equation no. 93 at position 1.1.1.2 (literal 1, the left-hand side, and in it the second summand of the sum under the outer \(n\)) using the left-hand side of equation no. 73. Paramodulation is our rw with one difference: variables may be substituted in both equations so that the pattern matches (unification instead of matching). In Otter \(+\) associates to the right: x+y+z means \(x + (y + z)\).

We can write each such step with the five rules: Inst gives the two equations used, with their variables substituted, CongrArg puts the rewriting into a context, and Symm and Trans glue everything together. A program that translates a whole Otter proof in this way, step by step, into theorems of our kernel is like a tactic: we do not have to trust it, because the kernel checks each of its theorems. Writing it is a good exercise (exercise 9).

3.5.1.9. Searching versus checking#

Let us compare the numbers. According to EQP’s log, the contradiction appeared after 678,232 s, that is, after 7.85 days of search. Otter, to which EQP’s proof suggested what to look for, needed 18.3 s for the proof of the theorem. Checking a ready-made proof object is then just a walk through the steps.

Why is checking so easy? Because an equational proof is just a chain of rewritings. A program that searches for a proof has to guess which equations to combine, where, and with which substitution. The number of possibilities grows exponentially, and EQP needed unification modulo commutativity and associativity, clever selection strategies and a bound on the size of equations. A program that checks gets all these decisions ready-made and only compares terms: each step is a few nodes Inst, CongrArg, Symm and Trans.

It is the same asymmetry as in §3.4, where our solver went through hundreds of thousands of terms to find a proof of the involution law that a human writes in nine steps. And the same one that made it possible to check the archive of the proof of the Riemann hypothesis, although nobody will read it in full.

3.5.1.10. Literature and further reading#

  • W. McCune, Robbins Algebras Are Boolean — the page with the EQP and Otter proofs, the proof object, the checking program and Winker’s lemmas; the proofs discussed in this part are there. The program EQP, together with its source code, is available without restrictions.

  • W. McCune, Solution of the Robbins Problem, Journal of Automated Reasoning 19(3), 263–276 (1997) (DOI); the proofs from the article are on a separate page.

  • E. V. Huntington, New sets of independent postulates for the algebra of logic, with special reference to Whitehead and Russell’s Principia Mathematica, Trans. AMS 35, 274–304 (1933) (DOI) and Boolean algebra. A correction, Trans. AMS 35, 557–558 (1933) (DOI).

  • S. Winker, Robbins algebra: Conditions that make a near-Boolean algebra Boolean, Journal of Automated Reasoning 6(4), 465–489 (1990) (DOI) and Absorption and idempotency criteria for a problem in near-Boolean algebras, Journal of Algebra 153(2), 414–423 (1992) (DOI).

  • B. I. Dahn, Robbins Algebras Are Boolean: A Revision of McCune’s Computer-Generated Solution of Robbins Problem, Journal of Algebra 208(2), 526–532 (1998) (DOI).

  • A. L. Mann, A Complete Proof of the Robbins Conjecture (2003) — a complete proof including Huntington’s theorem; the original has disappeared from the author’s web page, but there is a copy in the Internet Archive.

  • G. Kolata, Computer Math Proof Shows Reasoning Power, The New York Times, December 10, 1996; McCune added corrections (among other things, Tarski worked at Berkeley, not at Stanford).

  • Formalizations: A. Grabowski, Robbins Algebras vs. Boolean Algebras, Formalized Mathematics 9(4), 681–690 (2001) — Mizar; M. Wampler-Doty, A Complete Proof of the Robbins Conjecture, Archive of Formal Proofs (2010) — Isabelle; J. Tan, Archive/Robbins.lean in Mathlib (2026) — Lean 4.

3.5.2. Bound variables and de Bruijn indices#

In a logic with quantifiers and functions (\(\forall x\), \(\lambda x\)), substitution has to avoid bound variables. In the term fun y => x + y the variable y is bound and x is free. The naive substitution \(x := y\) gives fun y => y + y: the free y has been “captured”, and the term means something else (the function \(y \mapsto 2y\) instead of \(z \mapsto y + z\)). A correct substitution must first rename the bound variable.

In 1972 N. G. de Bruijn proposed a notation without names of bound variables: a bound variable is replaced by a number that says how many binders (fun, \(\forall\)) one has to pass going up the tree to reach its binder; \(0\) means the nearest one. Then fun y => x + y is λ. x + #0, and fun x => fun y => x is λ. λ. #1. A simple program:

from kernel import subst


def de_bruijn(t, binders=()):
    """A term with names -> de Bruijn notation; ("fun", x, t) is fun x => t."""
    if isinstance(t, str):
        return f"#{binders.index(t)}" if t in binders else t
    if t[0] == "fun":
        return ("λ", de_bruijn(t[2], (t[1],) + binders))
    return (t[0],) + tuple(de_bruijn(a, binders) for a in t[1:])


examples_db = {"fun y => x + y": ("fun", "y", ("+", "x", "y")),
               "fun x => fun y => x": ("fun", "x", ("fun", "y", "x")),
               "fun x => x": ("fun", "x", "x"),
               "fun y => y": ("fun", "y", "y")}
for text, t in examples_db.items():
    print(f"{text:20} -> {de_bruijn(t)}")

t = examples_db["fun y => x + y"]
print("substitution x := y, naive:     ", subst(t, {"x": "y"}))
print("substitution x := y, de Bruijn: ", subst(de_bruijn(t), {"x": "y"}))
fun y => x + y       -> ('λ', ('+', 'x', '#0'))
fun x => fun y => x  -> ('λ', ('λ', '#1'))
fun x => x           -> ('λ', '#0')
fun y => y           -> ('λ', '#0')
substitution x := y, naive:      ('fun', 'y', ('+', 'y', 'y'))
substitution x := y, de Bruijn:  ('λ', ('+', 'y', '#0'))

The terms fun x => x and fun y => y, which differ only in the name of the bound variable, have the same notation λ. #0. Comparing terms — for example the middle terms in the rule Trans — is therefore again an ordinary comparison of trees, as in our kernel. Substitution cannot capture anything, because a bound variable has no name. The price: when we substitute a term that itself contains indices, the indices have to be shifted; this is the most delicate place of kernels with binders.

This is how Lean’s kernel writes terms: the constructor Expr.bvar stores exactly a de Bruijn index. In Lean’s documentation (the file Expr.lean) the term fun x : Nat => ∀ y : Nat, x = y contains bvar 1 in place of x and bvar 0 in place of y. We cite de Bruijn’s paper as: N. G. de Bruijn, Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church–Rosser theorem, Indagationes Mathematicae 75(5), 381–392 (1972) (DOI).

3.5.3. Completeness and truth tables#

The soundness theorem from §3.4 says that the kernel accepts only equations true in all models. The converse implication is given by Birkhoff’s theorem (1935): if an equation \(s = t\) holds in every model of a set of equations \(E\), then it can be derived from \(E\) with our five rules.

Proof sketch (the term model). Write \(s \sim t\) when the equation \(s = t\) has a proof from \(E\). The rules Refl, Symm and Trans say that \(\sim\) is an equivalence relation, and CongrArg that it is compatible with the operations. The equivalence classes of terms therefore form an algebra: we compute an operation on classes using representatives. This algebra is a model of \(E\). If a valuation assigns to a variable \(x\) the class of a term \(t_x\), then the value of a term \(u\) is the class of the term \(u[x := t_x]\) (induction on \(u\)), and for an axiom \(l = r\) we have \(l[x := t_x] \sim r[x := t_x]\) by the rule Inst. So if \(s = t\) holds in all models of \(E\), it also holds in this one, under the valuation \(x \mapsto [x]\). The values are the classes \([s]\) and \([t]\), so \(s \sim t\), that is, a proof exists. \(\square\)

For Boolean algebras, moreover, it suffices to check one model: an equation true in the algebra \(\{0, 1\}\) holds in every Boolean algebra. In the algebra of subsets of a set \(X\) the operations are computed “point by point”: a point \(a \in X\) belongs to the value of a term exactly when the computation in \(\{0, 1\}\) gives \(1\) under the valuation “does \(a\) belong to \(v(x)\)”. Stone’s theorem (1936) says that every Boolean algebra is isomorphic to a subalgebra of the algebra of subsets of some set, and a subalgebra inherits equations. A truth table therefore decides whether an equation is a theorem of Boolean algebras:

zero_one = subsets(1)                               # the algebra {0, 1}
for text in ["x * (y + z) = x * y + x * z", "n(x + y) = n(x) * n(y)",
             "x + y * z = (x + y) * z"]:
    v = counterexample(text, zero_one, range(2))
    print(f"{text:28}", "true" if v is None else f"false, e.g. {v}")
x * (y + z) = x * y + x * z  true
n(x + y) = n(x) * n(y)       true
x + y * z = (x + y) * z      false, e.g. {'x': 1, 'y': 0, 'z': 0}

The truth table tells us that a proof exists, but does not give it: the kernel will not accept it. To get a proof tree one has to write a tactic that builds it, for example by reducing both sides to a normal form (exercise 11). The Robbins problem shows that sometimes already the question whether a proof exists is hard: for Robbins algebras it was not known in advance what their models are, so a truth table gave nothing.

Sources: G. Birkhoff, On the Structure of Abstract Algebras, Proc. Cambridge Philos. Soc. 31(4), 433–454 (1935) (DOI); M. H. Stone, The theory of representations for Boolean algebras, Trans. AMS 40(1), 37–111 (1936) (DOI).

3.5.4. Associativity from Huntington’s axioms#

Associativity is not among the axioms H1–H8 of 1904. Associativity \(x + (y + z) = (x + y) + z\) follows from them, but its proof is long. In Huntington’s system of 1933 associativity is an axiom — different systems of axioms differ in what we get for free and what has to be proved. With a small size bound our solver does not find a proof:

from boolean import theory
from tactics import search

H = [f"H{i}" for i in range(1, 9)]
j0 = theory()

d, examined = search(j0, "x + (y + z) = (x + y) + z", H, max_size=9)
print("proof found:", d is not None, "| terms examined:", examined)
proof found: False | terms examined: 2664

The classical proof avoids blind search thanks to the cancellation lemma: if \(a \cdot x = b \cdot x\) and \(a \cdot n(x) = b \cdot n(x)\), then \(a = b\), because

\[ a = a \cdot (x + n(x)) = a \cdot x + a \cdot n(x) = b \cdot x + b \cdot n(x) = b \cdot (x + n(x)) = b. \]

For \(a = x + (y + z)\) and \(b = (x + y) + z\) both products with \(x\) equal \(x\) (by idempotence and absorption), and both products with \(n(x)\) equal \(y \cdot n(x) + z \cdot n(x)\) (by distributivity and \(x \cdot n(x) = 0\)). Writing this down in our kernel is exercise 10.

3.5.5. Lean’s kernel#

Lean’s logic is a dependent type theory: proofs are terms, theorems are their types, and the kernel checks types. In doing so the kernel has to compute: two terms that reduce to the same thing (for example after unfolding definitions) are equal for it — this is the so-called definitional equality. It also has bound variables (de Bruijn indices), inductive types and universes. That is why Lean’s kernel is much larger than ours; it is written in C++ (the directory src/kernel in Lean’s repository, among others the file type_checker.cpp).

The principle, however, is the same: the kernel searches for nothing. Lean’s tactics build proof terms just as our rw and calc build trees. A proof can be exported to a text file with the program lean4export and checked by another program. Independent implementations of the kernel are NanoDA (C. Bailey, in Rust) and lean4lean (M. Carneiro, written in Lean itself). The proof of the Riemann hypothesis was accepted both by Lean’s kernel and by NanoDA (§3.4).

The Robbins problem is already in Lean too: the file Archive/Robbins.lean in Mathlib (J. Tan, 2026) derives the Huntington equation from the Robbins axioms and then builds from a Robbins algebra a Boolean algebra in the sense of Mathlib (BooleanAlgebra). In doing so it follows the formalization in Isabelle (AFP, 2010), which in turn follows Mann’s paper.

3.5.6. Exercises#

  1. ★ Check by hand that in the algebra \(\{0, 1\}\) with the operation \(x + y = \max(x, y)\) and \(n(x) = 1 - x\) the Robbins equation holds (four valuations). Does it also hold for \(x + y = \min(x, y)\)? Why is this not a coincidence?

  2. ★ Prove that in every Robbins algebra the function \(n\) is onto, and in a finite one also one-to-one. Does it follow that \(n(n(x)) = x\)? Give a permutation of the set \(\{0, 1, 2\}\) that does not satisfy this equation.

  3. ★ Open the file Archive/Robbins.lean in Mathlib. How is the Robbins equation written there, and how does this notation differ from ours?

  4. ★★ Prove in detail the fact used in the proof of the corollary: in a finite commutative semigroup every element has an idempotent multiple. Check it with a program for multiplication modulo \(12\): for each \(x\) find the smallest \(m \ge 1\) for which \(x^m\) is an idempotent.

  5. ★★ Show that in a Huntington algebra \(n\) is one-to-one (hint: the left-hand side of the Huntington equation depends on \(x\) only through \(n(x)\)). Change the function robbins_tables so that it searches for Huntington algebras, and compare their numbers with the numbers of Robbins algebras for \(k \le 8\).

  6. ★★ Remove associativity from the function robbins_tables (keep commutativity and the Robbins equation). How many tables do you find for \(k = 3, 4, 5\)? Does any of them satisfy the Huntington equation?

  7. ★★ Write step 130 of the Otter proof quoted above with the five rules of our kernel: write out equations 93 and 73 from McCune’s page, point out the substitutions, the context and the places where Symm and Trans are needed. How many nodes does this tree have?

  8. ★★ Write a function inverse to de_bruijn: from the notation with indices make a term with names, inventing fresh names for the bound variables. Check that composing the two functions does not change the de Bruijn notation of the examples from this part.

  9. ★★★ Write a replayer for Otter proofs: a program that translates every line of a proof (paramodulation, demodulation by associativity, swapping sides) into a theorem of our kernel. Download the proofs of Winker’s lemmas from McCune’s page and check them in a kernel whose only axioms are commutativity, associativity and the Robbins equation. Which assumptions does assumptions list for the last theorem?

  10. ★★★ Prove in our kernel associativity \(x + (y + z) = (x + y) + z\) from the axioms H1–H8, using the cancellation lemma for the concrete terms \(a = x + (y + z)\) and \(b = (x + y) + z\). Why can the cancellation lemma not be written as a single theorem in our logic?

  11. ★★★ Write a tactic that, for an equation true in the algebra \(\{0, 1\}\), builds a proof from the axioms H1–H8 (for example by reducing both sides to a sum of products of all variables or their complements). Test it on the Robbins equation.