Natural Transformations¶
A natural transformation from one functor to
another gives, for each object, a component that converts the first functor's output into the
second's (Mac Lane, 1998). Its naturality equation
says that converting and then mapping an arrow agrees with mapping and then converting, for every
arrow of the source category. The module gives the NaturalTransformation interface and natural
transformations defined by their components.
natural_transformations
¶
Natural transformations between endofunctors.
A natural transformation η: F ⇒ G is a family of morphisms {η_A: F(A) → G(A)} indexed by objects, satisfying the naturality condition:
η_B ∘ F(f) = G(f) ∘ η_A for all f: A → B
This module provides:
NaturalTransformation (abstract)
└── ComponentwiseNT — defined by a callable producing components
NaturalTransformation
¶
Bases: ABC
Abstract natural transformation η: F ⇒ G.
Subclasses must implement component to produce η_A for
each object A.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The source functor F.
TYPE:
|
target
|
The target functor G.
TYPE:
|
Source code in src/quivers/categorical/natural_transformations.py
component
abstractmethod
¶
verify_naturality
¶
verify_naturality(f: Morphism, atol: float = 1e-05) -> bool
Verify the naturality condition for a given morphism.
Checks that η_B ∘ F(f) ≈ G(f) ∘ η_A for f: A → B.
| PARAMETER | DESCRIPTION |
|---|---|
f
|
A morphism f: A → B to check naturality against.
TYPE:
|
atol
|
Absolute tolerance for tensor comparison.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the naturality square commutes within tolerance. |
Source code in src/quivers/categorical/natural_transformations.py
ComponentwiseNT
¶
Bases: NaturalTransformation
A natural transformation defined by a callable.
Wraps a function obj ↦ morphism into a NaturalTransformation. Useful for constructing natural transformations from explicit component definitions.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
The source functor F.
TYPE:
|
target
|
The target functor G.
TYPE:
|
component_fn
|
A function that, given an object A, returns η_A: F(A) → G(A). |
Source code in src/quivers/categorical/natural_transformations.py
Cited sources¶
Saunders Mac Lane. Categories for the Working Mathematician. Volume 5 of Graduate Texts in Mathematics. Springer, 2 edition, 1998. URL: https://link.springer.com/book/10.1007/978-1-4757-4721-8, doi:10.1007/978-1-4757-4721-8.