Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions .github/workflows/krl-verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,36 +139,47 @@ jobs:
- name: Checkout
uses: actions/checkout@v7.0.1

- name: Install Agda + standard library
- name: Install Agda + pinned standard library
run: |
set -euo pipefail
# Agda binary from apt; the standard library is NOT taken from apt.
# The packaged agda-stdlib differs between runner images: noble ships
# no .agda-lib, resolute ships one with `include: src`. Overwriting it
# with `include: .` (the previous step) made every `import Data.*`
# fail with FileNotFound once ubuntu-latest moved to resolute.
sudo apt-get update
sudo apt-get install -y --no-install-recommends agda agda-stdlib
# Ubuntu ships the stdlib source but omits its .agda-lib registration.
printf 'name: standard-library\ninclude: .\n' \
| sudo tee /usr/share/agda-stdlib/standard-library.agda-lib >/dev/null
mkdir -p "$HOME/.agda"
echo /usr/share/agda-stdlib/standard-library.agda-lib > "$HOME/.agda/libraries"
echo standard-library > "$HOME/.agda/defaults"
# Agda writes interface (.agdai) files into the library's _build dir;
# the apt stdlib is root-owned, so make it writable for the (non-root)
# runner user that invokes `agda`.
sudo chmod -R a+rwX /usr/share/agda-stdlib

- name: Check Agda proofs under --safe
sudo apt-get install -y --no-install-recommends agda-bin
Comment thread
hyperpolymath marked this conversation as resolved.
Resolved
# Shared pinned provisioning script, copied byte-identically from
# hyperpolymath/rsr-template-repo scripts/provision-agda-stdlib.sh
# (template commit 4a72fe74b83593dd636d9535154bf16060005221). It clones
# agda-stdlib v2.3, checks the tag against its commit, writes a project
# libraries file, appends AGDA_LIBRARIES to GITHUB_ENV, and fails when
# Agda is older than 2.7.0. Nothing under ~/.agda is read or written.
bash scripts/provision-agda-stdlib.sh "$RUNNER_TEMP/agda/agda-stdlib"
agda --version | head -1

- name: Check Agda proofs under --safe --without-K --cubical-compatible
run: |
set -e
shopt -s nullglob
# Agda prints non-ASCII identifiers in its diagnostics; under a POSIX
# locale it dies with "commitBuffer: invalid argument" (exit 42)
# instead of reporting. Keep the caller's locale when it is UTF-8.
case "${LC_ALL:-${LC_CTYPE:-${LANG:-}}}" in
*[Uu][Tt][Ff]-8* | *[Uu][Tt][Ff]8*) ;;
*) export LC_ALL=C.UTF-8 ;;
esac
found=0
for f in $(find verification/proofs/agda -name '*.agda' 2>/dev/null); do
echo "── agda --safe $f"
echo "── agda --safe --without-K --cubical-compatible $f"
# Run from the file's own directory so the top-level module name
# (e.g. `DihedralQuandle`) matches the file name as Agda requires.
( cd "$(dirname "$f")" && LC_ALL=C.UTF-8 agda --safe "$(basename "$f")" )
# `-i .` keeps that directory a source root next to the library.
( cd "$(dirname "$f")" && agda --safe --without-K --cubical-compatible -i . --library-file="$AGDA_LIBRARIES" --no-default-libraries -l standard-library "$(basename "$f")" )
found=1
done
if [ "$found" = "0" ]; then echo "No Agda proofs found"; exit 1; fi
echo "PASS: all Agda proofs check under --safe"
echo "PASS: all Agda proofs check under --safe --without-K --cubical-compatible"

tlaplus-model-check:
name: TLA+ model check (TLC)
Expand Down
107 changes: 107 additions & 0 deletions scripts/provision-agda-stdlib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
#
# provision-agda-stdlib.sh [DIR]
#
# The one shared, pinned way an estate repo gets the Agda standard library.
# Repos copy this file byte-identically from rsr-template-repo; do not fork it.
#
# Why it exists: each Agda repo wrote its own stdlib setup, and Ubuntu's apt
# agda-stdlib package now ships standard-library.agda-lib with `include: src`.
# Workflows that overwrote that file with `include: .` made Agda search a
# directory holding no modules. This script never reads or writes apt's copy
# and never touches ~/.agda: it clones a tag, verifies the commit, and writes
# a private libraries file.
#
# Environment (all optional):
# AGDA_STDLIB_VERSION tag to clone (default v2.3)
# AGDA_STDLIB_COMMIT full commit SHA the tag must resolve to
# (default 8326c7475af1fa456ca04a0203c168d5d7ff842b)
# AGDA_STDLIB_REPO clone URL (default https://github.com/agda/agda-stdlib)
# AGDA_MIN_VERSION minimum Agda compiler; fails below it (default 2.7.0,
# the oldest compiler agda-stdlib v2.3 documents as tested)
# RUNNER_TEMP base for the default directory
# GITHUB_ENV when set, AGDA_LIBRARIES=<path> is appended to it
#
# A repo that must stay on another release overrides VERSION and COMMIT together;
# changing one without the other fails the commit check, loudly.
#
# Output: the libraries-file path on stdout (export it as AGDA_LIBRARIES).
# Exit: 0 ok; 1 provisioning or pin failure; 2 misuse.

set -euo pipefail

VERSION="${AGDA_STDLIB_VERSION:-v2.3}"
COMMIT="${AGDA_STDLIB_COMMIT:-8326c7475af1fa456ca04a0203c168d5d7ff842b}"
REPO="${AGDA_STDLIB_REPO:-https://github.com/agda/agda-stdlib}"
AGDA_MIN="${AGDA_MIN_VERSION:-2.7.0}"

if [ "$#" -gt 1 ]; then
echo "usage: $(basename "$0") [DIR]" >&2
exit 2
fi
if [[ ! "$COMMIT" =~ ^[0-9a-f]{40}$ ]]; then
echo "FAIL: AGDA_STDLIB_COMMIT must be a full 40-character lowercase SHA, got '$COMMIT'" >&2
exit 2
fi

if ! command -v agda >/dev/null 2>&1; then
echo "FAIL: 'agda' not found on PATH; install the compiler first." >&2
exit 1
fi
AGDA_VERSION_LINE="$(agda --version | head -1)"
echo "$AGDA_VERSION_LINE" >&2
AGDA_ACTUAL="$(grep -oE '[0-9]+(\.[0-9]+)+' <<<"$AGDA_VERSION_LINE" | head -1 || true)"
if [ -z "$AGDA_ACTUAL" ]; then
echo "FAIL: cannot read an Agda version from '$AGDA_VERSION_LINE'." >&2
exit 1
fi
if [ "$(printf '%s\n%s\n' "$AGDA_MIN" "$AGDA_ACTUAL" | sort -V | head -1)" != "$AGDA_MIN" ]; then
{
echo "FAIL: Agda $AGDA_ACTUAL is older than $AGDA_MIN, the minimum for agda-stdlib $VERSION."
echo " (Ubuntu apt's agda-bin can be 2.6.3.) Install a newer compiler, or set"
echo " AGDA_MIN_VERSION together with AGDA_STDLIB_VERSION/COMMIT if you know better."
} >&2
exit 1
fi

if [ "$#" -eq 1 ]; then
DIR="$1"
else
DIR="$(mktemp -d "${RUNNER_TEMP:-${TMPDIR:-/tmp}}/agda-stdlib.XXXXXX")/agda-stdlib"
fi

if [ -e "$DIR" ] && [ -n "$(ls -A "$DIR" 2>/dev/null)" ]; then
echo "FAIL: $DIR exists and is not empty; refusing to reuse an unverified tree." >&2
exit 1
fi
mkdir -p "$(dirname "$DIR")"
DIR="$(cd "$(dirname "$DIR")" && pwd)/$(basename "$DIR")"

git -c advice.detachedHead=false clone --quiet --depth 1 --branch "$VERSION" "$REPO" "$DIR" >&2
ACTUAL="$(git -C "$DIR" rev-parse HEAD)"
if [ "$ACTUAL" != "$COMMIT" ]; then
{
echo "FAIL: agda-stdlib $VERSION resolved to $ACTUAL, expected $COMMIT."
echo " The tag moved or the pin is wrong; not using this tree."
} >&2
rm -rf "$DIR"
exit 1
fi
if [ ! -f "$DIR/src/Data/Nat.agda" ]; then
echo "FAIL: $DIR/src/Data/Nat.agda missing; the clone is not a stdlib source tree." >&2
exit 1
fi

LIBS="$DIR/libraries"
printf '%s\n' "$DIR/standard-library.agda-lib" >"$LIBS"
# Written by us, with `include: src`, so no other file can redirect the search.
printf 'name: standard-library\ninclude: src\n' >"$DIR/standard-library.agda-lib"

echo "agda-stdlib $VERSION ($ACTUAL) provisioned at $DIR" >&2
if [ -n "${GITHUB_ENV:-}" ]; then
printf 'AGDA_LIBRARIES=%s\n' "$LIBS" >>"$GITHUB_ENV"
fi
echo "export AGDA_LIBRARIES=$LIBS" >&2
printf '%s\n' "$LIBS"
4 changes: 2 additions & 2 deletions verification/proofs/agda/DihedralQuandle.agda
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{-# OPTIONS --safe #-}
{-# OPTIONS --safe --without-K --cubical-compatible #-}
-- SPDX-License-Identifier: MPL-2.0
-- Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
--
-- ===========================================================================
-- Dihedral (Takasaki) quandle axioms — machine-checked under `agda --safe`
-- Dihedral (Takasaki) quandle axioms — machine-checked under `agda --safe --without-K --cubical-compatible`
-- ===========================================================================
--
-- Discharges the algebraic core of obligation M1 ("Quandle axioms preserved")
Expand Down
Loading