Types and Spaces¶
This page gives the denotation of the syntactic categories TypeExpr (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 implemented as the forward direction of the dx.Lens family in quivers.dsl.resolution.
1. Syntactic categories¶
We assume the following grammar fragment, whose constructors are realised 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, and \(C \in \{\mathrm{Euclidean}, \mathrm{Simplex}, \mathrm{PositiveReals}, \mathrm{UnitInterval}\}\) 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\).
2. Denotation of types¶
Type denotation is a function
We omit the environment argument when it is clear.
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.
3. Free monoids¶
The runtime value layer exposes a FreeMonoid object class, which arises in the grammar fragment as the carrier of strings over an alphabet (see Grammar fragment). It does not have surface syntax in .qvr: free monoids are constructed at the value layer by grammar-rule and chart-parser combinators rather than declared by the user.
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 realised as a SetObject.
4. Denotation of spaces¶
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. 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 Euclidean(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 TypeExpr 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
ProductSetandCoproductSetrealise 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 TypeExpr denote equal finite sets in \(\mathbf{FinSet}\), not merely isomorphic ones, when the implementation uses the canonical flattened normal form.
6. Resolution as a lens¶
The map \(\llbracket \cdot \rrbracket_{\mathrm{Ty}}\) is realised in code as the forward component of TypeExprToSetObject(env), an instance of dx.Lens[TypeExpr, SetObject, TypeExpr]. The complement is the original TypeExpr AST node, so the backward direction recovers the unresolved syntax verbatim. Both round-trip laws hold by construction:
The same structure holds for SpaceExprToContinuousSpace, with codomain \(\mathbf{SBor} \cup \iota(\mathbf{FinSet})\) (the disjoint union of the two object classes, used to admit the mixed-domain fallback).