---
title: Internal Language for Imperative Multicategories
url: https://www.emergentmind.com/topics/internal-language-for-imperative-multicategories
type: topic
---

# Internal Language for Imperative Multicategories

Searching arXiv for the cited papers and directly related work on imperative multicategories, effect categories, and categorical program logics.
Internal language for imperative multicategories is a formal syntax–semantics interface for effectful, multi-output computation in which programs are interpreted in imperative multicategories, namely uniformly traced distributive multicategories whose unary morphisms form a copy-discard category. In this setting, multimorphisms, labels, coproduct-based control flow, and fixpoint-based looping are handled within a single algebraic framework, and representability yields imperative categories together with derived program logics for correctness, incorrectness, and relational reasoning [2507.18238]. Its immediate categorical background is the earlier theory of effect categories, where semi-products and sequential products were introduced to model multiple arguments in the presence of effects, distinguishing pure from arbitrary functions and strong equations from semi-equations [0707.1432].

## 1. Historical and conceptual antecedents

Dumas–Duval–Reynaud’s theory of effect categories extends a cartesian weak category $V$ of pure functions by a weak category $C$ of all functions, while also distinguishing two notions of equation: strong equations, denoted $\equiv$, and semi-equations, denoted $\sqsubseteq$ [0707.1432]. The relation $\sqsubseteq$ is weaker than $\equiv$, is transitive, coincides with $\equiv$ on $V$, satisfies substitution, and satisfies replacement only when the postcomposed arrow is pure. This decorated setting permits binary semi-products in cases where one leg is pure and, from these, left and right sequential products
$$
f_1 \ltimes f_2 = (id_{Y_1}\times f_2)\circ (f_1\times id_{X_2}),
\qquad
f_1 \rtimes f_2 = (f_1\times id_{Y_2})\circ (id_{X_1}\times f_2).
$$
These constructions encode evaluation order explicitly, and in general $f_1\ltimes f_2$ and $f_1\rtimes f_2$ need not coincide up to $\equiv$; when $C=V$ and $\sqsubseteq=\equiv$, sequential products recover the ordinary cartesian product [0707.1432].

Although multicategories are not directly defined in that earlier paper, a multicategory-like structure can be constructed from a cartesian effect category by iterating sequential products and composing with pure “collectors.” For a common domain $X$, one defines left sequential pairings such as
$$
\{f_1,f_2\}_l=(f_1\ltimes f_2)\circ \{id_X,id_X\},
$$
and more generally $f_1\ltimes\cdots\ltimes f_n$ by associating to the left. Judgments then distinguish pure from effectful terms, and equations distinguish strong from weak equality. This suggests a direct precursor to the later internal language: multiple arguments are not combined by an undifferentiated cartesian product, but by ordered composition whose laws are controlled by weakened projection principles and observational equality [0707.1432].

## 2. Categorical substrate of imperative multicategories

The 2025 formulation begins from symmetric premonoidal structure. A copy-discard premonoidal category $(C,\otimes,I)$ is a symmetric premonoidal category in which each object $X$ has copy and discard maps
$$
\Delta_X:X\to X\otimes X,
\qquad
!_X:X\to I,
$$
forming a central cocommutative comonoid compatible with $\otimes$ and with the unit object. Concretely, the axioms include coassociativity, counit, cocommutativity, monoidal compatibility
$$
\Delta_{X\otimes Y}=(\Delta_X\otimes \Delta_Y)\circ (id_X\otimes \sigma_{X,Y}\otimes id_Y),
\qquad
!_{X\otimes Y}=!_X\otimes !_Y,
$$
and unit compatibility $\Delta_I=id_I$, $!_I=id_I$ [2507.18238].

A distributive monoidal category is finitely cocomplete and has canonical distributors
$$
\delta^L_{X;Y,Z}: X\otimes (Y+Z)\cong (X\otimes Y)+(X\otimes Z),
\qquad
\delta^R_{X,Y;Z}: (X+Y)\otimes Z\cong (X\otimes Z)+(Y\otimes Z),
$$
as natural isomorphisms. On the multicategorical side, a cocartesian multicategory carries coactions by finite functions $\sigma:m\to n$, written $\ast\{f\}\{\sigma\}$, and a distributive multicategory is additionally equipped with a tensor on multimorphisms satisfying associativity, unitality, and an interchange law [2507.18238].

A traced distributive multicategory is then defined by a fixpoint operator
$$
fix: M(X;X,Y_1,\ldots,Y_n)\to M(X;Y_1,\ldots,Y_n),
$$
subject to morphism naturality, action naturality, strength, duplication, and dinaturality. Uniformity strengthens the ordinary traced setting: if
$$
\ast\{h \circ (f_1,\ldots,f_n)\}(\nu_n + id_m)
=
g \circ \ast\{(id,\ldots,id,h,\ldots,h)\}(id_n + \nu_m),
$$
then
$$
\ast\{h \circ (fix(f_1),\ldots,fix(f_n))\}(\nu_n)
=
fix(\ast\{g\}(\nu_m)).
$$
An imperative multicategory is precisely a uniformly traced distributive multicategory whose unary morphisms form a copy-discard category. An imperative category is a representable imperative multicategory, so that coproducts are represented by objects $Y_1+\cdots+Y_n$ with injections and case maps, yielding a distributive copy-discard category with uniform trace on coproduct [2507.18238].

## 3. Syntax, binding structure, and equational theory

The internal language is defined over a distributive signature $(\Sigma_0,\Sigma)$, where $\Sigma_0$ is a set of basic types and each generator set
$$
\Sigma(X_1,\ldots,X_n; (Y_{1,1},\ldots,Y_{1,m_1}),\ldots,(Y_{\ell,1},\ldots,Y_{\ell,m_\ell}))
$$
is intended as a family of multimorphisms
$$
\bigotimes_{j=1}^n X_j \to \bigoplus_{i=1}^{\ell}\bigotimes_{j=1}^{m_i} Y_j^i.
$$
Variables are drawn from a countably infinite set $V$, labels from a countably infinite set $L$, a context has the form $\Gamma=x_1:X_1,\ldots,x_n:X_n$, and an index is a list $\Delta=(\alpha_1:\Psi_1),\ldots,(\alpha_k:\Psi_k)$ of available jump targets with their arities [2507.18238].

Judgments have the form $\Gamma \vdash p:\Delta$. The primitive term formers are return, generator, and loop. Return yields
$$
\Gamma \vdash \alpha(x_1,\ldots,x_n):\Delta
$$
when $(\alpha:X_1,\ldots,X_n)\in \Delta$. A generator term has the shape
$$
\Gamma \vdash f(x_1,\ldots,x_n)\{y_{i,1},\ldots,y_{i,m_i}.p_i\}_{i=1}^{\ell}:\Delta,
$$
and a loop term has the shape
$$
\Gamma \vdash \{\alpha(x_1,\ldots,x_n)\}\{u_1,\ldots,u_n.p\}:\Delta.
$$
The language is quotiented by $\alpha$-equivalence, and it admits both variable substitution and label substitution. Variable substitution is defined inductively, for example
$$
\alpha(x_1,\ldots,x_n)[u\mapsto v]\equiv \alpha(x_1[u\mapsto v],\ldots,x_n[u\mapsto v]),
$$
while label substitution includes the clause
$$
\{\alpha(x)\}\{\alpha\mapsto u.q\}\equiv q[u\mapsto x].
$$
These substitution operations generate derived structural rules such as exchange, contraction, weakening, whiskering, and multiwhiskering [2507.18238].

The equational theory is governed by an interchange axiom and loop axioms. Interchange states that two independent computations can be rearranged into an equivalent tensor-like form over the combined index $\Delta_1\otimes \Delta_2$. The loop axioms are dinaturality, diagonal, and uniformity. The diagonal axiom identifies nested loops with a single loop after a suitable label substitution, and the non-posetal uniformity axiom expresses precisely the fixpoint uniformity needed for invariant-style reasoning [2507.18238].

A posetal version enriches each generator set with a partial order and adds monotonicity rules for return, loop, and generators. It also includes top and bottom principles and a posetal uniformity rule, in forward and backward form, that lifts inequalities on guarded bodies to inequalities on the resulting loops. This order-enriched layer is what later supports correctness and incorrectness logics [2507.18238].

## 4. Denotational semantics, soundness, and completeness

Given an assignment of basic types and generators into an imperative multicategory, the semantics interprets objects by $\llbracket X\rrbracket\in Obj(C)$ and extends to lists by
$$
\llbracket ()\rrbracket = I,
\qquad
\llbracket X,\vec X\rrbracket=\llbracket X\rrbracket\otimes \llbracket \vec X\rrbracket.
$$
Each generator $f\in \Sigma(\vec X;\vec Y_1,\ldots,\vec Y_\ell)$ is interpreted by
$$
\llbracket f\rrbracket:\llbracket \vec X\rrbracket \to \llbracket \vec Y_1\rrbracket + \cdots + \llbracket \vec Y_\ell\rrbracket.
$$
Return terms are interpreted using copy-discard reindexing $(\sigma)^\star$ and injection into the appropriate coproduct branch:
$$
\llbracket \Gamma \vdash \alpha_i(x_\sigma):\Delta\rrbracket = \ast\{(\sigma)^\star\}\{i\}.
$$
Loop terms are interpreted by composing a reindexing map, the fixpoint operator, and branch projections $i^\star_{kj}$, while generator terms are interpreted by duplicating the input and distributing over the branches of the coproduct [2507.18238].

This denotational semantics is sound for the language axioms and complete via a syntactic model. The soundness theorem states that the interpretation respects the interchange and loop axioms. The completeness theorem states that the syntactic model of terms itself forms an imperative multicategory, with multicategory structure, cocartesian coactions, predistributive copy-discard structure, and fixpoint or trace axioms; therefore any equation valid in all imperative multicategories already holds in the syntax [2507.18238].

Representability connects the multicategorical language to more familiar categorical semantics. Imperative categories arise as representable imperative multicategories or as Kleisli categories of partially additive monads such as the maybe, powerset, and subdistribution monads on distributive categories. Under the hypotheses of Jacobs’s theorem and Hasuo’s generic trace theory, these Kleisli categories carry uniform and posetal uniform traces, yielding posetal imperative categories [2507.18238].

## 5. Derived guarded-command structure and program logics

Within the internal language one derives an adaptation of Dijkstra’s guarded command language. Guards have type $\Gamma\vdash b:\Omega$ with $\Omega=(\alpha_1:(),\alpha_2:())$, and the derived combinators include left and right constants, negation, conjunction, disjunction, and guarded pick
$$
[b ? t_1 : t_2]\equiv \{b\}\{\alpha_1,\alpha_2\}\{t_1,t_2\}.
$$
Predicates have type $\Gamma\vdash p:\Upsilon$ with $\Upsilon=(\upsilon:())$, and derived forms include $\top$, $\bot$, conjunction, conditionals, guard-to-predicate conversion $b^\#$, and variable substitution. Commands are endomorphisms $\Gamma\vdash c:\Psi$ with $\Psi=(\eta:(X_1,\ldots,X_n))$; the language derives skip, abort, sequencing, assertions, variable assignment, generator assignment, if-then-else, and while. Among the key equalities are associativity and unit laws for sequencing, simplifications for constant guards, and loop unfolding:
$$
while\ b\ do\ c \equiv \{b\}\{(c ; while\ b\ do\ c)\}\{\}.
$$
States, observations, choices, samples, cosubstitutions, and mute operations are defined similarly [2507.18238].

