Internal Language for Imperative Multicategories
- Internal Language for Imperative Multicategories is a formal syntax–semantics interface for effectful, multi-output computations using uniformly traced distributive multicategories.
- It unifies multimorphisms, labels, coproduct-based control flow, and fixpoint-based looping within a single algebraic framework.
- The framework provides sound denotational semantics and derived program logics for correctness, incorrectness, and relational reasoning.
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 (Bonchi et al., 24 Jul 2025). 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 of pure functions by a weak category of all functions, while also distinguishing two notions of equation: strong equations, denoted , and semi-equations, denoted (0707.1432). The relation is weaker than , is transitive, coincides with on , 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
These constructions encode evaluation order explicitly, and in general and 0 need not coincide up to 1; when 2 and 3, 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 4, one defines left sequential pairings such as
5
and more generally 6 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 7 is a symmetric premonoidal category in which each object 8 has copy and discard maps
9
forming a central cocommutative comonoid compatible with 0 and with the unit object. Concretely, the axioms include coassociativity, counit, cocommutativity, monoidal compatibility
1
and unit compatibility 2, 3 (Bonchi et al., 24 Jul 2025).
A distributive monoidal category is finitely cocomplete and has canonical distributors
4
as natural isomorphisms. On the multicategorical side, a cocartesian multicategory carries coactions by finite functions 5, written 6, and a distributive multicategory is additionally equipped with a tensor on multimorphisms satisfying associativity, unitality, and an interchange law (Bonchi et al., 24 Jul 2025).
A traced distributive multicategory is then defined by a fixpoint operator
7
subject to morphism naturality, action naturality, strength, duplication, and dinaturality. Uniformity strengthens the ordinary traced setting: if
8
then
9
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 0 with injections and case maps, yielding a distributive copy-discard category with uniform trace on coproduct (Bonchi et al., 24 Jul 2025).
3. Syntax, binding structure, and equational theory
The internal language is defined over a distributive signature 1, where 2 is a set of basic types and each generator set
3
is intended as a family of multimorphisms
4
Variables are drawn from a countably infinite set 5, labels from a countably infinite set 6, a context has the form 7, and an index is a list 8 of available jump targets with their arities (Bonchi et al., 24 Jul 2025).
Judgments have the form 9. The primitive term formers are return, generator, and loop. Return yields
0
when 1. A generator term has the shape
2
and a loop term has the shape
3
The language is quotiented by 4-equivalence, and it admits both variable substitution and label substitution. Variable substitution is defined inductively, for example
5
while label substitution includes the clause
6
These substitution operations generate derived structural rules such as exchange, contraction, weakening, whiskering, and multiwhiskering (Bonchi et al., 24 Jul 2025).
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 7. 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 (Bonchi et al., 24 Jul 2025).
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 (Bonchi et al., 24 Jul 2025).
4. Denotational semantics, soundness, and completeness
Given an assignment of basic types and generators into an imperative multicategory, the semantics interprets objects by 8 and extends to lists by
9
Each generator 0 is interpreted by
1
Return terms are interpreted using copy-discard reindexing 2 and injection into the appropriate coproduct branch:
3
Loop terms are interpreted by composing a reindexing map, the fixpoint operator, and branch projections 4, while generator terms are interpreted by duplicating the input and distributing over the branches of the coproduct (Bonchi et al., 24 Jul 2025).
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 (Bonchi et al., 24 Jul 2025).
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 (Bonchi et al., 24 Jul 2025).
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 5 with 6, and the derived combinators include left and right constants, negation, conjunction, disjunction, and guarded pick
7
Predicates have type 8 with 9, and derived forms include 0, 1, conjunction, conditionals, guard-to-predicate conversion 2, and variable substitution. Commands are endomorphisms 3 with 4; 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:
5
States, observations, choices, samples, cosubstitutions, and mute operations are defined similarly (Bonchi et al., 24 Jul 2025).
The same formalism yields several program logics. A correctness triple 6 is valid when
7
In any posetal imperative category with 8 and 9, 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 0 is valid when 1, and an outcome-like predicate-correctness triple 2 is valid when 3 (Bonchi et al., 24 Jul 2025).
Relational program logics are derived via couplings. A coupling of 4 and 5 is a morphism
6
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 (Bonchi et al., 24 Jul 2025).
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
7
exists when one leg is pure, and sequential products 8 and 9 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 (Bonchi et al., 24 Jul 2025, 0707.1432).
The motivating examples from effect categories make the point concrete. For partiality, one takes 0 and 1, with 2 iff 3 and 4 for 5. For state, one starts from a cartesian category 6 with distinguished 7 and interprets arrows 8 in 9 as arrows 0 in 1; 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
2
has the intended semantics “write 3; then read at 4” (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 5, 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 (Bonchi et al., 24 Jul 2025)