KWasm: Semantics of WebAssembly in K
This repository presents a prototype formal semantics of WebAssembly.
It is currently under construction.
For examples of current capabilities, see the unit tests under the
The following files constitute the KWasm semantics:
- data.md provides the (functional) data of WebAssembly (basic types, type constructors, and values).
- numeric.md provides the functional rules for numeric operators.
- wasm.md is the main KWasm semantics, containing the configuration and transition rules of WebAssembly.
These additional files extend the semantics to make the repository more useful:
- test.md is an execution harness for KWasm, providing a simple language for describing tests/programs.
./kwasm runner script
After building the definition, you can run the definition using
The most up-to-date documentation will always be in
Run the file
./kwasm run tests/simple/arithmetic.wast
To run proofs, you can similarly use
./kwasm, but must specify the module to use for proving.
For example, to prove the specification
./kwasm prove tests/proofs/simple-arithmetic-spec.k -m KWASM-LEMMAS
You can optionally override the default backend using the
--backend BACKEND flag:
./kwasm run --backend java tests/simple/arithmetic.wast ./kwasm prove --backend haskell tests/proofs/simple-arithmetic-spec.k -m KWASM-LEMMAS
There are three backends of K available, the OCAML backend for concrete execution, the Java backend for symbolic reasoning and proofs, and the experimental Haskell backend for developers.
This repository generates the build-products for both backends in
The following are needed for building/running KWasm:
- Pandoc >= 1.17 is used to generate the
*.kfiles from the
- GNU Bison, Flex, and Autoconf.
- GNU libmpfr and libtool.
- Java 8 JDK (eg. OpenJDK)
- Opam, important: Ubuntu users prior to 15.04 must build from source, as the Ubuntu install for 14.10 and prior is broken.
opam repositoryalso requires
- Haskell Stack.
Note that the version of the
stacktool provided by your package manager might not be recent enough. Please follow installation instructions from the Haskell Stack website linked above.
On Ubuntu >= 15.04 (for example):
sudo apt install \ autoconf curl flex gcc libffi-dev libmpfr-dev libtool maven \ opam openjdk-8-jdk pandoc pkg-config python3 python-pygments \ python-recommonmark python-sphinx time zlib1g-dev
stack (if needed):
stack upgrade export PATH=$HOME/.local/bin:$PATH
After installing the above dependencies, make sure the submodules are setup:
git submodule update --init --recursive
If you haven't already setup K's OCaml dependencies more recently than February 1, 2019, then you also need to setup the K OCaml dependencies:
NOTE: It may prove useful to first do
rm -rf ~/.opam if you've setup K projcets in the past and are experiencing trouble with the newest opam libraries.
This is a fairly destructive operation, and will break any other projects that depend on specific locally installed ocaml packages.
Similarly, you'll need to setup K's Rust dependencies:
Install repository specific dependencies:
And then build the semantics:
To only build specific backends, you can do
make build-ocaml, or
Media and documents
media/ directory contains presentations and reports about about KWasm.
The documents are named with an approximate date of presentation/submission, what type of document it is, and a brief contextual name, e.g., name of conference where it was held.
GhostScript is a dependency for building documents of type
sudo apt install ghostscript
To build all documents in the media file:
test contains all the currently passing tests.