arXiv:2609.07097cs.LOSep 2026

Manuscript Offprint

arXiv:2609.07097

Optimising Metamath Proofs for Human Working Memory

Jeremy Lindsay, Cezary Kaliszyk, Christine Rizkallah

Jeremy Lindsay, Cezary Kaliszyk, and Christine Rizkallah

University of Melbourne, Australia

jeremy.n.lindsay@student.unimelb.edu.au

cezary.kaliszyk@unimelb.edu.au

christine.rizkallah@unimelb.edu.au

Abstract. Mathematical proofs vary in legibility. While most proof optimisation techniques seek to minimise proof size, the strategic reordering of inferences can reduce the working memory demand of proof checking without altering overall size. Metamath serves as a prime case study for this approach: its verification architecture requires proof steps to be ordered in a manner that prioritises algorithmic efficiency over readability. In this paper, we introduce algorithms to minimise both peak and cumulative memory consumption, applying the latter as a novel proxy for sustained human cognitive effort. We achieve this by representing proofs as directed acyclic graphs and modelling their execution as a pebbling game. Finding an optimal ordering via brute force is computationally infeasible, so we use heuristics to provide approximations. We apply these algorithms across Metamath's ZFC set theory library and present case studies demonstrating how automated reordering systematically improves the presentation of formal mathematics.

Keywords: Metamath · Proof reordering · Working memory · Pebbling games · Legibility · Cumulative cost · Set.mm

1 Introduction

An important aspect of proof readability is the demand it places on a reader's working memory. Consider a mathematician presenting a proof on a chalkboard, writing down intermediate results and erasing them when they are no longer needed. The total amount of chalk used reflects the proof's length, and the size of the board limits the number of results that can be simultaneously retained for later reference. Yet, if even a small chalkboard is continuously cluttered with results awaiting later reference, the audience may become overwhelmed. We, therefore, prefer proofs that are not only short and space-efficient, but that also keep the running total of retained intermediate results low. In this paper, we introduce algorithms to reorder proof steps that minimise the latter two metrics, while preserving the proof length.

  • Submitted version. A revised version is to appear in CICM 2026, LNAI, Springer.

Formal mathematics libraries of proof assistants like Lean [14], Rocq [23], and Metamath [13], provide a natural setting for this problem. Their proofs have explicit dependency structure, so valid reorderings can be specified precisely rather than judged informally. The methods we present in this paper are general-purpose and require only abstract graph-based representations of proof structure. Nevertheless, we perform our experiments on Metamath proofs in particular, for a few reasons. First, Metamath's syntax and verification mechanisms are simple, making it straightforward to export proofs into a graph format. Second, Metamath requires proof steps to be ordered in a highly specific manner that is optimised for verification rather than readability. By default, Metamath proof editors display proofs in this native format, though they allow steps to be reordered during the editing stage. Thus Metamath provides a clear testbed for studying whether automatic reordering can improve the presentation of formal proofs.

Our approach is as follows. We represent a proof as a directed acyclic graph (DAG) whose vertices are distinct inferences and edges represent logical dependencies. A traditional, sequential presentation of the proof is then a topological order on this DAG. To model memory demand as the proof is followed step by step, we use the formalism of pebbling games. It has been shown for a variety of metrics that brute force methods for computing an optimal topological order are infeasible in practice [5,19,21]. We therefore turn to heuristic algorithms.

Our contributions are the following:

We formulate the problem of optimising proofs for sustained demand on working memory. This is captured by cumulative memory use across the proof, which we measure alongside the better-studied objective of minimising peak memory consumption.

We introduce metrics closely related to Karol Pák's legibility metrics [18,19], and show where our memory consumption metrics diverge.

We introduce a novel variant of the pebbling game that treats unpebbling as an automatic process, simplifying memory calculations as a result.

We develop heuristic reordering methods that combine ideas from Fellner and Paleo's greedy algorithm [5], Sethi-Ullman numbering [22], and other lightweight ordering criteria. We apply these algorithms to Metamath's ZFC set theory library set.mm, analyse the results, and present case studies.

More broadly, this contributes towards improving proof legibility for humans, a problem that is likely to become more important as LLM-based proof generation and proof transformation become more common [6,25,27].

References (26)