---
title: "TurboLean compiler proof coverage"
description: "How my TurboLean fork followed a compiler proof through the code that runs, checked which calls qualify, and measured its reach without overstating it."
url: https://mh0pe.github.io/blog/where-the-proof-stops/
author: "Madison Hope Steiner"
published: 2026-11-28
modified: 2026-11-28
---

[← All writing](https://mh0pe.github.io/blog/)

# Where does the proof stop?

**The bracket stops before native code** Under the theorem’s assumptions, a successful source run has a target run with the same value and final modeled heap. That comparison does not reach the native executable.

What my TurboLean fork taught me about proving a compiler pass, measuring its reach, and saying where the guarantee ends.

[My commit: use one LCNF-to-LNIR lowerer](https://github.com/awsmadi/turbo-lean/commit/f5bbc8fa86fb79cfb12fa746cf0fd788c62b85ae)

By [Madison Hope Steiner](https://mh0pe.github.io/about/)

TurboLean Developer tools

**In this article**

Follow the program to the edge of the proof

At a glance

A compiler can translate a function without having a proof that the translation preserves its behavior. I wanted to know which functions the proof actually covered.

If a compiler gives me an executable, what would make me comfortable saying it preserves the program I wrote? A test can tell me the two programs agreed on the inputs I tried. A proof can tell me something more, but only about the translation it describes and under the conditions it names. I want both answers. I don't want either to stand in for the other.

That distinction shaped my work in the TurboLean fork. The project translates Lean programs through several representations before they run. I worked on one crossing in that chain: from Lean's LCNF representation to TurboLean's lower-level LNIR. The question was not how much of the compiler I could call verified. It was whether I could point to the exact translation, say what the theorem promises, and show where a particular function falls.

## Make the theorem follow the code that runs.

The first problem was an implementation problem. It's easy to have a lowerer you can reason about and another version that the compiler actually calls. I removed the second, unproved route in my fork so the bridge and the proof could refer to one lowerer. That is what the first drawing follows: one translation, with the result it produces kept separate from what we can prove about that result.

Follow the program across the one translation the theorem talks about.

**One path for the code and the proof.**

The compiler caller and the theorem refer to the same lowering from LCNF to LNIR.

**Diagram key**

The outlined marker follows the single translation discussed in the proof, from left to right.

**Left: LCNF input**
The Lean representation the source evaluator describes.

**Right: LNIR output**
The lower-level representation the target evaluator describes.

- [My commit: use one LCNF-to-LNIR lowerer](https://github.com/awsmadi/turbo-lean/commit/f5bbc8fa86fb79cfb12fa746cf0fd788c62b85ae)
- [My commit: separate source evaluation from lowering](https://github.com/awsmadi/turbo-lean/commit/d091e96a33d59061d0e5d41205b152affcd6689d)

I also split the evaluator for the incoming representation away from the lowerer. They still share definitions for the language they talk about, but the evaluator can describe how the source program runs without translating it first. That gave me a useful comparison in tests. If both sides go through the same translation just to tell me what the source means, it is much harder to know what that test has checked.

The split is not the theorem. It gives the theorem and the tests a cleaner object to talk about. And having one path is not an argument that every input to it is covered. The next question is what the theorem needs to know about the function it sees.

## A function brings its callees with it.

Take a function that calls a helper, which in turn calls another helper. The first function might look simple. Its translation can still depend on what happens at the end of that chain. I changed the coverage check to follow those calls before counting the original function as proved.

Both examples start with a caller and a helper. Look at what happens at the far end of each chain.

**The proof follows the calls.**

One illustrative chain can qualify. The other has an unaccounted-for callee and stays outside the proof.

**Diagram key**

Both rows begin alike. The full chain has to qualify under the theorem's conditions.

**Top row: Eligible chain**
The calls remain in scope if each reachable declaration qualifies.

**Bottom row: Unaccounted-for call**
A missing callee record is not evidence that the call qualifies.

- [My commit: count only eligible local-call chains](https://github.com/awsmadi/turbo-lean/commit/99b5987c6adfb36d2fb27f04b2575d433b050a84)

In the fork's local-call measurement, the whole reachable chain has to be accounted for. The declarations have to lower, the relevant names have to agree, and the call sites have to use arguments the theorem handles. This check is for non-recursive calls. An unaccounted-for callee or a cycle keeps the caller out of the proved count. Where the function did lower, it can still be recorded as translated without proof. That is information, not a verdict that the generated program is wrong.

This matters because a proof with a condition does not fail to be useful when the condition is narrow. My job was to stop the reporting code from erasing the condition. I wanted a reader to be able to explain why an entry moved into the proved column, and why the next entry didn't.

- [My commit: local-call soundness lemmas](https://github.com/awsmadi/turbo-lean/commit/a518cd58540f0080a89f45046cea71d0968a183f)

## Stop the claim where the theorem stops.

The local-call theorem is a one-way result. If lowering succeeds, the environments and context agree, and the source evaluator successfully runs the function with the given fuel bound, the target evaluator returns the same value and final modeled heap. Fuel bounds the evaluation in the model. It isn't a measure of time. If source evaluation fails, or never finishes, this theorem doesn't tell me what the target does.

Watch where the comparison stops. The native executable is beyond the marked boundary.

**The comparison ends at the model.**

Under the theorem's conditions, the modeled runs finish with the same value and heap. Native code is outside this result.

**Diagram key**

The bracket links only the source and target models; it never crosses the vertical boundary.

**Left of the line: Compared**
Successful modeled runs give the same value and final modeled heap under the assumptions.

**Right of the line: Not compared**
The executable and subsequent native stages are outside this theorem.

- [Read the theorem in the pinned fork](https://github.com/awsmadi/turbo-lean/blob/33edb2ddad34fcc6c7d834f1b4e6d17f51b2c0ae/lean/LeanNative/Proofs/LowerCalls.lean#L1405-L1425)
- [My commit: fix the heap mismatch and record what's left](https://github.com/awsmadi/turbo-lean/commit/5a0d2e57f98e1925891cd302027cd2abe840c66b)

In the separate recursion work, I fixed a case that made the heap comparison matter. Both modeled runs returned zero. One freed an object and the other left it live. A test that checked only the return value would have missed it. That fix closed a specific gap, not the full recursive lowering result. And neither result proves the native binary correct. Code generation after LNIR, the rules for calling native functions, and what runs on the machine are outside the comparison.

There is a related mistake in code review. A theorem's statement can stay the same while its proof body changes. Some importing modules can observe that body during checking. In the fork I kept the edit classified as proof-only, but had the verifier recheck dependents when there were importers. That is more work than rechecking only the edited file. It is also a cost a reviewer can see and explain.

Tests make the same kind of claim. [A regression test should prove it can object](https://www.linkedin.com/pulse/regression-test-should-prove-can-object-madison-hope-steiner-cissp-cx93f/) asks a check to show that it would notice the change it guards.

- [My commit: recheck importers after proof edits](https://github.com/awsmadi/turbo-lean/commit/5c71a577c5e1961eb5b6cbc8bc55ed5c4cc95a96)

## Put the denominator beside the claim.

The receipt changed how I would talk about coverage. In the pinned run, 880 of 902 declarations in the targeted C1 tests counted as proved. In the pinned Batteries library, 53 of 10,658 did. Neither number is a correction to the other. One set exercises the constructs the work was targeting. The other makes it harder to mistake that success for coverage of a larger body of Lean code.

Read the count beside each bar. The bars have equal length, but their denominators are different.

**The proof depends on what you count.**

Each bar is one named input set in the pinned fork receipt. The small proved share of Batteries is not rounded up.

**Same proof boundary** ** Corrected count**

The Batteries count was corrected from 59 to 53 of 10,658. The intermediate 49 reflects reclassification, not another run. The modeled result and heap comparison still do not cover native execution.

**Diagram key**

The bars show fractions of each named input set, with the proved count and its denominator printed above.

**First solid segment: Proved**
The receipt counts the declaration as covered by the modeled proof.

**Vertical stripes: Translated without proof**
The measured path produced a translation outside the proof count.

**Striped segment: Rejected**
The measured path rejected it. This is not a judgment about stock Lean.

- [Pinned fork receipt: all three input sets](https://github.com/awsmadi/turbo-lean/blob/33edb2ddad34fcc6c7d834f1b4e6d17f51b2c0ae/scripts/lcnf_coverage_results.json)
- [My commit: reconcile 59, 49, and 53 on Batteries](https://github.com/awsmadi/turbo-lean/commit/0af6c9ce4a82cec669932df781f379114b8d0dc6)

The most useful result was a number that went down. On the same Batteries input set, the previous count was 59. When I fixed the classifier to see a helper call after a reference-count or set operation, ten of those entries no longer qualified as call-free. Applying the local-call rule admitted four. The result was 53. The intermediate 49 is a reclassification of the recorded facts, not another run. If I had optimized for the headline number, I would have missed the correction that made it worth publishing.

I want the receipt to travel with the result, so it records the measured source revision, Lean 4.35.0, the inputs, and digests of code used to produce the classification. It also records translated but unproved declarations separately from rejected ones. Compiler-generated auxiliaries were excluded from these denominators. A label that says a declaration was rejected is about this measurement path, not a claim that Lean cannot compile it.

The roadmap pull request I opened was closed as superseded. The maintainer credited the work and carried pieces into narrower changes. Later upstream work on bounded recursion is a separate result with its own conditions. The numbers shown here remain the measured fork snapshot, not measurements of upstream today.

**Read every category in the pinned receipt**

1. Targeted C1 tests: 880 proved, 0 translated without proof, 22 rejected, out of 902 declarations.
2. Std/Init + C2: 48 proved, 65 translated without proof, 1,692 rejected, out of 1,805 declarations.
3. Pinned Batteries: 53 proved, 1,066 translated without proof, 9,539 rejected, out of 10,658 declarations.

The rejected-but-not-lowered count in the source is part of rejected, not a fourth category.

I first wrote about this habit for test coverage in [The missing denominator](https://www.linkedin.com/pulse/missing-denominator-madison-hope-steiner-cissp-pgcnc/): the first question in a coverage review is what the report counted.

- [My commit: check digests against measured source](https://github.com/awsmadi/turbo-lean/commit/fc0a943591e4871e57a53358174eb36495768d15)
- [Maintainer's note on the superseded roadmap PR](https://github.com/Th0rgal/turbo-lean/pull/493#issuecomment-7236488984)
- [Upstream's separate bounded recursion work](https://github.com/Th0rgal/turbo-lean/pull/498)

**For a closer technical look**

- The local-call coverage rule checks the reachable transitive set of declarations, including the call arguments and the naming conditions required by the proof.
- The theorem preserves a successful result and the modeled heap, under its stated conditions. It is not a termination guarantee, a proof of failure behavior, or a theorem about an executable.
- The receipt commit 33edb2d records measurements from source 0004587 with Lean 4.35.0. See the pinned record for the external input revision and classifier digests.

## What I take from it

Before I repeat a claim about a verified compiler, I want to know which path it takes, which behaviors the theorem compares, and what the count leaves out. If I can't trace those answers back to the work, what exactly am I asking someone else to trust?

## Code and further reading

- [My commit: separate source evaluation from lowering](https://github.com/awsmadi/turbo-lean/commit/d091e96a33d59061d0e5d41205b152affcd6689d)
- [My commit: use one LCNF-to-LNIR lowerer](https://github.com/awsmadi/turbo-lean/commit/f5bbc8fa86fb79cfb12fa746cf0fd788c62b85ae)
- [My commit: local-call soundness lemmas](https://github.com/awsmadi/turbo-lean/commit/a518cd58540f0080a89f45046cea71d0968a183f)
- [My commit: count only eligible local-call chains](https://github.com/awsmadi/turbo-lean/commit/99b5987c6adfb36d2fb27f04b2575d433b050a84)
- [Read the theorem in the pinned fork](https://github.com/awsmadi/turbo-lean/blob/33edb2ddad34fcc6c7d834f1b4e6d17f51b2c0ae/lean/LeanNative/Proofs/LowerCalls.lean#L1405-L1425)
- [My commit: fix the heap mismatch and record what's left](https://github.com/awsmadi/turbo-lean/commit/5a0d2e57f98e1925891cd302027cd2abe840c66b)
- [My commit: recheck importers after proof edits](https://github.com/awsmadi/turbo-lean/commit/5c71a577c5e1961eb5b6cbc8bc55ed5c4cc95a96)
- [My commit: check digests against measured source](https://github.com/awsmadi/turbo-lean/commit/fc0a943591e4871e57a53358174eb36495768d15)
- [My commit: reconcile 59, 49, and 53 on Batteries](https://github.com/awsmadi/turbo-lean/commit/0af6c9ce4a82cec669932df781f379114b8d0dc6)
- [Pinned fork receipt: all three input sets](https://github.com/awsmadi/turbo-lean/blob/33edb2ddad34fcc6c7d834f1b4e6d17f51b2c0ae/scripts/lcnf_coverage_results.json)
- [My commit: record the pinned remeasurement](https://github.com/awsmadi/turbo-lean/commit/33edb2ddad34fcc6c7d834f1b4e6d17f51b2c0ae)
- [Maintainer's note on the superseded roadmap PR](https://github.com/Th0rgal/turbo-lean/pull/493#issuecomment-7236488984)
- [Upstream's separate bounded recursion work](https://github.com/Th0rgal/turbo-lean/pull/498)

Covers work from November 2026 Posted November 28, 2026

Also on

- On DEV from Dec 3
- [Hashnode](https://mh0pe.hashnode.dev/where-the-proof-stops)
- In editorial review at HackerNoon
- On daily.dev from Dec 3

- [Compiler correctness](https://mh0pe.github.io/blog/?tag=Compiler%20correctness#topic-developer-tools)
- [Formal verification](https://mh0pe.github.io/blog/?tag=Formal%20verification#topic-developer-tools)
- [Reproducibility](https://mh0pe.github.io/blog/?tag=Reproducibility#topic-developer-tools)

[See TurboLean in the public workbench](https://mh0pe.github.io/work/#turbolean-coverage)

## Read next.

Security

### [The tools are part of the result.](https://mh0pe.github.io/blog/reproducible-security-checks/)

Why I added a pinned scanner environment to ASH, and what reproducibility can and cannot tell you.
