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
23 changes: 23 additions & 0 deletions .github/workflows/proofs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
name: Core proofs and expected rejections
runs-on: ubuntu-latest
timeout-minutes: 15
container: debian:trixie-slim

Check warning on line 32 in .github/workflows/proofs.yml

View workflow job for this annotation

GitHub Actions / Hypatia neurosymbolic scan

[hypatia] workflow .github/workflows/proofs.yml:32 pins container `debian:trixie-slim` by tag — tag is mutable; pin by sha256 digest instead
steps:
- name: Install the pinned prover
run: |
Expand Down Expand Up @@ -125,6 +125,29 @@
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"
} >> "$GITHUB_STEP_SUMMARY"
- name: Bridge check fails on a broken or axiom-dependent bridge
run: bash tests/check_lean_bridge_test.sh
# M-2: MaxPlus agrees with tropical-types' Tropical semiring. The bridge
# imports one file of hyperpolymath/tropical-types at the commit
# scripts/check-lean-bridge.sh pins (PROOF-POLICY §8.5.1, imported
# repositories).
- name: M-2 bridge to tropical-types, and receipt
env:
SOURCE_SHA: ${{ github.sha }}
run: |
set -euo pipefail
out="$(bash scripts/check-lean-bridge.sh)"
echo "$out"
{
echo "## M-2 bridge receipt"
echo ""
echo "- source commit: \`$SOURCE_SHA\`"
echo "- checker: \`$(lean --version)\`"
echo "- invocation: \`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"
sed -n 's/^PASS: .*; \(.*\)$/- axioms: \1/p' <<<"$out"
} >> "$GITHUB_STEP_SUMMARY"

# Rocq recheck leg (PROOF-POLICY §2): re-proved by hand. Dedukti transport
# is unavailable for this development (docs/status/PROOF-STATUS.adoc).
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
== Changelog

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

* C-4b: `src/ResourceAlgebra/Instances/Diamond.agda` adds the diamond
lattice M3 (⊕ = join, ⊗ = meet, 𝟘 = bottom, 𝟙 = top), with
`Diamond-ordered`, `Diamond-annihilating` and `Diamond-not-dioid`: an
annihilating ordered algebra that is not a dioid. The Lean and Rocq legs
re-prove it. A tenth expected rejection,
`tests/reject/DiamondDistributes.agda`, must fail with `a != bot of type
Grade`.
* M-2: `verification/bridges/tropical-types/TropicalBridge.lean` proves in
Lean that `MaxPlus` is isomorphic to tropical-types' `Tropical` and that
the isomorphism carries ⊕, ⊗, 𝟘 and 𝟙 to its `CommSemiring` instance's
operations, against tropical-types pinned at `f2e465c`, with no axiom.
`scripts/check-lean-bridge.sh` runs it in the Lean leg of `proofs.yml`,
and `tests/check_lean_bridge_test.sh` shows it fails on an error, an
axiom or no printed theorem.
* Both rows stay ungraded. The receipt still describes `47de4a8`, which
predates C-4b. M-2 has no Agda witness, so it cannot reach PWG-3.

== 2026-11-17 — `CI/gate` starts on `pull_request`; tamper guard

* `CI/gate` now also starts on `pull_request`, and a tamper guard is added.
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Five instances are checked against it:
|===
| Instance | Source of the definition | Alternatives / sequence | Status
| `Instances.Loss` | echo-types `experimental/echo-additive/Grade.agda`, transcribed | min / + on ℕ ∪ {∞} | transcribed, PROVEN
| `Instances.MaxPlus` | tropical-types `TropicalSessionTypes.lean`, transcribed | max / + on ℕ ∪ {−∞} | transcribed, PROVEN; Lean bridge OPEN
| `Instances.MaxPlus` | tropical-types `TropicalSessionTypes.lean`, transcribed | max / + on ℕ ∪ {−∞} | transcribed, PROVEN; agreement with tropical-types' Lean instance PROVEN by a Lean bridge (M-2)
| `Instances.HWM` | occupancy-types' occupancy algebra, which adopts it (its O-1) | componentwise max / peak-and-drift | PROVEN; signed drift OPEN
| `Instances.MinMax` | typed-wasm L11 bottleneck (`Tropical.tropMax`), which now transcribes it (`tropMax = minMaxSeq`) | min / max on ℕ ∪ {∞} | PROVEN; typed-wasm transcription TESTED there
| `Instances.Questions` | ours: the powerset lattice of `n` downstream questions, a "which" grade | intersection / union on `n` booleans | PROVEN; sound per question, not jointly (Q-4)
Expand Down
10 changes: 6 additions & 4 deletions docs/status/PROOF-NEEDS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ expected rejection fails with its stated message.
| `tests/reject/`, `scripts/check-agda.sh`

