A short technical note introducing a max-plus (tropical) algebraic approach to resource-aware type systems, with applications to worst-case cost analysis and protocol typing.
Conventional resource-aware type systems track resources additively
(e.g. linear logic’s !A ⊗ B). The tropical / max-plus semiring
replaces sum/max — so type-system operations naturally compose to the
worst-case bound rather than a probabilistic / average-case figure.
This makes the resulting analysis directly applicable to:
-
Latency budgets in distributed protocols.
-
Worst-case stack/heap usage in resource-constrained embedded code.
-
Provable upper bounds on adversarial protocol round-counts.
document/-
The note itself (AsciiDoc source). The publishable artefact.
impl/-
A reference implementation — a small worked checker exercising the type-system rules from the note.
docs/-
Supplementary material — proofs, derivations, related-work survey.
audits/-
Audit logs from the estate-wide review processes (Hypatia neurosymbolic scan, governance-reusable checks, etc.).
metadata/-
Machine-readable metadata (citations, related-work links, dependency declarations).
git clone git@github.com:hyperpolymath/tropical-resource-typing.git
cd tropical-resource-typing/document/
# Render to HTML (asciidoctor required):
asciidoctor -o /tmp/note.html main.adoc-
Licence: MPL-2.0. (Migrated from PMPL-1.0-or-later 2026-05-26 per the estate licence-debt audit, hyperpolymath/standards#196.)
-
Maturity: research note. The implementation is intentionally small — a "shows the rules" reference, not a production checker.
-
Audit findings: see
docs/tech-debt-2026-05-26.mdif present (added by the 2026-05-26 estate tech-debt scan).
Two dependency-free Lean 4 proofs sit at the repository root — the
order-reversing twins of one tropical duality, built together by Lake and
pinned to Lean 4.13.0 (lean-toolchain, import Init only, no Mathlib):
TropicalSessionTypes.lean-
The max-plus semiring (⊕ = max, ⊗ = +) grading speculative session types:
soundness(static grade = dynamic wall-clock cost) andtropical_grade_le_sequentialTotal(the QTT refinement,max ≤ sum). TropicalAdapterPath.lean-
The min-max / bottleneck semiring (⊕ = min, ⊗ = max) grading adapter paths. Home of
hub_ceiling, the no-go corollary that closes Protocol Squisher’s universal-interoperability claim. (Source: the frozen provenance archive inprotocol-squisher, left unchanged there.)
The two are connected by the order-reversing involution g ↦ maxGrade − g,
proved here as a lattice anti-isomorphism (De Morgan: it exchanges min and
max), not a semiring homomorphism.
On top of the two twins sits a reusable, consumer-facing resource-grade axis
for downstream languages (e.g. my-lang): a single Lean library, import Resource.
Resource.Algebra.*-
The interface —
ResourceSemiring(ops + semiring laws) and the orderedResourceAlgebra(preorder + monotone operations), bundled with the canonical dioid-order builder and the parametric transport theoremparametric_resource_transport(aliasresource_laws_sufficient_for_consumers) overConsumerLawBundle. Resource.Instances.*-
Concrete instances all satisfying the one interface:
LinearandAffine({0,1,ω}usage, differing only in order),MaxPlus,MinPlus, andMinMax. Resource.Stress-
Proves the tropical carriers are infinite — the stress test that the abstraction is not a finite
{0,1,ω}reification. Resource.EchoBridge-
A resource algebra may measure Echo residues (direction
E → R); Echo is not a resource instance. Noecho-typesdependency.
The contract and vocabulary (resource grade vs resource algebra vs tropical
instance vs residue measure; "tropical is not Echo") are in
FOUNDATION_CONTRACT.md; full detail in
docs/RESOURCE-ALGEBRA.adoc.
lake build # green; no network depslake build is green and every headline theorem depends only on propext
(+ Quot.sound) — no sorry, no Classical.choice. Full detail, build/verify
recipe, theorem index and provenance: docs/LEAN-FORMALIZATION.adoc.
-
Start with
document/for the conceptual content. -
Cross-reference
impl/to see the rules in code. -
Consult
audits/if you want to see the estate-wide checks that have run against this repo.
See CONTRIBUTING.md. GPG-signed commits required. Feedback on the note’s framing or proofs is especially welcome — open an Issue rather than a PR for substantive disagreements.
-
hyperpolymath/standards— canonical estate standards. -
hyperpolymath/echo-types— sibling formal-foundations work in Agda. -
hyperpolymath/typed-wasm— the typed-wasm target where the resource-typing rules from this note may eventually be deployed in practice.