KWasm: Semantics of WebAssembly in K
Want to Support KWasm Development?
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 KWASM-LEMMAS
You can optionally override the default backend using the
--backend BACKEND flag:
./kwasm run --backend llvm tests/simple/arithmetic.wast ./kwasm prove --backend haskell tests/proofs/simple-arithmetic-spec.k KWASM-LEMMAS
There are two backends of K available, the LLVM backend for concrete execution, and the Haskell backend for symbolic reasoning and proofs.
This repository generates the build-products for the 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)
- 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.
- LLVM For building the LLVM backend.
- Z3 version 4.8.11
On Ubuntu >= 15.04 (for example):
sudo apt-get install --yes \ autoconf bison clang++-8 clang-8 cmake curl flex gcc libboost-test-dev libffi-dev \ libgmp-dev libjemalloc-dev libmpfr-dev libprocps-dev libprotobuf-dev libtool \ libyaml-dev lld-8 llvm llvm-8 llvm-8-tools maven openjdk-8-jdk pandoc pkg-config \ protobuf-compiler 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
Install repository specific dependencies:
Note that KWASM requires Z3 version 4.8.11, which you may need to install from a source build if your package manager supplies a different version. To do so, follow the instructions here after checking out the correct tag in the Z3 repository:
git clone https://github.com/Z3Prover/z3.git cd z3 git checkout z3-4.8.11 python scripts/mk_make.py cd build make sudo make install
And then build the semantics:
To only build a specific backend, you can do
make build-llvm 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.