Skip to content

A Docker image for running the ACL2 theorem proving system and books in JupyterLab.

License

Notifications You must be signed in to change notification settings

jimwhite/acl2-jupyter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ACL2-Jupyter Docker Image

Use A Computational Logic for Applicative Common Lisp (ACL2) in Jupyter notebooks running in a container with just a command or two.

Availability

This image is available on the GitHub Container Registry at jimwhite/acl2-jupyter.

The project source is at https://github.com/jimwhite/acl2-jupyter.

Credits

This project is built from:

Using a prebuilt image locally

By default, running this Docker image will launch the JupyterLab server on port 8888.

docker pull ghcr.io/jimwhite/acl2-jupyter:latest
docker run -it --rm -p 8888:8888 -v $(PWD):/home/jovyan/work acl2-jupyter

To get the CLI just supply the command. For SBCL and ACL2 in a terminal you'll want rlwrap.

docker run -it --rm -v $(PWD):/home/jovyan/work acl2-jupyter rlwrap acl2

Using sudo within the container does not require a password.

Using a prebuilt image in a GitHub Codespace (free!)

There is a devcontainer.json file in the repo so use the "New codespace" action in the "+" dropdown (middle of the buttons at top right of the repo page) then enter "jimwhite/acl2-jupyter" for "Select repository". The smallest machine type is 2 CPUs which is plenty.

Dropdown: New codespace Select repository: jimwhite/acl2-jupyter
Create new codespace Building codespace...

It takes a few minutes to build the codespace because the image is fairly large (~10GB). After it loads there may be some messages about various extensions loading or not and such but they can (probably) be ignored. Choose "My codespaces" from the top left menu icon, then select the codespace for the "jimwhite/acl2-jupyter" repo, click "Show more actions for this codespace" (... menu at the right), and choose "Open in JupyterLab".

My codespaces Open in JupyterLab

And success!

JupyterLab with Python3, ACL2, and SBCL

The Free Tier on GitHub gets 120 CPU hours free: https://docs.github.com/en/billing/concepts/product-billing/github-codespaces. The small dual CPU is $0.18 per hour after the free allocation.

But GitHub recently deployed budgets for all billed services with $0 allocation by default; so if you get a "Billing Error" message, go to your billing settings and set appropriate quotas.

Old Usage

By default, running this Docker image will drop you into the ACL2 REPL. The "basic" selection of books (per the ACL2 Makefile) has been certified, but you may want to certify additional books. One way to do this is to start a Docker container with a shell rather than ACL2; one can do that with a command like docker run -it atwalter/acl2 /bin/bash. Then, one can use cert.pl to certify some books before starting ACL2. A full example is shown below, where lines prefixed by $ indicate commands executed outside of Docker and # indicate commands executed inside of the Docker container.

$ docker run -it atwalter/acl2 /bin/bash
# cert.pl ~/acl2/books/sorting/isort
# acl2
# ACL2 !> (include-book "sorting/isort" :dir :system)
# ACL2 !> (isort '(5 2 1 4 3))
(1 2 3 4 5)

Note that when the Docker container exits, the certificates for any books certified since the container was started will be lost. If you find yourself repeatedly needing to certify the same set of books, you can create a new Docker image based on this one. You can find an example Dockerfile in examples/certified-books/Dockerfile.

Building

The jq command-line tool must be installed to use the provided Makefile to build an ACL2 Docker image. This tool is used to get the latest commit hash for the ACL2 repo from Github.

So which jq and then brew install jq or sudo apt-get install jq as appropriate if not already installed.

This project uses several submodules from https://github.com/yitzchak. Either use git clone --recurse-submodules or run make git-submodules to sync those files.

git clone https://github.com/jimwhite/acl2-jupyter.git
cd acl2-jupyter
make git-submodules
make
make run

The make run will run sharing the CWD as above (docker run -it -p 8888:8888 -v $(PWD):/home/jovyan/work acl2-jupyter).

To enable reproducible builds and reduce image size, image build time, and download bandwidth during a build, the Dockerfile expects that it is provided a ACL2_REPO_LATEST_COMMIT build argument. This argument must be set to a URL-safe string corresponding to a commit or tag format that Github understands. I have tested this with full commit hashes and short commit hashes (e.g. the first 8 characters of the full commit hash). As suggested above, the build make target will use Github's API to determine the commit hash for the latest commit to the ACL2 repo and pass that to Docker when building an image.

Multi-Platform Building

This image is now built and distributed as a multi-platform Docker image. This means that both a linux/amd64 and linux/arm64 version of the image are built, and Docker should automatically use the appropriate version for your computer's architecture.

The images on Docker Hub and the GitHub Container Registry are built using the build-multiplatform and build-multiplatform-ghcr make targets. To use these targets, you need to be using a Docker builder that is capable of building for both the linux/amd64 and linux/arm64 platforms. macOS' emulation for linux/amd64 is at present insufficient, as it does not emulate FPU traps and ACL2 expects these traps to occur. So, I build the images using a Docker builder that consists of two nodes (an Apple Silicon machine and an x86-64 machine). The best information I've found on how to do this is in this Medium post.

Notes

By default, certification is done with 4 parallel tasks. This can be changed by overriding the ACL2_CERT_JOBS variable of the Makefile. For example, to use 2 tasks instead, run make build ACL2_CERT_JOBS=2.

To provide additional arguments to the make command that will be used to build ACL2's books, you can override the ACL2_CERTIFY_OPTS variable of the Makefile. Notice that this will override the effects of the ACL2_CERT_JOBS variable, so you will need to provide the appropriate -j option in that case.

By default, the "basic" book selection is certified. This can be changed by overriding the ACL2_CERTIFY_TARGETS build argument. Multiple targets can be provided to this argument if desired.

Sources

# sha256 of quicklisp.lisp = 4a7a5c2aebe0716417047854267397e24a44d0cce096127411e9ce9ccfeb2c17
wget -kL -P context https://beta.quicklisp.org/quicklisp.lisp

git submodule add https://github.com/jimwhite/acl2-kernel.git context/acl2-kernel
git submodule add https://github.com/yitzchak/archlinux-cl.git context/archlinux-cl
git submodule add https://github.com/yitzchak/common-lisp-jupyter.git context/quicklisp/local-projects/common-lisp-jupyter
git submodule add https://github.com/yitzchak/delta-vega.git context/quicklisp/local-projects/delta-vega
git submodule add https://github.com/yitzchak/resizable-box-clj.git context/quicklisp/local-projects/resizable-box-clj
git submodule add https://github.com/yitzchak/ngl-clj.git context/quicklisp/local-projects/ngl-clj

Base Image

ACL2-Jupyter uses the quay.io/jupyter/minimal-notebook:latest image (source https://github.com/jupyter/docker-stacks/tree/main/images/minimal-notebook) because we want the JupyterLab stuff to work and we're gonna build SBCL and ACL2 the way we want anyhow. Note that the DockerHub image is no longer updated.

For a full complement of Python support including PySpark use BASE_IMAGE=quay.io/jupyter/pyspark-notebook:latest image (source https://github.com/jupyter/docker-stacks/tree/main/images/pyspark-notebook)

Moar Information

About

A Docker image for running the ACL2 theorem proving system and books in JupyterLab.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •