Traced Monoidal¶
Cartesian and iterative traced monoidal structures, with trace and
partial_trace operations.
traced
¶
Traced monoidal categories: feedback and fixpoint.
A traced monoidal category is a symmetric monoidal category (C, ⊗, I) equipped with a trace operator:
Tr^U_{A,B}: C(A ⊗ U, B ⊗ U) → C(A, B)
satisfying naturality, dinaturality, vanishing, superposing, and yanking axioms.
In the V-enriched fuzzy-relation setting, the trace corresponds to a fixpoint computation: given f: A × U → B × U, the trace "feeds back" the U component:
Tr(f)(a, b) = ⋁_u f((a, u), (b, u))
which is the join (existential) over the feedback variable.
For the tropical algebra, this computes shortest-cycle distances. For general algebras, it may require iteration to a fixpoint.
This module provides:
TracedMonoidal (abstract)
├── CartesianTrace — trace on the cartesian monoidal structure
└── IterativeTrace — trace via fixpoint iteration
trace() — apply the trace operator
partial_trace() — trace over a subset of feedback wires
TracedMonoidal
¶
TracedMonoidal(monoidal: MonoidalStructure, algebra: Algebra | None = None)
Bases: ABC
Abstract traced monoidal category.
Provides the trace operator Tr^U_{A,B} on a monoidal structure.
| PARAMETER | DESCRIPTION |
|---|---|
monoidal
|
The underlying monoidal structure.
TYPE:
|
algebra
|
The enrichment algebra.
TYPE:
|
Source code in src/quivers/categorical/traced.py
trace
abstractmethod
¶
Apply the trace operator.
Given f: A ⊗ U → B ⊗ U, compute Tr^U(f): A → B.
| PARAMETER | DESCRIPTION |
|---|---|
morph
|
The morphism f: A ⊗ U → B ⊗ U.
TYPE:
|
feedback
|
The feedback object U.
TYPE:
|
domain
|
The external domain A.
TYPE:
|
codomain
|
The external codomain B.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Morphism
|
The traced morphism Tr^U(f): A → B. |
Source code in src/quivers/categorical/traced.py
verify_yanking
¶
verify_yanking(feedback: SetObject, atol: float = 1e-05) -> bool
Verify the yanking axiom: Tr^U(σ_{U,U}) = id_U.
The trace of the braiding/swap should be the identity.
| PARAMETER | DESCRIPTION |
|---|---|
feedback
|
The object U to test.
TYPE:
|
atol
|
Absolute tolerance.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if yanking holds within tolerance. |
Source code in src/quivers/categorical/traced.py
CartesianTrace
¶
CartesianTrace(algebra: Algebra | None = None)
Bases: TracedMonoidal
Trace on the cartesian monoidal structure (FinSet, ×, 1).
For a morphism f: A × U → B × U, the cartesian trace is:
Tr^U(f)(a, b) = ⋁_u f((a, u), (b, u))
This is the join over the feedback dimensions of the tensor's diagonal (where the U components of domain and codomain agree).
| PARAMETER | DESCRIPTION |
|---|---|
algebra
|
The enrichment algebra.
TYPE:
|
Source code in src/quivers/categorical/traced.py
trace
¶
Compute the cartesian trace via diagonal extraction and join.
| PARAMETER | DESCRIPTION |
|---|---|
morph
|
f: A × U → B × U.
TYPE:
|
feedback
|
The feedback object U.
TYPE:
|
domain
|
The external domain A.
TYPE:
|
codomain
|
The external codomain B.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ObservedMorphism
|
Tr^U(f): A → B. |
Source code in src/quivers/categorical/traced.py
IterativeTrace
¶
IterativeTrace(monoidal: MonoidalStructure, algebra: Algebra | None = None, max_iter: int = 100, atol: float = 1e-06)
Bases: TracedMonoidal
Trace via fixpoint iteration.
For algebras where the trace does not have a closed-form expression, this computes the trace by iterating:
x_0 = ⊥
x_{n+1} = f(a, x_n)(b, x_n) (schematically)
until convergence. This works for continuous algebras on complete lattices (Kleene's fixpoint theorem).
| PARAMETER | DESCRIPTION |
|---|---|
monoidal
|
The monoidal structure.
TYPE:
|
algebra
|
The enrichment algebra.
TYPE:
|
max_iter
|
Maximum number of iterations.
TYPE:
|
atol
|
Convergence tolerance.
TYPE:
|
Source code in src/quivers/categorical/traced.py
trace
¶
Compute the trace via fixpoint iteration.
| PARAMETER | DESCRIPTION |
|---|---|
morph
|
f: A ⊗ U → B ⊗ U.
TYPE:
|
feedback
|
The feedback object U.
TYPE:
|
domain
|
The external domain A.
TYPE:
|
codomain
|
The external codomain B.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ObservedMorphism
|
Tr^U(f): A → B. |
Source code in src/quivers/categorical/traced.py
trace
¶
trace(morph: Morphism, feedback: SetObject, domain: SetObject, codomain: SetObject, algebra: Algebra | None = None) -> Morphism
Convenience function: apply cartesian trace.
Given f: A × U → B × U, compute Tr^U(f): A → B using the CartesianTrace.
| PARAMETER | DESCRIPTION |
|---|---|
morph
|
The morphism f: A × U → B × U.
TYPE:
|
feedback
|
The feedback object U.
TYPE:
|
domain
|
The external domain A.
TYPE:
|
codomain
|
The external codomain B.
TYPE:
|
algebra
|
The enrichment algebra.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Morphism
|
The traced morphism Tr^U(f): A → B. |
Source code in src/quivers/categorical/traced.py
partial_trace
¶
partial_trace(morph: Morphism, feedback_indices: tuple[int, ...], algebra: Algebra | None = None) -> Morphism
Trace over a subset of feedback wires in a product.
Given f: (A₁ × ... × Aₙ) → (B₁ × ... × Bₙ) where some pairs (Aᵢ, Bᵢ) are feedback wires (Aᵢ = Bᵢ), compute the partial trace over the specified pairs.
| PARAMETER | DESCRIPTION |
|---|---|
morph
|
The morphism.
TYPE:
|
feedback_indices
|
Indices of the product components to trace over. These components must have matching shapes in domain and codomain.
TYPE:
|
algebra
|
The enrichment algebra.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ObservedMorphism
|
The partially traced morphism. |
Source code in src/quivers/categorical/traced.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |