pub trait Adjunction<L, R>{
// Required methods
fn left_adjunct<A, B, F>(a: A, f: F) -> R::Type<B>
where F: Fn(L::Type<A>) -> B;
fn right_adjunct<A, B, F>(la: L::Type<A>, f: F) -> B
where F: Fn(A) -> R::Type<B>;
fn unit<A>(a: A) -> R::Type<L::Type<A>>;
fn counit<B>(lrb: L::Type<R::Type<B>>) -> B;
}Expand description
The Adjunction trait defines a pair of adjoint functors $L$ (Left) and $R$ (Right).
§Category Theory
An Adjunction $L \dashv R$ exists between two categories $\mathcal{C}$ and $\mathcal{D}$ if there is a natural isomorphism between the set of morphisms: $$ \text{Hom}{\mathcal{D}}(L(A), B) \cong \text{Hom}{\mathcal{C}}(A, R(B)) $$
This is one of the most profound concepts in mathematics, generalizing the idea of “opposites” or “duals”. Examples include Free/Forgetful functors, Currying/Uncurrying, and Quantifiers ($\exists \dashv \text{const} \dashv \forall$).
§Mathematical Definition
The isomorphism is defined by two natural transformations:
- Unit ($\eta$): $id \to R \circ L$
- Counit ($\epsilon$): $L \circ R \to id$
Satisfying the triangle identities:
- $R(\epsilon) \circ \eta_R = id_R$
- $\epsilon_L \circ L(\eta) = id_L$
§Use Cases
- Conservation Laws: In Discrete Exterior Calculus (DEC), the Boundary Operator ($\partial$) and Exterior Derivative ($d$) are adjoints. $\langle d\phi, J \rangle = \langle \phi, \partial J \rangle$.
- Optimization: Relating a constraint space (Primal) to a Lagrange multiplier space (Dual).
Required Methods§
Sourcefn left_adjunct<A, B, F>(a: A, f: F) -> R::Type<B>
fn left_adjunct<A, B, F>(a: A, f: F) -> R::Type<B>
The Left Adjunct: $(L(A) \to B) \to (A \to R(B))$ Transforms a function on the “Left” structure to a function on the “Right” structure.
Sourcefn right_adjunct<A, B, F>(la: L::Type<A>, f: F) -> B
fn right_adjunct<A, B, F>(la: L::Type<A>, f: F) -> B
The Right Adjunct: $(A \to R(B)) \to (L(A) \to B)$ Transforms a function on the “Right” structure to a function on the “Left” structure.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.