Each example is a program with its specification, Lean proofs about both, compiled forms of the program, and records of runs. A linked heading leads to the example's guide in the leanexe repository, which states the theorems, their premises, and the commands that run it.
Developing these examples added 50 entries to the internal verification knowledge base (VKB), which every development session consults. A review decided on each entry before it entered the VKB. The work found nine leanexe issues, which are fixed and merged along with leanexe's move to Lean v4.34.1, and filed thirteen more, each with a reproduction. It also filed four issues on Lean and one request to Batteries, and a port of leanexe to Lean v4.36.0 builds all 3,200 library modules and is under test.
Seven examples use theorems that OpenAI proved in Lean and published in 2026 in its math repository: Certified residual reduction for linear systems, Persistence of reaction networks, Bound-state energies of layered potentials, Classical capacity of a decaying qubit, Second neighborhoods in oriented graphs, Least energy of point arrangements in the plane, and Winning moves in the Snaky game. Each of these programs computes or checks the conditions of such a theorem, and Lean proofs connect the compiled code through that check to the theorem.
The program computes the two-dimensional probability of collision of two space objects at a close approach, the number that satellite operators use to decide on avoidance maneuvers. The program returns an interval, and the soundness theorem states that the interval contains the exact value of the model's integral for the real values of the inputs, so a verdict against a threshold is a statement about that exact value. A second version of the program accepts the objects' states and covariances from a conjunction data message and projects them onto the encounter plane in interval arithmetic. The compiled module agrees with native Lean bit for bit on 1,174 generated calls, and a reference value computed to 50 digits lies inside the interval in each of 69 test runs.
For each ten-second slice of a satellite pass, this program decides whether a ground station sees the satellite at or above a minimum elevation angle. It takes ranges rather than single values: a box that holds every position the satellite occupies during the slice, and ranges for the station's position, its local vertical, and the sine of the minimum angle. With arithmetic that rounds every result outward, it computes a range for how far the satellite stands above the minimum angle and answers guaranteed, excluded, or undecided.
Proofs checked by the Lean proof assistant show that a guaranteed answer holds for every combination of values in the ranges and that an excluded answer fails for every one of them. The proofs cover the WebAssembly code that leanexe's verified compiler produces from the program. They assume that the ranges contain the true values, which the program cannot check, and that the WebAssembly engine follows the standard.
The same program also runs as C code that the CompCert verified compiler turns into machine code, as a function called by an ordinary program on a PC and as a whole program on a 64-bit ARM processor without an operating system, and the proofs extend to the C code of both. For the ARM processor they cover the whole program, from reading the cells to writing their classes. The proofs of the C code assume that CompCert's proofs hold and that leanexe's Lean copy of CompCert's C semantics is faithful, and on the ARM processor also that the emulated processor and its devices work as documented.
A ground station is booked in reservations, and after each one it needs a setup time before the next can begin. This program checks a schedule against the ten-second cells of a satellite pass, which a verified classifier has marked as guaranteed visible, excluded, or undecided. It accepts a reservation only when every instant of it falls in a guaranteed cell, and the schedule only when no reservation, extended by its setup time, overlaps another.
Proofs checked by the Lean proof assistant show that during an accepted reservation the satellite stands at or above the elevation mask for every position that the cells' ranges allow, and that an accepted schedule has no overlap. They also show that a reservation that starts before it ends is rejected only when it reaches an instant that no guaranteed cell covers. The proofs cover the WebAssembly code that leanexe's verified compiler produces, and they assume that the cells' ranges hold the true positions and that the WebAssembly engine follows the standard.
The same program also runs as C code that the CompCert verified compiler turns into machine code for a PC, called by an ordinary program. The C form handles up to 65,536 cells and 65,536 reservations in a memory of 16 MiB. The proofs extend to one call of the C function under the assumptions that CompCert's proofs hold and that leanexe's Lean copy of CompCert's C semantics is faithful.
A satellite's position is never known exactly, and the forces on it are known only approximately. The program checks a short arc of a satellite's orbit: an untrusted propagator supplies polynomial segments of 60 s that approximate the orbit, and the program bounds the polynomials' residual against two-body gravity with Earth's oblateness (J2) and a bounded disturbance, bounds how fast that force changes on boxes around the path, and certifies on each segment an envelope of the error that grows with time. It returns a tube around the path.
Proofs checked by the Lean proof assistant show that every solution of the equations of motion that starts in the initial box, under every disturbance within its bound and every value of the uncertain constants, stays inside the tube for the whole arc, and that such solutions exist. The visibility and reservation examples assume that a supplied box contains the satellite's position, and a tube can supply that box with a proof. The proofs cover the WebAssembly code that leanexe's verified compiler produces. On five test orbits under four uncertainty budgets, the checker accepts all 40 arcs of 10 and 30 minutes, and the tube's half-width at the end of an arc is at most 2.72 times that of the narrowest possible box at 10 minutes and at most 3.27 times at 30 minutes.
Three programs use the tubes. One proves that two satellites' tubes stay at least a chosen distance apart over a time window, names a moment when their predicted paths come closer, or reports that it cannot decide; the answer is a statement about the model, not a collision probability. The second bounds how far a satellite can stray from a simple ellipse over a window, the margin that older screening tools assume. The third follows a satellite through an engine burn whose start and stop times are uncertain: it splits the arc at every bound of the switching times and encloses both the burning and the coasting motion in each uncertain interval, so the tube covers every allowed switching time. Proofs checked by Lean show each of these claims for the WebAssembly code.
The tube checker and the three programs that use the tubes also run as C functions that CompCert compiles for 64-bit Arm processors, and as programs for a 64-bit Arm processor without an operating system, compiled by CompCert and as boot images whose machine code leanexe generates. For each form a theorem states that it computes the checked result, and on every test run every form wrote the WebAssembly module's output.
A flight plan for a fleet of drones gives each drone a path: its position as a smooth curve in time. This program checks such a plan at every instant of a time window: that every two drones stay a set distance apart, that each drone stays inside its assigned corridors, and that each path keeps within limits on speed and acceleration, with margins for a drone that strays from its path by a stated distance or runs early or late by a stated time. A check that samples the curves can miss a crossing between samples, so the program bounds each curve over whole intervals of time through its Bernstein coefficients, rounds every computation outward, splits an interval when its bound is too coarse, and answers certified, inconclusive, or invalid input.
Proofs checked by the Lean proof assistant show that a certified plan meets every requirement at every time of the window, for every motion within the margins. The proofs cover the WebAssembly code that leanexe's verified compiler produces. No theorem states that a given plan is certified; for the four-drone plan in the figure, the checker certified every pair and corridor in 94 cell evaluations.
The checker also runs as a C function that CompCert compiles for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system: one that CompCert compiles, which reads a plan from memory, and a boot image whose machine code leanexe generates, which reads it from the serial port. For each form a theorem states that it computes the checker's answer, with the same guarantee for a certified plan.
A planar positioning stage holds a platform on three telescoping legs whose lengths are measured. Several poses of the platform, called assembly modes, can give the same three lengths, and a numerical solver can return one of them while missing another. This program searches a range of positions and all rotations with interval arithmetic, which rounds every computed bound outward, and returns small boxes that together contain every pose that fits the lengths. It certifies a box when a contraction test on an interval enclosure of the equations' derivative shows that the box holds exactly one pose, and it reports an exact count only when every pose lies in a certified box.
Proofs checked by the Lean proof assistant show that the returned boxes cover every pose in the range, that each certified box contains exactly one pose, and that certified boxes are disjoint, so the exact count counts distinct poses. The proofs cover the WebAssembly code that leanexe's verified compiler produces. In tests, the symmetric stage of the design note gives an exact count of 2, at rotations of plus and minus 75.5 degrees, and the Lean kernel checks one of its two certificates; with legs of length 1, the singular pose stays in a returned box, as a theorem states. For the stage in the figure, the program certifies six poses.
The solver also runs as a C function that CompCert compiles for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system: one that CompCert compiles and a boot image whose machine code leanexe generates, which reads its input from the serial port. For each form, the theorems state that a run returns the boxes and counts with the same guarantees or stops with an error code and no result. No proof bounds the search's memory, so the theorems do not exclude that error for a valid input; on every test input, every form returned the module's result.
Two sensors report the position of the same object in the plane, each with a covariance matrix whose ellipse describes the report's uncertainty. When the errors of the two reports may be correlated in an unknown way, covariance intersection combines them with a weight w between 0 and 1 into a fused estimate. This program computes the fused covariance and center in double-precision arithmetic that rounds every result outward, so it returns intervals that contain the exact results, or it rejects its inputs.
Proofs checked by the Lean proof assistant show that the fused ellipse contains every point that lies in both input ellipses, that the program accepts only positive-definite covariances and a weight strictly between 0 and 1, and that its intervals contain the exact fused covariance and center. The proofs cover the WebAssembly code that leanexe's verified compiler produces. They assume that the WebAssembly engine follows the standard, and they do not cover the choice of the weight.
The same program also runs as C code that the CompCert verified compiler turns into machine code for a PC, called by an ordinary program, and the proofs extend to one call of the C function under the assumptions that CompCert's proofs hold and that leanexe's Lean copy of CompCert's C semantics is faithful. It also runs without an operating system on a 64-bit ARM processor, as machine code that leanexe generates from the WebAssembly module. There the proofs cover the whole run, from the bytes that arrive on the serial port to the bytes that the program writes back. They assume that the processor and its devices behave as leanexe's model of them states, with no compiler, assembler, or linker among the assumptions.
A gripper holds a part at a few points of contact. Each contact can push but not pull, resists sliding only up to its friction limit, and belongs to a jaw whose actuator can press only so hard. This program decides whether a gripper can hold a part still under every load in a stated range. An external solver proposes forces at the contacts for each extreme load as exact fractions, and the program checks each proposal in exact integer arithmetic: the forces and their turning effects cancel the load, every contact pushes, none slips, and no jaw exceeds its rating. A failed proposal leaves the question open.
Proofs checked by the Lean proof assistant show that when every proposal passes, every load in the range has contact forces that hold the part, that every check equals its condition with no overflow, and that in the design note's case the load over one contact has no balancing forces, although a check that adds the two contacts' friction capacities would accept it. The proofs cover the WebAssembly code that leanexe's verified compiler produces. They concern a rigid model and say nothing of the forces that a particular compliant gripper develops.
The checker also runs as a C function that CompCert compiles for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system: one that CompCert compiles, which reads a message of inputs from memory, and a boot image whose machine code leanexe generates, which reads it from the serial port. For each form a theorem carries the checker's claims, and in tests the C form matched the WebAssembly module on 2,010 inputs and both programs on more than 200 runs each.
The program authorizes battery power limits for a solar-and-battery site. An optimizer without proofs proposes limits, and the authorizer accepts them only when every trajectory that the site's model admits meets the site's energy and grid limits, or stays no further outside a limit than a return to the inverter's fallback mode would. The authorizer compiles to a WebAssembly module of 6,316 bytes, and a gateway built around it runs without an operating system on a Cortex-M7 board against a simulated site. In one simulated day of 1,440 one-minute steps on the board, each output record equals the record that the gateway produces in native Lean.
The program is the protection layer of a battery management system for a pack of four lithium iron phosphate cells. A Cortex-M7 board receives the pack's sensor readings one record at a time over a serial line and answers each record with a protection state and a permit for each of three relays. The main theorem states that a nonzero permit follows an operator's reset, a start, and records that passed every check, and a second theorem states the same for every answer that the board's flash image writes after a reset. On the board, all 37 scenarios of a fault-injection schedule passed, and a replay of the Lean specification on the bytes sent to the board reproduced all 288 of its answers.
Grid operators can raise the capacity of a transmission line by rating it from measured weather, since wind and cold air cool the conductor. This module rates each of six overhead lines, which share a conductor and differ in the bearing of their spans, from bounds on the conductor's temperature, the air temperature, the wind speed and direction, and the sunlight, and it credits the cooling of a wind across the line's span. It returns each line's rating and the time for which a larger proposed current keeps the conductor at or below its maximum temperature, and it checks that every power injection in a range keeps each line of a network within its limit in the DC power flow model. Proofs checked by the Lean proof assistant show that at the rating the conductor stays at or below its maximum temperature under the heat balance of IEEE Std 738, for all weather within the bounds, and that the rating is the largest current that the program's test admits. The standard's formulas for the cooling enter the proofs as a premise. The proofs cover the WebAssembly code that leanexe's verified compiler produces.
A heater's workpiece can be below its limit when the power cuts off and still overshoot afterward, as heat stored in the hot element flows into it. This program checks one more pulse against a model of the element and the workpiece as two thermal masses, in which every heat capacity, coupling, heat loss, power, starting temperature, ambient temperature, and relay delay is a range. It bounds both temperatures through the pulse, the relay's delay, and the cooling that follows, and it accepts only when its bounds keep the workpiece below the limit until both bodies are below it, after which neither can warm past it.
Proofs checked by the Lean proof assistant show that an accepted pulse keeps the modeled workpiece below its limit at every later time, for every combination of values in the ranges and every relay delay. They also show that the design note's case peaks at exactly 500/9 °C and is rejected, and that a pulse from a cooler state is accepted. The proofs cover the WebAssembly code that leanexe's verified compiler produces. The guarantee concerns the model: a real heater also needs measured evidence for its starting temperatures, its parameters, and the relay's deadline.
The checker also runs as a C function that CompCert compiles for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system: one that CompCert compiles, which reads its input from memory, and a boot image whose machine code leanexe generates, which reads it from the serial port. For each form a theorem states that it computes the checker's result, and on all 71 test messages every form wrote the WebAssembly module's output.
A notch filter removes one frequency from a signal, and a motor drive uses one to keep its controller from exciting a mechanical resonance. This program runs two notch filters in sequence, at one quarter and one sixth of the sample rate, in a small processor's fixed-point arithmetic: 32-bit samples and coefficients, full 64-bit products, and one rounding down per output. Proofs checked by the Lean proof assistant show that for every input of at most a quarter of full scale, no sum inside either filter overflows its 64-bit register and no output reaches the limits of its range. Each output stays within 38 steps of the 32-bit scale of the exact result, and the exact filter cuts every frequency within 0.05% of the sample rate of the first notch, and within 0.2% of the second, to under a tenth of its amplitude. The proofs cover the WebAssembly code that leanexe's verified compiler produces.
The filter also runs as a C function that the CompCert verified compiler turns into machine code for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system, which take a message of up to 4,096 samples and write the outputs to the serial port: one that CompCert compiles, which reads its message from memory, and a boot image whose machine code leanexe generates, which reads it from the serial port. For each form a theorem states that on samples of at most a quarter of full scale it returns without an error the outputs of the integer filter, which stay within 38 steps of the exact result, given room in memory for the outputs in the C function's case.
A thermocouple produces a small voltage from the temperature difference between its two junctions, and NIST publishes the reference polynomial that converts the voltage of each thermocouple type to a temperature. This program performs the conversion for type T thermocouples from 0 to 400 °C. It takes intervals for the measured voltage, the reference-junction temperature, and the probe's deviation from the reference function, and it returns an interval that contains every hot-junction temperature consistent with them. Separate statuses mark a reading that may lie outside 0 to 400 °C, a reading that no temperature in that range explains, such as microvolts entered as millivolts, and invalid input.
Proofs checked by the Lean proof assistant show that the returned interval contains every consistent temperature, with NIST's nine decimal coefficients taken exactly, and that the reference function increases strictly over the range, with a slope between 38 and 63 µV/°C that the Lean kernel checks. The interval's width is at most the compensated voltage's width divided by 38 µV/°C, plus a rounding allowance below 10−9 °C, so a width of 10 µV gives at most 0.264 °C. The proofs cover the WebAssembly code that leanexe's verified compiler produces. In tests, the module's reference function agrees with all 401 entries of NIST's table within 0.0005 mV.
The readout also runs as a C function that the CompCert verified compiler turns into machine code for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system: one that CompCert compiles, which reads a reading from memory, and a boot image whose machine code leanexe generates, which reads it from the serial port. The theorem for the C function covers every bit pattern of the six inputs. The theorems for the two programs cover their whole runs with the same claims, and those for the boot image name the bytes that it writes for each reading.
A vibration alarm compares a machine's vibration in a band of frequencies with a threshold. This program takes a block of accelerometer samples, a band of frequency bins, a threshold, and the limits of the sensor's calibration: a range for its gain, any constant offset, and a bound on the remaining error. It returns a range that holds the band's RMS vibration for every calibration within those limits, and it reports above or below only when the whole range lies on one side of the threshold.
Proofs checked by the Lean proof assistant show that the range holds the band RMS of the calibrated signal for every calibration within the limits, including the rounding of leanexe's Fourier transform, and that the range is wider than the exact one by at most a stated rounding term. The constant offset cancels exactly for a band that excludes the zero frequency. The proofs cover the WebAssembly code that leanexe's verified compiler produces. On Paderborn University's recordings of a healthy bearing and of one with outer-ring damage, the verdict was definite for 99.2% and 68.8% of the blocks. The theorems concern each recorded block, not the condition of a bearing.
The alarm also runs as a C function that CompCert compiles for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system: one that CompCert compiles, which reads a block from memory, and a boot image whose machine code leanexe generates, which reads it from the serial port. The theorems for each form carry the same claims, including the width bound.
The Goertzel algorithm measures the power of a signal at one frequency with a second-order recurrence over its samples, which costs one multiplication per sample instead of a full Fourier transform. This program computes it in double-precision arithmetic, and proofs checked by the Lean proof assistant bound its error against the exact power of the samples at the frequency of each coefficient it uses. A detector of telephone key tones (DTMF) runs eight such filters, at the row frequencies 697, 770, 852, and 941 Hz and the column frequencies 1209, 1336, 1477, and 1633 Hz, over frames of 205 samples at 8 kHz, and reports a key when the strongest row and the strongest column pass four tests.
The proofs state that the detector reports the key of every pair of tones within 1.5% of a key's frequencies, with amplitudes of at least 210, a twist of at most ±8 dB, and noise of at most 10 per sample, and that it reports no key for a single tone or a quiet frame. The detector runs as a WebAssembly module, as a C function that CompCert compiles for x86-64, as an AArch64 program without an operating system that CompCert compiles, and as an AArch64 Image whose machine code leanexe generates. Each form has a theorem that carries the detector's behavior to it, and for the two AArch64 programs the theorem names the key that the program writes for a message of 205 samples read as 16-bit integers.
The program is a matching engine for the central limit order book of one instrument. It matches limit and market orders by price-time priority, with self-trade prevention, cancels, and reductions that keep priority, and it writes an event for every acceptance, rejection, trade, cancellation, and reduction. A specification defines the book's rules over lists, and a refinement proof shows that the program, which keeps up to 4,096 resting orders in fixed arrays, computes the specification. The program compiles to a WebAssembly module of 15,662 bytes and to C, and a theorem states the output and the exit status of a WASI process that runs the book over standard input and output.
Expected shortfall is the average loss over the worst part of a set of scenarios: at the level 90%, over the worst 10% of the probability, which may include part of one scenario. This program takes weighted scenarios whose losses are known only within intervals, computes a range that contains the expected shortfall of every loss vector within them, and compares the range with a limit. An untrusted optimizer proposes a certificate, a threshold and each scenario's share of the tail in whole numbers, which the program checks exactly before it computes the range with rounding directed outward.
Proofs checked by the Lean proof assistant show that the range contains the expected shortfall even for a poor certificate, and that a verdict of within the limit means an expected shortfall at or below the limit for every loss within the intervals. The theorems concern the supplied scenarios and intervals; they say nothing about whether the scenarios describe future losses. The proofs cover the WebAssembly code that leanexe's verified compiler produces.
The program also runs as a C function that CompCert compiles for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system: one that CompCert compiles and a boot image whose machine code leanexe generates, which reads its inputs from the serial port. For each form a theorem carries the same claims.
A repricing layer computes the loss intervals from a book of positions instead of taking them as input. The book holds long and short futures, European calls, and European puts on one underlying. The layer values the book now, and in each scenario at a common horizon, by the Black–Scholes formula with leanexe's complementary error function and its proved error bounds. A position that expires today settles at today's price in every scenario, and the layer rejects as invalid input a position that would expire between now and the horizon, since the scenarios give no price at which it would settle. One WebAssembly export passes the loss intervals to the certifier and returns its result with the identifiers of the snapshot and the model that it was given, unchanged.
Proofs checked by Lean show that each loss interval contains the scenario's loss under the formula: the book's current value less its value in the scenario, plus the stated costs. The certifier's range and verdict therefore hold for those losses. The theorems take the Black–Scholes formula as a stated model, which no proof derives from a model of prices. They concern only the supplied book, scenarios, and model parameters. The proofs cover the WebAssembly code that leanexe's verified compiler produces.
The repricing export also runs as a C function that CompCert compiles for 64-bit Arm processors, and as a program that CompCert compiles for a 64-bit Arm processor without an operating system, which reads its inputs from memory. For each form a theorem carries the same claims. It also runs as a boot image whose machine code leanexe generates, and which reads its message from the serial port. The kernel checks that the image file's bytes are those that leanexe's code generator produces, and the theorems hold in leanexe's model of the processor and its devices, through a theorem of leanexe's for programs that read tables of constants, as the export's exponential, logarithm, and error function do. In tests, each of 102 messages gave the WebAssembly module's result, or its error result for the five malformed ones, in QEMU both emulated and under KVM.
Risk systems often summarize how a portfolio responds to market moves with a quadratic model: a loss built from first- and second-order sensitivities to a few factor shocks. This program checks that the model's loss stays below a limit for every shock up to a given size. An untrusted solver proposes one number, a multiplier, and optionally a set of scales; the program combines them with the model into a small matrix and shows it positive definite by elimination in interval arithmetic, rounding every step outward. When the check fails, the program answers inconclusive and claims nothing. A second check confirms a proposed shock that breaks the limit.
Proofs checked by the Lean proof assistant show that a certified result bounds the quadratic loss by the limit on the whole stress set, for every symmetric model, convex or not, and that a confirmed shock lies in the set and exceeds the limit. These theorems concern the quadratic model alone and say nothing about how likely a loss is. The proofs cover the WebAssembly code that leanexe's verified compiler produces.
A second pair of exports takes the model's coefficients as intervals. One certifies the limit for every coefficient choice within the intervals at once, by elimination on an interval matrix that encloses every certificate matrix. The other starts from the sensitivities to the original risk factors and a factor matrix, encloses the normalized coefficients with outward rounding, and certifies the limit for every shock that the factor matrix maps from the unit ball. Proofs checked by Lean show both claims for the WebAssembly code, and the compiled forms below carry them too. For the model of the first figure, with each first- and second-order sensitivity known only to within a relative error w, the lowest limit that the module certifies rises from 1.30 for exact sensitivities to 1.72 at w = 25%.
A quadratic model approximates a portfolio's full repricing loss, and a limit that the model satisfies can fail for the full loss. Another export bounds the difference between the two for a book of futures and European calls and puts on one underlying, under a relative move of the underlying's price and an absolute move of its volatility. It covers the stress disk with a grid of cells and reprices the whole book over each cell in interval arithmetic with outward rounding, using the Black–Scholes formula from the repricing layer of the expected shortfall example. From the cells it obtains a bound on how far the full loss can exceed the model on the disk, and it checks the model's certificate at the limit lowered by that bound. It confirms a proposed stress by repricing the book at that stress alone, or through the model and a bound on how far the model can exceed the full loss.
Proofs checked by Lean show that a certified result means a full loss at or below the limit at every stress of the disk, and that a confirmed stress lies in the disk with a full loss above the limit. The theorems take the Black–Scholes formula as a stated model of the book's value, with the rates and each position's time to expiry unchanged by the stress. No theorem limits how far the computed bound may exceed the true difference, and when the bound is too wide, the program answers inconclusive. In tests against an untrusted high-precision repricing, the bound exceeded the largest difference between the full loss and the model by an amount that halved as the cells' width halved. In the same tests, a certificate for the quadratic model of a book of short puts passed the check at a limit that the book's full loss exceeds, and the export instead confirmed a proposed stress inside the disk at which the full loss breaks that limit.
A call theorem for each WebAssembly export states that it returns its result without a trap when the memory has room for a stated number of bytes. Each check also runs as a C function that CompCert compiles for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system: one that CompCert compiles and a boot image whose machine code leanexe generates, which reads its inputs from the serial port. For each form a theorem carries the same claims. The full-loss export reads tables of constants for its exponential, logarithm, and error function, and leanexe's theorems for boot images do not cover a program that reads tables. This example proves a variant of leanexe's theorem that covers such a program, and the theorem of the full-loss boot image uses it.
The program counts single-winner ranked-choice contests under Section 1105 of the Oakland City Charter. The theorems state that the module returns, for every ballot file, the report that a Lean specification of the charter's rules defines, and they state the same for its WASI process, its C translation, and an AArch64 image that runs without an operating system. For the 2022 contest for School Director, District 4, of the Oakland Unified School District, the program's count of the published cast vote records matches the figures of Alameda County's corrected report. The County had first certified a count under a tabulator setting that withheld 235 ballots from round 1, and that count elected a different candidate. A second module counts contests under Maine's statute.
The program is a SHA-256 manifest checker like sha256sum -c, built from a request of a few lines and a plan that the user approved, both kept in the demo. Two other agents reviewed the specification of the checker's core against the request, and 99 test samples include the inputs that the reviewers identified. The theorems state, for every run of the WASI command under every host, that each output line says OK exactly when the file's SHA-256 equals the manifest's digest, that every file it opens is the manifest or a name listed in it, opened read-only under the preopened directory, and that it closes each descriptor before the next open and before it exits. The command's AArch64 Linux executable has the same theorems over Linux's system calls.
The program contains two finite-volume solvers for the two-dimensional Euler equations of an ideal gas, run on a four-quadrant Riemann problem. One verified module contains both solvers, and one call runs a whole calculation from the initial grid to the final one. The theorems state that the module returns the solvers' results without a trap, that the final states have positive density and pressure, that the flux in every direction has real eigenvalues and a basis of eigenvectors at them, and that each conserved total changes only by the boundary fluxes plus a rounding residual with a computed bound. The compiled forms include WebAssembly, C, a bare-metal AArch64 program built with CompCert, and an AArch64 Image. Convergence to a solution of the continuous equations is unproved.
The Lanyon.AI article The Euler Equations of Gas Dynamics motivated this example, which solves the article's four-quadrant problem on the same 800 × 800 grid. Lanyon's CompressibleEuler repository holds generated C kernels for single cell interfaces, with no program that runs a calculation. Its Lean theorems state properties of the kernels' formulas over the real numbers, and no proof relates them to the C's binary64 arithmetic. Its issues report inputs on which the C's results differ from the formulas, and hyperbolicity theorems whose statements hold for any eigenvalue formula. Here the theorems cover the compiled module that runs the whole calculation, and they hold for the binary64 words that it returns.
Iterative solvers often repeat one cheap correction, adding a weighted residual to the current solution, many times with the same matrix. This program chooses one or two weights and checks that a 64-bit floating-point run of the cycle shrank the true residual of the iterate it returns. It encloses the matrix's numerical range in a disk and in a rectangle of 32 × 8 cells, bounds the cycle's residual polynomial there with interval arithmetic, and extends the bound to every vector through Crouzeix's inequality with the constant 2, whose Lean proof OpenAI published in 2026. It then accounts for every rounding error of the run.
Proofs checked by the Lean proof assistant show that a certified cycle shrinks the exact residual of every vector by the stated factor, that the weight search returns the first passing candidate in its stated order, and that the returned binary64 iterate's true residual is at most the requested fraction of the initial one. The theorems cover every real matrix from 1 × 1 to 64 × 64 with one to eight weights; the tests run the design's 2 × 2, 32-variable, and 42-variable cases. The proofs use OpenAI's Lean proof of Crouzeix's inequality with the constant 2, which formalizes the result of OpenAI's paper A direct proof of the complete Crouzeix inequality. OpenAI's math repository holds the Lean proof and a note on the scope of the formalization. The proofs cover the WebAssembly code that leanexe's verified compiler produces.
The program also runs as a C function that CompCert compiles for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system: one that CompCert compiles and a boot image whose machine code leanexe generates. For each form a theorem carries the same claims.
Chemists and biologists model reacting substances with reaction networks, which list the substances that combine, what they produce, and how fast. A basic question about such a model is whether every substance stays present, with no amount falling toward zero or growing without limit. This program reads a network from a short text file and checks whether every reaction can be undone by some chain of reactions, a property called weak reversibility. When the check fails, it names each reaction without a way back and draws no conclusion about the amounts.
Proofs checked by the Lean proof assistant show that an accepted file denotes a mass-action system and that a passing check establishes weak reversibility. With positive rates and starting amounts, a theorem that OpenAI proved in Lean in 2026 then guarantees that every amount stays between two positive bounds for all time. The theorem states that the bounds exist, not what they are, and the program computes none. OpenAI's Lean proof of this theorem formalizes the result of its paper Boundedness and persistence of weakly reversible mass-action systems, and OpenAI's math repository holds the Lean proof and a note on the scope of the formalization. The proofs use that theorem and cover the WebAssembly code that leanexe's verified compiler produces. For the edited Schlögl model, a theorem shows that every positive solution decays to zero, so the check rejects a model that is not persistent.
The checker also runs as a C function that CompCert compiles for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system: one that CompCert compiles and a boot image whose machine code leanexe generates, which reads the file from the serial port. For each form a theorem carries the same claims; a very large network can exhaust a run's memory, and the run then stops without a verdict, which the theorems allow. The forms gave the expected output on all of more than 2,000 test files.
A stack of semiconductor layers traps electrons at negative energies, the bound states. This program reads a stack, given as layer boundaries and well depths, and returns a number with a proof that it exceeds the summed magnitudes of all bound-state energies, counted with multiplicity. It rounds every 64-bit floating-point operation outward, with proved enclosures of π and of square roots. It works in units where ℏ²/2m = 1; the README gives the conversion for depths in electronvolts, positions in nanometers, and an effective mass.
Proofs checked by the Lean proof assistant show that an accepted input denotes a step potential to which OpenAI's 2026 Lean proof of the sharp Lieb–Thirring inequality applies, and that the returned number bounds the sum through that theorem. The inequality's constant, 4/(3√3π), is the best possible: the potential 3 sech²(2x) attains it. As a corollary, every single bound state lies above the negative of the bound. OpenAI's Lean proof of the inequality formalizes the result of its paper Sharp one-dimensional Lieb–Thirring constants, and OpenAI's math repository holds the Lean proof and a note on the scope of the formalization. The proofs use that theorem and cover the WebAssembly code that leanexe's verified compiler produces.
The program also runs as a C function that CompCert compiles for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system: one that CompCert compiles and a boot image whose machine code leanexe generates, which reads the stack from the serial port. For each form a theorem carries the same claims.
A qubit held in a quantum memory relaxes toward the temperature of its surroundings. The generalized amplitude-damping channel describes this with two numbers: the probability that the excitation decays during the storage time, and the excited population of the environment. This program computes the channel's classical capacity, the number of bits per use that can be sent reliably without entanglement shared in advance, when the receiver decodes many uses together. It bounds a function of one variable from below at chosen points and from above on every cell of a partition, with logarithms and square roots in rounded arithmetic whose errors the bounds include, and returns an interval that contains the capacity, as narrow as a requested tolerance.
Proofs checked by the Lean proof assistant show that the returned interval contains the capacity for every valid input, and that a result marked successful is no wider than the tolerance. The theorems use OpenAI's 2026 Lean proof that the capacity equals the maximum of a function of one variable, which formalizes the result of OpenAI's paper Classical capacity and entropy inequalities for generalized amplitude damping. OpenAI's math repository holds the Lean proof and a note on the scope of the formalization. The program's logarithm is its own enclosure, proved from Mathlib's series for the logarithm. The proofs cover the WebAssembly code that leanexe's verified compiler produces.
The program also runs as a C function that CompCert compiles for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system: one that CompCert compiles and a boot image whose machine code leanexe generates, which reads the request from the serial port. For each form a theorem carries the same claims.
In an oriented graph, each arc joins two different vertices in one direction, and no two vertices are joined both ways. The first neighbors of a vertex are the vertices that its outgoing arcs reach, and its second neighbors are the vertices at directed distance exactly two, which excludes the vertex and its first neighbors. Seymour's second-neighborhood conjecture asserts that every nonempty finite oriented graph has a vertex with at least as many second neighbors as first neighbors. This program reads an oriented graph of up to 4,096 vertices, keeps each vertex's first neighbors as a row of bits, and forms each second neighborhood from the union of the rows of the vertex's first neighbors. It returns the first vertex whose first count is at most its second, with both counts. It rejects an input that exceeds its limits or is not an oriented graph.
Proofs checked by the Lean proof assistant show that the program's two counts at a vertex are the sizes of the neighborhoods that OpenAI's definitions give, and that the returned vertex has at least as many second neighbors as first neighbors. With OpenAI's 2026 Lean proof of the conjecture, they also show that the search finds such a vertex in every valid graph. OpenAI's Lean proof of the conjecture formalizes the result of its paper A proof of Seymour's second-neighborhood conjecture, and OpenAI's math repository holds the Lean proof and a note on the scope of the formalization. The proofs cover the WebAssembly code that leanexe's verified compiler produces.
The checker also runs as a C function that CompCert compiles for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system. One program, which CompCert compiles, reads a graph of up to about a million arcs from memory. The other, a boot image whose machine code leanexe generates, reads any graph that the checker accepts, up to 8,388,608 arcs, from the serial port. For each form a theorem carries the same claims, and the theorems for the boot image name the bytes that it writes.
For points that fill the plane at one point per unit area, the energy per point depends on their arrangement and on the potential through which they repel one another. OpenAI's 2026 Lean proof shows that the triangular lattice, the arrangement of the centers of a honeycomb's cells, has the least energy of all such arrangements for every completely monotone potential. Such a potential is a function of the squared distance that is nonnegative and whose successive derivatives alternate in sign. This program computes that least energy for two families of potentials that the proof covers: the Gaussians exp(−αr²) and the inverse powers r−2s for whole numbers s from 2 to 64. It sums the lattice's terms over shells of lattice points with arithmetic that rounds every sum outward, adds a proved bound on the shells that it leaves out, and returns an interval.
Proofs checked by the Lean proof assistant show that both families meet the conditions of OpenAI's theorem, and through that theorem that the interval's lower end is at most the energy of every arrangement of density one. They also show that the upper end is at least the lattice's energy. The program's theorems fix the density at one and cover only these two families of potentials. OpenAI's Lean proof of the lattice's optimality formalizes the result of its paper An atomic certificate for triangular-lattice universal optimality, and OpenAI's math repository holds the Lean proof and a note on the scope of the formalization. The proofs cover the WebAssembly code that leanexe's verified compiler produces.
The program also runs as a C function that CompCert compiles for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system. One program, which CompCert compiles, reads a request from memory. The other, a boot image whose machine code leanexe generates, reads the request from the serial port. For each form a theorem carries the same claims, and the theorems for the boot image name the bytes that it writes.
In the Snaky game, Maker and Breaker take turns claiming free cells of the infinite square grid, and Maker moves first. Maker wins once it owns every cell of a copy of Snaky, a shape of six cells, in any position, rotation, or reflection. OpenAI's 2026 Lean proof gives a legal strategy that wins within 21 Maker moves against every legal Breaker play from the empty board, and its theorem also checks the disjointness of the players' cells and the move counts throughout play. The proof derives the win from a finite certificate of conditional winning positions, but its strategy picks each move with the axiom of choice, so Lean cannot run the strategy.
This program stores OpenAI's certificate in tables. Given Breaker's moves so far, it returns a status and, for a move or a win, Maker's next cell. The other statuses report a Breaker move on a claimed cell and more than 20 Breaker moves. It reads each coordinate as a 64-bit signed integer, so its theorems cover Breaker's moves in that range, while OpenAI's theorem covers the whole grid.
Proofs checked by the Lean proof assistant show that each cell that the program returns is free and that it reports each status exactly when the status's condition holds. They also show that against every Breaker play whose first 20 moves are legal, Maker's cells hold a copy of Snaky after Maker's 21st move, and that the strategy that the program defines meets the conclusion of OpenAI's theorem. OpenAI's Lean proof formalizes the result of its paper Snaky in 21 Maker moves, and OpenAI's math repository holds the Lean proof and a note on the scope of the formalization. The proofs cover the WebAssembly code that leanexe's verified compiler produces, and a call theorem states that the module returns its answer without a trap when the memory has room for 2,312 bytes.
The program also runs as a C function that CompCert compiles for 64-bit Arm processors, and as two programs for a 64-bit Arm processor without an operating system. One program, which CompCert compiles, reads Breaker's moves from memory. The other, a boot image whose machine code leanexe generates, reads them from the serial port. For each form a theorem carries the same claims, and the theorems for the boot image name the bytes that it writes.
In tests, Maker won every game against random and greedy Breakers by its eighth move. Against a Breaker that keeps the certificate's bound on Maker's remaining moves as large as possible, Maker won every game at its 21st move, the theorem's bound. Every answer passed the tests' own checks of its cell and status, and every move was the one that the certificate prescribes. The C function and both programs without an operating system gave the module's answers on their test inputs.
This library provides whole numbers of any size to programs written for leanexe's verified compiler. The library stores a natural number as its digits in base 232, called limbs, one limb to a 64-bit word, and an integer as a sign and such a magnitude. It compares, adds, subtracts, multiplies, and divides naturals and integers, with both truncated and Euclidean division for integers. It converts integers to and from decimal text with an optional leading minus sign and no leading zero, so that each integer has one text. Each integer operation also has an export that takes its operands as decimal text and returns the result as text, with a status that reports a malformed operand or a division by zero.
Proofs checked by the Lean proof assistant show that every arithmetic function returns the exact result in canonical form, with no zero limb at the top and no negative zero, when its arguments are in that form. They also show that the text that the library writes for an integer equals Lean's toString of it, and that reading accepts exactly the texts that the library writes and returns their integers. Addition, subtraction, multiplication, and division call the functions of leanexe's MultiPrecision library, which implement Knuth's Algorithms A, S, M, and D, and the proofs use MultiPrecision's theorems about them. Call theorems state that each export of the WebAssembly module returns its result without a trap when the memory has room for a stated number of bytes, linear in the operands' lengths. The proofs cover the WebAssembly code that leanexe's verified compiler produces.
The library also runs as C functions that CompCert compiles for 64-bit Arm processors, and the proofs extend to one call of each C function in a memory of 256 MiB. The proofs of the C functions assume that CompCert's proofs hold and that leanexe's Lean copy of CompCert's C semantics is faithful. In tests, the C functions returned the WebAssembly module's results on every call.
A calculator that uses the library reads a message such as mul 123 -456 and writes a status and the result: 0 -56088 for that message. It runs as two programs for a 64-bit Arm processor without an operating system, each with a theorem for its whole run. One, which CompCert compiles, reads its message from memory. The other is a boot image whose machine code leanexe generates, and it reads the message from the serial port. For the boot image, Lean's kernel checks that the file's bytes are those that leanexe's code generator produces, and the theorems hold in leanexe's model of the processor and its devices, with no compiler, assembler, or linker among the assumptions. In tests, every result that either program wrote equaled the one that Node.js's BigInt computes.
A second iteration of the library adds a faster product and a faster reader of decimal text, as new exports beside the first iteration's. From 48 limbs on, a threshold chosen by timing, the new product uses Karatsuba's method, which needs three multiplications of half-length numbers in place of four. The new reader converts blocks of digits and then combines adjacent pairs of blocks pass after pass with the new product, as in the divide-and-conquer algorithm of Brent and Zimmermann's Modern Computer Arithmetic. Proofs show that the new product and the new reader of integers return the first iteration's results.
A third iteration adds a faster division and a faster conversion to decimal text that uses the new division. The division, Burnikel and Ziegler's recursive method as Brent and Zimmermann give it, computes the top half of the quotient by a recursive call, subtracts one product computed by Karatsuba's method from the remainder, and computes the bottom half in the same way. The conversion, Brent and Zimmermann's Algorithm 1.26, divides the number by a power of 109 computed by squaring and converts the quotient and the remainder in the same way. Below thresholds chosen by timing, both use the earlier quadratic methods.
Proofs show that, for arguments in canonical form, the third iteration's division returns exactly the first iteration's quotient, remainder, and status, and its conversion writes exactly the first iteration's text. Both work in one array allocated at the start of a call, so the bounds on their allocation are linear in the operands' lengths. Proofs also show that their recursion never reaches the compiled code's limit of 1,000 nested calls, so their call theorems need no premise on its depth. Call theorems and C theorems cover the exports of both later iterations as they cover the first iteration's.
In Node.js 26 on an x86-64 processor, the times of the second iteration's product and of the third iteration's division and conversion grow by a factor of about three for each doubling of the length from 256 limbs on, the rate of Karatsuba's method, against four for the first iteration's functions. At 100,000 limbs the second iteration's product takes 0.75 s, against 26 s for the first iteration's and 23 ms for V8's BigInt, which adds the Toom–Cook and FFT methods above Karatsuba's. The third iteration divides a number of 200,000 limbs by one of 100,000 limbs in 1.5 s, against 31 s for the first iteration's division and 0.19 s for V8's. The second iteration reads a number of 100,000 limbs, about 963,000 digits, from decimal text in 0.95 s, against 10.7 s for the first iteration's reader and 59 ms for V8's. The third iteration writes such a number as text in 1.7 s, against 30 s for the first iteration's conversion and 0.15 s for V8's.
A fourth iteration adds the greatest common divisor, its extended form, the modular inverse, modular exponentiation, and bitwise operations, for naturals and integers. The greatest common divisor uses Lehmer's double-digit method, Brent and Zimmermann's Algorithm 1.17: each step decides as many quotients as the leading 62 bits of the two numbers allow and applies them in one pass over the full numbers, and it takes a step of Euclid's algorithm with the third iteration's division when the leading bits decide none. Exponentiation uses a sliding window, Algorithm 2.14, and reduces each product by Montgomery's method, Algorithm 2.6, for an odd modulus of fewer than 380 limbs, and by the third iteration's division for an even modulus and for longer odd moduli, a threshold chosen by timing. The bitwise and, or, exclusive or, complement, and shifts treat integers in two's complement.
Proofs show that each new function returns, in canonical form, the result of Lean's or Mathlib's function of the same meaning for every input: Nat.gcd and Int.gcd, a ^ e % m with a status for a zero modulus, and Nat.land, Int.land, Nat.shiftLeft, and their kin. The extended form returns the cofactors of Brent and Zimmermann's Algorithm 1.20, which satisfy Bézout's identity within stated bounds, and the inverse lies between 0 and the modulus when it exists, with a status otherwise. The greatest common divisor and the exponentiation each work in one array allocated at the start of a call, every allocation bound is linear in the operands' lengths, and proofs bound the depth of the recursion for every input. Call theorems cover the new exports of the WebAssembly module and of its C form, as for the earlier iterations. In tests, the WebAssembly module agreed with BigInt on 8,461 checks, and the C form agreed with the module on 1,718 cases.
In the same tests, the greatest common divisor of two numbers of 12,288 limbs took 0.59 s, against 21.7 s for Euclid's algorithm over V8's BigInt, and that of two numbers of 100,000 limbs took 37.6 s. An exponentiation with a modulus of 64 limbs took 28 ms, 2.9 times as long as square-and-multiply over BigInt, whose multiplication and division use faster methods at large sizes, and one with a modulus of 512 limbs took 9.1 s.