Licenses Are Functors

Software licenses have algebraic structure. Not metaphorically. The operations are composition and aggregation, and they behave like a semiring.

The derivation category

Every derivative work has a source. Milewski wrote a blog post. I translated it to Python. Someone forks my translation. Each step is a morphism in a category where the objects are works and the arrows are derivations.

Derivations compose: if A derives from B and B derives from C, then A derives from C. Every work has an identity derivation (itself, unmodified). That’s a category.

The obligation functor

A license is a functor from the derivation category to a category of obligations. It maps each work to a set of permissions, and each derivation arrow to a rule for how those permissions propagate.

CC BY maps every derivation to one obligation: credit the source. The functor preserves composition: if A derives from B derives from C, credit both B and C.

CC BY-SA maps every derivation to two obligations: credit the source, and license the derivative the same way. The share-alike clause is the natural transformation that makes the obligation recursive.

CC BY-SA-NS adds a third: credit, share-alike, and if you serve the derivative over a network, share the source. Same functor, one more component.

The semiring

Combine two works as a derivative and the stricter license absorbs (CC BY-SA ⊗ MIT = CC BY-SA, a lattice join); bundle them side by side and each keeps its own license (a product).

Join for derivation, product for aggregation. Semiring.

The algebra is the same one that governs type-level arithmetic:

LicenseSemiring roleRule
AGPLabsorberAGPL ⊗ anything = AGPL
MITonecontributes no obligation
Public domainzeroabsorbs nothing

Kleisli obligations

Derivation isn’t deterministic. A coding agent reads a blog post and produces one of many possible implementations. The output is nondeterministic: derive : Work → M(Work), where M is the monad of possible derivatives.

That makes the derivation chain a Kleisli category. The license functor lifts through Kleisli composition the same way the Writer monad carries a log. Each derivation step appends its license constraint. The obligation accumulates.

CC BY-SA through Kleisli composition is Canon. The share-alike obligation propagates forward through the chain, regardless of which specific derivative the agent produced. The nondeterminism is in the code. The obligation is in the license. The functor carries the second through the first.

LicenseFunctor behaviorInformation loss
AGPLlossless (full source required)zero
CC BY-SApreserves opennesslow
MITforgets everything except credithigh
Public domainconstant functor (no obligation)total

Permissiveness is information loss. The data processing inequality applies: the functor can’t create obligations that weren’t in the source. Copyleft preserves. Permissive loses.

Canon compounds

Canon is the CC BY-SA functor applied to a growing derivation graph. Copyleft is irrevocable, so the graph can only grow. The functor maps the growth of the corpus to the growth of the obligation surface. It scales with the category it acts on.

PageLeft is the index of the image. It stores what the functor produces: copyleft works, their derivation chains, their attribution edges. Search over the image, and you search over the obligation graph.


Every link above goes to a runnable REPL where you can modify the example. The vocabulary is not decorative.

ask june-bot about this post