Objects¶
Categorical objects including finite sets, products, coproducts, and free monoids.
objects
¶
Categorical objects: finite sets, products, coproducts, and free monoids.
The set-object family is a sum type with four variants — :class:FinSet,
:class:ProductSet, :class:CoproductSet, :class:FreeMonoid — discriminated
by kind. SetObject is the :class:dx.TaggedUnion root that gathers
them; X * Y and X + Y work on any pair of variants.
SetObject
¶
Bases: TaggedUnion
The category of finite sets, product sets, and coproduct sets.
Variants share two derived properties (:attr:size, :attr:shape) and
the * / + operators for product and coproduct construction.
FinSet
¶
Bases: SetObject
A named finite set with a fixed cardinality.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Human-readable name for the set.
TYPE:
|
cardinality |
Number of elements (must be
TYPE:
|
ProductSet
¶
Bases: SetObject
Cartesian product of finite sets.
Nested products are flattened: ProductSet(components=(A, ProductSet(components=(B, C))))
constructs to ProductSet with components == (A, B, C).
CoproductSet
¶
Bases: SetObject
Tagged union (coproduct) of finite sets.
The flat cardinality is the sum of component cardinalities; the shape is
a single dimension of that total size with offsets recoverable from
:attr:offsets.
offsets
¶
offsets() -> tuple[int, ...]
Per-component flat offsets, computed from cumulative sizes.
Source code in src/quivers/core/objects.py
146 147 148 149 150 151 152 153 154 | |
offset
¶
offset(index: int) -> int
Return the flat offset for the i-th component.
Source code in src/quivers/core/objects.py
164 165 166 | |
component_range
¶
component_range(index: int) -> tuple[int, int]
Return (start, end) flat indices for the i-th component.
Source code in src/quivers/core/objects.py
168 169 170 171 172 | |
FreeMonoid
¶
Bases: SetObject
Free monoid on a generator set, truncated to max_length.
Represents all tuples (strings) from elements of generators with
length 0 through max_length. Internally a coproduct
Unit + G + G×G + ... + G^max_length; obtain it via
:meth:as_coproduct.
| ATTRIBUTE | DESCRIPTION |
|---|---|
generators |
The generator set.
TYPE:
|
max_length |
Maximum string length (inclusive).
TYPE:
|
as_coproduct
¶
as_coproduct() -> CoproductSet
Return the underlying coproduct view.
Source code in src/quivers/core/objects.py
219 220 221 | |
encode
¶
encode(word: tuple[int, ...]) -> int
Encode a word (tuple of generator indices) to a flat index.
Source code in src/quivers/core/objects.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
decode
¶
decode(flat_index: int) -> tuple[int, ...]
Decode a flat index back to a word.
Source code in src/quivers/core/objects.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |