← Latest papers
💻 computer science

A Diagrammatic Basis for Computer Programming

This paper introduces Kleene-Cartesian rig categories and their associated tape diagrams as a graphical notation capable of conveniently representing imperative programs and various program logics.

Original authors: Filippo Bonchi, Alessandro Di Giorgio, Elena Di Lavore

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

Original authors: Filippo Bonchi, Alessandro Di Giorgio, Elena Di Lavore

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 describe how a computer program works. Usually, we do this with code (text) or flowcharts (diagrams). But what if we could describe programs using a single, unified visual language that handles both what the data is (like numbers or names) and how the program moves (like loops and decisions)?

This paper introduces exactly that: a new way to draw programs called Tape Diagrams, built on a mathematical foundation called Kleene-Cartesian Rig Categories.

Here is the breakdown in simple terms, using analogies.

1. The Two Big Problems: Data vs. Control

Think of a computer program as a factory.

  • Data Flow (The Products): This is the stuff moving through the factory. Raw materials go in, get processed, and come out as finished goods. In math, this is like a "Cartesian" system where things can be copied and thrown away easily (like making a photocopy of a document or shredding it).
  • Control Flow (The Machines): This is the machinery deciding what happens next. "If the part is red, paint it; if it's blue, discard it." Or, "Keep painting until the box is full." This involves loops and choices. In math, this is like a "Kleene" system, which is great at handling repetition (like a loop) and branching (like an "if/else" statement).

The Problem: Historically, mathematicians and computer scientists had two different languages to describe these two things. One language was great for data but bad for loops. The other was great for loops but messy for data. It was like trying to build a house using a hammer for the nails and a screwdriver for the wood, but having to switch tools constantly and losing track of the blueprint.

2. The Solution: The "Rig" Category (The Double-Tool)

The authors introduce a concept called a Rig Category.

  • The Analogy: Imagine a "Rig" (short for Ring, but without the subtraction) as a Swiss Army Knife for math. It has two main tools built into one handle:
    1. Tool A (The Copy/Share Tool): Handles data. It lets you split a wire into two (copying data) or merge two wires (combining data).
    2. Tool B (The Loop/Choice Tool): Handles control. It lets you create a loop (a feedback wire that goes back to the start) or a choice (a wire that splits into "yes" or "no" paths).

The magic of this paper is showing how these two tools can work together perfectly without breaking the rules of logic. They call this a Kleene-Cartesian Rig Category.

3. The Visual Language: Tape Diagrams

How do you draw this? The authors use Tape Diagrams.

  • The Analogy: Imagine a reel of film or a tape measure.
    • The Inner Layer (The Circuit): Inside the tape, you draw standard string diagrams. These represent the data flow (the products moving through the factory).
    • The Outer Layer (The Tape): The tape itself represents the control flow (the machines deciding the path).
    • Nesting: You can put a whole "inner circuit" inside a "tape loop." This means you can visually see a loop (the tape) containing a complex data process (the circuit).

It's like looking at a subway map (control flow) where every station has a detailed blueprint of the train station inside it (data flow).

4. Why Does This Matter? (The "Assembly Language" for Logic)

The paper claims these diagrams act as an "Assembly Language" for program logic.

  • What is Assembly Language? It's a low-level code that talks directly to the hardware. It's precise and powerful.
  • The Paper's Claim: By using these Tape Diagrams, you can prove that famous rules of computer science (like Hoare Logic, used to prove programs are bug-free) aren't just arbitrary rules made up by humans. Instead, they naturally fall out of the geometry of the diagrams.

Example:
If you draw a "While Loop" in this system, the diagram automatically forces the rules of the loop to be correct. You don't have to memorize a rulebook; the shape of the tape is the rule.

5. Real-World Examples in the Paper

The authors show this works for:

  • Natural Numbers: They can draw the Peano axioms (the rules for counting 0, 1, 2...) using these tapes.
  • Imperative Programs: They can translate standard code (like x = x + 1 or if x > 0 then...) into these diagrams.
  • Relational Logic: They can prove that two different programs do the exact same thing just by looking at whether their diagrams can be transformed into each other.

Summary

This paper is like inventing a new universal grammar for computer programs.

  • Before: We had separate languages for "how data moves" and "how decisions are made."
  • Now: We have Tape Diagrams, a single visual language where data and control flow are woven together.
  • The Benefit: It makes it easier to reason about complex software, prove that programs are correct, and understand the deep mathematical structure behind the code we write every day.

It turns the abstract, scary math of "categories" into a set of intuitive, drawable rules that look like a mix of a circuit board and a flowchart, finally unifying the two halves of programming into one beautiful picture.

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 →