One structure,
taken seriously.
MathStruct is an open-source research collective building tooling for mathematics, scientific computing and AI/ML. Our working bet is that all three keep producing the same thing: systems built from parts with typed interfaces, joined by composition. Category theory is the mathematics of exactly that, and taking it seriously gives tools that do more than their usual counterparts.
It started as a pitch.
MathStruct began as a startup idea: a new format for mathematical knowledge, a graph of definitions, statements and proofs that is at the same time a graph of code. It came from dissatisfaction with how mathematics is shared, and with how many better tools already existed and went unused.
- Distribution
Papers are sealed
Results travel through publishers and a slow round of peer review, as documents that cannot be linked into, corrected in place or built on directly.
- The web
Hyperlinks and wikis, unused
Linked, collectively maintained knowledge became normal almost everywhere else. In mathematics it was used half-heartedly, ignored, or looked down on.
- Certainty
Lean, overlooked
A machine-checked guarantee that a statement holds is something no journal can offer. For years most of the community paid it little attention.
- Learning
No personal paths
Given what you know and where you want to go, the route through a knowledge graph is a computation. Nobody was computing it.
- Data
Nothing to train on
There was no good data for autoformalisation, or for its reverse. A graph that keeps each informal statement next to its formal one is exactly that data.
We wanted to build a platform around this. It did not get off the ground then; others have since gone after parts of the same picture, Axiom Math among them, with serious venture funding. The ideas stayed, and live on in Sophia, Moonkale and the Category Theory & ML Wiki.
How the library came together
Lenticulum.jl has an older origin: a question that waited years for its answer, which arrived one piece at a time.
From a sensor-fusion problem to a library, in six steps.
- The question
Learnable factor graphs
Working on a sensor-fusion problem with GTSAM: factor graphs combine measurements beautifully, but they are Gaussian, linearised and built by hand. What if they were non-Gaussian, non-linear and learned? At the time, there was no obvious way.
GTSAM ↗ - Piece 1
Implicit layers and adjoints
Differentiating through the solution of an equation instead of through the steps of a solver.
Implicit layers tutorial ↗ - Piece 2
Energy-based models
Models that score configurations instead of computing outputs, which is what a factor is.
LeCun et al., A tutorial on energy-based learning ↗ - Piece 3
Parametric lenses
Curiosity led to category theory, and there to a compositional account of forward-and-backward computation with parameters.
Cruttwell et al., Categorical foundations of gradient-based learning ↗ - Piece 4
Diffusion models as priors
Regularising an inverse problem with conditional sampling (DiffPIR, RED-Diff, proximal diffusion methods), then the theory behind it: how a learned prior and a data term are combined, step by step.
- Piece 5
Statistical games
The category the rest had been pointing at: Bayesian lenses with a loss attached.
St Clere Smithe & Perin, AutoBayes ↗ - Assembled
Lenticulum.jl →
Relation learners on factor graphs, in Julia: learn relations, not functions.
Move fast and break things. Then write down what broke, and why.
Optimists, with tests.
We think the AI age is good news for research, and we would like to show how to do it well: fast, in the open, and checked.
- 01
We are not in academia
A vault of ours may contain a mistake, and that is fine. We would rather publish early and be corrected than polish in private. Found an error? Comment on the page, or better, fix it in a pull request.
- 02
We have no staff to delegate to
A professorship has doctoral students, a company has employees; we have neither, yet. We have agents that run experiments, check derivations and chase failing tests. Making that reliable is part of the research.
- 03
The creative temperament has the edge
Research long rewarded the industrious: whoever could grind through the implementation and the hundredth experiment. AI tilts the balance towards the person with more ideas than hands, many people with ADHD among them. Something of a great reversal.
- 04
Build the moonshot now
A project of MathStruct's scope would have been unthinkable for a group our size a year ago. If you have a moonshot in a drawer, now is the time to take it out.
- 05
A different research format
Open vaults instead of sealed papers, negative results written down instead of dropped. Some projects will fail, and Sophia's own risk list says it might. When one does, the vault will say why, so whoever tries next starts further along.
- 06
No building on technical debt
Agents make a rewrite cheap, so we pick the better-designed stack: Julia rather than Python, C++ and PyTorch; Rust rather than JavaScript and React, or C++ on the backend. Rust has proved especially good for coding with agents, since its strict compiler catches their mistakes early. Poor performance and a large memory footprint count as bugs.
“Isn’t this just AI slop?”
Fair question. Here is our answer.
- Julia
- Python
- C++
- Rust
- Pascal
- JavaScript
written by hand, long before agents
-
Human research code was never the gold standard
The usual fate of a paper's code is a repository abandoned the day the paper is accepted, and a review of it rarely makes pleasant reading. Current models have learned established engineering practice, and much of what they write is cleaner than what most of us wrote by hand.
-
We work on the process, not just the prompts
We follow and try out what is emerging as good practice for AI-written code: spec-driven development, careful harness design, chains of independent reviewers. The code is tested, benchmarked and profiled.
-
Correctness can be proved, not only tested
Formal software verification shows that an implementation meets its specification. We intend to use it, and FiniteFields is a first step. FiniteFields on GitHub ↗
-
We read the code
We wrote Julia, Python, C++, Rust, Pascal and JavaScript long before any of this, and we still review what the agents produce. The gain in productivity is simply too large to leave on the table.
Research, written down.
Fast does not mean careless about what we claim. Every project says what works, what does not, and what is planned.
- 01
Open by default
Code, notes, design decisions and negative results are public. The software is MIT-licensed.
- 02
Every project is a vault
An Obsidian vault published with Quartz: concepts, derivations and design notes link to each other and to the code, including what it does not do and what went wrong on the way.
- 03
Tested against what is known
Where a closed form exists, the code is tested against it. Approximations say so, and status pages say what is unfinished.
- 04
Asynchronous, on GitHub
Issues, pull requests and discussions. Comments on any page of any vault go straight into GitHub Discussions.
- 05
AI in the open
We use AI coding agents, and say so. Each repository has an AGENTS.md with the same rules for agents and people.
Have a problem? Bring it.
Implicit learning, learning relations instead of functions, will take a while to become a familiar idea. If you want it applied to your problem, or suspect it fits but do not see how, talk to us: we can design and engineer a solution with you.
- Simulation
- Trading
- Omics
- Language models
- Robotics
- Your problem
The core projects are and will stay open source. Commercial products may be built downstream of them, by us or by others, without closing the core.
Every level counts.
A comment pointing out an error, a note, a test, a feature, a research question to work on together: all welcome. The best first step is a comment on the page in question, or a discussion on GitHub. Contributions are credited; CONTRIBUTING.md explains how, including authorship on releases.
@software{lenticulum,
author = {{MathStruct}},
title = {Lenticulum.jl},
publisher = {Zenodo},
doi = {10.5281/zenodo.23314723},
url = {https://mathstruct.org/Lenticulum.jl/}
}