Skip to content
An Econ-ARK project

Bellman-SYM concepts

Summary

A model is written as stages, which are joined into periods and a trellis. Bellman-SYM elaborates the stage files into a semantic graph, a record of the model's operations and of their mathematical meaning that a person and a machine can read and that depends on no solver. The graph makes solver code verifiable, since every routine has a stated mathematical operation to compute, and a change of numerical method leaves the stage files unchanged.

Bellman-SYM is a highly expressive declarative functional programming system for dynamic recursive problems.

1 Bellman-SYM

Consider a household that arrives with assets, receives income, chooses consumption, and saves what remains. In Bellman-SYM, this decision problem is written as a modular stage in a stage file, a .bl file. Although an economist first describes the problem as relations between economic quantities such as consumption and income, its solution and simulation are higher-order operations, that is, operations on functions rather than on numbers. In the Bellman equation of such a problem, for instance, the expected continuation value function is combined with current utility and maximized over the feasible choices to obtain the decision value function. These operations define the stage's Bellman operator, but how they compose, and the numerical assumptions under which they are approximated, are usually left implicit or embedded in numerical procedures.

Bellman-SYM makes the structure of solution and simulation explicit through elaboration, which turns the stage files into a semantic graph that depends on no solver and that a person and a machine can both read. The semantic graph is a typed record of the meaning of the written model: it records the functional operations, the mathematical objects on which they act and which they produce, and how they compose3 (in the terms of universal algebra, a many-sorted algebra2). The map that takes the stage files to their elaborated meaning is what we call the meaning map, Υ (Upsilon, see Figure 1). The graph is then a single source from which the model can be implemented, in different numerical implementations and under different calibrations and settings, or its theoretical structure written out.

Drawn in the axonometric manner of the modularity figure. At the left, you, drawn as the Adam Smith avatar; you write the stage files, a pile of sheets. Elaboration, the meaning map Upsilon, turns them into the semantic graph, a platform carrying the stage's two operators as boxes on a wire between its three perches, inside a region marked as the meaning, the model stated in full. The graph's denotations give the formal mathematics, a sheet above the files with the Bellman equation and the law of motion on it, which you read back. Compiled by Rho, on whose arrow the AI sits, inside a band marked outside Bellman-SYM, it gives code, a fan of three tiles named HARK, Dolo and QuantEcon. You write V(m) = maxcu(c) + β E V′(m′)m′ = R(m − c) + y′ denotations read Formal math Stage files Υ elaborate the meaning ≅ the model, stated in full x≺ x x≻ Semantic graph outside Bellman-SYM AI Ρ compile HARK Dolo QuantEcon Compiled code
Figure 1. The meaning map Υ: elaboration turns the stage files into the semantic graph, whose denotations are the formal mathematics; the representation map Ρ (Rho) compiles the graph into code, a step outside Bellman-SYM.

Expressive power

Bellman-SYM can express recursive decision processes in the sense of Sargent and Stachurski,4 a class of dynamic programs more general than Markov decision processes. It includes life-cycle and infinite-horizon models, models with discrete choices and branches, and the individual problems of heterogeneous-agent models together with the distributions they generate.

2 Modularity

A stage represents a single decision problem as a Bellman operator, that is, as one recursive program. In the household's consumption and saving problem, the stage states what the household knows before its income is drawn, what it learns when the income is realized, what it chooses, and how its continuation value is formed. The three points at which its information is fixed, arrival, decision and continuation, are the stage's perches.

The internal structure of a stage follows the information available within its decision problem, not the model around it: a stage is a self-contained program that refers neither to the rest of the model nor to its position in time. Modularity requires repeated declarations to retain their operators and calibration sources. Stages join into a period, one step of the horizon, such as one year of a life cycle, and a trellis is a diagram of periods joined by connections. With compatible inputs and outputs, stages can be rearranged, replaced or reused to form different models, so a richer model is built by adding stages to an existing one rather than by rewriting it. A stage receives what differs between periods as a field. Age, for example, can be a constant value-type field, typed !vlu @ !cnst, computed from the next period's age. The user supplies its terminal value when realizing the model. A fixed table or function gives income at that age. A trellis position is only an address: no stage or period file takes it as an argument that adjusts a parameter. Recipes nevertheless permit calibration, methods and settings to be selected by position; the package does not enforce modularity. Methods and settings lie outside that condition.

Three axonometric drawings of the housing tenure model, left to right. Stochastic decision stages: six loose modules named on their front faces, tenure choice, owner housing, owner consumption, renter housing, renter consumption and portfolio choice, each with a green square socket at its arrival end and a cyan peg at its continuation end; the tenure choice carries two pegs, one for owning and one for renting, and the portfolio choice two sockets. Period: a plate on which the modules are assembled, the tenure choice first, then the owner's two stages in one lane and the renter's two in another, with a thin line over the top faces tracing the two routes and a peg seated in a socket at every seam; four modules are lowered into place one after another, and then, after a pause, the portfolio choice is lowered onto the period's end, where the two routes rejoin. Trellis: the life cycle, six of its twenty periods drawn, each a plate carrying a small copy of the period and each beginning on the last stage of the one before it, each level in its own shade of blue; the periods are lowered in one by one. The sequence plays once. tenurechoice ownerhousing ownerconsumption renterhousing renterconsumption portfoliochoice Stochastic decision stages Period Trellis
Figure 2. The housing tenure model assembled from its stages, with a period drawn as a plate: the tenure choice stage forks into an owner's lane and a renter's lane, a portfolio stage from another model is added where the lanes rejoin, and six of the twenty periods of the life cycle are stacked into the trellis.

3 Layers of meaning and computational representation

3.1 Specifying a stage

The semantic graph denotes the mathematical operations required to solve and simulate the model, and a numerical implementation must approximate them. Bellman-SYM lets you declare the numerical assumptions explicitly as methods, such as linear interpolation, Monte Carlo simulation and the endogenous grid method.1 Because the theory of the stage is written first and the methods are declared separately, the same stage can be implemented in different toolkits and with different numerical approaches, and each implementation can be checked against the mathematical model that it approximates.

Each method is declared in a methods file and attached to a place in the stage: to a whole block, as the endogenous grid method is attached to the policy block; to an operation inside a block, as a quadrature rule is attached to an expectation; or to a named function that is to be stored, as linear interpolation is. The numerical options of a method, such as the size of a grid, are its settings, whose values are supplied separately.

Settings are distinct from the model's parameters, the exogenous economic quantities that enter its theoretical description rather than its numerical methods. Parameter values are also supplied separately from the symbolic model, so that the theoretical model, its calibration and its numerical approximation remain distinct. Even without parameter values, methods or settings, elaboration produces a symbolic stage, whose semantic graph represents the theory with the parameters left symbolic. The stage is then specified by attaching methods through methodization, supplying parameter values through calibration, and supplying their settings through configuration. The stage API also permits calibration before methodization, the order retained by the trellis factory (Figure 3).

Three axonometric drawings: symbolic stage plus specifications gives the specified stage. Symbolic stage: the block of the modularity figure, with its green arrival socket, its cyan continuation peg and two square pads on top, its two operators. Specifications: three separate groups of scattered pieces, four short plugs marked beta, rho, R and sigma, labelled parameter values, in the stage's navy; four tapered blocks named on their faces EGM, VFI, linear and Gauss-Hermite, labelled methods, in a middle blue; three dials with a flange and a pointer, labelled settings, in a light blue. Specified stage: the block with the plugs in its front face, the Gauss-Hermite and EGM blocks on its two pads, and a dial on each; the plugs slide into the face, then the methods and then the dials are lowered into place, once. Symbolic stage β R ρ σ parameter values EGM linear VFI Gauss-Hermite methods settings Specifications Gauss-HermiteEGM Gauss-HermiteEGM Specified stage +
Figure 3. Calibration, methodization and configuration supply the three bindings, in the order retained by the trellis factory. Stage binding verbs change the stage in place; trellis binding verbs return separate occurrences and preserve the earlier trellis. Parameter values define the economic problem; methods and settings define its numerical treatment.

3.2 From semantics to code

Once a stage has been specified, you can use its semantic graph to assemble code that solves and simulates the model. This step, realization, is the representation map Ρ (Rho) of Figure 1, and it lies outside Bellman-SYM. The graph identifies the mathematical operation that each routine must implement, the method chosen for it, and how its inputs and outputs connect to the rest of the calculation, so you can draw on the routines of an existing toolkit or write your own while keeping an explicit account of the model that they are intended to approximate.

The Rosetta stone supports this step by recording which operations and methods are realized by routines in toolkits such as HARK, Dolo and QuantEcon, together with the conventions under which each correspondence holds. Its cards are being rebuilt one at a time from routines that have been checked.

3.3 Matsya

Project Bellman's AI assistant, matsya, which is to draft stage files from a prose description and to assemble solver code from the semantic graph and the Rosetta stone, is not part of this release; its page returns when it is written.

4 Workflow

The workflow separates the description of the economic problem from the choices made to compute its solution.

  1. Write the stages. Describe each decision problem in a stage file, stating its timing, information, choices and equations, and state how the stages join into periods and how the periods form the model's trellis.
  2. Elaborate and inspect the model. Bellman-SYM produces a semantic graph that makes the functional operations and their composition explicit. The resulting symbolic stage lets you check the mathematical problem before supplying parameter values, numerical methods or settings.
  3. Specify the stages. For one stage, attach numerical methods through methodization, supply parameter values through calibration, and supply their settings through configuration. The trellis factory retains calibration before methodization. Each step adds its binding to the stage; the specified stage, the stage after the three, records the choices needed for implementation but is not yet solver code.
  4. Realize and check the model. Implement the graph's operations with routines from the chosen toolkit or with your own code, and compose them to solve and simulate the model. Then check the numerical approximation against the mathematical description that the graph retains.

  1. Carroll, C. D. (2006). The method of endogenous gridpoints for solving dynamic stochastic optimization problems. Economics Letters, 91(3), 312–320. The end-of-period value function is equation (11), p. 314. ↩

  2. Goguen, J. A., Thatcher, J. W., Wagner, E. G. and Wright, J. B. (1977). Initial algebra semantics and continuous algebras. Journal of the ACM, 24(1), 68–95, §2, pp. 71–75. ↩

  3. Backus, J. (1978). Can programming be liberated from the von Neumann style? A functional style and its algebra of programs. Communications of the ACM, 21(8), 613–641, §12, pp. 625–630. ↩

  4. Sargent, T. J. and Stachurski, J. (2025). Dynamic Programming, Volume I: Finite States. Cambridge University Press, Chapter 8, "Recursive Decision Processes"; and Dynamic Programming, Volume II: General States, forthcoming, online draft edition at dp.quantecon.org, Chapter 7. ↩