| PN-5
| Close or keep stating the open theory rows: C-4b (an annihilating ordered
algebra that is not a dioid) and M-2 (agreement with tropical-types' Lean
semiring).
| `PROOF-STATUS.adoc`
| Grade the two ungraded theory rows, or keep stating why they are not.
C-4b (an annihilating ordered algebra that is not a dioid) is PROVEN in all
three legs and needs a receipt for a commit that contains it. M-2
(agreement with tropical-types' Lean semiring) is PROVEN by a Lean bridge
only; it has no Agda witness, so it cannot reach PWG-3.
| `PROOF-STATUS.adoc`, `verification/bridges/tropical-types/`
|===

== Out of scope here
Expand Down
98 changes: 87 additions & 11 deletions docs/status/PROOF-STATUS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ ungraded: 2. The grades hold at source commit
receipt describes (`verification/receipts/resource-algebra-proofs_praxis.deed`).
The standards reader (`deed_lint.js --proof-receipt-json`) derives every
grade there from the legs and receipts, and refuses a recorded grade that
differs (§8.4). The two ungraded rows are `OPEN` (C-4b, M-2). No row rests
differs (§8.4). Neither ungraded row is `OPEN` any more, but neither has a
grade. C-4b is `PROVEN` in all three legs on this tree, but the receipt
describes `47de4a8`, which predates it: it stays ungraded until a receipt
describes a commit that contains it. M-2 is `PROVEN` by a Lean bridge only.
Its statement names a Lean-only object, so it has no Agda witness and
cannot reach PWG-3 (§8.1): it stays ungraded until an Agda statement of it
exists. No row rests
on an axiom: the Agda leg is `--safe` with the trusted base below, the Rocq
leg prints every theorem closed under the global context, and the Lean leg
prints no axiom for any theorem.
Expand All @@ -36,7 +42,7 @@ dependent type theories (§8.3).
-W error -i src`, and every module also
declares `--exact-split --no-sized-types --no-guardedness` (the estate
strict flag set, from main #21) over `src/ResourceAlgebra/All.agda`, the unit tests
(`tests/unit/AllTests.agda`) and the nine expected rejections. A rejection
(`tests/unit/AllTests.agda`) and the ten expected rejections. A rejection
must fail at its invalid declaration with the message its `-- EXPECT:` line
names. A refusal with any other message fails the gate, and so does any
warning, `UnsupportedIndexedMatch` included. Until 2026-11-16 the gate
Expand Down Expand Up @@ -68,11 +74,12 @@ receipts for the canonical profile. On 2026-11-09, `_≤_` and the
constructor-injectivity lemmas were restated so that the core checks under
`--cubical-compatible` with no `UnsupportedIndexedMatch` warning. The
statements of the theorems below did not change.
* *Expected rejections.* Nine claims must be refused, each with the message
* *Expected rejections.* Ten claims must be refused, each with the message
its `-- EXPECT:` line names. In order, those messages are:
`min m n != max m n`, `p != zero`, `suc _ != zero`, `max m n != m + n`,
`max p₁ (n₁ + p₂) != p₁ + p₂`, `3 != 5`, `inf != fin 3`, `… != bot` and
`false != true`.
`max p₁ (n₁ + p₂) != p₁ + p₂`, `3 != 5`, `inf != fin 3`, `… != bot`,
`false != true` and `a != bot of type Grade` (C-4b's control,
`tests/reject/DiamondDistributes.agda`).
These are controls for the PROVEN rows. They are not themselves theorems.

== Recheck legs (every row)
Expand Down Expand Up @@ -237,6 +244,7 @@ equations as Lean's `or`/`and` and Rocq's `orb`/`andb`.
| C-2 | `≼-refl`, `≼-trans`, `≼-antisym`, `𝟘-least`, `⊕-upperˡ`, `⊕-upperʳ`, `⊕-least` | `ResourceAlgebra.le_refl`, `le_trans`, `le_antisym`, `zero_least`, `add_upperl`, `add_upperr`, `add_least` | `le_refl`, `le_trans`, `le_antisym`, `zero_least`, `add_upperl`, `add_upperr`, `add_least`
| C-3 | `IsDioid.ordered` | `IsDioid.ordered` | `dioid_ordered`
| C-4a | `HWM-dioid`, `HWM-not-annihilating` | `dioid_not_annihilating` (their conjunction) | `dioid_not_annihilating` (their conjunction)
| C-4b | `Grade`, `Diamond`, `Diamond-ordered`, `Diamond-annihilating`, `Diamond-not-dioid` | `DGrade`, `Diamond`, `Diamond_ordered`, `Diamond_annihilating`, `Diamond_not_dioid`, and `ordered_annihilating_not_dioid` (their conjunction) | the same names
| L-1 | `Loss`, `Loss-dioid`, `Loss-ordered`, `Loss-annihilating` | `Loss`, `Loss_dioid`, `Loss_ordered`, `Loss_annihilating` | the same names
| M-1 | `MaxPlus`, `MaxPlus-dioid`, `MaxPlus-ordered`, `MaxPlus-annihilating` | `MaxPlus`, `MaxPlus_dioid`, `MaxPlus_ordered`, `MaxPlus_annihilating` | the same names
| H-1 | `HWM`, `HWM-dioid`, `HWM-ordered` | `HWM`, `HWM_dioid`, `HWM_ordered`, `HWM_zero_eq_one` | the same names
Expand All @@ -262,6 +270,12 @@ equations as Lean's `or`/`and` and Rocq's `orb`/`andb`.
| S-4 | `bottleneck-is-not-sum` | `bottleneck_is_not_sum` | `bottleneck_is_not_sum`
|===

C-4b's carrier is `Grade` in Agda and `DGrade` in Lean and Rocq; the join
and meet have the same tables in all three. Agda proves each law by
evaluating one Boolean check over every choice of grades and reading it back
through soundness lemmas; Lean and Rocq prove the same equations by case
analysis on the grades. The statements do not change.

F-5's classifier `Loss→MaxPlus` returns Agda's `_⊎_`, a sum in `Set` that
says *which* of the two maps a morphism is. Both legs now return a sum too
(Lean's `PSum`, Rocq's `sumbool`), so the statements correspond exactly.
Expand All @@ -270,6 +284,58 @@ only that a morphism is one of the two: a weaker statement, so the receipts
at `9f175cc` do not recheck F-5's classifier either (see Receipts). No leg rests
on an assumption beyond its prover's kernel.

=== M-2 bridge (Lean only)

M-2 does not carry the record above. Its statement names tropical-types'
`instance : CommSemiring Tropical`, a Lean 4 object, so it is proved in
Lean against that object and in no other prover.

[cols="1,1,1,1,2",options="header"]
|===
| Leg | Route | §5 | §2.2 | Receipts

| Agda
| `unavailable`: the statement names a Lean object
| —
| —
| —

| Rocq
| `unavailable`: the statement names a Lean object
| —
| —
| —

| Lean
| source, Lean core only, no Mathlib
| `PROVEN`: no axiom (`#print axioms` reports none for any of the six
printed theorems)
| `LEAN-CHECKED`
| none yet: the step runs in the Lean leg of `proofs.yml` and writes an
"M-2 bridge receipt" to the job summary
|===

