← Latest papers
💻 computer science

TensorRocq: Enabling diagrammatic reasoning in Rocq

The paper introduces TensorRocq, a verified toolkit for the Rocq proof assistant that bridges the gap between formal proofs and diagrammatic reasoning by converting symmetric monoidal category terms into hypergraphs to enable intuitive string diagram manipulation and equational rewriting.

Original authors: Benjamin Caldwell, William Spencer, Robert Rand

Published 2026-04-21
📖 5 min read🧠 Deep dive

Original authors: Benjamin Caldwell, William Spencer, Robert Rand

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are trying to solve a complex puzzle, but instead of moving the pieces around on a table, you are forced to write out a 50-page legal contract describing exactly how every single piece connects to every other piece.

That is essentially what working with Symmetric Monoidal Categories (SMCs) in a computer proof assistant (like Rocq, a tool used to verify mathematical proofs) feels like. It's powerful, but it's incredibly tedious.

Here is a simple breakdown of what the paper "TensorRocq" is about, using some everyday analogies.

The Problem: The "Legal Contract" vs. The "Flowchart"

The Paper's World (SMCs):
In physics, quantum computing, and logic, we often deal with processes that happen in sequence (one after another) or in parallel (side-by-side).

  • On Paper: Scientists draw String Diagrams. Think of these like flowcharts or subway maps. You draw a line, connect it to a box, and draw another line out. If two diagrams have the same connections, they represent the same process. It's intuitive. You can just see the answer.
  • In the Computer (Rocq): Computers don't "see" pictures; they see text. To represent a string diagram, the computer forces you to write a rigid, nested text structure (like ((A * B) * C) * D).
    • The Frustration: In a real diagram, it doesn't matter if you group (A * B) first or (B * C) first; the connection is the same. But in the computer's text, (A * B) * C is not the same as A * (B * C).
    • The Result: To prove two diagrams are equal, you have to spend 90% of your time writing code just to rearrange the parentheses (associativity) so the computer thinks the two sides look identical. It's like trying to prove two sentences mean the same thing by rewriting them until they use the exact same word order, even if the grammar is different.

The Solution: TensorRocq

The authors built TensorRocq, a tool that acts like a "translator" and a "smart editor" for these proofs.

1. The Translator (The "Hypergraph" Bridge)

Imagine you have a messy pile of LEGO instructions written in a foreign language (the rigid text). TensorRocq has a magic translator that instantly converts that text into a LEGO model (a hypergraph).

  • In this LEGO model, the computer stops caring about the order of the bricks. It only cares about how they are connected.
  • If two LEGO models have the same connections, the computer knows they are the same, regardless of how the instructions were written.

2. The "Smart Editor" (Rewriting)

Once the computer sees the LEGO model, it can perform "diagrammatic rewriting."

  • Old Way: You manually tell the computer, "Move this brick here, then swap these two, then regroup these three..." (tedious).
  • TensorRocq Way: You say, "Replace this whole cluster of bricks with that other cluster," and the computer instantly checks if the connections match. If they do, it swaps them out. It ignores the "parentheses noise" and focuses on the "connectivity signal."

3. The "Universal Dictionary" (Tensors)

How does the computer know the LEGO models are actually the same? It uses Tensors.

  • Think of a Tensor as a "black box" that describes what a process does mathematically (like a matrix in linear algebra).
  • TensorRocq translates both the messy text and the LEGO models into this mathematical "black box" language. If the black boxes produce the same result, the computer knows the diagrams are equivalent. This acts as the "truth serum" that verifies the rewrite is correct.

Why This Matters: The "VyZX" Example

The paper shows off this tool by applying it to VyZX, a library for quantum computing.

  • Before: Proving that three specific quantum gates (CNOTs) act like a "swap" operation took 45 lines of code. Most of those lines were just the programmer struggling to rearrange the parentheses to make the computer happy.
  • After: Using TensorRocq, the same proof took 17 lines. The code now looks like the actual diagram: "Connect these, swap those, and done." The computer handles the boring rearranging in the background.

The Big Picture Analogy

Imagine you are a city planner.

  • Without TensorRocq: You have to prove two traffic systems are identical by listing every single car's GPS coordinates, speed, and timestamp in a spreadsheet. If Car A is 0.001 seconds ahead of Car B in your list, you have to manually edit the spreadsheet to make them line up perfectly before you can say the systems are the same.
  • With TensorRocq: You look at a map. You see two intersections. You realize, "Hey, the roads connect the same way!" You don't care about the exact timing of the cars; you just know the structure is identical. TensorRocq lets you work with the map (the diagram) while the computer quietly handles the spreadsheet (the text) in the background.

Summary

TensorRocq is a tool that lets mathematicians and computer scientists write proofs the way they naturally think: using pictures and connections. It automatically handles the boring, rigid details of computer syntax, making proofs shorter, easier to read, and less prone to human error. It bridges the gap between the "paper proof" (diagrams) and the "computer proof" (rigid code).

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →