Base Change

Change of enriching category for V-enriched categories.

base_change

Change of enrichment (change of base) for V-enriched categories.

A lax monoidal functor F: V → W between quantales induces a change-of-base 2-functor from V-Cat to W-Cat. This transforms all morphism tensors by applying F elementwise, changing the enrichment algebra from V to W.

This module provides:

BaseChange (abstract)
├── BoolToFuzzy   — inclusion {0,1} ↪ [0,1]
└── FuzzyToBool   — thresholding [0,1] → {0,1}

BaseChange

Bases: ABC

Abstract change of enrichment from quantale V to quantale W.

Subclasses must implement source, target, and apply_to_values. apply_to_morphism is derived.

source abstractmethod property

source: Quantale

The source quantale V.

target abstractmethod property

target: Quantale

The target quantale W.

apply_to_values abstractmethod

apply_to_values(tensor: Tensor) -> Tensor

Apply the value-level map V → W elementwise.

PARAMETER DESCRIPTION
tensor

A V-valued tensor.

TYPE: Tensor

RETURNS DESCRIPTION
Tensor

The corresponding W-valued tensor.

Source code in src/quivers/categorical/base_change.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@abstractmethod
def apply_to_values(self, tensor: torch.Tensor) -> torch.Tensor:
    """Apply the value-level map V → W elementwise.

    Parameters
    ----------
    tensor : torch.Tensor
        A V-valued tensor.

    Returns
    -------
    torch.Tensor
        The corresponding W-valued tensor.
    """
    ...

apply_to_morphism

apply_to_morphism(morph: Morphism) -> ObservedMorphism

Transform a V-morphism to a W-morphism.

Applies the value-level map to the morphism's tensor and returns an observed morphism with the target quantale.

PARAMETER DESCRIPTION
morph

A morphism enriched over V.

TYPE: Morphism

RETURNS DESCRIPTION
ObservedMorphism

The same morphism re-enriched over W.

Source code in src/quivers/categorical/base_change.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
def apply_to_morphism(self, morph: Morphism) -> ObservedMorphism:
    """Transform a V-morphism to a W-morphism.

    Applies the value-level map to the morphism's tensor and
    returns an observed morphism with the target quantale.

    Parameters
    ----------
    morph : Morphism
        A morphism enriched over V.

    Returns
    -------
    ObservedMorphism
        The same morphism re-enriched over W.
    """
    new_tensor = self.apply_to_values(morph.tensor.detach())

    return observed(
        morph.domain,
        morph.codomain,
        new_tensor,
        quantale=self.target,
    )

BoolToFuzzy

Bases: BaseChange

Inclusion of the boolean quantale into the fuzzy quantale.

The identity map {0, 1} ↪ [0, 1]. Boolean-valued tensors are already valid fuzzy-valued tensors, so this is the identity on tensor values.

apply_to_values

apply_to_values(tensor: Tensor) -> Tensor

Identity: {0,1} values are already in [0,1].

Source code in src/quivers/categorical/base_change.py
112
113
114
def apply_to_values(self, tensor: torch.Tensor) -> torch.Tensor:
    """Identity: {0,1} values are already in [0,1]."""
    return tensor.clone()

FuzzyToBool

FuzzyToBool(threshold: float = 0.5)

Bases: BaseChange

Thresholding from the fuzzy quantale to the boolean quantale.

Applies a threshold: values >= threshold become 1, others become 0. This is a right adjoint to BoolToFuzzy.

PARAMETER DESCRIPTION
threshold

The threshold value. Must be in (0, 1). Default 0.5.

TYPE: float DEFAULT: 0.5

Source code in src/quivers/categorical/base_change.py
129
130
131
132
133
def __init__(self, threshold: float = 0.5) -> None:
    if not (0.0 < threshold < 1.0):
        raise ValueError(f"threshold must be in (0, 1), got {threshold}")

    self._threshold = threshold

threshold property

threshold: float

The threshold value.

apply_to_values

apply_to_values(tensor: Tensor) -> Tensor

Threshold: values >= threshold → 1, else → 0.

Source code in src/quivers/categorical/base_change.py
148
149
150
def apply_to_values(self, tensor: torch.Tensor) -> torch.Tensor:
    """Threshold: values >= threshold → 1, else → 0."""
    return (tensor >= self._threshold).float()