Flexible Instruction-Set Semantics via Type Classes

Thomas Bourgeat, Ian Clester, Andres Erbsen, Samuel Gruetter, Pratap Singh +2 more
4/1/2021
cs.LO

Official code: mit-plv/riscv-coq (123 stars, Rocq Prover, BSD-3-Clause, last commit 2026-11-13).

Abstract

Instruction sets, from families like x86 and ARM, are at the center of many ambitious formal-methods projects. Many verification, synthesis, programming, and debugging tools rely on formal semantics of instruction sets, but different tools can use semantics in rather different ways.

Show full abstract

As a result, a central challenge for that community is how semantics should be written and what techniques should be used to connect them to new use cases. The best-known work applying single semantics across quite-different tools relies on domain-specific languages like Sail, where the language and its translation tools are specialized to the realm of instruction sets. We decided to explore a different approach, with semantics written in a carefully chosen subset of Haskell. This style does not depend on any new language translators, relying instead on parameterization of semantics over type-class instances. As a result, a semantics can be a first-class object within a logic, and application of a semantics for a new kind of tool can be a first-class operation in the logic, allowing sharing of theorems across applications. Our case study is for the open RISC-V instruction-set family, and we have used a single core semantics to support testing, interactive proof, and model checking of both software and hardware. We especially highlight an application of a first-class semantics within Coq that can be instantiated in different ways within one proof: simulation between variants where multiplication is implemented in hardware or in the machine code of a particular software trap handler.

View on arXivView PDF

Code Implementations(1)

mit-plv/riscv-coqOfficial100%
BSD-3-Clause

RISC-V Specification in Coq

12320Rocq Prover, CJun 22, 20182 weeks agoBSD-3-Clause

Similar Papers

Cite this paper

@article{bourgeat2021flexible,
  title  = {Flexible Instruction-Set Semantics via Type Classes},
  author = {Thomas Bourgeat and Ian Clester and Andres Erbsen and Samuel Gruetter and Pratap Singh and Andrew Wright and Adam Chlipala},
  year   = {2021},
  eprint = {2104.00762},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2104.00762}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2104.00762.svg)](https://codeofpaper.com/paper/2104.00762)

Discussion