LeanHardware: Bringing Formal Assurance to Vibe Hardware Development from Intent to RTL via Lean 4

Wenji Fang, Ziyi Yang, Peichen Xie, Xian Zhang, Ruize Tang, Tianyu Chen, Fan Yang, Jing Wang, Yao Lu, Mengming Li, Wenkai Li, Zhiyuan Yan, Hongce Zhang, Zhiyao XiearXiv 2026

TL;DR

"Vibe coding" has arrived in chip design: engineers describe what they want in plain English, and AI agents write the hardware description code (RTL). LeanHardware brings mathematical certainty to this workflow by using the Lean 4 theorem prover in two stages—first turning fuzzy English specs into executable, designer-verified models, and then mathematically proving that the AI-generated Verilog faithfully implements them. Across 329 hardware designs, this approach pushes functional correctness above 91–98% while providing unbounded formal proof certificates.

What Problem Does This Paper Address?

As large language models (LLMs) get better at writing Verilog, two stubborn correctness gaps keep AI-generated hardware from being trustworthy:

  1. Specification alignment: Natural-language specs are notoriously messy. They often contain ambiguities, contradictions, or missing details. If an LLM guesses what you meant without asking, it might build the wrong chip—even if the code is bug-free.
  2. Implementation correctness: Even with a crystal-clear spec, AI-generated RTL can still have subtle bugs. Existing verification fixes either rely on simulation (which only tests a finite set of inputs) or formal methods that either check only a few hand-picked properties, only work up to a fixed number of clock cycles, or force you to abandon standard Verilog generation workflows.

Methods

LeanHardware tackles both gaps inside a single unified Lean 4 framework, splitting the workflow into two stages:

Fig. 2: Overview of the two-stage LeanHardware workflow: (1) specification formalization and designer intent clarification, and (2) proof-guided RTL generation and certification.
  • Stage 1: Execution-Guided Intent Clarification. Instead of treating the English spec as gospel, an LLM translates it into multiple candidate LeanSpec models—executable formal models representing different possible interpretations. LeanHardware runs these models on concrete test inputs to expose ambiguities (models disagree), incompleteness (multiple outputs are allowed), or contradictions (no valid output exists). Armed with this concrete behavioral evidence, the LLM asks the designer targeted clarification questions. Once the designer answers, the spec and LeanSpec are locked in as the ground-truth reference, and a transaction-level abstraction is derived and proved consistent.
  • Stage 2: Proof-Guided RTL Implementation. The LLM directly generates standard Verilog from the clarified spec. A deterministic parser translates that Verilog into LeanRTL (a word-level Lean 4 representation of RTL semantics, validated via round-trip sequential equivalence checking). Then, an agentic theorem prover constructs refinement relations, invariants, and lemmas to prove that LeanRTL refines LeanSpec across arbitrary execution cycles—no fixed cycle bound. If a proof fails, the agent uses the feedback to fix either the proof or the Verilog.

Datasets

The authors evaluate LeanHardware on 329 designs drawn from four standard RTL generation benchmarks (focusing on specification-to-RTL tasks):

  • VerilogEval (156 designs)
  • RTLLM (50 designs)
  • CVDP (78 designs)
  • ChipBench (45 designs)

Because these benchmarks lack live human designers, the authors use a separate "oracle" LLM with access to the hidden reference RTL to simulate designer answers to Stage 1's clarification questions—without ever exposing the reference code to the generation or proving agents.

Key Insights and Ideas

  • For strong LLMs, spec quality is the real bottleneck: When using a frontier model (gpt-5.6-sol), clarifying the specification drove almost all of the accuracy gains. Formal proving mainly served as a machine-checked certificate rather than a bug-fixer. For weaker LLMs, however, proof-guided correction still provided substantial accuracy boosts.
  • Concrete execution beats text-only review: Running candidate LeanSpec models on actual inputs gives designers concrete behavioral differences ("Should done go high at cycle 2 or cycle 3?"), making it far easier to spot and resolve hidden spec flaws than reading prose alone.
  • Separating what from how: Current benchmarks mix functional requirements with cycle-level implementation details. The authors argue for a specification hierarchy that separates required behavior (verification constraints) from microarchitectural choices (optimization space).

Key Results

  • End-to-end correctness: LeanHardware achieves 98% on VerilogEval, 98% on RTLLM, 94% on CVDP, and 91% on ChipBench.
  • Stage 1 impact: Specification clarification alone lifts RTL correctness from 81.5% to 96.0% on corrected benchmarks, resolving 89.9% (1,455 of 1,619) of identified spec issues—including 100% of issues in VerilogEval, RTLLM, and ChipBench.
Fig. 4: RTL generation results before and after LeanHardware spec- ification clarification.
  • Stage 2 proof coverage: LeanHardware establishes complete, unbounded refinement proofs for 79.0% of designs against cycle-level specs and 92.1% against transaction-level specs.
  • Real-world scale: Beyond small benchmarks, the authors verified a five-stage RISC-V CPU supporting 38 instructions against an executable ISA-level specification.

Limitations and Future Work

  • Runtime and token overhead: While Stage 1 is cheap (1–3 minutes per design), Stage 2's theorem proving incurs 5–10× higher runtime and token costs than direct RTL generation.
  • Unresolved complex proofs: About 8–21% of designs only achieved partial proofs due to unresolved state correspondences, complex logic, or proof resource limits.
  • Input generation: Stage 1 currently relies on an LLM to propose test inputs for diagnosing specs; the authors note systematic input generation as future work.
  • Scope: The work targets functional RTL and does not address physical design, manufacturing, or packaging.

Summary updated

BibTeX
@misc{fang2026leanhardware,
  author = {Wenji Fang and Ziyi Yang and Peichen Xie and Xian Zhang and Ruize Tang and Tianyu Chen and Fan Yang and Jing Wang and Yao Lu and Mengming Li and Wenkai Li and Zhiyuan Yan and Hongce Zhang and Zhiyao Xie},
  title = {{LeanHardware: Bringing Formal Assurance to Vibe Hardware Development from Intent to RTL via Lean 4}},
  year = {2026},
  eprint = {2612.05355},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2612.05355},
}
Figure