Skip to content
Draft
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
53 changes: 44 additions & 9 deletions .github/workflows/coq-proof-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,56 @@ jobs:
# Coq job: the recipe fails if `agda` is absent, and every `*.agda` under
# formal/agda/ is checked without being listed.
#
# NOT the estate's pinned Agda. The proof lanes pin Agda 2.7.0.1 (mathesis
# `agda-proof-policy.yml`); this job runs Ubuntu 24.04's `agda-bin`, 2.6.3,
# and asserts that version so a silent package change fails the job. A run
# here is a real check under the canonical flags but is not receipt-grade.
# Provisioning 2.7.0.1 is an open owner decision (formal/agda/README.adoc).
# The estate's pinned Agda, 2.7.0.1 (mathesis `agda-proof-policy.yml`,
# AGDA_VERSION): the official static Linux binary from the agda/agda v2.7.0.1
# release, verified against a SHA-256 pinned here before it is unpacked.
# The usability check from `--cubical` uses agda/cubical v0.8 (the last
# release supporting 2.7.0.1), fetched by commit SHA and asserted.
# A green run is a real check on the pinned version; it is still not a
# receipt (no recorded receipt, no Lean leg — formal/agda/README.adoc).
agda-proofs:
runs-on: ubuntu-24.04
timeout-minutes: 15
timeout-minutes: 20
defaults:
run:
shell: bash
env:
AGDA_CI_VERSION: "2.6.3"
AGDA_CI_VERSION: "2.7.0.1"
AGDA_TARBALL_URL: "https://github.com/agda/agda/releases/download/v2.7.0.1/Agda-v2.7.0.1-linux.tar.xz"
AGDA_TARBALL_SHA256: "975b515a14877ab6bce5bfc641e16c4a3ee52ca5d7f846577dee80aa2145db8a"
CUBICAL_REPO: "https://github.com/agda/cubical"
CUBICAL_COMMIT: "3291fc1d8cae1409cc54d4f9cca7366158b573d7" # tag v0.8
steps:
- uses: actions/checkout@v7.0.1

- name: Install Agda and just (Ubuntu packages)
- name: Install just (Ubuntu package)
run: |
set -euo pipefail
sudo apt-get update -qq
sudo apt-get install -y -qq agda-bin just
sudo apt-get install -y -qq just

- name: Install Agda 2.7.0.1 (release binary, SHA-256 pinned)
run: |
set -euo pipefail
d="$RUNNER_TEMP/agda-dl"; mkdir -p "$d"
curl -fsSL --proto =https --proto-redir =https --retry 3 -o "$d/agda.tar.xz" "$AGDA_TARBALL_URL"
echo "${AGDA_TARBALL_SHA256} $d/agda.tar.xz" | sha256sum -c -
tar -xJf "$d/agda.tar.xz" -C "$RUNNER_TEMP"
root="$RUNNER_TEMP/Agda-v${AGDA_CI_VERSION}"
echo "$root/bin" >> "$GITHUB_PATH"
# The static binary's built-in data dir is the release builder's
# path; point it at the unpacked primitives.
echo "Agda_datadir=$root/data" >> "$GITHUB_ENV"

- name: Fetch agda/cubical v0.8 (by commit SHA)
run: |
set -euo pipefail
c="$RUNNER_TEMP/cubical"
git init -q "$c"
git -C "$c" fetch -q --depth 1 "$CUBICAL_REPO" "$CUBICAL_COMMIT"
git -C "$c" checkout -q FETCH_HEAD
test "$(git -C "$c" rev-parse HEAD)" = "$CUBICAL_COMMIT"
echo "CUBICAL_DIR=$c" >> "$GITHUB_ENV"

- name: Record and assert the prover version
run: |
Expand All @@ -177,3 +206,9 @@ jobs:

- name: Planted controls — each must fail the gate
run: just -f formal/justfile check-agda-controls

- name: Usability from --cubical (agda/cubical v0.8)
run: just -f formal/justfile check-agda-cubical

