Monoidal coherence solver
Decision procedures for equality of morphisms in a monoidal category, in the style of Mac Lane's coherence theorem. Three variants are exposed, covering progressively richer fragments:
Structural— the bare coherence theorem: any two parallel composites of structural isomorphisms (associators, unitors, and their inverses) are equal. No generating morphisms.MorSolve/MorRewrite(withMorAtoms) — the same, extended with opaque generating morphisms (boxes). They discharge goals that hold by naturality and bifunctoriality / interchange of_⊗₁_and_∘_, e.g.(s ⊗₁ id) ∘ (id ⊗₁ t) ≈ s ⊗₁ t;MorRewriteadditionally fires rules.SymSolve/SymRewrite(withSymAtoms) — the morphism solver over a symmetric monoidal category, so the term language additionally carries the braidingσand goals may use it.
This file is the user-facing entry point. It is literate Agda: the
implementation lives in the Categories.Coherence.Monoidal.* submodules, and
here each solver is given a short documented re-definition — a thin alias
delegating to the implementation — so that jumping to a solver's definition
lands on this documentation. The test suites in
Categories.Coherence.Monoidal.Test.* exercise each variant.
Structural: coherence of structural isomorphisms
Structural C vars instantiates the solver at a target monoidal category
C, with vars a Vec of object atoms. Its term language is the free
monoidal category over those atoms with no generating morphisms
(mor = λ _ _ → ⊥), so every morphism is a structural iso. solveM f g
then discharges ⟦ f ⟧₁ ≈ ⟦ g ⟧₁ for any parallel pair f g, the content
of Mac Lane's coherence theorem (MacLane.CoherenceThm.all-Comm, via the
normal-form functor). Use it for associator/unitor bookkeeping in a
goal with no generators; the Test.Frontend suite's Coherence module
exercises it.
MorRewrite / MorSolve: the monoidal morphism solver
MorRewrite C vars gens adds generating morphisms. vars are the object atoms and
gens is the signature: one (source , target , interpretation) triple per
generator — the arities are ObjTerms over the atoms, the interpretation a
C-morphism between their images. It exposes the term DSL S over those
generators and the solver solveMor!, which discharges a goal between
interpretations of front-end terms whose normal forms agree — handling
monoidal coherence together with naturality and the interchange law for
_⊗₁_/_∘_. rewriteMor! and friends additionally fire a user-supplied
equational rule in a context (rewriteMorAuto! locates it automatically).
See Categories.GradedKleisli for a call site.
Warning: MorRewrite is slow to open. Prefer MorSolve if you simply want
to call solveMor!.
Example
A worked example over an arbitrary monoidal category C, with two object atoms
A , B and two generators s : A → A, t : B → B. The solver takes the whole
signature as a single vector of triples —
each (source , target , interpretation) — and exposes in one open the term
DSL S, the generators gen i, and the solver solveMor!. (open FreeMonoidalHelper supplies just the atom term V, so the arities can be
written.) Each goal is
then stated in C's own vocabulary; the solveMor! arguments are the two
front-end terms whose normal forms it compares.
SymRewrite / SymSolve: the symmetric/braided morphism solver
SymRewrite C Sym vars gens is the analogue of MorRewrite for a symmetric monoidal
C (Sym : Symmetric (C .monoidal)); same one-vector-of-triples signature.
The term language additionally carries the braiding σ, normalised by
σσ-cancellation, the two naturality slides and disjoint interchange;
solveMorσ! lands σ on the target's braiding.
Scope and limitations
The solver family is sound but not complete: it may return nothing on a
true equation. The full list of what it does not decide — the ambiguous
rank convention, opaque generators, the braided hexagon and straddling
boxes, and the meta-properties (incompleteness, no confluence claim) — is
catalogued, with machine-checked witnesses, in
Categories.Coherence.Monoidal.Test.Limitations.