The same formalism yields several program logics. A correctness triple $\{p\}\ c\ \{q\}$ is valid when
$$
\{p\};c \le c;\{q\}.
$$
In any posetal imperative category with $\bot\le f$ and $f;\top \le \top$, one obtains rules such as skip, composition, deterministic-total assignment, guarded choice, loop invariance by uniformity, loop unrolling, deterministic if-then-else, deterministic while, monotonicity, conjunction, fail, assert, and top or bottom rules. An incorrectness triple $[s]\ c\ [t]$ is valid when $s;c\ge t$, and an outcome-like predicate-correctness triple $p \vdash c \vdash q$ is valid when $p\le c;\{q\}$ [2507.18238].

Relational program logics are derived via couplings. A coupling of $f_1:X_1\to Y_1$ and $f_2:X_2\to Y_2$ is a morphism
$$
h:X_1\otimes X_2 \to (Y_1\otimes Y_2)+Y_1+Y_2
$$
satisfying the prescribed marginal equations, and strong couplings are those factoring through the first injection. Relational correctness and incorrectness rules then follow from coupling composition, product couplings for total morphisms, symmetry, and if/while couplings under total or deterministic guards. The result is a uniform derivation of unary and relational logics from the same internal language and the same categorical axioms [2507.18238].

## 6. Relation to effect categories, examples, and limitations

The internal language for imperative multicategories generalizes the earlier insight that multiple arguments in effectful settings must be treated sequentially rather than by ordinary cartesian products. In effect categories, a semi-product
$$
f_1\times v_2=\{f_1\circ p_1, v_2\circ p_2\}:X_1\times X_2\to Y_1\times Y_2
$$
exists when one leg is pure, and sequential products $\ltimes$ and $\rtimes$ enforce evaluation order. Projection laws then mix strong and weak equations, and swap or associativity hold only in decorated form. The 2025 multicategorical language packages the same phenomenon into a structure with distributivity for choice, copy-discard for dataflow and assertions, and uniform trace for loops; standard traced monoidal categories do not by themselves enforce uniformity, and the 2025 framework treats that extra principle as essential for invariant reasoning [2507.18238] [0707.1432].

The motivating examples from effect categories make the point concrete. For partiality, one takes $V=Set$ and $C=Part$, with $f\sqsubseteq g$ iff $D(f)\subseteq D(g)$ and $f(x)=g(x)$ for $x\in D(f)$. For state, one starts from a cartesian category $V_0$ with distinguished $S$ and interprets arrows $X\to Y$ in $C$ as arrows $S\times X\to S\times Y$ in $V_0$; the semi-congruence is observational equality on results, while state changes may differ. In both cases the failure of full cartesian behavior explains why left and right sequencing need not coincide. The worked imperative example with `write` and `read` makes the order explicit: the composite
$$
op := read \circ \pi_{X_2} \circ (write \ltimes id_{X_2}) : X_1\times X_2 \to Y
$$
has the intended semantics “write $x_1$; then read at $x_2$” [0707.1432].

Several limitations are explicit. In effect categories, the semi-congruence may be non-symmetric and does not satisfy full replacement, so decorated proofs cannot always be transported verbatim from cartesian categories. In imperative multicategories, the theory assumes finite coproducts, distributivity with $\otimes$, copy-discard comonoids, posetal enrichment, and uniform trace; the internal language is unstructured, and some proof rules depend on determinism, totality, or posetal uniformity. The stated open directions include external logic beyond internal predicate combinators, separation logic and premonoidal semantics, enrichment from posets to metrics or quantales, broader characterizations of posetal uniformity, nesting of multiple effects, exceptions, closed Freyd categories, traced premonoidal categories, and diagrammatic logics of decorations [2507.18238]

Source: https://www.emergentmind.com/topics/internal-language-for-imperative-multicategories