* *Bridge.* `verification/bridges/tropical-types/TropicalBridge.lean`
imports this repository's Lean leg (`ResourceAlgebra.lean`) and
tropical-types' `TropicalSessionTypes.lean`. It proves `rmax_eq_max`
(this leg's `rmax` is Lean's `Nat.max`), that `toHT` and `ofHT` are
inverse, and that `toHT` sends ⊕, ⊗, 𝟘 and 𝟙 to `tAdd`, `tMul`, `.bot` and
`.val 0` (`maxplus_agrees_tropical`). Four `example`s check by `rfl` that
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
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).
* *Trusted boundary.* tropical-types' own instance laws depend on `propext`
and `Quot.sound` at that commit. The bridge theorems do not use those laws
and depend on no axiom. The `example`s mention the instance and so are not
counted.
* *Grade.* None. PWG-3 needs an Agda witness (§8.1), and there is none.

== Core (Core.agda)

[cols="1,4,2,1",options="header"]
Expand Down Expand Up @@ -301,9 +367,13 @@ the least-upper-bound half is `⊕-least`, from main #21)
| 1

| C-4b
| An annihilating ordered algebra need not be a dioid.
| `OPEN`: no instance witnesses it yet
| ungraded
| An annihilating ordered algebra need not be a dioid. The diamond lattice
M3 (`Instances/Diamond.agda`: ⊕ = join, ⊗ = meet, 𝟘 = bottom, 𝟙 = top) is
ordered and annihilating, and is not a dioid: a ⊗ (b ⊕ c) = a, while
(a ⊗ b) ⊕ (a ⊗ c) = 𝟘.
| `PROVEN` (`Diamond`, `Diamond-ordered`, `Diamond-annihilating`,
`Diamond-not-dioid`); control `tests/reject/DiamondDistributes.agda`
| ungraded: no receipt yet describes a commit that contains it
|===

