LLM-powered proof automation for the Lean theorem prover, offering tactic suggestions, proof search and premise selection.
NethermindEth/LeanCIL
A Lean 4 framework for machine-checked proofs of correctness and memory safety against compiled .NET CIL from C#, F#, and other .NET languages.
- Stars
- 110
- Forks
- 3
- Open issues
- 21
- Last commit
- yesterday
What is it?
LeanCIL extracts Common Intermediate Language from compiled .NET assemblies and checks Lean 4 proofs against an explicit model of those instructions. Proofs can cover every input satisfying a contract, loop termination, checked memory access, and counterexamples to incorrect implementations. Previously proved method contracts can be composed without unfolding helper bodies.
The workflow has a CLI with commands to list methods, extract a method and its reachable calls, check extraction artifacts, and verify a named theorem with kernel replay and an axiom audit. Successful verification writes a verified.json report tied to the SHA-256 of the assembly. Consumer packages let application specifications and proofs live in a separate Lean project pinned to LeanCIL.
The supported subset covers integer arithmetic, selected control flow, managed calls, reference-free structs, and arrays and spans over supplied storage. Floating-point arithmetic, general class allocation, virtual dispatch, ordinary recursion, and exception handlers are outside the model. The project does not claim complete CLR or JIT verification.
Key features
- 01Proves functional properties for all inputs satisfying a contract, using Lean 4 proofs.
- 02Extracts and validates CIL from compiled C#, F# and other .NET assemblies.
- 03Checks memory access, bounds, initialization and alignment in a checked memory model.
- 04Composes previously proved method contracts without unfolding helper bodies.
- 05Produces a verified.json report bound to the assembly's SHA-256 hash.
Use cases
- Proving that a .NET arithmetic or buffer routine behaves correctly for all inputs.
- Checking that a loop over a span terminates and leaves memory outside its writable region unchanged.
- Finding counterexamples that show an implementation violates its intended specification.
Quick start
- 1
Install Lean 4.35.0 via elan and .NET SDK 10.0.403 from the checkout
- 2
Build the Lean project from the checkout
lake build - 3
Pack the Extractor as a local NuGet package
dotnet pack Extractor -c Release -o artifacts/packages - 4
Install the leancil global tool from the local package
dotnet tool install --global Nethermind.LeanCIL --add-source artifacts/packages --version 0.1.0
Things to know
- Supports only a restricted subset of CIL; general class allocation, virtual dispatch, exception handlers and floating-point arithmetic are unsupported.
- Requires both a Lean 4 toolchain and the .NET SDK, with specific pinned versions.
- Early-stage project at version 0.1.0 with a small community.
Topics
FAQ
- What is LeanCIL?
- A Lean 4 framework for machine-checked proofs of correctness and memory safety against compiled .NET CIL from C#, F#, and other .NET languages. LeanCIL extracts Common Intermediate Language from compiled .NET assemblies and checks Lean 4 proofs against an explicit model of those instructions. Proofs can cover every input satisfying a contract, loop termination, checked memory access, and counterexamples to incorrect implementations. Previously proved method contracts can be composed without unfolding helper bodies.
- Is LeanCIL free to use? What license does it have?
- LeanCIL is open source under the Other license. Check the license terms before using it in commercial products.
- Is LeanCIL still maintained?
- Actively maintained. The last commit to LeanCIL was on Nov 5, 2026.
- What can I use LeanCIL for?
- Proving that a .NET arithmetic or buffer routine behaves correctly for all inputs. Checking that a loop over a span terminates and leaves memory outside its writable region unchanged. Finding counterexamples that show an implementation violates its intended specification.
- How do I install LeanCIL?
- Install Lean 4.35.0 via elan and .NET SDK 10.0.403 from the checkout Build the Lean project from the checkout: lake build Pack the Extractor as a local NuGet package: dotnet pack Extractor -c Release -o artifacts/packages Install the leancil global tool from the local package: dotnet tool install --global Nethermind.LeanCIL --add-source artifacts/packages --version 0.1.0
- Where can I get LeanCIL?
- The source code and installation instructions are on GitHub: https://github.com/NethermindEth/LeanCIL
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Lean 4 framework for specifying, executing, and formally verifying neural networks, with shape-checked tensors and PyTorch-style training.
Lean 4 ahead-of-time compiler that turns ordinary Lean programs into WebAssembly for Node, serverless, edge, WASI and browser targets.
A programming language that uses laws and proofs to make AI-written code verifiable, and compiles to fast parallel CPU and GPU code.
A TypeScript implementation of the TLA+ interpreter and model checker, a drop-in replacement for the Java-based TLC that runs in browsers, Node, and Bun.
A Lean 4 formalization of the Stacks Project, the open-source algebraic geometry reference, built on Mathlib with machine-checked proofs.