Skip to content

BELLMAN-DDSL

A Domain-Specific Language for Modular Bellman Problems

Bridging Syntax, Mathematics, and Computation


Slide 1: The Reproducibility Problem

The Crisis in Computational Economics

Research code often conflates three distinct concerns:

Layer What it represents Typical state
Syntax What the modeler writes Ad-hoc, tool-specific
Mathematics The economic model Implicit in code
Computation Numerical implementation Entangled with model

Result: Models are hard to verify, compare, or extend.

"Is this code solving the model I think it is?"


Slide 2: The Mapping Gap

Three Worlds, No Clear Bridge

┌─────────────┐         ┌─────────────────┐         ┌─────────────────┐
│   SYNTAX    │   ???   │   MATHEMATICS   │   ???   │   COMPUTATION   │
│             │ ──────> │                 │ ──────> │                 │
│  YAML/Code  │         │ Bellman Operators│        │  Python/NumPy   │
└─────────────┘         └─────────────────┘         └─────────────────┘

Problems with ad-hoc approaches:

  • No formal semantics for model specification
  • Solver details leak into model definition
  • Mathematical properties not verifiable from code
  • Changing numerics requires rewriting models

Slide 3: Backus's Vision (1977)

"Can Programming Be Liberated from the von Neumann Style?"

John Backus proposed an algebra of programs:

Programs should be built from a small set of functional forms (combinators) that combine existing functions into new ones—without variables, with precise algebraic laws.

Key insight: Separate what from how

FP Concept DDSL Application
Objects States, values, policies
Functions Transitions, operators
Functional Forms Stage composition, expectations
Algebra Bellman operator laws

Slide 4: The DDSL Solution

Two Representation Maps

                    Υ (Upsilon)                      ρ (rho)
    ┌──────────┐ ──────────────────> ┌────────────┐ ──────────────> ┌─────────────┐
    │  SYNTAX  │    Mathematical     │    MATH    │  Computational  │    CODE     │
    │  (YAML)  │      Meaning        │ (Operators)│   Realization   │  (Python)   │
    └──────────┘                     └────────────┘                 └─────────────┘
         │                                                                │
         │                    methodize, calibrate                        │
         └────────────────────────────────────────────────────────────────┘
Map Domain → Codomain Purpose
Υ Syntax → Math Platonic interpretation (solver-independent)
ρ Calibrated Model → Code Numerical realization (grid-aware)

Υ defines meaning; ρ defines computation.


Slide 5: Stages and Perches

The ADC Information Structure

A stage is a modular unit with three perches (information sets):

         ┌─────────────────────────────────────────────────────┐
         │                      STAGE                          │
         │                                                     │
    ─────┼──▶ [ARRIVAL] ──g_ad──▶ [DECISION] ──g_de──▶ [CONT] ─┼──▶
         │      _arvl              _dcsn    ↑         _cntn    │
         │                                  │                  │
         │                         shock / choice              │
         └─────────────────────────────────────────────────────┘

Perches are information sets, not operator endpoints: - Arrival _arvl: What you know when entering - Decision _dcsn: Information available for choice - Continuation _cntn: Post-decision state


Slide 6: Composition via Functional Forms

Building Complex Models from Simple Pieces

Following Backus, DDSL uses functional forms for composition:

Form Notation DDSL Use
Composition f ∘ g Chain stages: cons ∘ noport
Construction [f, g] Parallel state updates
Apply-to-all α f Expectation over shocks
Insert / f Backward induction fold

Example: A period as stage composition

period:
  stages: [noport_stage, cons_stage]    # Sequential composition
  twister: {a: k}                       # Inter-period adapter

Periods compose into nests via twisters (rename maps).


Slide 7: The dolo-plus Pipeline

From Syntax to Solution

┌────────────────┐     ┌────────────────┐     ┌────────────────┐
│  Stage YAML    │     │   Methodized   │     │   Calibrated   │
│  (dolo-plus SYM)   │────▶│     Stage      │────▶│     Stage      │
│                │     │  + settings    │     │  + values      │
└────────────────┘     └────────────────┘     └────────────────┘
        │                                              │
        │ Υ                                            │ ρ
        ▼                                              ▼
┌────────────────┐                           ┌────────────────┐
│  Mathematical  │                           │   Compiled     │
│   Operators    │                           │  gufunctions   │
└────────────────┘                           └────────────────┘

Three functors transform stages: 1. Methodize: Attach solution scheme (grids, bounds) 2. Configure: Bind settings (grid sizes, tolerances) 3. Calibrate: Substitute parameter values


Slide 8: What DDSL Enables

Reproducibility Through Rigor

Capability How DDSL Achieves It
Model verification Υ maps syntax to mathematical objects with precise semantics
Solver independence Mathematical model exists before choosing numerics
Composability Stages combine via algebraic laws
Reproducibility Same syntax → same math → verifiable results

Practical benefits: - Swap solvers without changing models - Compare implementations against mathematical specification - Build model libraries with guaranteed composition - Automated verification of Bellman structure


Slide 9: Current Status & Next Steps

DDSL Implementation Progress

Component Status
Stage syntax (ADC perches) ✅ Complete
Decorators & calibration ✅ Complete
Methodization pipeline ✅ Complete
Period/nest instantiation 🔨 In progress
Stage → operator translation 🔨 In progress

Open questions: - Perch shift semantics (measurability vs representation) - Twister direction conventions - Adapter abstraction (adapter_intra / adapter_inter)

Resources: - GitHub: bright-forest/bellman-ddsl - Backus 1978: Can Programming Be Liberated?