# EVMYulLean

> An executable model of the EVM (Cancun fork) and of Yul, the Solidity compiler's intermediate language, in Lean 4 by Nethermind. The EVM part passes almost all Cancun conformance tests.

The authors describe the project as work in progress and subject to change. The Yul model reuses the EVM's primitive operations but leaves out gas and several opcodes (see fragment).

- Kind: formal semantics
- Models: EVM bytecode (EVM Cancun fork; Yul (no version stated))
- Fragment: EVM: the state transition for the Cancun fork, including gas and exceptional halting. Precompiles are not written in Lean; they call external C or Python code through Lean's FFI. Yul: syntax and an interpreter that reuses the EVM primitive operations, without gas, CREATE and CREATE2, code-inspecting opcodes (EXTCODESIZE, EXTCODEHASH, EXTCODECOPY, CODECOPY, CODESIZE), fallback functions on receiving ether, or halting on SELFDESTRUCT.
- Written in: Lean 4
- Available in: Lean 4
- Stage: 1 (Validated)
- Licence: open-source, Apache-2.0
- Validation: The repository runs the Ethereum conformance tests (ethereum/tests) with its own test runner. Nethermind's February 2026 post reports 22,330 of 22,332 Cancun execution tests passing; the two others have unclear and possibly non-deterministic expected results. The Yul interpreter has its own small test suite. Results are reported by the authors; we did not re-run them.
- Latest release: main@047f630 (2025-09-23) https://github.com/NethermindEth/EVMYulLean/commits/main

## Stage

**Stage 1: Validated.**

| Stage | Criterion | Met | Evidence / note |
|---|---|---|---|
| 0 | Machine-checked or machine-readable definition | yes | [evidence](https://github.com/NethermindEth/EVMYulLean) |
| 0 | Fragment and version are stated | yes | [evidence](https://github.com/NethermindEth/EVMYulLean/blob/main/README.md) The README lists what the Yul model leaves out; the code fixes the target fork as Cancun (EvmYul/Wheels.lean). |
| 1 | Can be executed or tested | yes | [evidence](https://github.com/NethermindEth/EVMYulLean/blob/main/README.md) Conformance tests run with lake test; the Yul tests with lake exe yulSemanticsTests. |
| 1 | Published results against conformance tests or real implementations | yes | [evidence](https://www.nethermind.io/blog/a-trustworthy-formal-model-of-evm-yul-in-lean) 22,330 of 22,332 Cancun execution tests pass (author-reported, February 2026). |
| 2 | Adopted by the language or ISA owner, or covers the full current version and tracks new ones | no | [evidence](https://github.com/NethermindEth/EVMYulLean/blob/main/EvmYul/Wheels.lean) Adopted by the owner: no; full coverage: no; tracks new versions: no. Funded by an Ethereum Foundation grant, but not adopted as a reference. The authors list becoming an official executable reference as a possible future use. Only the Cancun fork is modeled (TargetSchedule is "Cancun"); later forks such as Prague and Osaka are not. The Yul model has the gaps listed above. No stated policy for new forks; the last commit on the default branch is from September 2025. |

Missing for Stage 2: Adopted by the language or ISA owner, or covers the full current version and tracks new ones.

## EVM-specific features

| Feature | Coverage |
|---|---|
| Gas | Supported — Gas is modeled for EVM bytecode. The Yul model has no gas. ([source](https://www.nethermind.io/blog/a-trustworthy-formal-model-of-evm-yul-in-lean)) |
| Storage | Supported ([source](https://github.com/NethermindEth/EVMYulLean/blob/main/EvmYul/EVM/Semantics.lean)) |
| External calls | Supported — For EVM bytecode. The Yul model does not support CREATE, CREATE2 or calls that depend on inspecting other contracts' code. ([source](https://github.com/NethermindEth/EVMYulLean/blob/main/README.md)) |
| Precompiles | Partial — Precompiles are not defined in Lean; the model calls external C or Python implementations through Lean's FFI, so their behavior is not defined in the logic. ([source](https://www.nethermind.io/blog/a-trustworthy-formal-model-of-evm-yul-in-lean)) |

## Sources
- [EVMYulLean repository and README](https://github.com/NethermindEth/EVMYulLean)
- [Nethermind, A trustworthy formal model of EVM+Yul in Lean (2026-02-06)](https://www.nethermind.io/blog/a-trustworthy-formal-model-of-evm-yul-in-lean)
- [Target fork setting (TargetSchedule = Cancun)](https://github.com/NethermindEth/EVMYulLean/blob/main/EvmYul/Wheels.lean)
- [Lake build file (Lean v4.22.0, mathlib, C hash libraries)](https://github.com/NethermindEth/EVMYulLean/blob/main/lakefile.lean)

---
Last checked 2026-11-26. Data: [JSON](/semantics/evm-yul.json) · Page: [HTML](/semantics/evm-yul/) · Methodology v0.1: [/methodology/](/methodology/) · Corrections: [/contribute/](/contribute/)
