# riscv-coq (MIT RISC-V specification in Rocq)

> A RISC-V model in Rocq (formerly Coq) from MIT, written for proofs rather than as a full reference. It is the target machine of the bedrock2 verified compiler and of MIT's end-to-end verified embedded system.

- Kind: formal semantics
- Models: RISC-V (No ISA manual version is stated.)
- Fragment: RV32I and RV64I with the M extension and part of Zicsr (CSR instructions). A and F instructions are decoded, but the main execute function treats them as unsupported. No compressed (C), vector or floating-point execution. Address translation is left abstract.
- Written in: Rocq
- Available in: Rocq
- Stage: 0 (Mechanized)
- Licence: open-source, BSD-3-Clause
- Validation: Most of the definitions were generated with hs-to-coq from MIT's Haskell riscv-semantics, which the paper reports running on parts of riscv-tests (rv64ui, rv64ua, rv64si, rv64mi) and booting Linux, without pass counts. We found no published conformance results for the Rocq version itself. Its main check is use in proofs: the bedrock2 compiler targets it, and the paper describes a processor proved correct against it (the PLDI 2021 lightbulb system).
- Latest release: v0.0.6 (2025-10-06) https://github.com/mit-plv/riscv-coq/releases/tag/v0.0.6
- Latest commit: 2026-11-13 https://github.com/mit-plv/riscv-coq/commits/master

## Stage

**Stage 0: Mechanized.**

| Stage | Criterion | Met | Evidence / note |
|---|---|---|---|
| 0 | Machine-checked or machine-readable definition | yes | [evidence](https://github.com/mit-plv/riscv-coq/tree/master/src/riscv/Spec) |
| 0 | Fragment and version are stated | yes | [evidence](https://github.com/mit-plv/riscv-coq#risc-v-specification-in-coq) The README states the fragment (RV32I/RV64I with M and A), but not an ISA manual version. The code treats A as unsupported in the main execute function. |
| 1 | Can be executed or tested | yes | [evidence](https://github.com/mit-plv/riscv-coq/blob/master/src/riscv/Platform/Run.v) The step function (run1) is an ordinary computable Rocq definition. We found no packaged simulator for running test binaries. |
| 1 | Published results against conformance tests or real implementations | no | No published conformance or differential-testing results for the Rocq model. The paper says the Haskell model it came from ran parts of riscv-tests, without pass counts. |
| 2 | Adopted by the language or ISA owner, or covers the full current version and tracks new ones | no | Adopted by the owner: no; full coverage: no; tracks new versions: no. We found no statement from RISC-V International about this model. Only I, M and part of Zicsr are executed. No stated policy for following new ISA versions. |

Missing for Stage 1: Published results against conformance tests or real implementations.

## ISA-level features

| Feature | Coverage |
|---|---|
| User-level instructions | Partial — I (32 and 64 bit) and M are executed. A is defined in ExecuteA.v but the main execute function (Execute.v) treats A as unsupported. No C (compressed) or B instructions. ([source](https://github.com/mit-plv/riscv-coq/blob/master/src/riscv/Spec/Execute.v)) |
| Floating-point instructions | Not supported — F and D instructions are decoded but not executed. ([source](https://github.com/mit-plv/riscv-coq/blob/master/src/riscv/Spec/Execute.v)) |
| Vector / SIMD instructions | Not supported — No vector (V) extension. ([source](https://github.com/mit-plv/riscv-coq/blob/master/src/riscv/Spec/Decode.v)) |
| Privileged mode | Partial — CSR instructions and exceptions are modeled in part; the paper marks Zicsr as partly supported in the Rocq version. ([source](https://arxiv.org/abs/2104.00762)) |
| Virtual memory | Not supported — Address translation is an abstract machine operation (translate); no page-table walk. ([source](https://github.com/mit-plv/riscv-coq/blob/master/src/riscv/Spec/VirtualMemory.v)) |
| Concurrency memory model | Not supported — The machine is a single hart; no RVWMO multiprocessor memory model. ([source](https://github.com/mit-plv/riscv-coq/blob/master/src/riscv/Platform/RiscvMachine.v)) |

## Sources
- [riscv-coq README](https://github.com/mit-plv/riscv-coq)
- [Commits (latest 03881b2, 2026-11-13)](https://github.com/mit-plv/riscv-coq/commits/master)
- [Flexible Instruction-Set Semantics via Type Classes (formerly: A Multipurpose Formal RISC-V Specification)](https://arxiv.org/abs/2104.00762)
- [bedrock2 depends on riscv-coq](https://github.com/mit-plv/bedrock2/tree/master/deps)
- [Integration Verification across Software and Hardware for a Simple Embedded System (PLDI 2021)](https://adam.chlipala.net/papers/LightbulbPLDI21/)
- [Haskell riscv-semantics (source of the generated definitions)](https://github.com/mit-plv/riscv-semantics)

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