NoCompiler is a formal verification toolkit for RISC-V machine code. Prove memory safety, and verify that optimized binaries preserve the behavior of the original code, powered by Lean 4.
$ cargo install --git https://github.com/h5i-dev/NoCompiler nocompiler-typed
Verify memory safety directly at the machine-code level, even for code written in unsafe Rust, generated by AI, or compiled from other languages.
Function signatures, memory permissions, and loop invariants on RV64 assembly, as comments any standard assembler accepts.
Generate typed assembly automatically from compiled C/C++ and Rust functions.
A type checker whose soundness is proved against a formal semantics of RISC-V.
79% of the musl libc functions we tried (23 of 29) verified on Clang's output, without changing an instruction.
#: fn sum [ρ, n] #: in a0: int(ρ), a1: int(n) #: borrow ρ ↦ bytes[8n] ro #: where 8 ∣ ρ #: out a0: int #: stack 0 sum: li a2, 0 beqz a1, .LBB0_2 .LBB0_1: #: inv [k] a0: int(ρ + 8n − 8k), a1: int(k), a2: int where 1 ≤ k ≤ n decreases k ld a3, 0(a0) add a2, a3, a2 addi a1, a1, -1 addi a0, a0, 8 bnez a1, .LBB0_1 .LBB0_2: mv a0, a2 ret
#: comments, so any RISC-V assembler still accepts the file.-O3 with Proven Equivalence.Optimize compiled functions for performance and resource efficiency. NoCompiler verifies that the optimized code preserves the behavior of the original implementation.
Explore optimizations beyond those produced by conventional compilers.
Let AI agents generate optimized assembly and use formal verification to validate their changes.
Prove that a rewrite preserves the observable behavior of the original code under its specified contract.
-O2 · sum.s.LBB0_1: ld a3, 0(a0) add a2, a3, a2 addi a1, a1, -1 addi a0, a0, 8 bnez a1, .LBB0_1
sh3add a1, a1, a0 .LBB0_1: ld a3, 0(a0) addi a0, a0, 8 add a2, a2, a3 bne a0, a1, .LBB0_1
experimentalExplore binary equivalence →
Benchmarks on real-world binaries, optimized directly by AI agents after -O3 compilation. Read the paper →
-O3
-O3
-O3
Why limit AI to writing source code? AI agents can generate machine code directly or further optimize the output of existing compilers, with formal verification providing safety and correctness guarantees.
-O3, with Equivalence Proved in Lean 4@misc{takahashi2026nocompiler,
title = {NoCompiler: Formally Verified Typed Assembly for RISC-V},
author = {Takahashi, Hideaki},
year = {2026},
url = {https://github.com/h5i-dev/NoCompiler}
}
#: comments; the instructions stay byte-identical.$ cargo install --git https://github.com/h5i-dev/NoCompiler nocompiler-typed