Appendix B: Tool Setup and Verification Quick Start
This appendix gives the shortest reproducible path to running the book’s companion examples. It prioritizes reproducibility (minimizing environment differences) over local customization.
- Container (recommended): use a devcontainer for a unified environment
- Local: run the same scripts with minimum dependencies such as Java,
curl, andunzip
The commands below are representative examples. Distribution formats and prerequisites may change, so consult Appendix E on primary sources when necessary.
You do not need every tool before you begin reading. By following this appendix, you should be able to reproduce at least one model checking workflow (Alloy/TLC/Apalache) and one program verification workflow (Dafny).
Target Tools (Minimum Set)
- Alloy
6.x(CLI execution) - TLA+
TLC(tla2tools.jar) - Apalache (SMT-based verification for TLA+)
- Dafny (verifier)
Notes:
- Theorem provers such as
RocqandIsabellehave larger dependency footprints, so this appendix primarily points to primary sources for them in Appendix E. Lean 4is included here only as a minimal setup at the end of the appendix as an optional path through the book.
Recommended: devcontainer (Fastest Reproducible Path)
Prerequisites:
- Docker is available
- You have an editor that can work with a devcontainer, such as
VS CodewithDev Containers
Steps:
- Open the book’s companion repository in a devcontainer by using
.devcontainer/ - On the first startup,
tools/bootstrap.shfetches the tool distributions and places them undertools/.cache/ - Run the following commands to execute the sample workflows
# Fetch tools (safe to rerun)
bash tools/bootstrap.sh
# Alloy (confirm SAT)
bash tools/alloy-check.sh --verbose examples/alloy/collection.als
# TLC (confirm No error)
bash tools/tlc-run.sh --config examples/tla/QueueBounded.cfg examples/tla/QueueBounded.tla
# Apalache (confirm NoError)
bash tools/apalache-check.sh --config examples/apalache/Counter.cfg --length 10 --init Init --next Next --inv Inv examples/apalache/Counter.tla
# Dafny (confirm 0 errors)
bash tools/dafny-verify.sh examples/dafny/Abs.dfy
Expected output (excerpt):
- Alloy:
SAT(for example, a line containingSATappears) - TLC:
Model checking completed. No error has been found. - Apalache:
The outcome is: NoErrorandEXITCODE: OK - Dafny:
finished with ... verified, 0 errors
Outputs such as counterexamples and logs are stored under .artifacts/. They are also uploaded as CI artifacts.
If any command fails, check the Java version, shell environment, and the primary sources listed in Appendix E before modifying the helper scripts.
Local Workflow (Without a Container)
Prerequisites (Linux/WSL)
- Java 17 or later, required to run
TLC,Alloy, andApalache curlandunzip
Use the same flow as in the devcontainer: run bash tools/bootstrap.sh to fetch the required files, then execute the scripts under tools/*.sh.
OS-specific Notes (Key Points)
- Windows:
- Running under
WSL2is recommended so that the assumptions behind the tool distributions and shell scripts match the environment - Install Java inside the WSL environment rather than relying on Java installed on the Windows side
- Running under
- macOS:
- Because
timeoutis not available by default, usingtools/tlc-run.sh --time-limitrequires a provider such asgtimeout(for example viacoreutilsfromHomebrew).tools/tlc-run.shautomatically detectstimeoutorgtimeout. - The Dafny distribution fetched by
tools/bootstrap.shtargets Linux, so on macOS use the official macOS distribution or install Dafny viadotnet tool
- Because
- Linux:
- Package names for Java differ by distribution. For example,
UbuntuandDebianuseopenjdk-17-jre.
- Package names for Java differ by distribution. For example,
Lean 4 Setup (Minimal Setup / Optional)
In this book, Lean 4 is positioned as an option for making theorem proving a maintainable engineering asset. See Chapter 9 for the conceptual role. Here, only the shortest path to a minimal setup is shown; consult the primary sources for detail.
What to Know First (Minimum)
elan: a tool for managing the Lean toolchain, including the Lean compiler and related componentsLake: Lean 4’s build and dependency-management tool, used for creating and building projects- VS Code extension: provides the interactive development experience, including type-checking results and goal display
Steps (Representative Example)
- Install
elanby following the primary source - Install
VS Codeand theLean 4extension by following the primary source - Create a minimal
Lean 4project and confirm that it starts correctly
mkdir -p lean-sandbox && cd lean-sandbox
lake init hello
lake build
Confirm:
- Open
lean-sandbox/inVS Codeand open the generated.leanfile - Confirm that no error appears and that the toolchain is active
Primary Sources (Official / Representative):
- Lean official site: https://lean-lang.org/
- Lean 4 (
GitHub): https://github.com/leanprover/lean4 elan: https://github.com/leanprover/elanVS CodeLean 4 extension: https://github.com/leanprover/vscode-lean4
Companion Automation (Reference Only)
The companion repository includes GitHub Actions workflows in .github/workflows/formal-checks.yml for lightweight pull-request checks and deeper nightly exploration.
If you want to run the equivalent lightweight path locally, execute bash examples/ci/pr-quick-check.sh.