In this repository, we provide a model of Rust MIR in K.
NOTE: This project is currently under reconstruction with changes and work outlined in Polkadot Referendum #749. Some features you may be familiar with (concrete execution and symbolic execution) are currently removed while project foundations are improved.
Currently, the project is working to stabilize the serialized output of stable MIR (see our current Rust PR) and develop the semantics for this output.
If you would like to try a legacy version of the project, this blog post has a tutorial on how to get started. However, it is important to install a legacy version for this to work, so when the tutorial prompts to install the latest version of KMIR with kup install kmir
, this should be replaced instead with kup install kmir --version v0.2.21
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>
At the moment, 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.
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.