Skip to content

hyperpolymath/tropical-types

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tropical-types

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.

The idea in one paragraph

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.

What’s in here

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).

Quickstart (reading)

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

Quickstart (running the reference impl)

cd impl/
just build
just test

Status

  • 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.md if present (added by the 2026-05-26 estate tech-debt scan).

Lean 4 formalization

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) and tropical_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 in protocol-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.

The resource-grade axis (Resource.*)

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 ordered ResourceAlgebra (preorder + monotone operations), bundled with the canonical dioid-order builder and the parametric transport theorem parametric_resource_transport (alias resource_laws_sufficient_for_consumers) over ConsumerLawBundle.

Resource.Instances.*

Concrete instances all satisfying the one interface: Linear and Affine ({0,1,ω} usage, differing only in order), MaxPlus, MinPlus, and MinMax.

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. No echo-types dependency.

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 deps

lake 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.

Reading order

  1. Start with document/ for the conceptual content.

  2. Cross-reference impl/ to see the rules in code.

  3. Consult audits/ if you want to see the estate-wide checks that have run against this repo.

Contributing

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.

Companion repositories

About

A short note introducing a max-plus (tropical) algebraic approach to resource-aware type systems, with applications to worst-case cost analysis and protocol typing.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Sponsor this project

  •  

Packages

 
 
 

Contributors