Skip to content
المشاريع

حول

Not Only Compiler. A typed assembly framework for machine-code generation, optimization, and formal verification in Lean 4.

أدوات التطوير

كيف تُقاس هذه الأرقام

124 نجمة12 التفرعات +11 خلال 24 ساعة

النمو المقاس للنجوم

خلال 24 ساعة
+١١
خلال 7 أيام
جارٍ جمع السجل
خلال 15 يومًا
جارٍ جمع السجل
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

NoCompiler

NoCompiler is a typed assembly framework for formally verifying memory safety and functional equivalence at the machine-code level, with soundness proofs in Lean 4. It enables formally verified machine-code generation and optimization, regardless of whether the code is written by humans, generated by compilers, or produced by AI agents.

Motivation

  • Can we go beyond compilers? AI agents can optimize machine code beyond conventional compiler passes. Formal verification ensures behavioral equivalence and memory safety.
  • Why trust a compiler? Source-level safety guarantees do not automatically extend to executable machine code without trusting the compilation process.
  • Why manually prove machine-code properties? A type system can automate reasoning about memory safety and functional equivalence directly at the machine-code level.
  • Why restrict AI agents to high-level languages? With a formally verified type system, AI agents could generate safe machine code directly, bypassing conventional compilers entirely.

Our answer

  • Typed assembly: Assembly with function signatures, memory permissions, and loop invariants.
  • Formally verified checker: Soundness proved in Lean 4 against formal machine semantics.
  • Static memory safety: Verifies memory accesses using arithmetic constraints and memory capabilities.
  • Functional equivalence: Verifies machine-code transformations using type invariants and relational reasoning.
  • Composable verification: Checked, manually proved, and trusted functions share a unified contract system.
  • Standard toolchain compatibility: Supports standard assemblers and calling conventions.
  • Verifiable compilation target: Auto-generates typed RV64 assembly from supported Rust and C/C++ functions.

Architecture Support

Feature RISC-V (RV64) AArch64
Typed assembly ✅ ✅
Memory safety verification ✅ ✅
Functional equivalence verification ✅ ✅
Compilation from C/C++ ✅ —
Compilation from Rust ✅ —

Below is an example of a typed RV64 function (see the grammar is in docs/typed/syntax.md):

#: 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

1. nocompiler CLI

1.1 Installation

Quick install (CLI and prebuilt Lean project):

curl -fsSL https://nocompiler.dev/install.sh | sh

Via Cargo:

cargo install nocompiler-cli
curl -fsSL https://nocompiler.dev/install.sh | sh -s -- --lean-only

From source:

cargo build --release -p nocompiler-cli
export PATH="$PWD/target/release:$PATH"
(cd lean && lake build NoCompiler)

1.2. CLI Examples

########## From Source Code (RV64) ######################
# Source → verified RV64 binary. Needs clang (C/C++) or nightly-2026-09-17 (Rust,
# see examples/rust-typed/README.md). Writes out/verified.elf, out/annotated.s, out/report.json.
nocompiler compile examples/sum.c --function sum -o out/
nocompiler compile --manifest-path examples/rust-typed/fixtures/word_ops/Cargo.toml \
    --bin word_ops --function word_ops::read_word -o out/ --prove

########## Memory Safety Verification ###################
# Check contracts with Rust and request a separate kernel-checked result.
nocompiler safe check examples/typed/sum.s
nocompiler safe prove examples/typed/sum.s
nocompiler safe link A.s B.s
# A compiled function as checkable text, tied to the object's bytes (docs/typed/cli.md)
nocompiler safe skeleton foo.o --function foo -o foo.s    # then add #: lines (safe annotate)
nocompiler safe verify-text foo.s foo.o

########## Functional Equivalence Verification ##########
# Request a Lean equivalence proof for two functions.
nocompiler equiv prove examples/rel/sum.s examples/rel/sum_endptr.s --prove --kernel
# Request an RV64 replacement proof under the original typed contract.
nocompiler verify examples/rel/sum.s examples/rel/sum_endptr.s

########## Binary Analysis Toolkit  #####################
# NoCompiler also provides a binary analysis toolkit supporting ELF,
# PE/COFF, and Mach-O binaries, with disassembly, decompilation,
# function and CFG recovery, IR lifting, and binary differencing.
nocompiler analyze funcs /bin/ls
nocompiler analyze decompile <binary> <symbol|address|all>
nocompiler analyze diff /bin/true /bin/false

2. Benchmarks

Memory Safety Verification: We evaluate NoCompiler on compiler-generated machine code from musl libc, verifying memory safety without modifying the original machine instructions.

musl libc: Rust checker verifies 23/29 functions, Lean checker 8/29

Machine-Code Equivalence & AI-Driven Optimization: AI agents can optimize machine code beyond -O3, cutting estimated cycles by up to 62%, and NoCompiler formally proves each rewrite equivalent to the original.

Estimated cycles relative to Clang 15 -O3 for six functions; AI-generated rewrites are up to 62% faster and proved equivalent in Lean 4

3. Trust

NoCompiler minimizes the trusted computing base (TCB) by proving the soundness of its checkers in Lean 4.

  • Trusted: The Lean kernel, formal machine semantics, contract semantics, and user-assumed contracts.
  • Not trusted: Compilers, assemblers, annotation generators, tactics, and proof authors.
  • RISC-V semantics: Tested against LLVM, QEMU, and Sail, but not formally proved equivalent to Sail.
  • AArch64 semantics: Based on Google DeepMind's formal AArch64 model.

4. Citation

Our work-in-progress papers cover memory safety and functional equivalence & AI-driven binary optimization. If you find NoCompiler interesting or useful in your research, please consider citing our work.

BibTeX
@misc{takahashi2026nocompiler_memory,
  title  = {Not Only Compilers: Typed {RISC-V} Assembly with Memory Safety Proved in {Lean 4}},
  author = {Takahashi, Hideaki},
  year   = {2026},
  url    = {https://nocompiler.dev/paper/nocompiler-memory-paper.pdf},
  note   = {Preprint}
}

@misc{takahashi2026nocompiler_equivalence,
  title  = {Not Only Compilers, But Also {LLMs}: Optimizing Machine Code Beyond {-O3}, with Equivalence Proved in {Lean 4}},
  author = {Takahashi, Hideaki},
  year   = {2026},
  url    = {https://nocompiler.dev/paper/nocompiler-equivalence-paper.pdf},
  note   = {Preprint}
}

5. License

NoCompiler is licensed under the Apache License 2.0. See LICENSE.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…