<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://invarians.org/index.php?action=history&amp;feed=atom&amp;title=Lean_theorem_prover%2FExplainers%2FChecking_a_proof_again_later</id>
	<title>Lean theorem prover/Explainers/Checking a proof again later - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://invarians.org/index.php?action=history&amp;feed=atom&amp;title=Lean_theorem_prover%2FExplainers%2FChecking_a_proof_again_later"/>
	<link rel="alternate" type="text/html" href="https://invarians.org/index.php?title=Lean_theorem_prover/Explainers/Checking_a_proof_again_later&amp;action=history"/>
	<updated>2026-10-21T06:48:28Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://invarians.org/index.php?title=Lean_theorem_prover/Explainers/Checking_a_proof_again_later&amp;diff=6769&amp;oldid=prev</id>
		<title>PMA Publisher: Published from the Principia Machina source</title>
		<link rel="alternate" type="text/html" href="https://invarians.org/index.php?title=Lean_theorem_prover/Explainers/Checking_a_proof_again_later&amp;diff=6769&amp;oldid=prev"/>
		<updated>2026-10-15T19:34:40Z</updated>

		<summary type="html">&lt;p&gt;Published from the Principia Machina source&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:34, 15 October 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{DISPLAYTITLE:Checking a proof again later}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{DISPLAYTITLE:Checking a proof again later}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Technical|Lean theorem prover/System/Proof export and independent checkers}}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Technical|Lean theorem prover/System/Proof export and independent checkers}}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{Lean theorem prover map}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A proof that Lean accepted today should still be checkable next year, by someone else, with other&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;A proof that Lean accepted today should still be checkable next year, by someone else, with other&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key pma_cutover_20261020t051351z-soft_:diff:1.41:old-6562:rev-6769:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>PMA Publisher</name></author>
	</entry>
	<entry>
		<id>https://invarians.org/index.php?title=Lean_theorem_prover/Explainers/Checking_a_proof_again_later&amp;diff=6562&amp;oldid=prev</id>
		<title>PMA Publisher: Published from the Principia Machina source</title>
		<link rel="alternate" type="text/html" href="https://invarians.org/index.php?title=Lean_theorem_prover/Explainers/Checking_a_proof_again_later&amp;diff=6562&amp;oldid=prev"/>
		<updated>2026-10-14T18:00:54Z</updated>

		<summary type="html">&lt;p&gt;Published from the Principia Machina source&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{DISPLAYTITLE:Checking a proof again later}}&lt;br /&gt;
{{Technical|Lean theorem prover/System/Proof export and independent checkers}}&lt;br /&gt;
&lt;br /&gt;
A proof that Lean accepted today should still be checkable next year, by someone else, with other&lt;br /&gt;
tools. This page says what Lean keeps once it has checked a file, how a kept proof can be checked&lt;br /&gt;
again by Lean and by programs written independently of Lean, and why the version of Lean has to&lt;br /&gt;
be fixed if a check is to be repeated exactly. It ends with the work that keeps proofs usable as&lt;br /&gt;
Lean and its libraries change.&lt;br /&gt;
&lt;br /&gt;
== What Lean keeps ==&lt;br /&gt;
&lt;br /&gt;
When Lean processes a source file, it saves what the file added to Lean&amp;#039;s environment, its table&lt;br /&gt;
of definitions and theorems, in a compiled file whose name ends in &amp;lt;code&amp;gt;.olean&amp;lt;/code&amp;gt;. The values&lt;br /&gt;
are stored just as they lie in memory, so a later run can load the file directly instead of&lt;br /&gt;
reading it piece by piece.&amp;lt;ref name=&amp;quot;refelab&amp;quot;&amp;gt;&amp;#039;&amp;#039;The Lean Language Reference&amp;#039;&amp;#039;, version for Lean 4.34.0, section &amp;quot;Elaboration and Compilation&amp;quot;. [https://lean-lang.org/doc/reference/4.34.0/Elaboration-and-Compilation/ lean-lang.org/doc/reference/4.34.0/Elaboration-and-Compilation], consulted 14 October 2026.&amp;lt;/ref&amp;gt;&lt;br /&gt;
A file that imports another reads its compiled form; it does not check the other file&amp;#039;s proofs&lt;br /&gt;
again.&lt;br /&gt;
&lt;br /&gt;
That is what makes large libraries practical, and it has a consequence. A theorem imported from a&lt;br /&gt;
compiled file is believed because it was checked when the compiled file was made. If something&lt;br /&gt;
went wrong at that moment, nothing later in the same run will notice.&lt;br /&gt;
&lt;br /&gt;
== Replaying the proofs ==&lt;br /&gt;
&lt;br /&gt;
The first way to check again is to replay. A tool now called &amp;lt;code&amp;gt;leanchecker&amp;lt;/code&amp;gt; reads the&lt;br /&gt;
definitions and proofs stored in compiled files and passes them through the Lean kernel once more.&lt;br /&gt;
It began as a separate program, &amp;lt;code&amp;gt;lean4checker&amp;lt;/code&amp;gt;; it was merged into Lean and has shipped&lt;br /&gt;
with every version of Lean since 4.28.0.&amp;lt;ref name=&amp;quot;l4c&amp;quot;&amp;gt;&amp;#039;&amp;#039;lean4checker&amp;#039;&amp;#039; (README of the archived project; now distributed with Lean as &amp;lt;code&amp;gt;leanchecker&amp;lt;/code&amp;gt;). [https://github.com/leanprover/lean4checker github.com/leanprover/lean4checker], consulted 13 October 2026.&amp;lt;/ref&amp;gt;&lt;br /&gt;
With the option &amp;lt;code&amp;gt;--fresh&amp;lt;/code&amp;gt; it replays everything from the start, imported files&lt;br /&gt;
included, which is slower.&amp;lt;ref name=&amp;quot;l4c&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lean&amp;#039;s guide to validating proofs says what replaying catches: faults in the way Lean manages the&lt;br /&gt;
Lean kernel&amp;#039;s state, for instance when it works in parallel or handles imports, and programs that&lt;br /&gt;
add theorems by going around the Lean kernel. It also says what replaying does not catch. The tool&lt;br /&gt;
uses the same Lean kernel, and it assumes the compiled files themselves are well formed.&amp;lt;ref name=&amp;quot;refval&amp;quot;&amp;gt;&amp;#039;&amp;#039;The Lean Language Reference&amp;#039;&amp;#039;, version for Lean 4.34.0, section &amp;quot;Validating a Lean Proof&amp;quot;. [https://lean-lang.org/doc/reference/4.34.0/ValidatingProofs/ lean-lang.org/doc/reference/4.34.0/ValidatingProofs], consulted 14 October 2026.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exporting a proof ==&lt;br /&gt;
&lt;br /&gt;
The second way is to take the proofs out of Lean altogether. A program called&lt;br /&gt;
&amp;lt;code&amp;gt;lean4export&amp;lt;/code&amp;gt; writes chosen definitions and theorems, with everything they depend on,&lt;br /&gt;
as plain text in a documented format: one record per line, each in JSON.&amp;lt;ref name=&amp;quot;l4e&amp;quot;&amp;gt;&amp;#039;&amp;#039;lean4export&amp;#039;&amp;#039; (README). [https://github.com/leanprover/lean4export github.com/leanprover/lean4export], consulted 13 October 2026.&amp;lt;/ref&amp;gt;&lt;br /&gt;
A program that reads this text needs no part of Lean. It sees the proofs exactly as the Lean&lt;br /&gt;
kernel would, without Lean&amp;#039;s parser, its notation or its tactics in between.&lt;br /&gt;
&lt;br /&gt;
Pollack had argued for this arrangement in 1998. A proof can be checked again by a second, simple&lt;br /&gt;
checker for the same logic, perhaps one whose correctness has been reviewed by experts and tested&lt;br /&gt;
on earlier proofs; if a few such checkers become trusted, people can keep using whatever tools&lt;br /&gt;
they like to construct proofs in the first place.&amp;lt;ref name=&amp;quot;pollack&amp;quot;&amp;gt;R. Pollack, &amp;quot;How to believe a machine-checked proof&amp;quot;, in Giovanni Sambin and Jan M. Smith (eds), &amp;#039;&amp;#039;Twenty Five Years of Constructive Type Theory&amp;#039;&amp;#039;, Oxford University Press, 1998, chapter 11 (from p. 205); first issued as BRICS Report RS-97-18, Aarhus University, 1997. [https://doi.org/10.7146/brics.v4i18.18945 doi:10.7146/brics.v4i18.18945]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Independent checkers ==&lt;br /&gt;
&lt;br /&gt;
Several programs check Lean proofs without using the Lean kernel.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Lean4Lean&amp;#039;&amp;#039;&amp;#039; is a checker written in Lean itself. Its author describes it as the first complete&lt;br /&gt;
checker for Lean 4 apart from the Lean kernel, which is written in C++; it runs between 20 and 50&lt;br /&gt;
per cent slower and can check the whole of Mathlib. Because it is written in a language in which&lt;br /&gt;
things can be proved, properties of the checker can be proved too, and the work has already led to&lt;br /&gt;
one fault in Lean&amp;#039;s checking being found and fixed.&amp;lt;ref name=&amp;quot;l4l&amp;quot;&amp;gt;Mario Carneiro, &amp;quot;Lean4Lean: Verifying a Typechecker for Lean, in Lean&amp;quot;, arXiv:2403.14064, version 3, 14 September 2025. [https://arxiv.org/abs/2403.14064 arxiv.org/abs/2403.14064]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;nanoda&amp;#039;&amp;#039;&amp;#039; is a checker written in Rust that reads the files &amp;lt;code&amp;gt;lean4export&amp;lt;/code&amp;gt;&lt;br /&gt;
writes.&amp;lt;ref name=&amp;quot;nanoda&amp;quot;&amp;gt;&amp;#039;&amp;#039;nanoda_lib&amp;#039;&amp;#039; (README), an external type checker for Lean 4 written in Rust. [https://github.com/ammkrn/nanoda_lib github.com/ammkrn/nanoda_lib], consulted 13 October 2026.&amp;lt;/ref&amp;gt;&lt;br /&gt;
Lean&amp;#039;s guide names it as developed independently, and as one of the checkers its strictest&lt;br /&gt;
procedure can use.&amp;lt;ref name=&amp;quot;refval&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;Lean Kernel Arena&amp;#039;&amp;#039;&amp;#039; is a site that presents, tests and compares checkers for Lean on a&lt;br /&gt;
common set of tests. When it was consulted for this page, its table listed the official checker&lt;br /&gt;
for Lean 4.34.1 beside Lean4Lean, nanoda and many others.&amp;lt;ref name=&amp;quot;arena&amp;quot;&amp;gt;&amp;#039;&amp;#039;Lean Kernel Arena&amp;#039;&amp;#039;. [https://arena.lean-lang.org arena.lean-lang.org], consulted 13 October 2026.&amp;lt;/ref&amp;gt;&lt;br /&gt;
Lean&amp;#039;s guide points to it for anyone who wants still more confidence.&amp;lt;ref name=&amp;quot;refval&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Agreement between checkers written by different people, in different languages, is evidence of a&lt;br /&gt;
different kind from a single check. When every one of them must accept, a fault would have to&lt;br /&gt;
be present in all of them at once to let a false proof through.&amp;lt;ref name=&amp;quot;refval&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Fixing the version ==&lt;br /&gt;
&lt;br /&gt;
A check can be repeated exactly only with the same version of Lean. A Lean project names the&lt;br /&gt;
version it uses in a one-line text file called &amp;lt;code&amp;gt;lean-toolchain&amp;lt;/code&amp;gt;, kept at the top of the&lt;br /&gt;
project; the toolchain manager, elan, reads it and runs that version. Lean&amp;#039;s reference advises&lt;br /&gt;
naming an exact version rather than a channel such as &amp;lt;code&amp;gt;stable&amp;lt;/code&amp;gt;, so that people working&lt;br /&gt;
together use the same one and older states of a project can still be checked and&lt;br /&gt;
tested.&amp;lt;ref name=&amp;quot;elan&amp;quot;&amp;gt;&amp;#039;&amp;#039;The Lean Language Reference&amp;#039;&amp;#039;, version for Lean 4.34.0, section &amp;quot;Managing Toolchains with Elan&amp;quot;. [https://lean-lang.org/doc/reference/4.34.0/Build-Tools-and-Distribution/Managing-Toolchains-with-Elan/ lean-lang.org/doc/reference/4.34.0/Build-Tools-and-Distribution/Managing-Toolchains-with-Elan], consulted 14 October 2026.&amp;lt;/ref&amp;gt;&lt;br /&gt;
The project this wiki records fixes its version of Lean at 4.34.1&lt;br /&gt;
(see [[Principia Machina/Lean transition|the move to Lean]]).&lt;br /&gt;
&lt;br /&gt;
== Why proofs need upkeep ==&lt;br /&gt;
&lt;br /&gt;
A proof, once checked, stays a proof in the logic it was checked in. What wears out is the&lt;br /&gt;
ability to run the check again with current tools.&lt;br /&gt;
&lt;br /&gt;
New versions of Lean appear every month, and Mathlib, the main library of mathematics, moves&lt;br /&gt;
with them.&amp;lt;ref name=&amp;quot;growing&amp;quot;&amp;gt;Anne Baanen, Matthew R. Ballard, Johan Commelin, Bryan Gin-ge Chen, Michael Rothgang and Damiano Testa, &amp;quot;Growing Mathlib: maintenance of a large scale mathematical library&amp;quot;, arXiv:2508.21593, version 2, 7 October 2025; to appear at the Conference on Intelligent Computer Mathematics (CICM) 2025. [https://arxiv.org/abs/2508.21593 arxiv.org/abs/2508.21593]&amp;lt;/ref&amp;gt; The authors of a 2025 paper on Mathlib&amp;#039;s maintenance write that code written for one version of Mathlib may no longer compile&lt;br /&gt;
with a newer one, and that a project which falls too far behind may find it can no longer&lt;br /&gt;
contribute its results back.&amp;lt;ref name=&amp;quot;growing&amp;quot; /&amp;gt;&lt;br /&gt;
To soften this, a theorem that is renamed keeps its old name for a grace period of several&lt;br /&gt;
months, marked as out of date; anyone who uses the old name gets a warning that names the new&lt;br /&gt;
one.&amp;lt;ref name=&amp;quot;growing&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The move from Lean 3 to Lean 4 was a change of this kind on a large scale: it meant translating&lt;br /&gt;
Mathlib into the new language. Notes left during that translation numbered well over 5,000 in the summer&lt;br /&gt;
of 2023 and roughly 1,500 when that paper was written in 2025.&amp;lt;ref name=&amp;quot;growing&amp;quot; /&amp;gt;&lt;br /&gt;
(See [[Lean theorem prover/History/Lean 1 to Lean 3|Lean 1 to Lean 3]] and&lt;br /&gt;
[[Lean theorem prover/History/Lean 4|Lean 4]].)&lt;br /&gt;
&lt;br /&gt;
Two practices follow. Keep the exact version with the proof, so that the original check can be&lt;br /&gt;
repeated. And expect to revise the proof when moving it to a newer version, so that it stays&lt;br /&gt;
usable by new work.&lt;br /&gt;
&lt;br /&gt;
== Next ==&lt;br /&gt;
&lt;br /&gt;
[[Lean theorem prover/Explainers/Stating the right thing|Stating the right thing]] turns to the&lt;br /&gt;
one question no re-check can answer: whether the statement says what was meant.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>PMA Publisher</name></author>
	</entry>
</feed>