Skip to content

Prove C-4b (diamond lattice) and M-2 (Lean bridge to tropical-types) - #48

Merged
hyperpolymath merged 3 commits into
mainfrom
claude/zealous-wozniak-2nherb
Nov 17, 2026
Merged

hyperpolymath merged 3 commits into
mainfrom
claude/zealous-wozniak-2nherb

Conversation

@hyperpolymath

@hyperpolymath hyperpolymath commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Closes the two OPEN theory rows in docs/status/PROOF-STATUS.adoc.

C-4b: an annihilating ordered algebra need not be a dioid

  • src/ResourceAlgebra/Instances/Diamond.agda defines the diamond lattice M3, with ⊕ = join, ⊗ = meet, 𝟘 = bottom and 𝟙 = top. It proves Diamond-ordered, Diamond-annihilating and Diamond-not-dioid. The counterexample is a ⊗ (b ⊕ c) = a while (a ⊗ b) ⊕ (a ⊗ c) = ⊥.
  • The module is in the All.agda cone, so it is checked under --safe --without-K --cubical-compatible.
  • The Lean leg re-proves it (61 of 61 printed theorems are axiom-free), and so does the Rocq leg (52 of 52 closed).
  • A tenth expected rejection, tests/reject/DiamondDistributes.agda, must fail with a != bot of type Grade.

M-2: MaxPlus agrees with tropical-types' CommSemiring Tropical

  • verification/bridges/tropical-types/TropicalBridge.lean proves in Lean that MaxPlus is isomorphic to Hyperpolymath.Tropical.Tropical. The isomorphism sends ⊕, ⊗, 𝟘 and 𝟙 to tAdd, tMul, .bot and .val 0, which are the fields of the instance. All six printed theorems are axiom-free.
  • scripts/check-lean-bridge.sh fetches tropical-types at the pinned commit f2e465c966d14d4986dfc492875cc54653d9751e and verifies that commit. It then compiles both modules with Lean 4.35.0 and checks the bridge. It prints the SHA256 of the imported file and of the bridge, for a §8.5.1 (import …) clause.
  • The script runs in the Lean leg of proofs.yml and writes an "M-2 bridge receipt" to the job summary.
  • tests/check_lean_bridge_test.sh shows the script fails on a compile error, on an axiom, and when no theorem is printed.

Grades: both rows stay ungraded

  • C-4b: the proof receipt still describes 47de4a8, which predates C-4b. The row needs a new receipt after merge.
  • M-2: its statement names a Lean-only object, so it has no Agda witness and cannot reach PWG-3 (§8.1). Its Agda and Rocq legs are recorded as unavailable.

The ledger, PROOF-NEEDS.adoc (PN-5), README.adoc and CHANGELOG.adoc say this.

