Not only Compiler

Verify and Optimize
Your Machine Code.

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
[nc] AI patches the binary · Lean proves it
Two scenes over the disassembly of a compiled summation loop. First, an AI, drawn as an eye, patches the loop's bytes in place into an end-pointer version; the relational checker proves the patched function equivalent to the original, and a second patch that steps by 16 bytes is rejected. Second, the original function is type-checked and proved memory safe; the eye patches a load to read 8 bytes further, and the type checker rejects it.

Typed RISC-V Assembly with Proved Memory Safety.

Verify memory safety directly at the machine-code level, even for code written in unsafe Rust, generated by AI, or compiled from other languages.

  • Typed RISC-V Assembly

    Function signatures, memory permissions, and loop invariants on RV64 assembly, as comments any standard assembler accepts.

  • C/C++ and Unsafe Rust Frontends experimental

    Generate typed assembly automatically from compiled C/C++ and Rust functions.

  • Formally Verified Checker in Lean 4

    A type checker whose soundness is proved against a formal semantics of RISC-V.

  • Formally Verified C Standard Library

    79% of the musl libc functions we tried (23 of 29) verified on Clang's output, without changing an instruction.

Explore the type system →
TYPED ASMexamples/typed/sum.s
#: 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
Signatures and loop invariants are #: comments, so any RISC-V assembler still accepts the file.

Optimize Beyond -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.

BEFOREclang -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
≡ proved in
Lean 4
AFTERrewrite · sum_endptr.s
  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 →

Cryptography

Fiat-Crypto

21.2% fewer cycles than the best compiler output
Embedded ML

TensorFlow Lite Micro

45% fewer cycles than Clang -O3
Fixed-point arithmetic

libfixmath

66% fewer cycles than Clang -O3
Signal processing

ESP-DSP

44% fewer cycles than Clang -O3

Let AI Directly Write and Optimize Machine Code.

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.

Prompts go through AI code generation, and source code goes through a compiler and then AI code optimization; both converge into NoCompiler's formal verification in Lean 4, which yields verified machine code. Prompts Source code Compiler outputLLVM / GCC AI Code Generation AI Code Optimization NoCompilerFormal Verification · Lean 4 ✓ Verified Machine Code

Read the Papers.

BIBTEXcite NoCompiler
@misc{takahashi2026nocompiler,
  title  = {NoCompiler: Formally Verified Typed Assembly for RISC-V},
  author = {Takahashi, Hideaki},
  year   = {2026},
  url    = {https://github.com/h5i-dev/NoCompiler}
}

Frequently Asked Questions.

What exactly does NoCompiler prove?
Two things, on the machine code. Memory safety: a checked function terminates, never faults, and touches only the memory its signature grants. Equivalence: an optimized function returns the same results and leaves the same memory as the original, under the original's contract. For code an AI writes from scratch, memory safety is proved; functional correctness needs a separate specification.
Do I have to change what the compiler emits?
No. You add type annotations as #: comments; the instructions stay byte-identical.
What do I have to trust?
The Lean kernel, the formal RISC-V semantics (tested against QEMU and Sail), the meaning of a signature, any unsafe contracts you assume, and, for now, the Rust checker for functions the Lean checker does not yet prove. Compilers, assemblers, annotation writers, and AI agents are not trusted.
Do I need to trust the AI that optimizes my code?
No. The AI only proposes a rewrite. NoCompiler proves it equivalent to the original or rejects it with an input that tells the two apart.

Check Your First Function.

Read the tutorial

Install

$ cargo install --git https://github.com/h5i-dev/NoCompiler nocompiler-typed