Skip to content

2. Primitive Objects

This section defines the primitive DDSL-native objects – the atomic building blocks of the DDSL algebra. Following Backus' Functional Programming (FP) framework, we distinguish between primitive values and primitive function symbols, both of which are "objects" in the algebraic sense.

2.1 The Primitive Object Universe (\(\mathbb{O}_P\))

The primitive object universe is a disjoint union:

\[\mathbb{O}_P = \mathbb{O}_P^{\mathrm{num}} \sqcup \mathbb{O}_P^{\mathrm{fun}}\]

where:

  • \(\mathbb{O}_P^{\mathrm{num}}\) is the set of primitive numerical values (data atoms)
  • \(\mathbb{O}_P^{\mathrm{fun}}\) is the set of primitive function symbols (Backus objects denoting operations, constructors, and mathematical notation)

Both families are "primitive objects" in the DDSL sense, but they play fundamentally different roles: - Elements of \(\mathbb{O}_P^{\mathrm{num}}\) are data – they denote values directly. - Elements of \(\mathbb{O}_P^{\mathrm{fun}}\) are operators – they denote functions, constructors, or mathematical notation that produce or transform objects.

We write \(\llbracket \cdot \rrbracket\) for the denotation (meaning) function that maps DDSL primitive symbols to their mathematical counterparts.

2.2 Primitive Numerical Values (\(\mathbb{O}_P^{\mathrm{num}}\))

Primitive numerical values are atomic data elements with direct mathematical meaning.

Numeric Atoms

Numeric literals that denote specific mathematical values:

  • Real literals: 0.95, -3.14159, 2.718
  • Integer literals: 42, -7, 0
  • Rational literals (if supported): 1/3, 22/7

Examples: - \(\llbracket \texttt{0.95} \rrbracket = 0.95 \in \mathbb{R}\) - \(\llbracket \texttt{42} \rrbracket = 42 \in \mathbb{Z}\)

Logical Atoms

  • Booleans: true, false
  • \(\llbracket \texttt{true} \rrbracket = \top\), \(\llbracket \texttt{false} \rrbracket = \bot\)

String Literals

  • Quoted strings: "consumption", "asset"
  • Used for identifiers, labels, and documentation

TODO: Should string literals belong here? or somewhere else?

Summary BNF for \(\mathbb{O}_P^{\mathrm{num}}\)

PrimitiveValue ::=
    RealLiteral       -- e.g., 0.95, -3.14
  | IntegerLiteral    -- e.g., 42, -7
  | BooleanLiteral    -- true | false
  | StringLiteral     -- "..."

2.3 Primitive Function Symbols (\(\mathbb{O}_P^{\mathrm{fun}}\))

Primitive function symbols are Backus objects – symbols that denote operations, constructors, or mathematical notation. This family includes:

  1. Space constructors (nullary function symbols)
  2. Mathematical constructors (set, distribution, interval constructors)
  3. Arithmetic and relational operators
  4. DDSL decorators
  5. Method constructors (discretization, quadrature, solver schemes)
  6. Syntactic operators (structural tokens)

2.3.1 Space Constructors (Nullary Function Symbols)

These are nullary constructors whose denotations are mathematical spaces:

Symbol Denotation
R \(\llbracket \texttt{R} \rrbracket = \mathbb{R}\)
R_+ \(\llbracket \texttt{R\_+} \rrbracket = \mathbb{R}_+ = [0, \infty)\)
Z \(\llbracket \texttt{Z} \rrbracket = \mathbb{Z}\)
N \(\llbracket \texttt{N} \rrbracket = \mathbb{N} = \{0, 1, 2, \ldots\}\)
N1 \(\llbracket \texttt{N1} \rrbracket = \mathbb{N}_{>0} = \{1, 2, 3, \ldots\}\)
B \(\llbracket \texttt{B} \rrbracket = \{\top, \bot\}\)

Note: R_+\(\mathbb{O}_P^{\mathrm{fun}}\) is a primitive function symbol (a nullary constructor); it is not a numerical value. The distinction is: 0.95\(\mathbb{O}_P^{\mathrm{num}}\) denotes a number, while R_+\(\mathbb{O}_P^{\mathrm{fun}}\) denotes a space.

2.3.2 Mathematical Constructors

These are function symbols that construct spaces or distributions when applied:

