Docs / AI Agents / Expression Schema

Expression Schema

The canonical JSON Schema for the Modellus expression language — the LaTeX-based mathematical notation used inside Expression shapes. Covers statement types, operator precedence, built-in functions, and AST node definitions.

View the full Expression Schema JSON — JSON Schema (Draft-07), 1331 lines.

Overview

The expression field of each ExpressionShape stores a \displaylines{} LaTeX block. Lines are separated by \\. Each line is parsed as one statement by the LatexMath grammar.

Statement Types

KindPatternTerm Type Produced
differential\frac{dx}{dt} = exprDIFFERENTIAL — requires initial value
functionname = exprPARAMETER (constant RHS) or FUNCTION (depends on other terms)
functionSubscriptx_{n} = f(x_{n-1})RECURRENCE — discrete-time iteration
functionSubscriptDigitx_0 = valuePARAMETER — initial/reference value
functionIndependentf(t) = exprFUNCTION — explicit argument form
conditionalname = \begin{cases}...\end{cases}FUNCTION — piecewise definition (≥ 2 rows)
displayexpr (no assignment)None — visual display only

Expression Nodes (AST)

The right-hand side of any statement is a MathExpr — a tree of these node types:

NodeDescriptionExample LaTeX
BinaryOpTwo operands with operator (+, -, ·, /)a + b
UnaryMinusNegation prefix-x
PowerExponentiationx^{2}
FractionDivision as \frac{}{}\frac{a}{b}
SqrtSquare root\sqrt{x}
FunctionCallBuilt-in function application\sin\left(x\right)
ComparisonRelational operatorx > 0
Logical\lor or \landa \lor b
TermReferenceReference to a named termv, \omega
NumberLiteralNumeric constant9.8
Constant\pi or e\pi
DeltaFinite difference operator\Delta x
SubscriptRefSubscript term accessx_{n-1}
AbsoluteAbsolute value bars|x|

Built-in Functions

CategoryFunctions
Trigonometric\sin, \cos, \tan, \cot, \sec, \csc
Inverse Trig\arcsin, \arccos, \arctan
Hyperbolic\sinh, \cosh, \tanh
Logarithmic\ln, \log
Two-argument\max(a,b), \min(a,b), \mod(a,b)
Utilitysign(x), rnd(x), irnd(x), int(x), round(x)
Other\det(x), \sqrt{x}

Operators & Precedence

PrecedenceOperatorsAssociativity
1 (lowest)\lor, \landLeft
2=, >, <, \ge, \le, \neqLeft
3+, -Left
4\cdot, /, implicit multiplicationLeft
5 (highest)^{}, \sqrt{}Right

LaTeX Templates

The schema includes a latexTemplates section providing ready-to-use LaTeX strings for common patterns that agents can emit directly into expression fields.

Name Tokens

Term names follow two patterns: