Skip to content

runtimeverification/mir-semantics

Repository files navigation

MIR Semantics

In this repository, we provide a model of the semantics of Rust's Stable MIR in K to enable symbolic execution of Rust programs and proofs of program properties.

Also included is the kmir tool, a python script that acts as a front-end to the semantics.

For Developers

KMIR Setup

Pre-requisites: python >= 3.10, pip >= 20.0.2, poetry >= 1.3.2, gcc >= 11.4.0, cargo == nightly-2024-11-29, k >= v7.1.205. To install K, follow the steps available in K's Quick Start instructions.

make build

Use make to run common tasks (see the Makefile for a complete list of available targets).

For interactive use, spawn a shell with poetry -C kmir/ shell (after poetry -C kmir/ install), then run an interpreter. Or directly run from mir-semantics root with poetry run -C kmir kmir <COMMAND>

Stable-MIR-JSON Setup

To interact with some of KMIR functionalities, it is necessary to provide the tool with a serialized JSON of a Rust program's Stable MIR. To be able to extract these serialized SMIR JSONs, you can use the Stable-MIR-JSON tool, setting it up with the following commands:

git submodule update --init --recursive
make stable-mir-json

For more information on testing, installation, and general usage of this tool, please check Stable-MIR-JSON's repository.

Usage

Use --help with each command for more details.

parse to parse a Stable MIR JSON file (*.smir.json) file to a K AST

kmir run to load an SMIR JSON generated by the stable-mir-json tool.

kmir gen-spec to take a SMIR JSON and create a K specification module that ensures termination of the program.

kmir prove run to run the prover on a spec generated by gen-spec.

kmir prove view to run the KCFG visualizer and inspect the proof steps.

Supporters

KMIR / mir-semantics is supported by funding from the following sources: