6. Representation Maps¶
This section defines the two fundamental semantic maps in the DDSL: the mathematical meaning map (Υ) and the computational representation map (ρ). These maps connect syntax to semantics and provide the bridge between mathematical theory and numerical computation.
6.1 The Two Meaning Maps¶
The DDSL uses two distinct maps to connect syntactic objects to their meanings:
Overview¶
| Map | Domain | Codomain | Purpose |
|---|---|---|---|
| Υ (Upsilon) | Syntactic objects | Mathematical objects | Platonic interpretation |
| ρ (rho) | Methodized + calibrated syntax | Numerical/AST objects | Computational realization |
These maps serve different purposes and operate at different stages of the pipeline:
Syntactic Stage ──Υ──> Mathematical Model (Platonic)
│
↓ M (methodization)
Methodized Stage ──────────────────────────────────────
│
↓ C (calibration)
Calibrated Stage ──ρ──> Numerical/AST (Computational)
6.2 The Mathematical Meaning Map (Υ)¶
Definition¶
Definition (Mathematical Meaning Map): $$ \Upsilon : \mathbb{S} \times \mathbb{C}_{\text{param}} \to \mathbb{DM} $$ is a map from syntactic stages (with parameter calibration) to mathematical dynamic-model operators.
The map Υ assigns to each syntactic construct its Platonic mathematical interpretation.
Key Properties¶
- Acts on syntax: Takes DDSL function objects and stages
- Can use parameters: Parameters define the mathematical problem
- Does NOT need methods or settings: The mathematical object exists independently of numerical approximation
- Produces true mathematical objects: Functions, operators, distributions in their idealized form
Υ on Different Object Types¶
Spaces¶
Spaces map to mathematical spaces (measurable spaces, subsets of \(\mathbb{R}^n\), etc.).
Functions¶
where \(\mathcal{V}(X)\) is a function space (e.g., bounded measurable functions on \(X\)).
Distributions¶
where \(\mathcal{P}(X)\) is the space of probability measures on \(X\).
Movers (Operators)¶
where \(\mathcal{A}(X)\) is the space of policy functions.
Registry Operators¶
Example: Buffer-Stock Arrival Mover¶
Under Υ, this becomes the mathematical operator:
where:
This is the true mathematical operator, not an approximation.
6.3 The Computational Representation Map (ρ)¶
Definition¶
Definition (Computational Representation Map): $$ \rho : (\mathbb{S}, \mathcal{M}, \mathbb{C}) \to \mathbb{F}^{\text{COMP}} $$ is a map from methodized and calibrated stages to computational representations (ASTs, numerical objects).
The map ρ transforms abstract specifications into an executatable representation.
Key Properties¶
- Requires methodization: Cannot construct numerical representation without knowing which algorithms to use
- Requires full calibration: All parameters AND settings must have values
- Uses the operator registry: Each registry operator maps to a specific implementation based on its method
- Produces primitive numerical objects: Grids, arrays, interpolators, solvers
Prerequisites for ρ¶
ρ can only be applied after: 1. Methodization \(\mathcal{M}\): Schemes attached to all operators 2. Parameter calibration \(\mathbb{C}_{\text{param}}\): Economic parameters have values 3. Settings calibration \(\mathbb{C}_{\text{settings}}\): Numerical settings have values
ρ on Different Object Types¶
Spaces → Grids¶
# DDSL
Xa @def R+
# With settings: grid_min_xa = 0.1, grid_max_xa = 10.0, n_xa = 50
# Under ρ
ρ(Xa) = {
type: "Grid1D",
points: numpy.linspace(0.1, 10.0, 50),
n_points: 50,
bounds: (0.1, 10.0)
}
Functions → Interpolators/Arrays¶
# DDSL
Va: Xa -> R @constructed{interpolation}
# With method: !linear, grid_size: n_xa = 50
# Under ρ
ρ(Va) = LinearInterpolator(
grid=ρ(Xa).points,
values=numpy.zeros(50), # initialized
extrapolation='clip'
)
Movers → Computational Operators¶
Note: the @methods: {...} line below is shown as a compact methodized-stage annotation to explain the ρ-map. In the three-file architecture, the authored stage.yml is purely symbolic and contains no @methods; these attachments come from methodization.yml.
# DDSL
B_arvl: Vv -> Va @via |
xv = g_av(xa, w)
Va(xa) = E_w[Vv(xv)]
@methods: {E_w: !gauss-hermite(n_nodes=5), Va: !linear}
# Under ρ
ρ(B_arvl) = def arrival_backward_operator(Vv_interp):
nodes, weights = gauss_hermite(5, mean=μ_w, std=σ_w)
Va_values = numpy.zeros(n_xa)
for i, xa in enumerate(grid_Xa):
Va_values[i] = sum(
w * Vv_interp(g_av(xa, node))
for node, w in zip(nodes, weights)
)
return LinearInterpolator(grid_Xa, Va_values)
Kernel reminder: g_av is a transition kernel (a pure function object). The methodization-relevant pieces here are the operator instances (E_w, APPROX/interpolation) needed to evaluate the mover under ρ.
Registry Operators → Implementations¶
| Registry Operator | Method | ρ Implementation |
|---|---|---|
E_w |
!gauss-hermite(n=5) |
numpy.polynomial.hermite.hermgauss(5) + weighted sum |
E_w |
!monte-carlo(n=1000) |
numpy.random.normal(size=1000) + sample mean |
argmax |
!golden-section(tol=1e-6) |
scipy.optimize.golden(..., tol=1e-6) |
argmax |
!grid-search(n=100) |
Exhaustive search over 100 points |
~ (draw) |
!simulate(seed=42) |
numpy.random.default_rng(42).normal(...) |
6.4 The Numerical Meaning Function (Lookup Table)¶
The numerical meaning function (or lookup table) records the concrete numerical instantiation of each symbol under a given calibration.
Definition¶
Definition (Numerical Meaning Function): $$ \nu : \mathbf{SYM} \times (\mathcal{M}, \mathbb{C}) \to \mathbb{O}_P^{\text{num}} $$ maps each symbol to its concrete numerical instantiation.
Structure¶
For each syntactic symbol, ν records:
numerical_meaning = {
# Spaces → Grids
'Xa': {
'type': 'grid',
'points': array([0.1, 0.3, ..., 10.0]),
'n_points': 50,
'bounds': (0.1, 10.0)
},
# Parameters → Values
'β': {'type': 'scalar', 'value': 0.96},
'γ': {'type': 'scalar', 'value': 2.0},
# Settings → Values
'n_xa': {'type': 'integer', 'value': 50},
'tol': {'type': 'float', 'value': 1e-6},
# Functions → Interpolators
'Va': {
'type': 'interpolator',
'grid': reference_to('Xa'),
'values': array([...]),
'method': 'linear'
},
# Operators → Callables
'E_w': {
'type': 'quadrature',
'method': 'gauss-hermite',
'nodes': array([...]),
'weights': array([...])
},
# Movers → Functions
'B_arvl': {
'type': 'operator',
'implementation': callable_function,
'input_type': 'interpolator(Xv)',
'output_type': 'interpolator(Xa)'
}
}
Usage in Runtime¶
The numerical meaning function serves as the runtime symbol table:
class NumericalMeaningTable:
def __init__(self, stage, methodization, calibration):
self.table = {}
self._build_table(stage, methodization, calibration)
def lookup(self, symbol):
"""Return numerical object for symbol."""
return self.table[symbol]
def lookup_grid(self, space_symbol):
"""Return grid points for a space."""
return self.table[space_symbol]['points']
def lookup_operator(self, operator_symbol):
"""Return callable for an operator."""
return self.table[operator_symbol]['implementation']
6.5 Relationship Between Υ and ρ¶
The Approximation Gap¶
The mathematical object under Υ and the numerical object under ρ are not equal:
The numerical representation is an approximation of the mathematical object.
Diagram¶
Υ
Syntax ─────────────────> Mathematical Object (true)
│ ↑
│ M │ limit
↓ │
Methodized ──────────────────────│
│ │
│ C │
↓ │
Calibrated ───────> ρ ───> Numerical Object (approximate)
Sources of Approximation¶
| Component | Mathematical (Υ) | Numerical (ρ) | Approximation |
|---|---|---|---|
| Space | \(\mathbb{R}_+\) | Grid of 50 points | Discretization |
| Function | \(V: X \to \mathbb{R}\) | Interpolant over grid | Interpolation error |
| Expectation | \(\int f \, d\mu\) | Weighted sum over nodes | Quadrature error |
| Optimization | \(\arg\max\) | Numerical search | Optimization tolerance |
Equality in the Limit¶
Under appropriate assumptions:
More precisely: - As grid resolution increases: interpolation error → 0 - As quadrature nodes increase: integration error → 0 - As optimization tolerance decreases: optimization error → 0
6.6 Primitive Numerical Objects¶
What Are Primitive Numerical Objects?¶
The numerical layer is built from primitive numerical objects (\(\mathbb{O}_P^{\text{num}}\)):
- Integers: Indices, counts, grid sizes
- Floats: Real values, coefficients
- Arrays: Vectors of integers or floats
- Finite sets: Index sets
Representation of "Real" Values¶
Mathematical real numbers are represented as: - Grid point values: Floats associated with integer indices - Coefficients: Interpolation coefficients - On-the-fly: Computed by evaluating AST expressions
Example: Function Representation¶
A function \(V: X \to \mathbb{R}\) is represented as:
- Grid: Array of floats [x_0, x_1, ..., x_n]
- Values: Array of floats [V(x_0), V(x_1), ..., V(x_n)]
- Interpolator: Callable that computes \(V(x)\) for any \(x\) using the grid and values
6.7 Agreement Conditions¶
Value Function Agreement¶
For any value function \(V\) and its representation \(\rho(V)\):
where \(h\) is the grid spacing and \(\epsilon_{\text{interp}}\) is the interpolation error bound.
Operator Agreement¶
For any mover \(\mathbb{B}\) and its representation \(\rho(\mathbb{B})\):
where \(\epsilon_{\text{op}}\) combines: - Input approximation error - Operator approximation error (quadrature, optimization) - Output approximation error (interpolation)
Distribution Agreement¶
For distributions, agreement is measured via Wasserstein distance:
6.8 The Methodized Uncalibrated Layer¶
Between Υ and ρ there exists an intermediate layer:
Definition¶
Definition (Methodized Uncalibrated Stage): A methodized uncalibrated stage \((\mathbb{S}, \mathcal{M})\) has: - Symbolic operators with schemes attached - Parameters may or may not have values - Settings remain symbolic
Properties¶
At this intermediate layer: - We can talk about approximate operator families (e.g., "Gauss-Hermite expectation") - We know the algorithmic structure but not the concrete numbers - This allows reasoning about convergence rates and error bounds parametrically
Example¶
We know:
- The expectation uses Gauss-Hermite quadrature
- The error is \(O(n_{\text{nodes}}^{-k})\) for some \(k\) depending on smoothness
- But we don't yet know the concrete value of n_nodes
6.9 Summary¶
The representation maps provide:
- Υ (Mathematical meaning):
- Maps syntax to Platonic mathematical objects
- Can use parameters (they define the math problem)
- Independent of numerical methods
-
Produces the "true" operators and functions
-
ρ (Computational representation):
- Maps methodized + calibrated syntax to numerical objects
- Requires methodization (which algorithms)
- Requires calibration (which values)
-
Produces executable ASTs and primitive numerical objects
-
Numerical meaning function ν:
- Lookup table for runtime symbol resolution
- Records concrete instantiation of each symbol
-
Used by execution engine
-
Key relationships:
- \(\rho \neq \Upsilon\) (numerical ≠ mathematical)
- Equality only in the limit
- Methodization sits between Υ and ρ
This two-map architecture ensures: - Mathematical precision: Clear semantics under Υ - Computational tractability: Concrete algorithms under ρ - Explicit approximation: Known gap between math and numerics - Convergence guarantees: Numerical solutions approach true solutions