LeanBET: Formally-verified surface area calculations in Lean

Ejike D. Ugwuanyi, Colin T. Jones, John Velkey, Tyler R. Josephson · 2026

Read LeanBET: Formally-verified surface area calculations in Lean by Ejike D. Ugwuanyi, Colin T. Jones, John Velkey, Tyler R. Josephson (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2605-16169.txt.

Introduction

Ugwuanyi and three colleagues present LeanBET, a runnable and formally checked BET surface-area pipeline in the Lean 4 prover. Real-world BET code runs many steps whose correctness is rarely spelled out. Their checked version covers window listing, monotonicity checks, knee choice, and linear regression, with floating-point runs and proofs over the reals. Against the BETSI reference, LeanBET matches to machine precision on 18 of 19 isotherms, missing by only 0.03 percent on UiO-66.

Catalog record

CREATOREjike D. Ugwuanyi, Colin T. Jones, John Velkey, Tyler R. Josephson
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE46926
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2605.16169

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

LeanBET: Formally-verified surface area calculations in Lean Ejike D. Ugwuanyi, Colin T. Jones, John Velkey, Tyler R. Josephson Abstract The Brunauer–Emmett–Teller (BET) method is a standard tool for estimating surface areas from adsorption isotherms, yet practical implementations involve multiple algorithmic steps whose correctness is rarely made explicit. In this work, we present a fully executable and formally verified BET analysis pipeline implemented in the Lean 4 theorem prover. Our formalization covers the complete BET Surface Identification (BETSI)-style workflow, including window enumeration, monotonicity checks, knee selection, and linear regression. We carry out computations in floating-point arithmetic and develop the corresponding correctness proofs over the real numbers, using a shared polymorphic implementation that supports both. On the proof side, we show that the regression coefficients returned by the algorithm agree with their specification-level definitions and minimize the least-squares error under the stated assumptions. We also formalize the algebraic derivation of the BET linearized expression and connect that result directly to the executable analysis pipeline. We further prove that the window enumeration is sound and complete, and that the admissibility checks and knee-based selection satisfy their formal specifications. We evaluate the implementation against the BETSI reference method on benchmark adsorption isotherms. Compared to BETSI, LeanBET agrees to machine precision for 18 of the 19 isotherms, with only a 0.03% deviation for the UiO-66 dataset. This demonstrates that a scientific computing workflow can be built in Lean, yielding both formal verification guarantees and numerical agreement with an established Python reference implementation. Keywords: Formal verification, Lean 4, BET surface area, gas adsorption 1. Introduction Scientific computing often relies on mathematical models whose derivations are written on paper, while their implementations are carried out separately in software. This separation can make it difficult to verify that the final computation faithfully reflects the underlying theory. Formal verification provides a way to address this problem. It is a method of checking, with machine assistance, that a computation follows from clearly stated mathematical definitions and logical steps. By expressing both the mathematics and the computation in a form that can be checked mechanically, formal verification helps bridge the gap between theory and implementation. In this work, we use derivation as specification. The algebraic development of the BET adsorption equation is formalized and directly linked to an executable analysis pipeline. We demonstrate this approach to scientific computing by formalizing the theory behind Brunauer–Emmett–Teller Theory and its implementation in surface area calculations. The Brunauer–Emmett–Teller (BET) theory describes multilayer physical adsorption of gas molecules on solid surfaces and remains one of the most widely used frameworks for quantifying specific surface area from adsorption isotherms [ 5 ] . In practice, BET analysis is usually carried out by selecting a relative pressure range, fitting the linearized BET equation over that interval, and extracting the monolayer capacity and surface area from the resulting regression parameters. Although the method is standard, the final surface area can depend strongly on the chosen fitting range. As a result, BET calculations that begin from the same isotherm may still lead to different reported values, reducing reproducibility across users, laboratories, and software implementations [ 21 ] [ 15 ] . Despite its longevity and prevalence, BET surface area analysis has long been known to rest on a set of restrictive assumptions about adsorption behavior [ 1 ] . The BET model extends the Langmuir monolayer adsorption framework to multilayer adsorption, assuming uniform surface sites, non-interacting adsorbate layers beyond the first, and a constant enthalpy of adsorption for layers above the monolayer [ 5 ] . These assumptions only hold approximately for many real materials, and the BET plot often exhibits linearity over a narrow and sometimes ambiguous relative-pressure range; hence, selecting an appropriate fitting region has become a central practical challenge in BET analysis [ 8 ] . To mitigate this ambiguity, a set of consistency criteria frequently attributed to Rouquerol and co-workers and adopted in practice has been used to help identify valid regions of linearity in BET plots and to exclude unphysical solutions such as negative monolayer capacities. These criteria include requiring a positive BET constant C , a monotonically increasing n(1-P/P_{0}) term over the selected range, and that the calculated monolayer coverage corresponds to a relative pressure within that range [ 17 ] . However, even when such criteria are applied, additional subjectivity remains, because multiple relative pressure intervals may satisfy the same consistency rules. This leaves the lower and upper bounds of the fitting range unspecified, leading to variability in reported BET areas. This subjectivity has profound consequences. In a recent round-robin study involving 61 laboratories and a shared set of high-quality adsorption isotherms, Osterrieth et al. demonstrated that BET surface areas calculated from the same data varied widely across laboratories, even when most participants reported using the consistency criteria in their analysis [ 15 ] . For some materials, the highest and lowest reported BET areas differed by more than a factor of five, highlighting that reproducibility issues arise not from experimental measurement alone, but also the fitting algorithms and human choices used to interpret that data. To address this reproducibility crisis, Osterrieth et al. introduced BET Surface Identification (BETSI), a Python-based computational framework that exhaustively enumerates all consecutive fitting windows on an isotherm, applies ordinary least-squares regression to each, and filters the resulting candidates using the Rouquerol criteria to produce an unambiguous BET area assignment [ 15 ] . While BETSI substantially reduces the subjectivity associated with manual fitting, it remains a numerical algorithm implemented in general-purpose software, leaving open the possibility of hidden implementation assumptions or subtle errors that could compromise its scientific guarantees. In this work, we present a different approach to BETSI-style analysis. Figure 1 provides a schematic overview of the formally verified BET analysis pipeline, illustrating how each executable transformation is justified by a corresponding mathematical proof. Rather than focusing solely on numerical performance or agreement with reference values, we develop a verified BETSI implementation in which correctness properties are formally specified and mechanically verified. The algorithm is implemented in Lean 4 which is both a programming language and theorem proving system that allows executable code and mathematical proofs to be written in the same environment [ 14 ] . When the algorithm returns a BET fit, Lean provides a machine-checked proof that the result satisfies the BETSI criteria as mathematically defined. The central contribution of this paper is therefore not a new BET algorithm, but a formally verified guarantee of correctness. The implementation is designed to be polymorphic, supporting efficient execution using floating-point arithmetic while enabling proofs over the real numbers. By separating computation from specification and proving soundness of the executable checks, we demonstrate how formal methods can be applied to a classical problem in adsorption science without sacrificing practical usability. Figure 1 : Overview of the formally verified BET analysis pipeline. The executable algorithm (top row) transforms adsorption data through BET linearization, windowed linear regression, and BETSI-style filtering to compute surface area and error metrics. Each computational step is paired with a corresponding formal proof (bottom blocks) establishing algebraic correctness of the BET linearization, least-squares optimality of linear regression, and soundness of the selection criteria. Numerical results are finally compared against the BETSI reference implementation. The

Read the complete text