== Instances
Expand All @@ -327,9 +397,15 @@ the least-upper-bound half is `⊕-least`, from main #21)
| M-2
| `MaxPlus` agrees with tropical-types' `instance : CommSemiring Tropical`
(Lean 4).
| `OPEN`: a cross-prover bridge obligation. No mechanical link exists, and
none is claimed.
| ungraded
| `PROVEN` in Lean only, by the bridge
`verification/bridges/tropical-types/TropicalBridge.lean`
(`maxplus_agrees_tropical`): `toHT` and `ofHT` are inverse, and `toHT`
sends ⊕, ⊗, 𝟘 and 𝟙 to tropical-types' `tAdd`, `tMul`, `.bot` and `.val 0`,
which are the fields of the instance. tropical-types is pinned at
`f2e465c966d14d4986dfc492875cc54653d9751e`; see "M-2 bridge" below for the
legs. The Agda and Rocq legs are `unavailable`: the statement names a Lean
object.
| ungraded: no Agda witness, so PWG-3 cannot be reached

| H-1
| `HWM` (peak, drift, with drift ≤ peak) is a `ResourceAlgebra`, `IsDioid`
Expand Down
69 changes: 69 additions & 0 deletions scripts/check-lean-bridge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
#
# check-lean-bridge.sh: the M-2 bridge (docs/status/PROOF-STATUS.adoc).
#
# verification/bridges/tropical-types/TropicalBridge.lean proves that this
# repository's MaxPlus (the Lean leg, verification/proofs/lean4) is isomorphic
# to the Tropical semiring of hyperpolymath/tropical-types. It imports one
# file of that repository, read at the commit pinned below. This script is the
# 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.
#
# 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.
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}"

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" \
|| { echo "ERROR: could not fetch $TT_REPOSITORY at $TT_COMMIT" >&2; exit 1; }
git -C "$work/tt" checkout -q FETCH_HEAD
got="$(git -C "$work/tt" rev-parse HEAD)"
[ "$got" = "$TT_COMMIT" ] \

Check failure on line 34 in scripts/check-lean-bridge.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=AaHqaj_xhCsqYpyjFQYb&open=AaHqaj_xhCsqYpyjFQYb&pullRequest=48
|| { echo "ERROR: fetched $got, not the pinned $TT_COMMIT" >&2; exit 1; }
[ -f "$work/tt/$TT_FILE" ] \

Check failure on line 36 in scripts/check-lean-bridge.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=AaHqaj_xhCsqYpyjFQYc&open=AaHqaj_xhCsqYpyjFQYc&pullRequest=48
|| { 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"

if ! out="$(cd "$(dirname "$BRIDGE")" && LEAN_PATH="$work/build" "$lean" "$(basename "$BRIDGE")" 2>&1)" \
|| grep -q 'error:' <<<"$out"; then
printf '%s\n' "$out" >&2
echo "ERROR: the bridge does not compile" >&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)"
if [ "$n_print" -eq 0 ] || [ "$n_free" != "$n_print" ]; then

Check failure on line 61 in scripts/check-lean-bridge.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=AaHqaj_xhCsqYpyjFQYe&open=AaHqaj_xhCsqYpyjFQYe&pullRequest=48

Check failure on line 61 in scripts/check-lean-bridge.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=AaHqaj_xhCsqYpyjFQYd&open=AaHqaj_xhCsqYpyjFQYd&pullRequest=48
printf '%s\n' "$out" >&2
echo "ERROR: only $n_free of $n_print bridge theorems are axiom-free" >&2
exit 1
fi

echo "PASS: M-2 bridge to $TT_REPOSITORY@$TT_COMMIT; $n_free of $n_print printed theorems depend on no axiom"
echo "import: $TT_REPOSITORY $TT_COMMIT $TT_FILE $(sha256sum "$work/tt/$TT_FILE" | cut -d' ' -f1)"
echo "bridge: $BRIDGE $(sha256sum "$BRIDGE" | cut -d' ' -f1)"
1 change: 1 addition & 0 deletions src/ResourceAlgebra/All.agda
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ import ResourceAlgebra.Instances.MaxPlus
import ResourceAlgebra.Instances.HWM
import ResourceAlgebra.Instances.MinMax
import ResourceAlgebra.Instances.Questions
import ResourceAlgebra.Instances.Diamond
import ResourceAlgebra.Separation
import ResourceAlgebra.Morphism
Loading
Loading