Why3 Installation and Editor Support
Why3 installation guide
There are several options for installing Why3 on your system. Instructions for each are detailed below. If you encounter difficulties when attempting to install locally or use the Docker image, we recommend that you just use the virtual appliance.- For those familiar with Docker, the fastest option is to pull the docker image, and run Why3 inside your browser.
- We provide a virtual appliance that can be run within a virtual machine. This will work on any platform supported by VirtualBox, and is the simplest option for those not familiar with Docker.
-
If using macOS or Ubuntu, you can install Why3 natively. Note that if you have previously installed
opam
on your system, then make sure that it is at version>=2.0
, and that yourocaml
version is>=4.0.8
. - Several editors (at least Visual Studio Code, Atom, and Emacs) offer support for WhyML syntax.
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 mfredrik/15414:why3-s22
-
Give the image a shorter tag:
docker tag mfredrik/15414:why3-s22 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
. -
Note that in order to stop this 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. - Note that if you are using a ARM-based Mac, you might get a warning about the image's platform not matching the detected host platform. You can safely ignore this warning.
Virtual Machine
For those who are not familiar with Docker, it may be simpler to use the virtual appliance created by the course staff.
- Install the latest version of Oracle VirtualBox.
- Download the Why3 virual appliance.
-
Launch VirtualBox, navigate to
Files/Import Appliance
, and select the virtual appliance that you downloaded. -
Start the virtual machine. You may want to create a shared folder with the home directory on your host machine, so that you can easily access your work.
You can do so by navigating to
Settings/Shared Folders
in the VirtualBox UI.
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.4.0
-
Install Z3:
brew tap stonebuddha/formulae; brew install z3@4.8.6
-
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.4.0, Z3 4.8.6, 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.4.0
-
Install Z3:
wget https://github.com/Z3Prover/z3/releases/download/z3-4.8.6/z3-4.8.6-x64-ubuntu-16.04.zip unzip z3-4.8.6-x64-ubuntu-16.04.zip sudo cp z3-4.8.6-x64-ubuntu-16.04/bin/z3 /usr/local/bin sudo chmod +x /usr/local/bin/z3
-
Install CVC4:
wget https://github.com/CVC4/CVC4/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.4.0, Z3 4.8.6, 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:
- VS code and its extension for WhyML
- Atom and its extension for WhyML
- Emacs or Aquamacs and its Why3 mode