Set Constructors: - subsetof: \(\llbracket \texttt{subsetof}(A) \rrbracket = \mathcal{P}(A)\) (powerset) - Interval: \(\llbracket \texttt{Interval}(a, b) \rrbracket = [a, b] \subset \mathbb{R}\) - Discrete: constructs finite discrete sets - powerset: alias for subsetof

Distribution Constructors: - Normal: \(\llbracket \texttt{Normal}(\mu, \sigma^2) \rrbracket = \mathcal{N}(\mu, \sigma^2)\) - Uniform: \(\llbracket \texttt{Uniform}(a, b) \rrbracket = \text{Uniform}(a, b)\) - LogNormal, Beta, Gamma, etc.

Type Constructors: - seq: sequence/list type constructor - bag: multiset type constructor - map: mapping type constructor - product: Cartesian product constructor - arrow: function type constructor

2.3.3 Arithmetic and Relational Operators

Core mathematical operators, treated as primitive function symbols:

Arithmetic: - +, -, *, /, ^ (exponentiation) - \(\llbracket \texttt{+} \rrbracket = (+) : \mathbb{R} \times \mathbb{R} \to \mathbb{R}\)

Relational: - =, <, >, <=, >=, !=

Mathematical Notation: - E (expectation operator) - argmax, argmin - sum, prod - sin, cos, exp, log, etc. (built-in functions)

2.3.4 DDSL Decorators

Decorators are primitive function symbols that control DDSL interpretation:

Decorator Denotation / Role
@def Definition operator: \(\llbracket \texttt{@def} \rrbracket = {:=}\)
@in Membership declaration: \(\llbracket \texttt{@in} \rrbracket = {\in}\)
@mapsto Function mapping: \(\llbracket \texttt{@mapsto} \rrbracket = {\mapsto}\)
@constructed Specifies construction method
@schema Declares method schema

These are not primitive numerical values; they are operators in the DDSL interpreter algebra.

2.3.5 Method Constructors

Method constructors are intensional operators that specify computational procedures. They are primitive function symbols whose outputs (after calibration and representation) are non-primitive objects.

Grid Constructors: - !linspace: linear spacing - !logspace: logarithmic spacing - !chebyshev: Chebyshev nodes

Quadrature/Sampling Constructors: - !gauss-hermite: Gauss-Hermite quadrature - !monte-carlo: Monte Carlo sampling - !simpson: Simpson's rule integration

Solver Constructors: - !brentq: Brent's root-finding method - !golden-section: golden section search - !newton: Newton's method

Interpolation Constructors: - !linear, !cubic, !spline

The ! prefix marks these as method constructor symbols.

2.3.6 Syntactic Operators

Structural tokens used in DDSL expression formation:

  • : (return/binding)
  • ~ (distributional relation)
  • -> (function arrow in expressions)
  • [ ] (list formation)
  • { } (set/record formation)
  • ( ) (grouping and application)

These are primitive function symbols used by the DDSL parser and interpreter.

Summary BNF for \(\mathbb{O}_P^{\mathrm{fun}}\)

PrimitiveFunctionSymbol ::=
    -- Space constructors
    'R' | 'R_+' | 'Z' | 'N' | 'N1' | 'B' | 'String'
    -- Set/type constructors
  | 'subsetof' | 'powerset' | 'Interval' | 'Discrete'
  | 'seq' | 'bag' | 'map' | 'product' | 'arrow'
    -- Distribution constructors
  | 'Normal' | 'Uniform' | 'LogNormal' | 'Beta' | 'Gamma'
    -- Arithmetic operators
  | '+' | '-' | '*' | '/' | '^'
    -- Relational operators
  | '=' | '<' | '>' | '<=' | '>=' | '!='
    -- Mathematical notation
  | 'E' | 'argmax' | 'argmin' | 'sum' | 'prod'
  | 'sin' | 'cos' | 'exp' | 'log' | ...
    -- Decorators
  | '@def' | '@in' | '@mapsto' | '@constructed' | '@schema'
    -- Method constructors
  | '!linspace' | '!logspace' | '!chebyshev'
  | '!gauss-hermite' | '!monte-carlo' | '!simpson'
  | '!brentq' | '!golden-section' | '!newton'
  | '!linear' | '!cubic' | '!spline'
    -- Syntactic operators
  | ':' | '~' | '->' | '[' | ']' | '{' | '}' | '(' | ')'

2.4 From Primitive Function to Concrete Object

