Types and Spaces¶
This page gives the denotation of the syntactic categories ObjectExpr (finite-set types) and SpaceExpr (continuous spaces). Both are interpreted compositionally by structural recursion on the syntactic constructors of quivers.dsl.ast_nodes, and both are realized by the unified resolution walk in quivers.dsl.compiler.resolution.
1. Syntactic categories¶
We assume the following grammar fragment, whose constructors are realized one-to-one by the AST classes named in parentheses.
Here \(n \in \mathbb{N}\) is an integer literal, \(X\) ranges over object names, \(S\) over space names, \(T\) over declared effect identifiers, and \(C \in \{\mathrm{Real}, \mathrm{Simplex}, \mathrm{Sphere}, \mathrm{Ball}, \mathrm{CholeskyFactor}, \mathrm{Covariance}, \mathrm{Correlation}, \mathrm{Orthogonal}, \mathrm{Stiefel}, \mathrm{LowerTriangular}, \mathrm{Diagonal}\}\) over constructor names. The notation \(C(\bar a; \bar k)\) stands for a constructor invocation with positional arguments \(\bar a\) and keyword arguments \(\bar k\). The two slash directions (/ and \) and the effect-apply form are residuated / effect-extended formers whose denotations live in a residuated-monoidal universe (Schemas §3); they have no denotation in the bare \(\mathbf{FinSet}\) stratum, and well-typedness restricts them to expressions whose every named atom resolves in a residuated universe such as FreeResiduated.
2. Denotation of types¶
Type denotation is a function
We omit the environment argument when it is clear.
The last three cases require the surrounding object universe to be residuated and/or effect-extended; otherwise the denotation is undefined and well-typedness rejects the expression.
If \(X\) is not bound in \(\rho_{\mathrm{obj}}\) but parses as a non-negative integer literal, the literal rule is used: this allows ad-hoc cardinalities such as f : 3 -> 4 without prior object declarations.
The cartesian product \(\times\) in \(\mathbf{FinSet}\) is associative and commutative up to canonical isomorphism. The implementation chooses the right-associated, flattened representative; this is enforced by the _flatten_products converter on ProductSet.components and the analogous flattener on CoproductSet.components. The chosen representatives are equal (not merely isomorphic) under the dx.Model structural equality used throughout the codebase.
2a. Object initializers¶
The surface form
object X : value
admits five initializer shapes for the right-hand side value, each binding \(X\) to a concrete object of \(\mathbf{FinSet}\) or \(\mathbf{SBor}\) built from explicit data rather than from a syntactic ObjectExpr. Each is interpreted at the value layer and contributes its denotation directly to \(\rho_{\mathrm{obj}}(X)\) (or \(\rho_{\mathrm{spc}}(X)\) for the continuous-space initializer):
| Initialiser | Denotation |
|---|---|
FinSet n |
a finite set of cardinality \(n\) |
Real d (or any other ContinuousSpace family invocation) |
a standard Borel space of the named family at the supplied parameters |
{e_1, …, e_n} |
the enum set on the named labels (§2a.1) |
FreeMonoid(X, max_length = n) |
the bounded Kleene closure (§2a.2) |
FreeResiduated(G, depth = d, ops = O) |
the depth-bounded free residuated category over \(G\) (§2a.3) |
The five initialisers share a single declaration form: there is no space X : … keyword variant. Whether \(X\) lands in \(\mathbf{FinSet}\) or \(\mathbf{SBor}\) is decided by the family invoked on the right-hand side; the surrounding object keyword is uniform.
2a.1 Enum sets¶
object Atoms = {NP, S, VP}
denotes the finite set whose elements are exactly the named labels, ordered by declaration position:
The label identity is part of the object: two enum sets with the same cardinality but different labels are different objects of \(\mathbf{FinSet}\) under the dx.Model structural equality used throughout the codebase.
A category C_1, …, C_n declaration is the singleton-cardinality special case (Schemas §1).
2a.2 Free monoids¶
The FreeMonoid(X, max_length = n) initializer binds \(X\) to the bounded Kleene closure of the generator set. See §3 below for the denotation.
2a.3 Free residuated categories¶
The FreeResiduated(G, depth = d, ops = O) initializer binds \(X\) to a finite enumeration of category expressions over the generators, closed under the chosen residuation operations up to a depth bound. The denotation is given in Schemas §4.
3. Free monoids¶
The runtime value layer exposes a FreeMonoid object class, which arises in the deduction fragment as the carrier of strings over an alphabet (see Weighted Deduction Fragment). At the surface, FreeMonoid(X, max_length = n) appears only as an object initializer (§2a.2 above), not as a ObjectExpr constructor: a free monoid must be bound to an object name via object Words = FreeMonoid(...) before it can be referenced as a type.
The denotation of FreeMonoid(generators = X, max_length = n) is the bounded Kleene star
a finite set of size \(\sum_{k=0}^{n} |\rho_{\mathrm{obj}}(X)|^{k}\). The bound \(n\) is supplied by the grammar's depth parameter; the unbounded free monoid \(\rho_{\mathrm{obj}}(X)^{*}\) is countably infinite and is not realized as a SetObject.
4. Denotation of spaces¶
The continuous-space sublanguage is the family-registry surface
Real d, Simplex d, plus the matrix-manifold and submanifold
variants below, combined under product via *. Each of these is
a family invocation against the ContinuousSpace family registry:
| Surface | Family identifier | Carrier | Parameters |
|---|---|---|---|
Real d |
Euclidean |
\(\mathbb{R}^d\) | dimension \(d\), optional low= / high= bounds (use low=0 for \((0, \infty)^d\) once a positive prior is attached; low=0, high=1 for \([0,1]^d\)) |
Simplex d |
Simplex |
\(\Delta^{d-1}\) | dimension \(d\) |
Sphere d |
Sphere |
\(S^{d-1} \subset \mathbb{R}^d\) | ambient dimension \(d\) |
Ball d [radius = r] |
Ball |
\(\{x \in \mathbb{R}^d : \lVert x \rVert_2 \le r\}\) | ambient dim \(d\), radius \(r\) |
CholeskyFactor d |
CholeskyFactor |
unit-row-norm lower-triangular \(d \times d\) | \(d\) |
Covariance d |
Covariance |
\(\mathrm{Sym}^+_d\) (SPD cone) | \(d\) |
Correlation d |
Correlation |
SPD with unit diagonal | \(d\) |
Orthogonal d |
Orthogonal |
\(O(d) \subset \mathbb{R}^{d \times d}\) | \(d\) |
Stiefel(rows, cols) |
Stiefel |
\(V_K(\mathbb{R}^N)\) with \(K \le N\) | rows \(N\), cols \(K\) |
LowerTriangular d |
LowerTriangular |
\(d \times d\) lower-triangular | \(d\) |
Diagonal d |
Diagonal |
\(\mathbb{R}^d\) via diagonal embedding | \(d\) |
The surface Real d resolves to the Euclidean class through the same family-registry lookup. New continuous-space families register through the same registry without surface keyword changes once the grammar adds the constructor name to the ContinuousConstructor AST node's accepted Literal[...], and the surface Family d [args] denotes Family(d, **args) against the registry.
For the matrix-manifold variants (CholeskyFactor, Covariance,
Correlation, Orthogonal, Stiefel, LowerTriangular) the
carrier is a flat \(d \times d\) (or \(N \times K\)) tensor laid out
row-major; the on-manifold predicate is enforced by the sampling
family that targets the space, not by the type. The membership
check ContinuousSpace.contains returns a per-batch boolean
mask testing the manifold equations up to a fixed numerical
tolerance (symmetric and SPD for Covariance;
orthogonal columns for Stiefel, etc.).
Space denotation is a function
For brevity write \(\rho = (\rho_{\mathrm{spc}}, \rho_{\mathrm{obj}})\). The constructor cases are:
each carrying its standard Borel \(\sigma\)-algebra (inherited as a
Borel submanifold of the ambient \(\mathbb{R}^{d}\) or \(\mathbb{R}^{d \times d}\)). The matrix carriers (CholeskyFactor,
Covariance, Correlation,
Orthogonal, Stiefel,
LowerTriangular) are stored as flat
row-major tensors; the manifold equations cut out a smooth submanifold of the ambient Euclidean space and the
Borel structure descends. The remaining cases are:
where \(\iota : \mathbf{FinSet} \hookrightarrow \mathbf{SBor}\) is the canonical inclusion (every finite set as a discrete standard Borel space). The fallback rule for SpaceName allows mixed-domain ProductSpace instances such as Real(3) * Token where Token : 256 is a previously declared object. The denotation is the product in \(\mathbf{SBor}\), which is well-defined precisely because \(\iota\) is a faithful functor preserving finite products.
5. Coherence¶
The two type-formers \(\times\) and \(+\) on ObjectExpr are interpreted by the cartesian product and disjoint union in \(\mathbf{FinSet}\), both of which are associative, commutative, and unital up to canonical isomorphism (with units the singleton \(\mathbf{1}\) and the empty set \(\emptyset\) respectively). Concretely:
- The flattening converters on
ProductSetandCoproductSetrealize the coherence isomorphisms \(((\tau_1 \times \tau_2) \times \tau_3) \cong (\tau_1 \times (\tau_2 \times \tau_3))\) as identities on the chosen representative. - Empty products denote \(\mathbf{1}\) (a singleton;
EmptySetfor coproducts denotes \(\emptyset\)). - The
EmptySetconstructor incategorical.monoidalis the unit for \(+\).
Mac Lane's coherence theorem guarantees that any two parses of the same ObjectExpr denote equal finite sets in \(\mathbf{FinSet}\), not merely isomorphic ones, when the implementation uses the canonical flattened normal form.
6. Resolution in code¶
Both denotations are realized by a single unified walk on ObjectExpr in quivers.dsl.compiler.resolution. The mixin _ResolutionMixin exposes _resolve_any_space, which dispatches on the AST kind field and returns either a SetObject (for DiscreteConstructor / TypeName / ObjectProduct / ObjectCoproduct resolving to finite sets) or a ContinuousSpace (for ContinuousConstructor / TypeName / ObjectProduct resolving to continuous spaces, including mixed-domain ProductSpace instances such as Real(3) * Token where Token : 256 is a previously declared finite object). The narrowing wrapper _resolve_type constrains the result to the discrete stratum so callers that know they want a SetObject can demand one without re-encoding the constraint at every call site. The mixed-domain case is well-defined precisely because the inclusion \(\iota : \mathbf{FinSet} \hookrightarrow \mathbf{SBor}\) is a faithful functor preserving finite products.