- name: Planted controls — each must fail the --cubical check
run: just -f formal/justfile check-agda-cubical-controls
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,5 @@ tools/vendor/
/affinescript-router/e2e/node_modules/
/tests/codegen-bun/collision/*.log
/tests/codegen-bun/collision/*.bun.js
# Agda >= 2.7 interface cache next to an .agda-lib
formal/agda-cubical/_build/
51 changes: 51 additions & 0 deletions formal/agda-cubical/CubicalCompat.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{-# OPTIONS --safe --cubical #-}
-- SPDX-License-Identifier: MPL-2.0
-- SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell (hyperpolymath)
--
-- CubicalCompat.agda
-- ══════════════════
-- Usability witness: the `formal/agda/` theory sources, which are checked
-- under the estate's canonical `--safe --without-K --cubical-compatible`,
-- import cleanly into a FULL `--cubical` development built on the agda/cubical
-- library (v0.8, the last release supporting Agda 2.7.0.1), and their
-- theorems are usable there as cubical paths.
--
-- This module proves nothing new about AffineScript. It is a compatibility
-- fixture: if either source loses `--cubical-compatible`, or starts using a
-- construct `--cubical` rejects, this module stops checking.
--
-- Checked by `just -f formal/justfile check-agda-cubical`.

module CubicalCompat where

open import Cubical.Foundations.Prelude using (Type; Path)
open import Cubical.Data.Equality.Conversion using (eqToPath; pathToEq)
open import Agda.Builtin.Maybe using (Maybe; nothing)
import Agda.Builtin.Equality as Eq

import QttSemiring as Q
import BorrowProvenance as B

-- Re-exported unchanged, in their inductive-equality (`Agda.Builtin`) form.
open Q public using (qplus-comm; qof-plus)
open B public using (safety; stuck-rejected; K1-rejected-by-theorem)

-- QttSemiring, as a cubical path …
qplus-comm-path : ∀ p q → Path Q.quant (Q.qplus p q) (Q.qplus q p)
qplus-comm-path p q = eqToPath (Q.qplus-comm p q)

-- … and as a path between FUNCTIONS. Function extensionality is not
-- available under `--without-K` alone; in cubical Agda it is a lambda over
-- the interval. This is the use a `--cubical` client gets that the source
-- cannot state itself.
qplus-flip-path : Path (Q.quant → Q.quant → Q.quant) Q.qplus (λ p q → Q.qplus q p)
qplus-flip-path i p q = qplus-comm-path p q i

-- The round trip lands back on the original theorem (inductive equality).
qplus-comm-roundtrip : ∀ p q → Q.qplus p q Eq.≡ Q.qplus q p
qplus-comm-roundtrip p q = pathToEq (qplus-comm-path p q)

-- BorrowProvenance: the K-1 (#554) verdict obtained from the rejection
-- theorem, as a cubical path.
K1-rejected-path : Path (Maybe B.CState) (B.chk B.initC B.K1) nothing
K1-rejected-path = eqToPath B.K1-rejected-by-theorem
5 changes: 5 additions & 0 deletions formal/agda-cubical/affinescript-cubical-compat.agda-lib
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- SPDX-License-Identifier: MPL-2.0
-- SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell (hyperpolymath)
name: affinescript-cubical-compat
include: . ../agda
depend: cubical-0.8
7 changes: 5 additions & 2 deletions formal/agda/BORROW-PROVENANCE-EXPERIMENT.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,11 @@ implemented refuted on three programs.* One result of each kind.
[#controls]
== What was run

All under Agda 2.6.3 (Ubuntu 24.04 `agda-bin`). The pinned 2.7.0.1 was not
available, so these are checks and not receipt-grade runs.
All under Agda 2.6.3 (Ubuntu 24.04 `agda-bin`); the two gate runs below were
repeated unchanged on the pinned Agda 2.7.0.1 (release binary) on 2026-12-01
with the same result, and the module also imports into a `--safe --cubical`
module (`formal/agda-cubical/`, see `README.adoc`). The nine mutations were
run on 2.6.3 only. No receipt exists, so none of this is receipt-grade.

* `just -f formal/justfile check-agda`: 2 modules, exit 0, no warning.
* `just -f formal/justfile check-agda-controls`: all 5 planted controls fail
Expand Down
132 changes: 108 additions & 24 deletions formal/agda/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ file, checked from this directory.
| `QttSemiring.agda`
| The QTT quantity semiring `{0, 1, ω}`: 21 statements, the same as
`formal/QttSemiring.v` (obligation P-4)
| Checks clean under the canonical flags on Agda 2.6.3. *Not yet checked on
the pinned Agda 2.7.0.1.* No Lean leg. No receipt. So still `ungraded`.
| Checks clean under the canonical flags on the pinned Agda 2.7.0.1 (and on
2.6.3); imports into a `--safe --cubical` module. No Lean leg. No receipt.
So still `ungraded`.

| `BorrowProvenance.agda`
| *Experiment* (#553, ADR-028 option G): on a toy reference calculus, the
checker's tracked loan set contains the provenance fibre for every program
in the second-class cut D; exclusivity and rejection for D+R4
| Checks clean under the canonical flags on Agda 2.6.3. A toy model, not
| Checks clean under the canonical flags on the pinned Agda 2.7.0.1 (and on
2.6.3); imports into a `--safe --cubical` module. A toy model, not
`lib/borrow.ml`. No Rocq or Lean leg, no receipt: `ungraded`. Record:
`BORROW-PROVENANCE-EXPERIMENT.adoc`.
|===
Expand All @@ -40,16 +42,73 @@ file, checked from this directory.
----
just -f formal/justfile check-agda # the gate
just -f formal/justfile check-agda-controls # five planted failures; each must fail the gate
# usability from full --cubical; needs an agda/cubical checkout at v0.8:
CUBICAL_DIR=/path/to/cubical just -f formal/justfile check-agda-cubical
CUBICAL_DIR=/path/to/cubical just -f formal/justfile check-agda-cubical-controls
----

The gate fails when `agda` is missing, when a module lacks the canonical
pragma, contains `postulate`, exits non-zero, or prints anything but
`Checking` lines (so a warning fails). Every `*.agda` under this directory is
checked; nothing is listed by hand.

CI runs both recipes in the `agda-proofs` job of
`.github/workflows/coq-proof-gate.yml`, on Ubuntu 24.04's `agda-bin` package
(Agda 2.6.3).
CI runs all four recipes in the `agda-proofs` job of
`.github/workflows/coq-proof-gate.yml`, on the pinned toolchain below.

=== Pinned toolchain

[cols="2,5",options="header"]
|===
| Component | Pin

| Agda
| 2.7.0.1, the official static Linux binary
`Agda-v2.7.0.1-linux.tar.xz` from the agda/agda `v2.7.0.1` release
(tag object `f24f2aaf…`, commit `a6fc20c27ae953149b53a8997ba4a1c8b17d628a`).
SHA-256 `975b515a14877ab6bce5bfc641e16c4a3ee52ca5d7f846577dee80aa2145db8a`;
CI verifies it before unpacking. The binary's built-in data directory is
the release builder's path, so `Agda_datadir` must point at the unpacked
`data/`.

| agda/cubical
| `v0.8`, commit `3291fc1d8cae1409cc54d4f9cca7366158b573d7` (library name
`cubical-0.8`). Its README's compatibility table pairs v0.8 with Agda
2.6.4.1 and 2.7.0.1; v0.9 (the latest tag, `b150186d…`) and `master`
require Agda 2.8.0, so v0.8 is the latest release usable with the pin.
CI fetches it by commit SHA and asserts `HEAD`. Used only by the
`--cubical` usability check; the theory sources import no library.
|===

=== Usability from `--cubical`

`formal/agda-cubical/CubicalCompat.agda` is a `--safe --cubical` module, in
its own library (`affinescript-cubical-compat`, `depend: cubical-0.8`), that
imports every module under this directory. It re-exports one or more theorems
of each unchanged, then uses them as cubical paths through the library's
`eqToPath` / `pathToEq`:

* `qplus-comm-path` — `QttSemiring.qplus-comm` as a `Path`;
* `qplus-flip-path` — a `Path` between the *functions* `qplus` and its flip:
function extensionality, which `--without-K` alone does not give;
* `qplus-comm-roundtrip` — back to the inductive `_≡_`;
* `K1-rejected-path` — `BorrowProvenance.K1-rejected-by-theorem` (the #554
verdict from the rejection theorem) as a `Path`.

`check-agda-cubical` fails if any module under this directory is not imported
by the fixture, so a new theory module must join it. Its controls show the
check is load-bearing: a source whose pragma drops `--cubical-compatible`
(keeping `--safe --without-K`) is refused by Agda with "Importing module
QttSemiring not using the --cubical-compatible flag from a module which
does", and a source with K available is refused for `--without-K` as well.

Decision: the sources stay at the canonical `--cubical-compatible`; nothing
was ported to full `--cubical`. `--cubical-compatible` is what makes a module
importable from cubical developments, so usability is proved by the import
rather than bought by changing the lane. Porting would move the modules out
of the PROOF-POLICY theory lane, add a library to their import cone, and cut
the Rocq and Lean legs for any statement using a cubical primitive (see the
comparison under "Extrapolation" below). A cubical client gets paths and
funext over these theorems for free, as the fixture shows.

== What is and is not established

Expand All @@ -67,17 +126,37 @@ Established, by runs in this session (2026-12-01, container Ubuntu 24.04):
definitions. A mutated table entry made the Agda check fail.
* The gate fails on each of five planted controls.

Established on the pinned Agda 2.7.0.1 (a later session, 2026-12-01, same
container image; toolchain pinned as in the table above):

* Both modules, unchanged, check with exit 0 and *no* output other than
`Checking` lines under `agda --safe --without-K --cubical-compatible`
(`check-agda`). No repair was needed; no statement or proof text changed.
Neither draws `UnsupportedIndexedMatch` on 2.7.0.1.
* `check-agda-controls`: all five planted controls still fail the gate on
2.7.0.1; the `indexed` control fails for the intended reason (2.7.0.1
prints `-W[no]UnsupportedIndexedMatch` and exits 0, and the gate rejects
the output).
* `check-agda-cubical`: `CubicalCompat.agda` checks against agda/cubical
v0.8 with exit 0 and no diagnostic, loading both sources;
`check-agda-cubical-controls`: all five controls fail it.
* All four recipes were replayed from a fresh download and a fresh cubical
fetch, exactly as the CI job runs them.

Not established:

* *The pinned Agda 2.7.0.1.* It could not be installed in the session. The
official release binary was downloaded (SHA-256
`975b515a14877ab6bce5bfc641e16c4a3ee52ca5d7f846577dee80aa2145db8a`, taken
from the download itself and not checked against an independent record),
but the session's permission policy refused to run it. A build from Hackage
failed because `cabal-install` 3.8.1 (Ubuntu) no longer verifies Hackage's
root keys; building around that check was refused too, correctly. So the
result above is a real check on a different Agda version, and it is *not*
receipt-grade.
* *An independent record of the Agda binary's digest.* The SHA-256 above was
computed from the download (twice, identical) and is pinned in CI from
then on (trust on first use). It was not compared with a digest published
by the Agda project: the release page and API were not reachable from the
session. Anyone with access can confirm it against the release asset's
`digest` field on GitHub. (An earlier session's attempt to build 2.7.0.1
from Hackage failed on `cabal-install` 3.8.1's root-key check; this
session used the release binary instead.)
* *The nine `BorrowProvenance` mutations* were run on 2.6.3 only, not
repeated on 2.7.0.1 (they are not scripted).
* *CI on the pin.* The job was replayed locally; its first GitHub Actions
run is on the PR that introduced it.
* *A Lean leg.* Lean 4.15.0 and 4.13.0 were downloaded and their SHA-256
digests match the ones `docs/COMPLETION-PLAN.adoc` §5.0 records
(`af71a256…`, `44ceeac7…`), but running them was refused in this session.
Expand Down Expand Up @@ -324,8 +403,10 @@ What drives the uncertainty, largest first:
. *The prelude.* No stdlib means ℕ and list lemmas are re-proved. `lia` is
used only 4 times across the seven files, so this is bounded, but
`QttDynamic`'s one `lia` closes 27 cases at once.
. *The pinned version.* Nothing here has run on Agda 2.7.0.1. Unification and
warning behaviour changed between 2.6.3 and 2.7; the files may need edits.
. *The pinned version.* The two committed modules needed no edit on Agda
2.7.0.1. The probe files above were measured on 2.6.3 only; unification and
warning behaviour changed between 2.6.3 and 2.7, so further files may still
need edits.
. *The other two legs.* Each Agda source also needs its statement comparison
with the Rocq leg and a new Lean leg (no Mathlib). The Lean leg was not
measured at all.
Expand Down Expand Up @@ -404,9 +485,11 @@ and the cross-prover comparison.
| Measured (Agda 2.6.3): the committed module checks unchanged with its pragma
replaced by `--safe --cubical`, because it uses only the inductive `_≡_`.
`--cubical` does not remove F1: the direct indexed match draws the same
`UnsupportedIndexedMatch` warning under `--safe --cubical`. Not measured:
restating the laws over `Path`, which is what a cubical development would
actually use, and which needs the two equalities bridged.
`UnsupportedIndexedMatch` warning under `--safe --cubical`. Measured on
Agda 2.7.0.1 with agda/cubical v0.8: the bridge works without restating
anything — `CubicalCompat.agda` turns the `_≡_` theorems into `Path`s with
the library's `eqToPath`, including a funext path. Not measured: proofs
written natively over `Path`.

| Other legs
| Rocq and Lean state the same thing.
Expand Down Expand Up @@ -475,10 +558,11 @@ admission record and any shared grade signature are estate-level items.

== Open decisions for the owner

. How to provision the pinned Agda 2.7.0.1 for this repository's CI: the
mathesis route (Guix time-machine with its `build/channels.scm`), or the
checksum-pinned official release binary. Until then the CI job runs
Agda 2.6.3 and says so.
. _Decided 2026-12-01:_ provisioning of the pinned Agda 2.7.0.1. The owner
asked for 2.7.0.1 plus the latest compatible agda/cubical; CI now uses the
checksum-pinned official release binary. The mathesis route (Guix
time-machine with its `build/channels.scm`) remains the alternative if the
estate wants one provisioning path for every lane.
. Whether `UnsupportedIndexedMatch` fails the gate (as here) or passes (as in
mathesis's `check-proofs.sh`).
. Whether to port the remaining theory files as they stand, or first repair
Expand Down
Loading
Loading