# LNSym

> Prove Armv8 (AArch64) machine code correct in Lean 4 by symbolic simulation over a hand-written model; aimed at AWS-LC cryptographic routines.

- Kind: toolchain
- Verifies: AArch64 (Armv8 user-mode code, mainly AWS-LC routines (SHA-512, AES-GCM, GCM).)
- Effort: Interactive — You write proofs step by step in a proof assistant.
- Stage: 0 (Research)
- Trust: Checker strong, Semantics partial, Frontend partial, Binary gap strong, Escape hatches partial
- Licence: open-source, Apache-2.0
- Latest release: main@49f8a1d (2026-11-06) https://github.com/leanprover/LNSym/commits/main
- Links: [repo](https://github.com/leanprover/LNSym), [docs](https://github.com/leanprover/LNSym#readme)

## Use it if
- You want to reason about AArch64 crypto assembly in Lean 4 and can work with a research-stage tool.
- Your code uses general-purpose, Advanced SIMD and crypto-extension instructions that LNSym already models.

## Look elsewhere if
- You need finished, reusable proofs; the AWS-LC proofs in the repository still contain sorry.
- Your code uses floating-point arithmetic, system registers, exceptions or SVE; these are not modeled.

## How it works (pipeline)

| Step | Component | Assurance | Note |
|---|---|---|---|
| frontend | Opcode lists copied from objdump into Lean definitions | trusted | Separate ELF tests extract AWS-LC symbols from a built library, but as far as we could tell they are not tied to the program definitions used in the proofs. |
| semantics | LNSym AArch64 model (hand-written in Lean 4) | validated | A subset of AArch64; co-simulated against Apple silicon (macOS runner) in CI with random tests per instruction class. |
| translation | Symbolic simulation tactics and bv_decide | checked |  |
| checker | Lean 4 kernel (`lean4`) | trusted | bv_decide steps also rely on Lean's compiler through the Lean.ofReduceBool axiom. |

## Trust

| Axis | Level | Summary | Note |
|---|---|---|---|
| Checker | Strong (green) | The Lean kernel checks proofs; bv_decide steps also trust Lean's compiler. | bv_decide checks SAT certificates with a verified checker run as compiled code (Lean.ofReduceBool). [source](https://github.com/leanprover/LNSym/blob/main/Proofs/AES-GCM/GCMInitV8Sym.lean) |
| Semantics | Partial (amber) | Hand-written AArch64 subset; random co-simulation against real Arm CPUs in CI. | We found no published report of the co-simulation results. [source](https://github.com/leanprover/LNSym/blob/main/.github/workflows/ci.yml) |
| Frontend | Partial (amber) | Opcodes are pasted from objdump into Lean; not linked to the binary by a proof. |  [source](https://github.com/leanprover/LNSym/blob/main/Tests/AES-GCM/GCMInitV8Program.lean) |
| Binary gap | Strong (green) | Proofs are about the machine code itself; no compiler is trusted. |  |
| Escape hatches | Partial (amber) | sorry is used in several proofs; Lean warns and |  [source](https://github.com/leanprover/LNSym/blob/main/Proofs/SHA512/SHA512Prelude.lean) |

## What it can prove

| Property | Support |
|---|---|
| No undefined behavior | Unknown — Proofs show no decoding error or unmodeled instruction is reached. The memory-safety part of the GCM init specification is commented out; we found no finished memory-safety proofs. ([source](https://github.com/leanprover/LNSym/blob/main/Proofs/AES-GCM/GCMInitV8Sym.lean)) |
| Functional correctness | Partial — Functional specifications can be stated and proved, but the main AWS-LC proofs are unfinished: SHA-512 and AES-GCM proofs contain sorry, and the GCM init proof covers one output register with the memory results commented out. ([source](https://github.com/leanprover/LNSym/tree/main/Proofs)) |
| Equivalence | Unknown |
| Information flow | Unknown — We found no constant-time or secrecy reasoning in the repository. |
| Concurrency | Not supported — The machine state is a single sequential processor. ([source](https://github.com/leanprover/LNSym/blob/main/Arm/State.lean)) |
| Termination and liveness | Unknown |

## ISA-level features

| Feature | Support |
|---|---|
| User-level instructions | Partial — A subset of AArch64 instruction classes (branches, data processing, loads and stores) needed for the target code; new instructions are added as needed. ([source](https://github.com/leanprover/LNSym/blob/main/doc/add_new_inst.md)) |
| Floating-point instructions | Not supported — Only FMOV between general and floating-point registers; no floating-point arithmetic. ([source](https://github.com/leanprover/LNSym/blob/main/Arm/Insts/DPSFP/Conversion_between_FP_and_Int.lean)) |
| Vector / SIMD instructions | Partial — A subset of Advanced SIMD plus AES, SHA-512 and polynomial-multiply crypto instructions; no SVE. ([source](https://github.com/leanprover/LNSym/tree/main/Arm/Insts/DPSFP)) |
| Privileged mode | Not supported — The state has no exception levels or system registers. ([source](https://github.com/leanprover/LNSym/blob/main/Arm/State.lean)) |
| Virtual memory | Not supported — Memory is a flat map from 64-bit addresses to bytes; no address translation. ([source](https://github.com/leanprover/LNSym/blob/main/Arm/State.lean)) |
| Concurrency memory model | Not supported — Single processor; no memory ordering. ([source](https://github.com/leanprover/LNSym/blob/main/Arm/State.lean)) |

## Stage

**Stage 0: Research.**

| Stage | Criterion | Met | Evidence / note |
|---|---|---|---|
| 0 | Publicly available | yes | [evidence](https://github.com/leanprover/LNSym) |
| 0 | At least one published verification uses it | yes | [evidence](https://github.com/leanprover/LNSym/tree/main/Proofs) Only the proofs in the repository: complete for small examples (for example popcount), unfinished for the AWS-LC routines. We found no paper or report. |
| 1 | Released or updated in the last 12 months | yes | [evidence](https://github.com/leanprover/LNSym/commits/main) Latest release: main@49f8a1d, 2026-11-06. |
| 1 | Installs and runs on current platforms | yes | [evidence](https://github.com/leanprover/LNSym/actions/workflows/ci.yml) CI passes on main with Lean v4.35.0 (November 2026). The repository had no commits from December 2024 to November 2026; work resumed in November 2026. It is not archived. |
| 1 | User documentation or tutorial | no | [evidence](https://github.com/leanprover/LNSym#readme) The README covers building and testing, and a short guide covers adding instructions; there is no guide to specifying and proving programs. |
| 1 | Used by a group other than its authors | no | None found. |
| 2 | Verified code in production at two or more independent organizations | no | None recorded. |
| 2 | Checker axis is not red | yes |  |
| 2 | Semantics axis is not red | yes |  |
| 2 | Public channel for soundness bugs | yes | [evidence](https://github.com/leanprover/LNSym/issues) Public issue tracker. |

Missing for Stage 1: User documentation or tutorial; Used by a group other than its authors.

## Projects
- [AWS-LC SHA-512 (sha512_block_armv8), unfinished](https://github.com/leanprover/LNSym/tree/main/Proofs/SHA512)
- [AWS-LC AES-GCM and GCM routines, partly proved](https://github.com/leanprover/LNSym/tree/main/Proofs/AES-GCM)

## Sources
- [LNSym README](https://github.com/leanprover/LNSym)
- [Commits (Dec 2024 gap; resumed Nov 2026)](https://github.com/leanprover/LNSym/commits/main)
- [LNSym contribution guidelines](https://github.com/leanprover/LNSym/blob/main/CONTRIBUTING.md)
- [SHA-512 loop proof (contains sorry)](https://github.com/leanprover/LNSym/blob/main/Proofs/SHA512/SHA512Loop.lean)
- [GCM init proof](https://github.com/leanprover/LNSym/blob/main/Proofs/AES-GCM/GCMInitV8Sym.lean)

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