Method constructors undergo a staged transformation from abstract symbol to concrete computational object:

  1. Primitive Function Symbol: !linspace\(\mathbb{O}_P^{\mathrm{fun}}\)
  2. Schema (with symbolic settings): !linspace{n_points: n_x, bounds: [0, 1]}
  3. Here n_x is a parameter symbol (not yet a primitive value)
  4. Calibrated Schema: !linspace{n_points: 50, bounds: [0, 1]}
  5. After calibration, n_x → 50 where 50\(\mathbb{O}_P^{\mathrm{num}}\)
  6. Represented Object: NumPy array [0.0, 0.02, ..., 1.0]
  7. A non-primitive computational object

Key Point: The method constructor !linspace is a primitive function symbol in \(\mathbb{O}_P^{\mathrm{fun}}\). Its output after representation is a non-primitive object (an array) not in \(\mathbb{O}_P\).

2.5 Closure Properties

The primitive object universe admits the following container constructions:

Value-Level Closure

\(\mathbb{O}_P^{\mathrm{num}}\) is closed under: - Finite tuples: \((a_1, \ldots, a_n)\) where each \(a_i \in \mathbb{O}_P^{\mathrm{num}}\) - Finite records: \(\{k_1: v_1, \ldots, k_n: v_n\}\) where each \(v_i \in \mathbb{O}_P^{\mathrm{num}}\) - Finite sets: \(\{a_1, \ldots, a_n\}\) where each \(a_i \in \mathbb{O}_P^{\mathrm{num}}\)

Mixed Container Closure

Container constructors allow forming structures whose elements may come from either \(\mathbb{O}_P^{\mathrm{num}}\) or \(\mathbb{O}_P^{\mathrm{fun}}\): - Schemas are records mixing numerical values and function symbols - Example: {method: !linspace, n_points: 50} combines a function symbol with a numerical value

Clarification: This closure is syntactic (container formation), not semantic. It does not imply operations like "union of functions" in a mathematical sense; rather, it allows finite collections containing objects from either family.

2.6 What Primitives Are NOT

Variables Are Not Primitives

Variables (e.g., xa, xv, w, a) are not elements of \(\mathbb{O}_P\). In the Backus framework, variables are part of the expression formation rules – they are pure syntactic binders, not objects in the algebra.

xa @in Xa
f: xa -> xa^2

Here: - Xa is a space constructor ∈ \(\mathbb{O}_P^{\mathrm{fun}}\) - xa is a variable bound by f (not a primitive, not a Backus object) - f is a function object using xa as a bound variable

Variables never become primitive objects; they remain syntactic placeholders.

Uncalibrated Parameters Are Not Primitives

A parameter is a symbol (e.g., β, γ, r) that is neither a decorator, nor a variable, nor a primitive function symbol. Parameters are not elements of \(\mathbb{O}_P\) until calibration assigns them values:

  • Before calibration: β is a symbol with a declared type (e.g., β @in R_+)
  • After calibration: β → 0.96 maps to 0.96\(\mathbb{O}_P^{\mathrm{num}}\)

The calibration process transforms parameter symbols into primitive numerical values.

2.7 Surface Syntax and Parsing Notation

This subsection addresses the parsing layer of the DDSL. The syntactic tokens listed here are primitive function symbols in \(\mathbb{O}_P^{\mathrm{fun}}\) (see §2.3.6); this section describes their role in surface syntax.

Structural Notation

Token Syntactic Role
: Binding/return: {x: y} binds x to y
[ ] Ordered list: [a, b, c]
{ } Set or record: {a, b} or {k: v}
( ) Grouping or application: f(x)
# Comment marker
" " String delimiter

Expression Formation

DDSL expressions are formed by combining primitive objects using syntactic operators. The DDSL interpreter maps syntactic expressions to their abstract syntax trees (ASTs) via the parsing function \(\rho\):

\[\rho : \text{SurfaceSyntax} \to \text{AST}\]

A DDSL syntactic sequence represents a functional expression. Composition of expressions follows implicit function composition rules (to be formalized in §3).


Summary: The primitive object universe \(\mathbb{O}_P = \mathbb{O}_P^{\mathrm{num}} \sqcup \mathbb{O}_P^{\mathrm{fun}}\) partitions into primitive numerical values (data atoms) and primitive function symbols (Backus objects). All mathematical notation, constructors, operators, and method symbols belong to \(\mathbb{O}_P^{\mathrm{fun}}\), even when their denotations are sets or distributions. Variables and uncalibrated parameters are not primitives.