From d0e839c29a94afb113828b2d941e12e05c391b94 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:49:03 +0000 Subject: [PATCH 1/2] Prove C-4b (diamond lattice) and M-2 (Lean bridge to tropical-types) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit C-4b: the diamond lattice M3, with join as alternatives and meet as sequence, is an ordered, annihilating resource algebra that is not a dioid (a ⊓ (b ⊔ c) = a, (a ⊓ b) ⊔ (a ⊓ c) = bot). It is proved in Agda (Instances/Diamond.agda, in the All.agda cone) and re-proved in the Lean and Rocq legs. A tenth expected rejection, tests/reject/DiamondDistributes, must fail with "a != bot of type Grade". M-2: verification/bridges/tropical-types/TropicalBridge.lean proves in Lean, with no axiom, that MaxPlus is isomorphic to tropical-types' Tropical and that the isomorphism carries the four operations to its CommSemiring instance's fields. scripts/check-lean-bridge.sh fetches tropical-types at a pinned commit and runs it in the Lean leg; a test shows it fails on an error, an axiom or no printed theorem. Both rows stay ungraded: the receipt describes 47de4a8, which predates C-4b, and M-2 has no Agda witness. The ledger, PROOF-NEEDS, README and CHANGELOG say so. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LiQzWJdcPfRU6YMDGRG8Xi --- .github/workflows/proofs.yml | 23 ++ CHANGELOG.adoc | 19 ++ README.adoc | 2 +- docs/status/PROOF-NEEDS.adoc | 10 +- docs/status/PROOF-STATUS.adoc | 98 ++++++- scripts/check-lean-bridge.sh | 69 +++++ src/ResourceAlgebra/All.agda | 1 + src/ResourceAlgebra/Instances/Diamond.agda | 266 ++++++++++++++++++ tests/check_lean_bridge_test.sh | 42 +++ tests/reject/DiamondDistributes.agda | 15 + .../tropical-types/TropicalBridge.lean | 111 ++++++++ verification/proofs/coq/ResourceAlgebra.v | 63 +++++ .../proofs/lean4/ResourceAlgebra.lean | 91 ++++++ 13 files changed, 794 insertions(+), 16 deletions(-) create mode 100755 scripts/check-lean-bridge.sh create mode 100644 src/ResourceAlgebra/Instances/Diamond.agda create mode 100755 tests/check_lean_bridge_test.sh create mode 100644 tests/reject/DiamondDistributes.agda create mode 100644 verification/bridges/tropical-types/TropicalBridge.lean diff --git a/.github/workflows/proofs.yml b/.github/workflows/proofs.yml index 2bfccf1..664772d 100644 --- a/.github/workflows/proofs.yml +++ b/.github/workflows/proofs.yml @@ -125,6 +125,29 @@ jobs: 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). diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index f31767c..9fcec7e 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -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 — Proof receipt and grades at 47de4a8 * `verification/receipts/resource-algebra-proofs_praxis.deed` now describes diff --git a/README.adoc b/README.adoc index 1491aa0..462dc58 100644 --- a/README.adoc +++ b/README.adoc @@ -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) diff --git a/docs/status/PROOF-NEEDS.adoc b/docs/status/PROOF-NEEDS.adoc index ee4f85b..ecdb44c 100644 --- a/docs/status/PROOF-NEEDS.adoc +++ b/docs/status/PROOF-NEEDS.adoc @@ -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 diff --git a/docs/status/PROOF-STATUS.adoc b/docs/status/PROOF-STATUS.adoc index 32a87e2..19892b7 100644 --- a/docs/status/PROOF-STATUS.adoc +++ b/docs/status/PROOF-STATUS.adoc @@ -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. @@ -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 @@ -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) @@ -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 @@ -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. @@ -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"] @@ -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 @@ -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` diff --git a/scripts/check-lean-bridge.sh b/scripts/check-lean-bridge.sh new file mode 100755 index 0000000..7f69761 --- /dev/null +++ b/scripts/check-lean-bridge.sh @@ -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" ] \ + || { echo "ERROR: fetched $got, not the pinned $TT_COMMIT" >&2; exit 1; } +[ -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" + +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 + 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)" diff --git a/src/ResourceAlgebra/All.agda b/src/ResourceAlgebra/All.agda index 54eecfc..3e13824 100644 --- a/src/ResourceAlgebra/All.agda +++ b/src/ResourceAlgebra/All.agda @@ -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 diff --git a/src/ResourceAlgebra/Instances/Diamond.agda b/src/ResourceAlgebra/Instances/Diamond.agda new file mode 100644 index 0000000..0231eee --- /dev/null +++ b/src/ResourceAlgebra/Instances/Diamond.agda @@ -0,0 +1,266 @@ +{-# OPTIONS --safe --without-K --cubical-compatible --exact-split --no-sized-types --no-guardedness #-} +-- SPDX-License-Identifier: MPL-2.0 +-- SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell +-- +-- The diamond lattice M3: a bottom, a top and three pairwise incomparable +-- atoms. Alternatives are the join, sequence is the meet, 𝟘 is the bottom +-- and 𝟙 the top. +-- +-- It is the witness for C-4b: an annihilating ordered resource algebra +-- that is not a dioid. The meet is monotone and the bottom absorbs under +-- it, but M3 is not a distributive lattice, so the meet does not +-- distribute over the join: a ∧ (b ∨ c) = a ∧ ⊤ = a, while +-- (a ∧ b) ∨ (a ∧ c) = ⊥ ∨ ⊥ = ⊥. +-- +-- The laws are closed statements over a five-element carrier. Each is +-- proved by one Boolean check that Agda evaluates (the check is `tt`), +-- read back through the soundness lemmas below. +module ResourceAlgebra.Instances.Diamond where + +open import Agda.Builtin.Bool using (Bool; true; false) +open import ResourceAlgebra.Prelude +open import ResourceAlgebra.Core + +data Grade : Set where + bot top a b c : Grade + +infixl 6 _⊔d_ +infixl 7 _⊓d_ + +-- Join: the alternatives. +_⊔d_ : Grade → Grade → Grade +bot ⊔d y = y +top ⊔d _ = top +a ⊔d bot = a +a ⊔d top = top +a ⊔d a = a +a ⊔d b = top +a ⊔d c = top +b ⊔d bot = b +b ⊔d top = top +b ⊔d a = top +b ⊔d b = b +b ⊔d c = top +c ⊔d bot = c +c ⊔d top = top +c ⊔d a = top +c ⊔d b = top +c ⊔d c = c + +-- Meet: the sequence. +_⊓d_ : Grade → Grade → Grade +bot ⊓d _ = bot +top ⊓d y = y +a ⊓d bot = bot +a ⊓d top = a +a ⊓d a = a +a ⊓d b = bot +a ⊓d c = bot +b ⊓d bot = bot +b ⊓d top = b +b ⊓d a = bot +b ⊓d b = b +b ⊓d c = bot +c ⊓d bot = bot +c ⊓d top = c +c ⊓d a = bot +c ⊓d b = bot +c ⊓d c = c + +---------------------------------------------------------------------- +-- A decision procedure for closed statements over the carrier + +private + infix 4 _==_ + infixr 3 _&&_ + infixr 2 _⇒_ + + T : Bool → Set + T true = ⊤ + T false = ⊥ + + _&&_ : Bool → Bool → Bool + true && y = y + false && _ = false + + _⇒_ : Bool → Bool → Bool + true ⇒ y = y + false ⇒ _ = true + + &&-l : ∀ x y → T (x && y) → T x + &&-l true _ _ = tt + &&-l false _ () + + &&-r : ∀ x y → T (x && y) → T y + &&-r true _ p = p + &&-r false _ () + + ⇒-mp : ∀ x y → T (x ⇒ y) → T x → T y + ⇒-mp true _ p _ = p + ⇒-mp false _ _ () + + -- Every grade satisfies p. + every : (Grade → Bool) → Bool + every p = p bot && (p top && (p a && (p b && p c))) + + every-sound : ∀ p → T (every p) → ∀ x → T (p x) + every-sound p h bot = &&-l (p bot) _ h + every-sound p h top = &&-l (p top) _ (&&-r (p bot) _ h) + every-sound p h a = &&-l (p a) _ (&&-r (p top) _ (&&-r (p bot) _ h)) + every-sound p h b = + &&-l (p b) _ (&&-r (p a) _ (&&-r (p top) _ (&&-r (p bot) _ h))) + every-sound p h c = + &&-r (p b) _ (&&-r (p a) _ (&&-r (p top) _ (&&-r (p bot) _ h))) + + _==_ : Grade → Grade → Bool + bot == bot = true + top == top = true + a == a = true + b == b = true + c == c = true + bot == top = false + bot == a = false + bot == b = false + bot == c = false + top == bot = false + top == a = false + top == b = false + top == c = false + a == bot = false + a == top = false + a == b = false + a == c = false + b == bot = false + b == top = false + b == a = false + b == c = false + c == bot = false + c == top = false + c == a = false + c == b = false + + ==-sound : ∀ x y → T (x == y) → x ≡ y + ==-sound bot bot _ = refl + ==-sound top top _ = refl + ==-sound a a _ = refl + ==-sound b b _ = refl + ==-sound c c _ = refl + ==-sound bot top () + ==-sound bot a () + ==-sound bot b () + ==-sound bot c () + ==-sound top bot () + ==-sound top a () + ==-sound top b () + ==-sound top c () + ==-sound a bot () + ==-sound a top () + ==-sound a b () + ==-sound a c () + ==-sound b bot () + ==-sound b top () + ==-sound b a () + ==-sound b c () + ==-sound c bot () + ==-sound c top () + ==-sound c a () + ==-sound c b () + + ==-refl : ∀ x → T (x == x) + ==-refl bot = tt + ==-refl top = tt + ==-refl a = tt + ==-refl b = tt + ==-refl c = tt + + -- An equation between two closed expressions in x, y, z, checked for + -- all 125 triples. + law₃ : (f g : Grade → Grade → Grade → Grade) + → T (every λ x → every λ y → every λ z → f x y z == g x y z) + → ∀ x y z → f x y z ≡ g x y z + law₃ f g h x y z = + ==-sound _ _ + (every-sound (λ z → f x y z == g x y z) + (every-sound (λ y → every λ z → f x y z == g x y z) + (every-sound (λ x → every λ y → every λ z → f x y z == g x y z) + h x) y) z) + + law₂ : (f g : Grade → Grade → Grade) + → T (every λ x → every λ y → f x y == g x y) + → ∀ x y → f x y ≡ g x y + law₂ f g h x y = + ==-sound _ _ + (every-sound (λ y → f x y == g x y) + (every-sound (λ x → every λ y → f x y == g x y) h x) y) + + law₁ : (f g : Grade → Grade) + → T (every λ x → f x == g x) → ∀ x → f x ≡ g x + law₁ f g h x = ==-sound _ _ (every-sound (λ x → f x == g x) h x) + + -- A conditional equation: x ⊔ y = y implies f x y z = g x y z. + cond₃ : (f g : Grade → Grade → Grade → Grade) + → T (every λ z → every λ x → every λ y → + (x ⊔d y == y) ⇒ (f z x y == g z x y)) + → ∀ z {x y} → x ⊔d y ≡ y → f z x y ≡ g z x y + cond₃ f g h z {x} {y} p = + ==-sound _ _ + (⇒-mp (x ⊔d y == y) (f z x y == g z x y) + (every-sound (λ y → x ⊔d y == y ⇒ f z x y == g z x y) + (every-sound (λ x → every λ y → x ⊔d y == y ⇒ f z x y == g z x y) + (every-sound + (λ z → every λ x → every λ y → + x ⊔d y == y ⇒ f z x y == g z x y) + h z) x) y) + (subst (λ w → T (w == y)) (sym p) (==-refl y))) + +---------------------------------------------------------------------- +-- The laws + +⊔d-assoc : ∀ x y z → (x ⊔d y) ⊔d z ≡ x ⊔d (y ⊔d z) +⊔d-assoc = law₃ (λ x y z → (x ⊔d y) ⊔d z) (λ x y z → x ⊔d (y ⊔d z)) tt + +⊔d-comm : ∀ x y → x ⊔d y ≡ y ⊔d x +⊔d-comm = law₂ _⊔d_ (λ x y → y ⊔d x) tt + +⊔d-idem : ∀ x → x ⊔d x ≡ x +⊔d-idem = law₁ (λ x → x ⊔d x) (λ x → x) tt + +⊓d-assoc : ∀ x y z → (x ⊓d y) ⊓d z ≡ x ⊓d (y ⊓d z) +⊓d-assoc = law₃ (λ x y z → (x ⊓d y) ⊓d z) (λ x y z → x ⊓d (y ⊓d z)) tt + +⊓d-top : ∀ x → x ⊓d top ≡ x +⊓d-top = law₁ (λ x → x ⊓d top) (λ x → x) tt + +⊓d-bot : ∀ x → x ⊓d bot ≡ bot +⊓d-bot = law₁ (λ x → x ⊓d bot) (λ _ → bot) tt + +Diamond : ResourceAlgebra +Diamond = record + { Grade = Grade + ; _⊕_ = _⊔d_ + ; _⊗_ = _⊓d_ + ; 𝟘 = bot + ; 𝟙 = top + ; alt = record { assoc = ⊔d-assoc ; comm = ⊔d-comm + ; idem = ⊔d-idem ; unitˡ = λ _ → refl } + ; seq = record { assoc = ⊓d-assoc ; unitˡ = λ _ → refl + ; unitʳ = ⊓d-top } + } + +-- Sequencing is monotone on both sides for the order ⊕ induces. +Diamond-ordered : IsOrdered Diamond +Diamond-ordered = record + { ⊗-monoˡ = cond₃ (λ z x y → (z ⊓d x) ⊔d (z ⊓d y)) (λ z x y → z ⊓d y) tt + ; ⊗-monoʳ = cond₃ (λ z x y → (x ⊓d z) ⊔d (y ⊓d z)) (λ z x y → y ⊓d z) tt + } + +Diamond-annihilating : IsAnnihilating Diamond +Diamond-annihilating = record + { annihilˡ = λ _ → refl + ; annihilʳ = ⊓d-bot + } + +-- Not a dioid: sequencing does not distribute over alternatives. +Diamond-not-dioid : ¬ IsDioid Diamond +Diamond-not-dioid d with IsDioid.distribˡ d a b c +... | () diff --git a/tests/check_lean_bridge_test.sh b/tests/check_lean_bridge_test.sh new file mode 100755 index 0000000..1166ddf --- /dev/null +++ b/tests/check_lean_bridge_test.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# scripts/check-lean-bridge.sh must fail when the bridge does not compile and +# when a bridge theorem depends on an axiom. A stub lean (LEAN=) compiles the +# two imported modules and then misreports the bridge, once each way. The +# script fetches tropical-types at its pin, so this test needs the network. +set -uo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +stub=$(mktemp -d); trap 'rm -rf "$stub"' EXIT + +make_stub() { # $1 name, $2 what the stub prints when checking the bridge, $3 its exit code + cat > "$stub/$1" < "\$2"; exit 0; fi +printf '%s\n' "$2" +exit $3 +STUB + chmod +x "$stub/$1" +} + +fails=0 +expect_fail() { # $1 stub, $2 message the script must give + out=$(LEAN="$stub/$1" bash scripts/check-lean-bridge.sh 2>&1); rc=$? + if [[ $rc -eq 0 ]] || grep -q '^PASS:' <<<"$out"; then + printf 'FAIL: %s: the script passed (exit %s)\n%s\n' "$1" "$rc" "$out" >&2; fails=1; return + fi + if ! grep -q -- "$2" <<<"$out"; then + printf 'FAIL: %s: the script stopped for another reason (exit %s)\n%s\n' "$1" "$rc" "$out" >&2; fails=1; return + fi + echo "PASS: $1 makes the script fail ($2)" +} + +make_stub axiom "'RA.TropicalBridge.rmax_eq_max' depends on axioms: [propext]" 0 +expect_fail axiom 'bridge theorems are axiom-free' + +make_stub broken "TropicalBridge.lean:1:0: error: unknown module prefix" 1 +expect_fail broken 'the bridge does not compile' + +make_stub silent "" 0 +expect_fail silent 'bridge theorems are axiom-free' + +exit $fails diff --git a/tests/reject/DiamondDistributes.agda b/tests/reject/DiamondDistributes.agda new file mode 100644 index 0000000..e765591 --- /dev/null +++ b/tests/reject/DiamondDistributes.agda @@ -0,0 +1,15 @@ +{-# OPTIONS --safe --without-K --cubical-compatible --exact-split --no-sized-types --no-guardedness #-} +-- SPDX-License-Identifier: MPL-2.0 +-- SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell +module DiamondDistributes where +open import ResourceAlgebra.Prelude +open import ResourceAlgebra.Core +open import ResourceAlgebra.Instances.Diamond + +-- Must fail: the diamond lattice M3 is not distributive. An atom met with +-- the join of the other two atoms is the atom itself (that join is the +-- top), while the join of the two meets is the bottom. Accepting this +-- would make Diamond a dioid and leave C-4b without a witness. +-- EXPECT: a != bot of type Grade +invalid : a ⊓d (b ⊔d c) ≡ (a ⊓d b) ⊔d (a ⊓d c) +invalid = refl diff --git a/verification/bridges/tropical-types/TropicalBridge.lean b/verification/bridges/tropical-types/TropicalBridge.lean new file mode 100644 index 0000000..59f7209 --- /dev/null +++ b/verification/bridges/tropical-types/TropicalBridge.lean @@ -0,0 +1,111 @@ +-- SPDX-License-Identifier: MPL-2.0 +-- SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell +import ResourceAlgebra +import TropicalSessionTypes + +/-! +# M-2: MaxPlus agrees with tropical-types' Tropical semiring + +The bridge between this repository's `MaxPlus` (M-1) and the +`instance : CommSemiring Tropical` of `hyperpolymath/tropical-types` +(`TropicalSessionTypes.lean`, namespace `Hyperpolymath.Tropical`), read at the +commit `scripts/check-lean-bridge.sh` pins. + +tropical-types builds that instance from four operations: +`add := tAdd`, `mul := tMul`, `zero := .bot`, `one := .val 0`. The bridge is +an isomorphism of carriers that carries ⊕, ⊗, 𝟘 and 𝟙 of `MaxPlus` to exactly +those four. The examples at the end confirm, by `rfl`, that the instance's +`+`, `*`, `0` and `1` are those operations. + +The theorems depend on tropical-types' definitions of `Tropical`, `tAdd` and +`tMul` only, which use no axiom. They do not use tropical-types' proofs of the +semiring laws (those use `propext` and `Quot.sound`): both sides prove their +own laws, and the isomorphism carries one set to the other. + +The only arithmetic difference is `max`: this repository's `rmax` is Agda's +three-equation recursion, tropical-types uses core `Nat.max`. `rmax_eq_max` +proves them equal. +-/ +namespace RA.TropicalBridge + +open Hyperpolymath.Tropical (CommSemiring) + +abbrev HT := Hyperpolymath.Tropical.Tropical + +theorem rmax_eq_max : ∀ m n : Nat, RA.rmax m n = Nat.max m n + | 0, n => (ite_eq_left (Nat.zero_le n)).symm + | m + 1, 0 => (ite_eq_right (Nat.not_succ_le_zero m)).symm + | m + 1, n + 1 => by + show RA.rmax m n + 1 = (if m + 1 ≤ n + 1 then n + 1 else m + 1) + rw [rmax_eq_max m n] + show (if m ≤ n then n else m) + 1 = (if m + 1 ≤ n + 1 then n + 1 else m + 1) + match Nat.decLe m n with + | isTrue h => rw [ite_eq_left h, ite_eq_left (Nat.succ_le_succ h)] + | isFalse h => rw [ite_eq_right h, ite_eq_right (fun h' => h (Nat.le_of_succ_le_succ h'))] + +/-- The carrier map, MaxPlus → tropical-types. -/ +def toHT : RA.Tropical → HT + | .val n => .val n + | .bot => .bot + +/-- Its inverse. -/ +def ofHT : HT → RA.Tropical + | .val n => .val n + | .bot => .bot + +theorem ofHT_toHT : ∀ x, ofHT (toHT x) = x + | .val _ => rfl + | .bot => rfl + +theorem toHT_ofHT : ∀ y, toHT (ofHT y) = y + | .val _ => rfl + | .bot => rfl + +theorem toHT_add : ∀ x y, toHT (RA.MaxPlus.add x y) + = Hyperpolymath.Tropical.tAdd (toHT x) (toHT y) + | .bot, .bot => rfl + | .bot, .val _ => rfl + | .val _, .bot => rfl + | .val m, .val n => congrArg Hyperpolymath.Tropical.Tropical.val (rmax_eq_max m n) + +theorem toHT_mul : ∀ x y, toHT (RA.MaxPlus.mul x y) + = Hyperpolymath.Tropical.tMul (toHT x) (toHT y) + | .bot, .bot => rfl + | .bot, .val _ => rfl + | .val _, .bot => rfl + | .val _, .val _ => rfl + +theorem toHT_zero : toHT RA.MaxPlus.zero = .bot := rfl + +theorem toHT_one : toHT RA.MaxPlus.one = .val 0 := rfl + +/-- M-2: `MaxPlus` and tropical-types' `Tropical` are isomorphic as +semirings. The isomorphism carries ⊕, ⊗, 𝟘 and 𝟙 to `tAdd`, `tMul`, `bot` +and `val 0`, the operations of `instance : CommSemiring Tropical`. -/ +theorem maxplus_agrees_tropical : + (∀ x, ofHT (toHT x) = x) ∧ (∀ y, toHT (ofHT y) = y) ∧ + (∀ x y, toHT (RA.MaxPlus.add x y) = Hyperpolymath.Tropical.tAdd (toHT x) (toHT y)) ∧ + (∀ x y, toHT (RA.MaxPlus.mul x y) = Hyperpolymath.Tropical.tMul (toHT x) (toHT y)) ∧ + toHT RA.MaxPlus.zero = .bot ∧ toHT RA.MaxPlus.one = .val 0 := + ⟨ofHT_toHT, toHT_ofHT, toHT_add, toHT_mul, toHT_zero, toHT_one⟩ + +/-! The instance's operations are the four the bridge targets. These refer to +the instance itself, whose law fields carry tropical-types' axioms, so they +are checked here but are not in the axiom-free count. -/ +example : ∀ x y : HT, x + y = Hyperpolymath.Tropical.tAdd x y := fun _ _ => rfl +example : ∀ x y : HT, x * y = Hyperpolymath.Tropical.tMul x y := fun _ _ => rfl +example : (0 : HT) = .bot := rfl +example : (1 : HT) = .val 0 := rfl + +end RA.TropicalBridge + +/-! ## Axioms (PROOF-POLICY §8.4) + +Each line below must read "does not depend on any axioms"; CI fails on any +other answer. -/ +#print axioms RA.TropicalBridge.rmax_eq_max +#print axioms RA.TropicalBridge.ofHT_toHT +#print axioms RA.TropicalBridge.toHT_ofHT +#print axioms RA.TropicalBridge.toHT_add +#print axioms RA.TropicalBridge.toHT_mul +#print axioms RA.TropicalBridge.maxplus_agrees_tropical diff --git a/verification/proofs/coq/ResourceAlgebra.v b/verification/proofs/coq/ResourceAlgebra.v index afe7c53..9bf2abf 100644 --- a/verification/proofs/coq/ResourceAlgebra.v +++ b/verification/proofs/coq/ResourceAlgebra.v @@ -321,6 +321,65 @@ Qed. Lemma dioid_not_annihilating : IsDioid HWM /\ ~ IsAnnihilating HWM. Proof. exact (conj HWM_dioid HWM_not_annihilating). Qed. +(** * Diamond (C-4b) + + The diamond lattice M3: join for alternatives, meet for sequence, the + bottom for 𝟘 and the top for 𝟙. Meet is monotone and the bottom + annihilates, but M3 is not distributive, so meet does not distribute + over join. Every law is a closed statement over five constructors. *) + +Inductive DGrade : Type := dbot | dtop | da | db | dc. + +(** Agda [_⊔d_], the join. *) +Definition djoin (x y : DGrade) : DGrade := + match x, y with + | dbot, y => y + | dtop, _ => dtop + | da, dbot => da | da, dtop => dtop | da, da => da | da, db => dtop | da, dc => dtop + | db, dbot => db | db, dtop => dtop | db, da => dtop | db, db => db | db, dc => dtop + | dc, dbot => dc | dc, dtop => dtop | dc, da => dtop | dc, db => dtop | dc, dc => dc + end. + +(** Agda [_⊓d_], the meet. *) +Definition dmeet (x y : DGrade) : DGrade := + match x, y with + | dbot, _ => dbot + | dtop, y => y + | da, dbot => dbot | da, dtop => da | da, da => da | da, db => dbot | da, dc => dbot + | db, dbot => dbot | db, dtop => db | db, da => dbot | db, db => db | db, dc => dbot + | dc, dbot => dbot | dc, dtop => dc | dc, da => dbot | dc, db => dbot | dc, dc => dc + end. + +Lemma Diamond_alt : IsAltMonoid djoin dbot. +Proof. split; intros; repeat match goal with x : DGrade |- _ => destruct x end; reflexivity. Qed. + +Lemma Diamond_seq : IsSeqMonoid dmeet dtop. +Proof. split; intros; repeat match goal with x : DGrade |- _ => destruct x end; reflexivity. Qed. + +Definition Diamond : ResourceAlgebra := + {| Grade := DGrade; radd := djoin; rmul := dmeet; rzero := dbot; rone := dtop; + ralt := Diamond_alt; rseq := Diamond_seq |}. + +Lemma Diamond_ordered : IsOrdered Diamond. +Proof. + split; unfold Le; simpl; intros z x y p; + destruct z, x, y; simpl in *; try reflexivity; discriminate p. +Qed. + +Lemma Diamond_annihilating : IsAnnihilating Diamond. +Proof. split; simpl; intros x; destruct x; reflexivity. Qed. + +(** Not a dioid: [a ⊓ (b ⊔ c) = a], while [(a ⊓ b) ⊔ (a ⊓ c) = ⊥]. *) +Lemma Diamond_not_dioid : ~ IsDioid Diamond. +Proof. + intro d. pose proof (distribl d da db dc) as h. simpl in h. discriminate h. +Qed. + +(** C-4b: an annihilating ordered algebra need not be a dioid. *) +Lemma ordered_annihilating_not_dioid : + IsOrdered Diamond /\ IsAnnihilating Diamond /\ ~ IsDioid Diamond. +Proof. exact (conj Diamond_ordered (conj Diamond_annihilating Diamond_not_dioid)). Qed. + (** * MinMax (N-1) *) Definition lmax (a b : LGrade) : LGrade := @@ -784,6 +843,10 @@ Print Assumptions add_upperr. Print Assumptions add_least. Print Assumptions dioid_ordered. Print Assumptions dioid_not_annihilating. +Print Assumptions Diamond_ordered. +Print Assumptions Diamond_annihilating. +Print Assumptions Diamond_not_dioid. +Print Assumptions ordered_annihilating_not_dioid. Print Assumptions Loss_dioid. Print Assumptions Loss_annihilating. Print Assumptions MaxPlus_dioid. diff --git a/verification/proofs/lean4/ResourceAlgebra.lean b/verification/proofs/lean4/ResourceAlgebra.lean index ee0e86b..779c535 100644 --- a/verification/proofs/lean4/ResourceAlgebra.lean +++ b/verification/proofs/lean4/ResourceAlgebra.lean @@ -910,6 +910,92 @@ theorem count_not_add : = lmin (fin (qcount 2 a)) (fin (qcount 2 b)) := fun f => absurd (fin_injective (f collapse shuffle) : (0 : Nat) = 1) (by decide) +/-! ## Diamond (C-4b) + +The diamond lattice M3: join for alternatives, meet for sequence, bottom +for 𝟘 and top for 𝟙. Meet is monotone and the bottom annihilates, but M3 is +not distributive, so meet does not distribute over join. Every law is a +closed statement over five constructors, discharged case by case. -/ + +inductive DGrade where + | bot | top | a | b | c + deriving DecidableEq + +/-- Agda `_⊔d_`, the join. -/ +def djoin : DGrade → DGrade → DGrade + | .bot, y => y + | .top, _ => .top + | .a, .bot => .a + | .a, .top => .top + | .a, .a => .a + | .a, .b => .top + | .a, .c => .top + | .b, .bot => .b + | .b, .top => .top + | .b, .a => .top + | .b, .b => .b + | .b, .c => .top + | .c, .bot => .c + | .c, .top => .top + | .c, .a => .top + | .c, .b => .top + | .c, .c => .c + +/-- Agda `_⊓d_`, the meet. -/ +def dmeet : DGrade → DGrade → DGrade + | .bot, _ => .bot + | .top, y => y + | .a, .bot => .bot + | .a, .top => .a + | .a, .a => .a + | .a, .b => .bot + | .a, .c => .bot + | .b, .bot => .bot + | .b, .top => .b + | .b, .a => .bot + | .b, .b => .b + | .b, .c => .bot + | .c, .bot => .bot + | .c, .top => .c + | .c, .a => .bot + | .c, .b => .bot + | .c, .c => .c + +abbrev Diamond : ResourceAlgebra where + Grade := DGrade + add := djoin + mul := dmeet + zero := .bot + one := .top + alt := { + assoc := by intro x y z; cases x <;> cases y <;> cases z <;> rfl + comm := by intro x y; cases x <;> cases y <;> rfl + idem := by intro x; cases x <;> rfl + unitl := fun _ => rfl } + seq := { + assoc := by intro x y z; cases x <;> cases y <;> cases z <;> rfl + unitl := fun _ => rfl + unitr := by intro x; cases x <;> rfl } + +theorem Diamond_ordered : IsOrdered Diamond where + mono_l z {x y} p := by + cases z <;> cases x <;> cases y <;> first | rfl | (cases p) + mono_r z {x y} p := by + cases z <;> cases x <;> cases y <;> first | rfl | (cases p) + +theorem Diamond_annihilating : IsAnnihilating Diamond where + annihill _ := rfl + annihilr x := by cases x <;> rfl + +/-- Not a dioid: `a ⊓ (b ⊔ c) = a`, while `(a ⊓ b) ⊔ (a ⊓ c) = ⊥`. -/ +theorem Diamond_not_dioid : ¬ IsDioid Diamond := fun d => + absurd (d.distribl .a .b .c : DGrade.a = DGrade.bot) (by decide) + +/-- C-4b: an annihilating ordered algebra need not be a dioid. -/ +theorem ordered_annihilating_not_dioid : + IsOrdered Diamond ∧ IsAnnihilating Diamond ∧ ¬ IsDioid Diamond := + ⟨Diamond_ordered, Diamond_annihilating, Diamond_not_dioid⟩ + end RA /-! ## Axioms (PROOF-POLICY §8.4) @@ -926,6 +1012,11 @@ other answer. -/ #print axioms RA.ResourceAlgebra.add_least #print axioms RA.IsDioid.ordered #print axioms RA.dioid_not_annihilating +#print axioms RA.Diamond +#print axioms RA.Diamond_ordered +#print axioms RA.Diamond_annihilating +#print axioms RA.Diamond_not_dioid +#print axioms RA.ordered_annihilating_not_dioid #print axioms RA.Loss #print axioms RA.Loss_dioid #print axioms RA.Loss_annihilating From 0f0a47a2e3e517039b37ceaf27f5bea46100a832 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:53:56 +0000 Subject: [PATCH 2/2] Rename the test's heredoc delimiter so the hygiene scan does not read it as a debt marker The Central Estate CI/CD Audit's code-hygiene check flagged the delimiter STUB in tests/check_lean_bridge_test.sh as an untracked debt marker. It is a heredoc delimiter, not debt; FAKE_LEAN names what the heredoc writes. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LiQzWJdcPfRU6YMDGRG8Xi --- tests/check_lean_bridge_test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/check_lean_bridge_test.sh b/tests/check_lean_bridge_test.sh index 1166ddf..b7137d9 100755 --- a/tests/check_lean_bridge_test.sh +++ b/tests/check_lean_bridge_test.sh @@ -9,12 +9,12 @@ cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." stub=$(mktemp -d); trap 'rm -rf "$stub"' EXIT make_stub() { # $1 name, $2 what the stub prints when checking the bridge, $3 its exit code - cat > "$stub/$1" < "$stub/$1" < "\$2"; exit 0; fi printf '%s\n' "$2" exit $3 -STUB +FAKE_LEAN chmod +x "$stub/$1" }