Checks run locally

  • scripts/check-agda.sh (Agda 2.6.3): PASS, core proofs, unit tests and all 10 expected rejections.
  • Lean 4.35.0: the Lean leg passes with 61 of 61 theorems axiom-free. scripts/check-lean-bridge.sh passes with 6 of 6 axiom-free. tests/check_lean_bridge_test.sh passes all 3 cases.
  • Rocq leg (Coq 8.18 with From Stdlib mapped to From Coq): 52 of 52 closed.
  • asciidoctor 2.0.26 with --failure-level WARN: all four changed .adoc files render clean.
  • Eight tests/workflows/* scripts fail locally in the same way on unmodified main, because their tools are missing in this container. They are not caused by this change.

After merge

  • A new receipt for the merge commit, bringing C-4b into the graded set and adding M-2's Lean leg with an (import …) clause.
  • In mathesis: bump the reader pin to a standards commit that reads (import …), then pin C-4b and M-2.

Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • Added a five-value lattice example, with proofs across Agda, Lean, and Rocq showing it is ordered and annihilating but not distributive.
    • Added a Lean proof that the MaxPlus operations correspond to those in the tropical-types library.
  • Documentation
    • Updated proof status and project documentation to describe these results and their verification coverage, including which results remain ungraded and where proof coverage is incomplete.
  • Tests
    • Added checks for Lean bridge validation and an expected rejection of the distributivity claim.

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LiQzWJdcPfRU6YMDGRG8Xi
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Adds the five-grade Diamond algebra and proofs in Agda, Lean, and Rocq. Adds a Lean bridge between MaxPlus and tropical-types, with a pinned-revision check in CI. Updates proof-status records and documentation for both proof efforts.

Changes: Diamond algebra proofs

Layer / File(s) Summary
Agda definition, proofs, and rejection test
src/ResourceAlgebra/Instances/Diamond.agda, src/ResourceAlgebra/All.agda, tests/reject/DiamondDistributes.agda
Defines the five-grade Diamond lattice and its resource algebra. Proves orderedness, annihilation, and non-dioid status, and adds an expected rejection for distributivity.
Lean and Rocq proofs
verification/proofs/lean4/ResourceAlgebra.lean, verification/proofs/coq/ResourceAlgebra.v
Adds Diamond definitions and proofs in both provers, including assumption checks.
Proof status and evidence
CHANGELOG.adoc, docs/status/PROOF-STATUS.adoc
Records the cross-prover results, expected rejection, and C-4b proof and receipt status.

MaxPlus tropical bridge

Layer / File(s) Summary
Lean bridge theorem
verification/bridges/tropical-types/TropicalBridge.lean
Defines inverse conversions between the carrier types and proves preservation of addition, multiplication, zero, and one.
Pinned bridge verification and CI receipt
scripts/check-lean-bridge.sh, tests/check_lean_bridge_test.sh, .github/workflows/proofs.yml
Fetches the pinned repository revision, compiles the bridge, checks axiom reports, tests failure cases, and adds an M-2 receipt to the Lean job summary.
M-2 proof status and documentation
README.adoc, CHANGELOG.adoc, docs/status/PROOF-NEEDS.adoc, docs/status/PROOF-STATUS.adoc
Documents the Lean bridge, its evidence and pin, and the absence of an Agda witness.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other

Sequence Diagram(s)

sequenceDiagram
  participant Job as Lean CI job
  participant Script as check-lean-bridge.sh
  participant Repository as Pinned tropical-types repository
  participant Lean as Lean compiler
  Script->>Repository: Fetch and verify pinned revision
  Script->>Lean: Compile imported module, ResourceAlgebra, and bridge
  Lean-->>Script: Compilation output and axiom reports
  Script->>Job: Print result and bridge digests
  Job->>Job: Add M-2 receipt to job summary
Loading

Possibly related PRs

Suggested reviewers: claude

Merge Risk: Minimal · up to 30a74

This PR adds proofs and documentation for the diamond lattice and a Lean bridge to tropical-types, plus a CI check for the bridge. It does not change runtime behavior. No merge-blocking risk was identified in the supplied changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two main changes: proving C-4b (diamond lattice) and M-2 (Lean bridge to tropical-types). The changeset adds the Diamond Agda instance, its Lean and Rocq counterparts, and the Trop…
Description check Passed The description follows the repository template's main sections: Summary (opening line and the C-4b and M-2 sections), Changes (per-item bullets), and Testing (the 'Checks run locally' section). It de…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two main changes: proving C-4b (diamond lattice) and M-2 (Lean bridge to tropical-types). The changeset adds the Diamond Agda instance, its Lean and Rocq counterparts, and the TropicalBridge Lean bridge with its check script, so the title matches the primary change. It is 68 characters and 10 words, which is slightly long but still clear.

Full details: Description check

Explanation

The description follows the repository template's main sections: Summary (opening line and the C-4b and M-2 sections), Changes (per-item bullets), and Testing (the 'Checks run locally' section). It describes the changes and the local test results in detail. The RSR Quality Checklist is not filled in, and the Screenshots section is absent. Those sections are not critical for this PR, so the description is mostly complete. The description also lacks the template's 'Closes #N' issue link, though it references PR #48 objectives and the PROOF-STATUS rows, and the template's 'Summary' heading is not used verbatim.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 0f0a47a and 30a74c6.

Files selected for processing: 1

  • CHANGELOG.adoc
Files skipped from review as they are similar to previous changes: 1

  • CHANGELOG.adoc

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

… 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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LiQzWJdcPfRU6YMDGRG8Xi
@hyperpolymath
hyperpolymath marked this pull request as ready for review November 17, 2026 17:50
@sonarqubecloud

Copy link
Copy Markdown

Copy link
Copy Markdown
Owner Author

CI/gate went to failure on 30a74c6 ("ci-gate could not produce a verdict"), run 44190722079. That failure does not come from this PR's diff:

  • The suite reusable hyperpolymath/proven-cicd-and-workflows/.github/workflows/ci-gate.yml@d2140a5 posts an early pending status whose description is re-run started: <run name>. Here the run name was 🔴 GATE: Invisible Character Detection. The statuses API refuses it: Validation failed: Description doesn't accept 4-byte Unicode. The step then writes the "no verdict" failure.
  • The same thing happens on any head, main included, whenever a workflow whose name has an emoji starts. Several of this repo's workflow names do.
  • It is last-writer-wins, so later evaluations overwrite it. On this head CI/gate is back to pending at 22:36:42Z.

No fix exists yet. A fix belongs in the suite reusable, not in this PR: drop or replace non-BMP characters in desc before the gh api call, for example jq '... | gsub("[\\x{10000}-\\x{10FFFF}]"; "")'. I am leaving the PR as it is. The final verdict comes from the completed evaluations and the 15-minute sweep.


Generated by Claude Code

@hyperpolymath
hyperpolymath merged commit 2b9bf3f into main Nov 17, 2026
52 checks passed
@hyperpolymath
hyperpolymath deleted the claude/zealous-wozniak-2nherb branch November 17, 2026 23:48
hyperpolymath pushed a commit that referenced this pull request Nov 18, 2026
Conflicts, all of the 'both sides added' kind:
- src/ResourceAlgebra/All.agda: keep the Evidence, Ledger and Diamond imports.
- verification/proofs/lean4/ResourceAlgebra.lean: keep both new sections,
  Evidence and ledger (E-1..E-3) and Diamond (C-4b).
- docs/status/PROOF-STATUS.adoc: the census text names all five ungraded
  rows (C-4b, M-2, E-1, E-2, E-3); thirteen expected rejections, the nine
  earlier ones plus Diamond's one and the evidence ledger's three; keep both
  the E-1..E-3 residual differences and the M-2 bridge section.
- docs/status/PROOF-NEEDS.adoc: main's updated row for C-4b and M-2, and
  PN-6 kept.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013CuBToxr5h9catptGiTsFX
hyperpolymath added a commit to hyperpolymath/rsr-template-repo that referenced this pull request Nov 18, 2026
… descriptions) (#450)

## Summary

Re-pins the CI gate reusable workflow from
`d2140a5a789e4ebec52f1bab0074181012660c3b` to
`09878f2a2c0a8907cc69fe48973ea604753ecab1`
(hyperpolymath/proven-cicd-and-workflows#144). The old pin posts
`CI/gate = failure` falsely when a workflow name contains an emoji,
because GitHub rejects 4-byte UTF-8 in a status description. That false
red was seen on hyperpolymath/resource-algebra#48.

`09878f2` is a commit on an UNMERGED suite branch (#144 is stacked on
#139), as `d2140a5` was. A second re-pin therefore follows #139's squash
merge.

This PR touches gate files, so the tamper guard may fail `guard / check`
until an admin applies the `gate-change-approved` label. Agents do not
apply it.

## Changes

- `.github/workflows/ci-gate.yml` (2 `uses:` lines) and
`.github/workflows/ci-gate-tamper-guard-caller.yml`: new SHA; `#
cicd-suite ...` comments kept.
- `.github/workflows/actions.lock`: workflow entries, dependency key and
`commit: sha1-...` record.
- `tests/workflows/squabble_gate_test.sh`: `SUITE_PIN`.
- `CHANGELOG.adoc`: new entry under Unreleased / Fixed. The older entry
mentioning `d2140a5` is history and untouched.
- The branch has two signed commits: the re-pin and a follow-up that
fixes blank-line placement in the CHANGELOG entry (no force-push was
allowed). Squash on merge.

## RSR Quality Checklist

### Required

- [x] Tests pass (the workflow tests listed below)
- [ ] Code is formatted / linter: not run, no source changed
- [x] No banned language patterns
- [x] No `unsafe` blocks, no banned functions
- [x] SPDX license headers untouched
- [x] No secrets, credentials, or `.env` files included

### As Applicable

- [x] `CHANGELOG` or release notes updated

## Testing

Run locally, all exit 0:

- `scripts/check-lock-sync.sh`: in sync and closed.
- `tests/workflows/squabble_gate_test.sh`: 166 passed, 0 failed.
- `tests/workflows/check_lock_sync_test.sh`: 137 PASS lines.
- `tests/workflows/lock_sync_fix_test.sh`: all cases passed.
- `tests/workflows/validate_workflows_test.sh`: 87 PASS lines.
- `tests/workflows/workflow_edges_test.sh`: 90 checks passed.

## What is NOT proven

- The emoji fix in a live run: only visible once `CI/gate` runs on this
PR.
- That `09878f2` survives the squash merge of #139.
- `actionlint` and `just test && just quality` were not run.
- This is a template repo: whether minted repos pick up the new pin was
not checked.

## Screenshots

N/A

---
_Generated by [Claude
Code](https://claude.ai/code/session_01J4QvDiRggj6apeRQKPpAVR)_

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Chores**
* Updated the CI gate and tamper-guard workflows to use a newer pinned
version.
* Updated the related workflow checks and changelog to reflect the new
version.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants