Skip to content
Open
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
82 changes: 56 additions & 26 deletions .github/workflows/proofs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ name: Agda proofs
#
# DEVIATION (PROOF-POLICY §6), state: open.
# Leg: the Agda leg of every theorem in docs/status/PROOF-STATUS.adoc.
# Image: the job runs in debian:trixie-slim pinned by digest (§8.2: isolated,
# the receipt names the image).
# Tool: Debian trixie agda-bin 2.6.4.3-1+b2, asserted below; apt checks
# the .deb against Debian's signed Packages index, and the receipt
# step prints that index's SHA256 for the package and the digest of
# the installed binary.
# Why: this repository has no Guix manifest and no proof container yet;
# the hosted runner has no Guix. The Debian package is an exact,
# signature-checked pin.
# Why: this repository has no Guix manifest and no proof container of its
# own yet; the hosted runner has no Guix. The digest-pinned Debian
# image and the exact, signature-checked package are the pin.
# Closes: when a Guix manifest (or the repo's container) provides Agda and
# this job installs from it.
on:
Expand All @@ -29,7 +31,8 @@ jobs:
name: Core proofs and expected rejections
runs-on: ubuntu-latest
timeout-minutes: 15
container: debian:trixie-slim
# Pinned by digest (PROOF-POLICY §8.2); re-pin deliberately.
container: debian:trixie-slim@sha256:a29215f6a35e51e22adffa17f89e9d2ef06214e64a2bad10d765c46aea49f11f
steps:
- name: Install the pinned prover
run: |
Expand Down Expand Up @@ -60,6 +63,7 @@ jobs:
echo ""
echo "- source commit: \`$SOURCE_SHA\`"
echo "- checker: \`$(agda --version)\`"
echo "- image: \`debian:trixie-slim@sha256:a29215f6a35e51e22adffa17f89e9d2ef06214e64a2bad10d765c46aea49f11f\` (isolated, pinned by digest)"
echo "- package: \`agda-bin $(dpkg-query -W -f='${Version}' agda-bin)\`, index SHA256 \`$(apt-cache show agda-bin=2.6.4.3-1+b2 | sed -n 's/^SHA256: //p' | head -1)\`"
echo "- binary SHA256: \`$(sha256sum "$(command -v agda)" | cut -d' ' -f1)\`"
echo "- invocation: \`$(sed -n 's/^flags=(\(.*\))$/\1/p' scripts/check-agda.sh)\`"
Expand All @@ -69,61 +73,82 @@ jobs:
} >> "$GITHUB_STEP_SUMMARY"

# Lean recheck leg (PROOF-POLICY §2): re-proved by hand, Lean core only.
# The qualifying run is `lake build` (§8.2, owner ruling 2026-11-17), in a
# container image pinned by digest, which the receipt names (§8.2, owner
# ruling 2026-11-16).
# DEVIATION (§6), state: open.
# Leg: the Lean leg of every theorem in docs/status/PROOF-STATUS.adoc.
# Tool: Lean 4.35.0, the upstream release archive, checked against the
# SHA256 below; the version is asserted against lean-toolchain.
# Image: ubuntu:24.04 pinned by digest (the same digest as januskey's
# recheck job).
# Tool: Lean 4.35.0 with Lake, the upstream release archive, checked
# against the SHA256 below; the version is asserted against
# lean-toolchain, and Lake's version is asserted too.
# Why: no Guix manifest or proof container provides Lean here yet.
# Closes: when a Guix manifest (or the repo's container) provides Lean.
lean-leg:
name: Lean recheck leg
runs-on: ubuntu-latest
timeout-minutes: 15
# ubuntu:24.04, resolved 2026-11-16; re-pin deliberately. Job containers
# run as root, so apt needs no sudo.
container: ubuntu:24.04@sha256:73b999393d07f2bf65a40373778a44dc9a6d54ad7718d29247d8ff9413c4d6a8
env:
LEAN_VERSION: '4.35.0'
LEAN_SHA256: '7289597a44543246c9227b8cae501767e095ce17f6d448b95fc4a8dc97268f6d'
DEBIAN_FRONTEND: noninteractive
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- name: Install the pinned Lean
run: |
set -euo pipefail
apt-get update
apt-get install --no-install-recommends -y ca-certificates curl git zstd
curl --proto '=https' --tlsv1.2 --fail --silent --show-error --location \
--output "$RUNNER_TEMP/lean.tar.zst" \
"https://github.com/leanprover/lean4/releases/download/v${LEAN_VERSION}/lean-${LEAN_VERSION}-linux.tar.zst"
echo "${LEAN_SHA256} $RUNNER_TEMP/lean.tar.zst" | sha256sum --check --strict
tar --zstd -xf "$RUNNER_TEMP/lean.tar.zst" -C "$RUNNER_TEMP"
echo "$RUNNER_TEMP/lean-${LEAN_VERSION}-linux/bin" >> "$GITHUB_PATH"
- name: Verify the checked Lean version
mkdir -p /opt/lean
tar --zstd -xf "$RUNNER_TEMP/lean.tar.zst" -C /opt/lean
rm "$RUNNER_TEMP/lean.tar.zst"
echo "/opt/lean/lean-${LEAN_VERSION}-linux/bin" >> "$GITHUB_PATH"
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- name: Verify the checked Lean and Lake versions
run: |
set -euo pipefail
test "$(cat verification/proofs/lean4/lean-toolchain)" = "leanprover/lean4:v${LEAN_VERSION}"
lean --version | grep -F "version ${LEAN_VERSION},"
lake --version | grep -F "Lean version ${LEAN_VERSION})"
- name: Lean leg
run: bash scripts/check-proofs.sh lean4
- name: Axioms and receipt
- name: Leg check fails on a failed build, an axiom or a rewritten manifest
run: bash tests/check_lean_leg_test.sh
- name: Axioms under lake, and receipt
env:
SOURCE_SHA: ${{ github.sha }}
run: |
set -euo pipefail
out="$(cd verification/proofs/lean4 && lean ResourceAlgebra.lean 2>&1)"
# A counted witness lists its axioms (§8.4). The leg is recorded as
# axiom-free, so every printed theorem must say so.
n_print="$(grep -c '^#print axioms' verification/proofs/lean4/ResourceAlgebra.lean)"
n_free="$(grep -c 'does not depend on any axioms' <<<"$out" || true)"
if [ "$n_free" != "$n_print" ]; then
echo "::error::only $n_free of $n_print theorems are axiom-free"; echo "$out"; exit 1
fi
# axiom-free, so every printed theorem must say so; the script takes
# that census from `lake build`.
result="$(bash scripts/check-lean-leg.sh | tee /dev/stderr | tail -1)"
src=verification/proofs/lean4
{
echo "## Lean leg receipt"
echo ""
echo "- source commit: \`$SOURCE_SHA\`"
echo "- checker: \`$(lean --version)\`"
echo "- image: \`ubuntu:24.04@sha256:73b999393d07f2bf65a40373778a44dc9a6d54ad7718d29247d8ff9413c4d6a8\` (isolated, pinned by digest)"
echo "- checker: \`$(lean --version)\`, \`$(lake --version)\`"
echo "- archive SHA256: \`$LEAN_SHA256\`"
echo "- invocation: \`lean ResourceAlgebra.lean\` in \`verification/proofs/lean4\` (core only, no Mathlib)"
echo "- input SHA256: \`$(sha256sum verification/proofs/lean4/ResourceAlgebra.lean | cut -d' ' -f1)\`"
echo "- axioms: $n_free of $n_print printed theorems depend on no axiom"
echo "- invocation: \`lake build\` in a copy of \`$src\` made by \`bash scripts/check-lean-leg.sh\` (core only, no Mathlib, no dependencies)"
for f in ResourceAlgebra.lean lakefile.toml lake-manifest.json lean-toolchain; do
echo "- input \`$f\` SHA256: \`$(sha256sum "$src/$f" | cut -d' ' -f1)\`"
done
echo "- script SHA256: \`$(sha256sum scripts/check-lean-leg.sh | cut -d' ' -f1)\`"
echo "- axioms: ${result#PASS: Lean leg under lake; }"
} >> "$GITHUB_STEP_SUMMARY"
- name: Bridge check fails on a broken or axiom-dependent bridge
run: bash tests/check_lean_bridge_test.sh
Expand All @@ -138,14 +163,19 @@ jobs:
set -euo pipefail
out="$(bash scripts/check-lean-bridge.sh)"
echo "$out"
br=verification/bridges/tropical-types
{
echo "## M-2 bridge receipt"
echo ""
echo "- source commit: \`$SOURCE_SHA\`"
echo "- checker: \`$(lean --version)\`"
echo "- invocation: \`bash scripts/check-lean-bridge.sh\`"
echo "- image: \`ubuntu:24.04@sha256:73b999393d07f2bf65a40373778a44dc9a6d54ad7718d29247d8ff9413c4d6a8\` (isolated, pinned by digest)"
echo "- checker: \`$(lean --version)\`, \`$(lake --version)\`"
echo "- invocation: \`lake build\` in a work directory made by \`bash scripts/check-lean-bridge.sh\`"
sed -n 's/^import: \(.*\) \(.*\) \(.*\) \(.*\)$/- import: `\1` at `\2`, `\3` SHA256 `\4`/p' <<<"$out"
sed -n 's/^bridge: \(.*\) \(.*\)$/- bridge: `\1` SHA256 `\2`/p' <<<"$out"
for f in "$br/lakefile.toml" "$br/lake-manifest.json" verification/proofs/lean4/lean-toolchain verification/proofs/lean4/ResourceAlgebra.lean scripts/check-lean-bridge.sh; do
echo "- input \`$f\` SHA256: \`$(sha256sum "$f" | cut -d' ' -f1)\`"
done
sed -n 's/^PASS: .*; \(.*\)$/- axioms: \1/p' <<<"$out"
} >> "$GITHUB_STEP_SUMMARY"

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,6 @@ verification/proofs/agda/*.agdai

# Agda interface files are build output (the gate runs --ignore-interfaces).
*.agdai

# Lake build output (the Lean legs build in a temp copy; never commit it)
.lake/
16 changes: 16 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
== Changelog

== 2026-11-18 — Agda, Lean and the M-2 bridge run isolated

* The Agda job runs in `debian:trixie-slim` pinned by digest. The Lean leg
and the M-2 bridge run in `ubuntu:24.04` pinned by digest, under `lake
build` (PROOF-POLICY §8.2). Their receipt summaries name the image and the
invocation. The Rocq job was already pinned by digest.
* `verification/proofs/lean4/lakefile.toml` and `lake-manifest.json`, and
`verification/bridges/tropical-types/lakefile.toml` and
`lake-manifest.json`, are dependency-free Lake packages whose manifests
are committed in I-JSON/JCS form. `scripts/check-lean-leg.sh` builds the
leg under lake and counts its axiom reports; `scripts/check-lean-bridge.sh`
now builds the bridge under lake, with the tropical-types pin unchanged.
`tests/check_lean_leg_test.sh` and the updated
`tests/check_lean_bridge_test.sh` plant each failure through a stub lake.
* No grade changes: a grade moves only with a new receipt.

== 2026-11-17 — C-4b and M-2 proved

* C-4b: `src/ResourceAlgebra/Instances/Diamond.agda` adds the diamond
Expand Down
21 changes: 14 additions & 7 deletions docs/status/PROOF-STATUS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ to show that it does. The receipt lists the four names and bindings.
and checks the proofs. It then writes a receipt to the run summary with the
source commit, `agda --version`, the package version and its SHA256 from
Debian's signed index, the digest of the installed binary, the flags read
from the script, and the import cone. Installing Agda from Debian rather
than Guix is a §6 deviation, recorded in `proofs.yml`; its state is `open`.
from the script, and the import cone. The job runs in `debian:trixie-slim`
pinned by digest, and the receipt names that image. Installing Agda from
Debian rather than Guix is a §6 deviation, recorded in `proofs.yml`; its
state is `open`.
* *History.* Until 2026-11-09 the gate ran `--safe --without-K
--no-libraries --double-check`. That profile passed in CI from 2026-10-14
(resource-algebra#4). Under §2.1 those runs are historical evidence, not
Expand Down Expand Up @@ -180,9 +182,12 @@ the strict flag set and `⊕-least` all changed after it.
=== The legs: where, how checked, toolchains

* *Lean.* `verification/proofs/lean4/ResourceAlgebra.lean`, checked by
`lean` 4.35.0 (pinned by `lean-toolchain`). CI installs the upstream
release archive against a SHA256 and asserts the version: a §6 deviation,
recorded in `proofs.yml`, state `open`. The arithmetic is proved by
`lake build` (Lean 4.35.0, pinned by `lean-toolchain`) on a copy of the
Lake package `verification/proofs/lean4/lakefile.toml`, which has no
dependencies; `lake-manifest.json` is committed. CI runs it through
`scripts/check-lean-leg.sh` in `ubuntu:24.04` pinned by digest, installs
the upstream release archive against a SHA256 and asserts the Lean and Lake
versions: a §6 deviation, recorded in `proofs.yml`, state `open`. The arithmetic is proved by
structural recursion, as in Agda's Prelude, so no theorem depends on
`propext` or `Quot.sound`. CI fails if any printed theorem depends on an
axiom.
Expand Down Expand Up @@ -370,8 +375,10 @@ these are the `+`, `*`, `0` and `1` of the instance.
* *Pin.* `scripts/check-lean-bridge.sh` fetches
`hyperpolymath/tropical-types` at
`f2e465c966d14d4986dfc492875cc54653d9751e`, checks the fetched commit,
compiles both modules with the pinned `lean` 4.35.0 and checks the bridge.
It fails on any error, on any printed theorem that depends on an axiom, and
builds both modules and the bridge as a Lake package
(`verification/bridges/tropical-types/lakefile.toml`, no dependencies, the
pin stays in the script) with `lake build` under the pinned Lean 4.35.0, in
the same digest-pinned image as the Lean leg. It fails on any error, on any printed theorem that depends on an axiom, and
when no theorem is printed (`tests/check_lean_bridge_test.sh`). It prints
the SHA256 of the imported file and of the bridge, for a receipt's
`(import …)` clause (§8.5.1).
Expand Down
55 changes: 34 additions & 21 deletions scripts/check-lean-bridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,31 @@
# only place the pin lives (PROOF-POLICY §8.5.1, imported repositories), so a
# repin changes this file and with it the home input digest.
#
# The three files are built as a dependency-free Lake package (PROOF-POLICY
# §8.2 names `lean` under `lake` as the qualifying run): the lakefile and its
# lake-manifest.json sit beside the bridge, and `lake build` runs in a work
# directory so no .lake/ output lands in the tree. The tropical-types pin stays
# here, not in a lake `require`.
#
# It fails loudly when: the pinned commit cannot be fetched or is not what was
# checked out; either module or the bridge does not compile; or any printed
# theorem depends on an axiom. On success it prints the facts a receipt needs.
# checked out; any module or the bridge does not build; any printed theorem
# depends on an axiom; the bridge prints no theorem or not all axiom-free; or
# the build rewrote lake-manifest.json. On success it prints the facts a
# receipt needs. LAKE overrides the lake binary.
set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.."

TT_REPOSITORY=hyperpolymath/tropical-types
TT_COMMIT=f2e465c966d14d4986dfc492875cc54653d9751e
TT_FILE=TropicalSessionTypes.lean
BRIDGE=verification/bridges/tropical-types/TropicalBridge.lean
lean="${LEAN:-lean}"
BRIDGE_DIR=verification/bridges/tropical-types
RA_FILE=verification/proofs/lean4/ResourceAlgebra.lean
TOOLCHAIN=verification/proofs/lean4/lean-toolchain
lake="${LAKE:-lake}"

work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
mkdir -p "$work/build"

git init -q "$work/tt"
git -C "$work/tt" fetch -q --depth 1 "https://github.com/$TT_REPOSITORY" "$TT_COMMIT" \
Expand All @@ -36,28 +46,31 @@ got="$(git -C "$work/tt" rev-parse HEAD)"
[ -f "$work/tt/$TT_FILE" ] \
|| { echo "ERROR: $TT_FILE is not in $TT_REPOSITORY at $TT_COMMIT" >&2; exit 1; }

compile() { # $1 dir, $2 file, $3 olean
local out
if ! out="$(cd "$1" && "$lean" -o "$3" "$2" 2>&1)" || grep -q 'error:' <<<"$out"; then
printf '%s\n' "$out" >&2
echo "ERROR: $2 does not compile" >&2
exit 1
fi
}
compile "$work/tt" "$TT_FILE" "$work/build/TropicalSessionTypes.olean"
compile verification/proofs/lean4 ResourceAlgebra.lean "$work/build/ResourceAlgebra.olean"
mkdir -p "$work/pkg"
cp -- "$BRIDGE_DIR/lakefile.toml" "$BRIDGE_DIR/lake-manifest.json" "$BRIDGE" \
"$RA_FILE" "$TOOLCHAIN" "$work/tt/$TT_FILE" "$work/pkg/"

if ! out="$(cd "$(dirname "$BRIDGE")" && LEAN_PATH="$work/build" "$lean" "$(basename "$BRIDGE")" 2>&1)" \
|| grep -q 'error:' <<<"$out"; then
if ! out="$(cd "$work/pkg" && "$lake" build 2>&1)" || grep -q 'error:' <<<"$out"; then
printf '%s\n' "$out" >&2
echo "ERROR: the bridge package does not build under lake" >&2
exit 1
fi
if grep -q 'depends on axioms' <<<"$out"; then
printf '%s\n' "$out" >&2
echo "ERROR: the bridge does not compile" >&2
echo "ERROR: a printed theorem depends on axioms" >&2
exit 1
fi
if ! cmp -s "$BRIDGE_DIR/lake-manifest.json" "$work/pkg/lake-manifest.json"; then
echo "ERROR: the build rewrote lake-manifest.json; commit the manifest lake writes" >&2
exit 1
fi

# A counted witness lists its axioms (§8.4): every printed theorem must say
# it depends on none.
n_print="$(grep -c '^#print axioms' "$BRIDGE")"
n_free="$(grep -c 'does not depend on any axioms' <<<"$out" || true)"
# A counted witness lists its axioms (§8.4): every theorem the bridge prints
# must say it depends on none. Lake prints each report as an
# `info: <file>:<line>:<col>:` line; count those attributed to the bridge.
bridge_name="$(basename -- "$BRIDGE")"
n_print="$(grep -cE '^#print axioms' "$BRIDGE" || true)"
n_free="$(grep -cE "^info: ${bridge_name//./\\.}:[0-9]+:[0-9]+: .* does not depend on any axioms\$" <<<"$out" || true)"
if [ "$n_print" -eq 0 ] || [ "$n_free" != "$n_print" ]; then
printf '%s\n' "$out" >&2
echo "ERROR: only $n_free of $n_print bridge theorems are axiom-free" >&2
Expand Down
54 changes: 54 additions & 0 deletions scripts/check-lean-leg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell
#
# check-lean-leg.sh: the Lean recheck leg under lake (PROOF-POLICY §8.2 names
# `lean` under `lake` as the qualifying kernel run). It builds the Lake package
# in verification/proofs/lean4 from a copy in a temporary directory, so no
# .lake/ build output lands in the tree, and takes the axiom census from that
# build. Lake prints each `#print axioms` report as an
# `info: <file>:<line>:<col>:` line.
#
# It fails loudly when: the build fails; any report says `depends on axioms`;
# the reports attributed to ResourceAlgebra.lean that say `does not depend on
# any axioms` differ in number from the `#print axioms` commands in the file
# (or there are none); or the build rewrote lake-manifest.json.
# LAKE overrides the lake binary.
set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.."

lake="${LAKE:-lake}"
src=verification/proofs/lean4
file=ResourceAlgebra.lean

work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
for f in lakefile.toml lake-manifest.json lean-toolchain "$file"; do
cp -- "$src/$f" "$work/"
done

if ! out="$(cd "$work" && "$lake" build 2>&1)"; then
printf '%s\n' "$out" >&2
echo "ERROR: the Lean leg does not build under lake" >&2
exit 1
fi
printf '%s\n' "$out"

if grep -q 'depends on axioms' <<<"$out"; then
echo "ERROR: a printed theorem depends on axioms" >&2
exit 1
fi

n_print="$(grep -cE '^[[:space:]]*#print[[:space:]]+axioms[[:space:]]' "$src/$file" || true)"
n_free="$(grep -cE "^info: ${file//./\\.}:[0-9]+:[0-9]+: .* does not depend on any axioms\$" <<<"$out" || true)"
if [ "$n_print" -eq 0 ] || [ "$n_free" != "$n_print" ]; then

Check failure on line 44 in scripts/check-lean-leg.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_resource-algebra&issues=AaHsR4HmLNFT6yhozjn5&open=AaHsR4HmLNFT6yhozjn5&pullRequest=53

Check failure on line 44 in scripts/check-lean-leg.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_resource-algebra&issues=AaHsR4HnLNFT6yhozjn6&open=AaHsR4HnLNFT6yhozjn6&pullRequest=53
echo "ERROR: only $n_free of $n_print printed theorems are axiom-free" >&2
exit 1
fi

if ! cmp -s "$src/lake-manifest.json" "$work/lake-manifest.json"; then
echo "ERROR: the build rewrote lake-manifest.json; commit the manifest lake writes" >&2
exit 1
fi

echo "PASS: Lean leg under lake; $n_free of $n_print printed theorems depend on no axiom"
Loading
Loading