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 — FinSet,
ProductSet, CoproductSet, FreeMonoid — discriminated
by kind. SetObject is the 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 (size, 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
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
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 | |
EnumSet
¶
Bases: SetObject
A finite set whose elements have explicit names.
Unlike FinSet, whose elements are anonymous integers
0..cardinality-1, an EnumSet carries a tuple of element
names; the cardinality is len(elements). Names must be unique.
Used for declaring atom collections (e.g. categorial-grammar atoms
like {NP, S, VP}) that other constructions reference by name.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Human-readable name for the set.
TYPE:
|
elements |
The element names. Must be unique and non-empty.
TYPE:
|
index
¶
index(name: str) -> int
Return the integer index of the element name.
Source code in src/quivers/core/objects.py
324 325 326 327 328 329 330 331 | |
FreeResiduated
¶
Bases: SetObject
The residuated category universe over a generator set.
Closes the generator atoms under the residuated monoidal connectives
(/, \, *, optional ◇ / □) up to a bounded
nesting depth. The runtime carrier is a finite enumeration of all
admissible category strings produced by
quivers.stochastic.categories.CategorySystem.from_generators.
| ATTRIBUTE | DESCRIPTION |
|---|---|
generators |
The atom generators (e.g.
TYPE:
|
depth |
Maximum nesting depth of category constructors.
TYPE:
|
ops |
The connectives to close under. Allowed names:
TYPE:
|
system
¶
system() -> object
Return the underlying CategorySystem.
The system is constructed on each call (cheap for small depths; callers expecting to use it multiple times should hold a reference). Storing the result inside the model would require a non-frozen field, which is incompatible with the dx.Model contract.
Source code in src/quivers/core/objects.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |