Syntax and Symbol Dictionaries

The MathJSON format is independent of any source or target language (LaTeX, MathASCII, etc…) or of any specific interpretation of the symbols used in a MathJSON expression ("Pi", "Sin", etc…).

A syntax dictionary defines how a MathJSON expression can be expressed into a specific target language (serialization) or constructed from a source language (parsing).

It includes definitions such as:

  • "The Power function is represented as "x^{n}""
  • "The Divide function is represented as "\frac{x}{y}"".

A symbol dictionary defines the vocabulary used by a MathJSON expression. This dictionary is independent of the syntax used to parse/serialize from another language but it defines the meaning of the symbols used in a MathJSON expression.

An entry in a symbol dictionary includes information necessary to correctly interpret it.

For example:

  • "Pi is a transcendental number whose value is approximately 3.14159265…"
  • "The Add function is associative, commutative, pure, idempotent and can be applied to arbitrary number of Real or Complex numbers".


A domain is similar to a type in a traditional programming language.

The domain of a symbol provides some contextual information about this symbol, for example: "x is a positive integer".

The codomain of a function indicates the set of values that a function maps to, or the domain of the "result" of the function.

Each entry in the symbol dictionary indicate the domain of the symbol, and for functions its codomain.


A MathJSON function such as Add, Sin or Equal can be used for a variety of purposes. It can be helpful to classify them in some broad categories:

inert The result of evaluating an inert function is the function and its arguments. This is more useful than it sounds: it can be used to ‘tag’ an input an indicate how it should be interpreted. Examples: Hold Evaluate Complex LatexString
constructor A function that takes a variety of inputs and return a new kind of object. Examples: Symbol String Interval Range
numeric A function whose arguments and return value are all numeric. Examples: Add Sin Exp Sqrt
predicate A predicate function returns a boolean. It can evaluate if a proposition is true or false. Examples: Equal IsPrime
logical A predicate whose arguments are also booleans. Examples: And Not Or

Customizing the Dictionaries

To define a custom syntax, provide custom syntax and custom symbol dictionaries when creating a ComputeEngine instance.

If no custom dictionaries are provided, the default ones are used. They are organized by topic as follow:

Arithmetic Add Multiply
Calculus Derive Integrate
Collections Sequence List Dictionary Set
Core Missing Nothing None All Identity InverseFunction LatexTokens
Logic And Or Not
Sets Union Intersection
Special Functions Erf Gamma Factorial
Trigonometry Cos Sin Tan