Skip to content

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

  1. Acts on syntax: Takes DDSL function objects and stages
  2. Can use parameters: Parameters define the mathematical problem
  3. Does NOT need methods or settings: The mathematical object exists independently of numerical approximation
  4. Produces true mathematical objects: Functions, operators, distributions in their idealized form

Υ on Different Object Types

Spaces

\[ \begin{align} \Upsilon(\texttt{Xa @def R+}) &= \mathbb{R}_+ \\ \Upsilon(\texttt{W @def R}) &= \mathbb{R} \\ \Upsilon(\texttt{A @def Interval(a\_min, a\_max)}) &= [a_{\min}, a_{\max}] \subset \mathbb{R} \end{align} \]

Spaces map to mathematical spaces (measurable spaces, subsets of \(\mathbb{R}^n\), etc.).

Functions

\[ \begin{align} \Upsilon(\texttt{g\_av: Xa × W -> Xv}) &= \mathrm{g}_{\prec\sim} : \mathbb{R}_+ \times \mathbb{R} \to \mathbb{R}_+ \\ \Upsilon(\texttt{u: A -> R}) &= u : [a_{\min}, a_{\max}] \to \mathbb{R} \\ \Upsilon(\texttt{Va: Xa -> R}) &= V_{\prec} \in \mathcal{V}(X_{\prec}) \end{align} \]

where \(\mathcal{V}(X)\) is a function space (e.g., bounded measurable functions on \(X\)).

Distributions

\[ \begin{align} \Upsilon(\texttt{D\_arvl: Dist(Xa)}) &= \mu_{\prec} \in \mathcal{P}(X_{\prec}) \\ \Upsilon(\texttt{D\_w: Dist(W)}) &= \mu_w \in \mathcal{P}(W) \end{align} \]

where \(\mathcal{P}(X)\) is the space of probability measures on \(X\).

Movers (Operators)

\[ \begin{align} \Upsilon(\texttt{B\_arvl: [Xv -> R] -> [Xa -> R]}) &= \mathbb{I} : \mathcal{V}(X_{\sim}) \to \mathcal{V}(X_{\prec}) \\ \Upsilon(\texttt{B\_dcsn: [Xe -> R] -> [Xv -> R, Xv -> A]}) &= \mathbb{B} : \mathcal{V}(X_{\succ}) \to \mathcal{V}(X_{\sim}) \times \mathcal{A}(X_{\sim}) \end{align} \]

where \(\mathcal{A}(X)\) is the space of policy functions.

Registry Operators

\[ \begin{align} \Upsilon(\texttt{E\_w}) &= \mathbb{E}_w[\cdot] : \text{conditional expectation operator} \\ \Upsilon(\texttt{argmax\_\{a ∈ Γ(x)\}}) &= \arg\max_{a \in \Gamma(x)} : \text{optimization operator} \end{align} \]

Example: Buffer-Stock Arrival Mover

B_arvl: Vv -> Va @via |
    xv = g_av(xa, w)
    Va(xa) = E_w[Vv(xv)]

Under Υ, this becomes the mathematical operator:

\[ \Upsilon(\texttt{B\_arvl}) : V_{\sim} \mapsto V_{\prec} \]

where:

\[ V_{\prec}(x_{\prec}) = \mathbb{E}_w[V_{\sim}(\mathrm{g}_{\prec\sim}(x_{\prec}, w))] = \int_W V_{\sim}(\mathrm{g}_{\prec\sim}(x_{\prec}, w)) \, d\mu_w(w) \]

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

  1. Requires methodization: Cannot construct numerical representation without knowing which algorithms to use
  2. Requires full calibration: All parameters AND settings must have values
  3. Uses the operator registry: Each registry operator maps to a specific implementation based on its method
  4. 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:

\[ \rho(\mathcal{M}(\mathbb{S}), \mathbb{C}) \neq \Upsilon(\mathbb{S}, \mathbb{C}_{\text{param}}) \]

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:

\[ \lim_{\substack{n \to \infty \\ \text{nodes} \to \infty \\ \text{tol} \to 0}} \rho(\mathcal{M}(\mathbb{S}), \mathbb{C}_n) = \Upsilon(\mathbb{S}, \mathbb{C}_{\text{param}}) \]

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}}\)):

  1. Integers: Indices, counts, grid sizes
  2. Floats: Real values, coefficients
  3. Arrays: Vectors of integers or floats
  4. 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)\):

\[ |V(x) - \rho(V)(x)| \leq \epsilon_{\text{interp}}(h) \]

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})\):

\[ \|\mathbb{B}(V) - \rho(\mathbb{B})(\rho(V))\|_\infty \leq \epsilon_{\text{op}} \]

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:

\[ W_1(\mu, \rho(\mu)) \leq \epsilon_{\text{dist}} \]

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

Methodized B_arvl = (B_arvl, {E_w: !gauss-hermite(n_nodes)})

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:

  1. Υ (Mathematical meaning):
  2. Maps syntax to Platonic mathematical objects
  3. Can use parameters (they define the math problem)
  4. Independent of numerical methods
  5. Produces the "true" operators and functions

  6. ρ (Computational representation):

  7. Maps methodized + calibrated syntax to numerical objects
  8. Requires methodization (which algorithms)
  9. Requires calibration (which values)
  10. Produces executable ASTs and primitive numerical objects

  11. Numerical meaning function ν:

  12. Lookup table for runtime symbol resolution
  13. Records concrete instantiation of each symbol
  14. Used by execution engine

  15. Key relationships:

  16. \(\rho \neq \Upsilon\) (numerical ≠ mathematical)
  17. Equality only in the limit
  18. 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