Why3 Installation and Editor Support
There are several options for installing Why3 on your system. Instructions for each are detailed below.
It is strongly recommended that you try the Docker alternative first. The Docker option is the most easily compatible with the largest variety of systems and configurations, and is the most likely to work for you. If you have the Docker alternative working, and want to explore the other options, then you can do so. However, if you encounter issues with the other options and you have a working Docker setup, then we will not be able to provide support for the other options.
Docker
If you already have Docker installed on your machine, or are familiar with how to use it, then this is likely the most straightforward way to get Why3 up and running.
- If you do not already have Docker installed, then follow the instructions on the Docker site for your platform.
-
Pull the Why3 Docker image:
docker pull mattfredrikson/why3:s25
-
Give the image a shorter tag:
docker tag mattfredrikson/why3:s25 why3
-
You can now run Why3 inside the docker image, and connect to its graphical interface through your web browser.
Assuming your home directory is in/home/student
, and there is a source filefoo.mlw
in that directory that you would like to work on, then you will run the command:docker run --rm -p 8080:8080 --env WHY3IDE=web --volume /home/student:/data --workdir /data why3 ide foo.mlw
-
Open a new browser window, and connect to
http://localhost:8080
. -
You can also run Why3 commands from the command line. For example, to run the prover
foo.mlw
, you can run:docker run --rm --volume /home/student:/data --workdir /data why3 prove foo.mlw
-
Strongly recommended: Make a shell script to simplify this invocation
Save this script as#!/bin/bash docker run --rm -p 8080:8080 --env WHY3IDE=web --volume /home/student:/data --workdir /data why3 "$@"
why3.sh
, and make it executable withchmod +x why3.sh
. Then you can run./why3.sh ide foo.mlw
to start the Why3 IDE, or./why3.sh prove foo.mlw
to run the prover. -
Notes:
- When using the IDE, in order to stop docker container, the best way is to use the
File/Quit
menu within the Why3 IDE. Once you have responded to the save prompt, this will cause the container to stop running on your system. - If you are using a Mac, you might get a warning about the image's platform not matching the detected host platform. You can safely ignore this warning.
- When using the IDE, in order to stop docker container, the best way is to use the
macOS
If any of these instructions fail because your operating system is unable to support the recommended versions, we suggest that you follow the VM or Docker setup instructions above instead.
- Install the Homebrew package manager.
-
Install
opam
and libraries for Why3:brew install hg darcs opam gtk+ gmp gtksourceview3 libgnomecanvas autoconf
-
Initialize opam, and answer yes if queried:
opam init; eval $(opam config env)
-
Install Why3 and Alt-Ergo:
opam install zarith lablgtk3 lablgtk3-sourceview3 why3 why3-ide alt-ergo.2.6.0
-
Install Z3:
brew tap stonebuddha/formulae; brew install z3@4.10.2
-
Install CVC4:
brew tap cvc4/cvc4; brew install cvc4/cvc4/cvc4
-
For ARM-based Macs, if you get an error saying "The x86_64 architecture is required for this software":
- Click “Get Info” for the iTerm application and select “Open using Rosetta”. (If you use Terminal, you should be able to find something similar)
-
If you try installing cvc4, now it might say "Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!"
If so, install Homebrew into /usr/local. In my case I just had to add
export PATH=/usr/local/Homebrew/bin:$PATH
to my.zshrc
file. - Now installing cvc4 should work.
-
Set up Why3 to detect all of the installed provers:
why3 config detect
- Make sure that the output of the previous step reflects that Why3 detected Alt-Ergo 2.6.0, Z3 4.10.2, and CVC4 1.8.
Ubuntu
These instructions are written assuming a recent version of Ubuntu (at least 18.04), or similar distribution. If you use something else, or these instructions do not work for you, then we recommend that you use either the Docker image or virtual appliance.
-
Install
opam
and libraries for Why3:sudo add-apt-repository ppa:avsm/ppa sudo apt update sudo apt-get install build-essential autoconf m4 make opam
-
Initialize opam, and answer yes if queried:
opam init; eval $(opam config env)
-
Install required dependencies:
sudo apt-get install libgmp-dev libgtksourceview2.0-dev
-
Install Why3 and Alt-Ergo:
opam install why3 why3-ide alt-ergo.2.6.0
-
Install Z3:
wget https://github.com/Z3Prover/z3/releases/download/z3-4.10.2/z3-4.10.2-x64-glibc-2.31.zip unzip z3-4.10.2-x64-glibc-2.31.zip sudo cp z3-4.10.2-x64-glibc-2.31/bin/z3 /usr/local/bin sudo chmod +x /usr/local/bin/z3
-
Install CVC4:
wget https://github.com/CVC4/CVC4-archived/releases/download/1.8/cvc4-1.8-x86_64-linux-opt sudo cp cvc4-1.8-x86_64-linux-opt /usr/local/bin/cvc4 sudo chmod +x /usr/local/bin/cvc4
-
Set up Why3 to detect all of the installed provers:
why3 config detect
- Make sure that the output of the previous step reflects that Why3 detected Alt-Ergo 2.6.0, Z3 4.10.2, and CVC4 1.8.
WSL2 on Windows 11
If you are using Windows 11 and do not want to use Docker, you may install Why3 on the Windows Subsystem for Linux.
- Install WSL2 Microsoft Support Page
- Install Ubuntu on WSL2 Ubuntu WSL Page
-
Enable GUI applications to run on your Ubuntu installation Microsoft Support Page
Note: If you are not running Windows 11 Build 22000 or higher, the above method may not work for you. An alternative is to run an X11 (X11 Wikipedia) server on windows, and connect your Ubuntu installation to this server. Instructions for this can be found here: Stackoverflow Post You will want to install the VcXsrv Windows X Server: Download - Once you have GUI applications working on your WSL2 Ubuntu installation, you can follow the steps above for Ubuntu.
Text editors with support for WhyML
The following text editors provide WhyML extensions, including syntax highlighting:
-
If you use VS Code, you can download this syntax highlighter. Then unzip it, and copy the entire
syntax-highlighting-for-why3
directory into[user home]/.vscode/extensions
. You may need to restart VS Code for the changes to take effect.
Note: After copying the directory into the extensions folder and restarting VS code, if it does not appear in your VS code UI then you may need to rename the directory tosyntax-highlighting-for-why3.syntax-highlighting-for-why3-0.0.1
. - Atom and its extension for WhyML
- Emacs or Aquamacs and its Why3 mode