Language Reference

Formulative Formula Language Reference

Notation

Characters

Language Characters
Source Description / Comment
space, tab, carriage return, form feed Whitespace characters
0-9 Arabic numerals, used in number Literals, Date Literals, and Identifiers
a-z, A-Z Latin alphabet, used in Identifiers (and exceptionally, operators)
any character[1] allowed in string literals only
\ Escape character
!, $, %, ', @ Style selector before Identifiers and Literals (bold, roman, double-struck, sans-serif, sans-serif italic)
-- any characters up to end of line Line comment[2]
/* any text spanning multiple lines */ Block comment
" String delimiter
#, *, +, ,, -, /, :, ;, <, =, >, ^, _, |, ~ Operator characters[3]

Notes

[1]Except the following characters, which cannot occur literally (must be escaped): (U+0022 ” QUOTATION MARK), (U+005C REVERSE SOLIDUS), (U+0085 NEXT LINE), (U+00A0 NO-BREAK SPACE), (U+2028 LINE SEPARATOR), (U+2029 PARAGRAPH SEPARATOR)
[2]The two HYPHEN-MINUS characters must be followed by a space or a tab before the actual comment
[3]Some operators are composed of multiple characters, e.g. ##, **, /\, -->, etc.
Source Escapes
Source Description / Comment
\alpha, \beta, \gamma, …[5] Greek lowercase letters α, β, γ, etc.
\Alpha, \Beta, \Gamma, … Greek uppercase letters Α, Β, Γ, etc.[4]
\epsilon, \varepsilon Alternative forms of the letter epsilon: ε, ϵ[6]
\theta, \vartheta Alternative forms of the letter theta: θ, ϑ
\kappa, \varkappa Alternative forms of the letter kappa: κ, ϰ
\rho, \varrho Alternative forms of the letter rho: ρ, ϱ
\phi, \varphi Alternative forms of the letter phi: φ, ϕ
\\ Set minus operator
\/~ Root operator

Notes

[4]Some Greek capital letters are visually indistinguishable from Latin letters (as in the example, Greek capital Alpha looks the same as Latin capital A). These are supported but not recommended (because of the visual ambiguity created by using them)
[5]The escapes listed in this table can be used anywhere in the source except string literals
[6]These variant forms are treated as entirely different characters, so e.g. ε and ϵ are two different Variables.

Identifiers

Identifiers are grouped by font style, which have semantic meaning in mathematical text. The default style is serif, italic, light. Other styles are noted. “normal” style is used for non-letter characters, which cannot be styled.

Variable Identifiers
Source Display Description / Comment
a, b, C, D
a , b , C , D
Single letter, italic lower or uppercase
myVariable
myVariable
Multiple letters also possible, but not recommended
!u, !v, !W
u , v , W
Bold italic as an alternative[7]
x___ x^*
x _ , x
Underline and Asterisk (“star”) embellishments[8]
x', x''
x , x
Primes[8], up to 4 primes supported
x^^->, x^^^, x^^~
x , x ^ , x ~
Arrow, circumflex (“hat”), and tilde embellishments[8]
x_'min, x_'max
x min , x max
Subscript keyword embellishment[8]
x^'last, x^'next
x last , x next
Superscript keyword embellishment[8]
!x___^^^_'sub^'sup
x _ ^ sub sup
Formatting and embellishments can be combined
x_1, x_2, x_n
x 1 , x 2 , x n
Numeric index is not an embellishment, but an index[9]

Notes

[7]bold variables are distinct from the light version, so x and x are two distinct Variables
[8](1, 2, 3, 4, 5) embellishments are “decorations” and create a distinct new Variable, so x and x are two distinct Variables
[9]indexed access targets a Slot of a “group” Variable, informally denoted by x . Each such Slot acts as a container on its own.
Built-in Mathematical Identifiers
Source Display Description / Comment
%Z, %N, %R, %C
Z , N , R , C
Double-struck (blackboard bold): Primitive Domains
~|~
Logical true
_|_
Logical false
00
Infinity
/0
Empty set
Standard Library Identifiers
Source Display Description / Comment
$e, $i, $\pi
e , i , π
(Roman) constants: Euler’s number, imaginary unit, π
$I_n
I n
indexed constant: n × n identity matrix
$!0_n, $!0_{n,m}
0 n , 0 n , m
(Roman, bold) indexed constant: zero vector in n dimensions, zero n by m Matrix
$kg, $mm, $s
kg , mm , s
(Roman) Unit identifiers
$!L, $!M, $!T
L , M , T
(Roman, bold) Dimension identifiers
$!year, $!h, $!d
year , h , d
(Roman, bold) Base Calendar duration identifiers
$abs, $sgn, $sin
abs , sgn , sin
(Roman, bold) Library Functions
$log_n, $round_k
log n , round k
(Roman, bold) “Parametrized” Functions[10]

Notes

[10]the “parameter” is part of the definition of the function. When invoking the function, the argument of the function must be supplied separately, e.g. y = log a x
Other Identifiers
Source Display Description / Comment
'key1, 'myKey
key1 , myKey
Sans-serif: Keyword identifier
@A, @B, @C
A , B , C
Sans-serif italic: Resource identifier

Primitives

Numbers

Number Literals
Source Display Description / Comment
123
123
Integer literal
123.456
123.456
Decimal literal
1.23 * 10^45
1.23 10 45
Scientific notation
00
Positive infinity on the extended real number line
1/2
1 2
Fraction
1.23 + 4.56 $i
1.23 + 4.56 i
Complex
-123
123
Negative sign, may require parentheses in expressions, e.g. 1 k
-1.23 * 10^{-45}
1.23 10 45
Negative exponent, requires { } grouping fences around value
-00
Negative infinity on the extended real number line
-1 / 2
1 2
Negative fraction
-1.23 - 4.56 $i
1.23 4.56 i
Negative real / imaginary part in a complex number
Number Arithmetic
Source Display Description / Comment
a + b
a + b
Addition
a - b
a b
Subtraction
a b
a b
Multiplication
a * b
a b
Multiplication, (alternative form, with operator visible)
a / b
a b
Division, normally denoted by a fraction bar; either numerator or denominator may require { } grouping fences around expression
a // b
a b
Inline division, an alternative form
{+}__{i=1}^^n a_i
i = 1 n a i
Sum with lower & upper bound; binds local variable i
{+}__{x (- S} x
x S x
Sum with a collection (set S ) binding a local variable x
{+} {{a_1, ..., a_n}}
a 1 , , a n
Sum with no limits, sums elements of a set
{*}__{i=1}^^n a_i
i = 1 n a i
Product with lower & upper bound, binds local variable i
{*}__{x (- S} x
x S x
Product with a collection (set S ) binding a local variable x
{*} {{a_1, ..., a_n}}
a 1 , , a n
Product with no limits, multiplies elements of a set
a ^ p, b ^ {n+1}
a p , b n + 1
Exponentiation, exponent may require { } grouping fences around an expression
\/~ a, \/~ {x + y}
a , x + y
Square root. Radicand may require { } grouping fences around an expression
n \/~ a, n\/~ {x + y}
a n , x + y n
_n_th root. Index & Radicand may require { } grouping fences around an expression
$sgn a
sgn a
Signum (sign) of a real number, sgn a = 1 a > 0 0 a = 0 1 a < 0
$inf S
inf S
Infimum of a set of real numbers S : greatest lower bound (or ) of the set
$sup S
sup S
Supremum of a set of real numbers S : smallest upper bound (or + ) of the set
$min S
min S
Minimum of a set of real numbers S
$min (a_1, ..., a_n)
min a 1 , , a n
Minimum of real numbers
$max S
max S
Maximum of a set of real numbers S
$max (a_1, ..., a_n)
max a 1 , , a n
Maximum of real numbers
$sum S
sum S
Sum of a set of real numbers S
$sum (a_1, ..., a_n)
sum a 1 , , a n
Sum of real numbers
$prod S
prod S
Product of a set of real numbers S
$prod (a_1, ..., a_n)
prod a 1 , , a n
Product of real numbers
{| a |}, $abs a
a , abs a
Absolute value of a number: a = abs a = a a 0 a a < 0
|_ a _|
a
Floor of a real number: the greatest integer smaller than or equal to a
|~ a ~|
a
Ceiling of a real number: the smallest integer greater than or equal to a
$int a
int a
Integer part of a real number: the closest integer to a towards zero.
$frac a
frac a
Fractional part of a real number: frac a = a int a
$round a
round a
Rounding of a real number: the closest integer to a
$round_k a
round k a
Rounding of a real number to k number of decimal digits ( 0 k 15 )
Numeric Relational Operators
Source Display Description / Comment
a = b /= c
a = b c
Equals / Does not equal[11]
a <> b >< c
a b c
Less than or greater than / Greater than or less than. Note that this is different (more strict) than non-equality.
a < b <= c <_ d
a < b c d
Less than / Less than or equal to (two different forms with identical meaning)
a > b >= c >_ d
a > b c d
Greater than / Greater than or equal to (two different forms with identical meaning)
a </= b </_ c
a b c
Less than and not equal to (two different forms with identical meaning)
a >/= b >/_ c
a b c
Greater than and not equal to (two different forms with identical meaning)
a /< b /<_ c
a b c
Not less than / Neither less than nor equal to
a /> b />_ c
a b c
Not greater than / Neither greater than nor equal to
a ~~ b /~~ c
a b c
Approximately equal to / Not approximately equal to[12]
a ~/= b /~= c
a b c
Approximately but not actually equal to / Neither approximately, nor actually equal to.
a <~~ b </~~ c
a b c
Less than or approximately equal to / Less than but not approximately equal to
a >~~ b >/~~ c
a b c
Greater than or approximately equal to / Greater than but not approximately equal to
a || b /|| c
a b c
Divides / Does not divide

Notes

[11]All relational operators may be “chained” (example: a = b = c ). Such notation is shorthand for a = b b = c . The table uses such chains to demonstrate more than one relational operator in one row.
[12]Maximum tolerance of approximate equality is a run-time option, defaulted to 10 14 .

Keywords

Keyword Literals
Source Display Description / Comment
'key
key
Keyword literal

Strings

String Literals
Source Display Description / Comment
"a string"
a string
Simple literal
""
Empty string
"\0"
\0
Escape: null (U+0000 <control> NULL)
"\b"
\b
Escape: backspace (U+0008 <control> BACKSPACE)
"\t"
\t
Escape: tabulator (U+0009 <control> CHARACTER TABULATION)
"\n"
\n
Escape: newline (U+000A <control> LINE FEED)
"\v"
\v
Escape: vertical tab (U+000B <control> LINE TABULATION)
"\f"
\f
Escape: form feed (U+000C <control> FORM FEED)
"\r"
\r
Escape: return (U+000D <control> CARRIAGE RETURN)
"\""
\"
Escape: quote (U+0022 ” QUOTATION MARK)
"\\"
\\
Escape: backslash (U+005C \ REVERSE SOLIDUS)
"\u{0}"
\u{0}
Escape: unicode (Any hexadecimal character allowed)
"\u{00}"
\u{00}
Escape: unicode (Any hexadecimal characters allowed)
"\u{000}"
\u{000}
Escape: unicode (Any hexadecimal characters allowed)
"\u{0000}"
\u{0000}
Escape: unicode (Any hexadecimal characters allowed)
"\u{00000}"
\u{00000}
Escape: unicode (Any hexadecimal characters allowed)
String Operations
Source Display Description / Comment
$len s
len s
Length of a string
(s)_k
s k
Part of a string: get character @ position k
(s)_{k_1, k_2, k_3}
s k 1 , k 2 , k 3
Part of a string: get multiple characters @ positions k 1 , k 2 , k 3 and concatenate
(s)_{k_1,...,k_2}
s k , , m
Part of a string: get substring from position k to m (inclusive)
s_1 *** s_2 *** s_3
s 1 s 2 s 3
Concatenation of strings

Logical Values

Logical Literals
Source Display Description / Comment
~|~
Logical true
_|_
Logical false
Logical Operations
Source Display Description / Comment
/\
Conjunction (logical AND)
\/
Disjunction (logical OR)
->
Implication (logical IMPLIES)
~
¬
Negation (logical NOT)

Date / Time & Durations

Date / Time & Duration Literals
Source Display Description / Comment
'2018-05-20
2018-05-20
Date literal (ISO YYYY-MM-DD)
'2018-05-20T01:02:03
2018-05-20 01:02:03
Date-Time literal (ISO YYYY-MM-DD HH:MM:SS)
'2018-05-20T01:02:03.456
2018-05-20 01:02:03.456
Date-Time literal (ISO YYYY-MM-DD HH:MM:SS.ms)
2 $!year + 3 $!month
2 year + 3 month
Calendar Duration literals
Date / Time Arithmetic and Manipulation
Source Display Description / Comment
$today
today
Current date (@ start of calculation)
$now
now
Current time (@ start of calculation)
$date (Y, M, D)
date Y , M , D
Construct Date value from integers ( Y : year, M : month, D : day
$date (!t)
date t
Extract Date value from a Date-Time value t
$time (Y, M, D, h, m, s)
time Y , M , D , h , m , s
Construct Date-Time value from integers ( Y : year, M : month, D : day, h : hour, m : minute, s : second)
$time (Y, M, D, h, m, s, ms)
time Y , M , D , h , m , s , ms
Construct Date-Time value from integers (sam as above plus ms : milliseconds)
$time (!d)
time d
Construct Date-Time value from a Date value d (expand with 00:00:00 time)
!d + t, !t + t
d + t , t + t
Addition of a time quantity t to a Date d or Date-Time t
!d + d
d + d
Addition of a Calendar Duration d to a Date d
!d - t, !t + t
d t , t t
Subtraction of a time quantity t from a Date d or Date-Time t
!d - d
d d
Subtraction of a duration d from a Date d
!d_2 - !d_1
d 2 d 1
Subtraction of two Dates (yields time quantity in days)
!t_2 - !t_1
t 2 t 1
Subtraction of two Dates (yields time quantity in seconds)
$dur (d_2, d_1)
dur d 2 , d 1
Compute Calendar Duration between two Dates
$dur (t_2, t_1)
dur t 2 , t 1
Compute Calendar Duration between two Date-Times
(!d)_'year, (!d)_'month, (!d)_'d
d year , d month , d d
Extract year / month / day component from a Date or Date-Time object d
(!t)_'h, (!t)_'minute, (!t)_'s, (!t)_'ms
t h , t minute , t s , t ms
Extract hour / minute / second / millisecond component from a Date-Time object t
(d)_'year, (d)_'minute, (d)_'s
d year , d minute , d s
Extract year / month / day / hour / minute / second / millisecond component from a CalendarDuration object d

Units, Quantities & Dimensions

Unit, Quantity & Dimension Literals
Source Display Description / Comment
$m, $kg, $s
m , kg , s
SI base Unit literal (meter, kilogram, second)
$A, $K, $mol, $cd
A , K , mol , cd
SI base Unit literal (ampere, kelvin, mole, candela)
$year, $month, $week
year , month , week
non-SI but common time Unit literals (year, month, week)
$h, $d, $minute
h , d , minute
non-SI but common time Unit literals (hour, day, minute)
$b, $B
b , B
non-SI but common amount of information Unit literals (bit, byte)
$cm, $\mug, $ms, $kA
cm , μg , ms , kA
SI decimal prefixed Unit literals (centimeter, microgram, millisecond, kiloampere)
$kb, $MB, $Kib, $MiB
kb , MB , Kib , MiB
SI decimal / IEC binary prefixed Unit literals (kilobit, megabyte, kibibit, mebibyte)
$m^2 $kg $s^{-3}
m 2 kg s 3
SI derived Unit literal (unit of power, a.k.a watt)
$m $kg $s^{-2}
m kg s 2
SI derived Unit literal (unit of force, a.k.a newton)
$Hz, $N, $Pa, $J
Hz , N , Pa , J
SI derived Unit literals with special names (hertz, newton, pascal, joule)
$N $m, $W $m^{-2}
N m , W m 2
SI derived Unit literals combining base units and units with special names
$!L, $!M, $!T, $!I
L , M , T , I
SI Dimension symbol literals (length, mass, time/duration, electric current)
$!\Theta, $!N, $!J
Θ , N , J
SI Dimension symbol literals (temperature, amount of substance, luminous intensity)
$!a, $!i
a , i
non-SI (extension) Dimension symbol literals (angle, amount of information)
$!L^2 $!M $!T^{-3}
L 2 M T 3
derived SI Dimension symbol literal (dimension of power quantities)
$!force, $!energy
force , energy
derived shorthand Dimension symbol literals with special names
$!1
1
Dimension literal for dimensionless quantities
1 $cm, 0.53 $W $h
1 cm , 0.53 W h
Quantity literals
Unit, Quantity & Dimension Operations
Source Display Description / Comment
u_1 u_2, u_1 * u_2
u 1 u 2 , u 1 u 2
Multiplication of units (e.g. N m )
u_1 / u_2, u_1 // u_2
u 1 u 2 , u 1 u 2
Division of units (e.g. m s )
u^x
u x
Exponentiation of unit u , exponent x , where x R (e.g. m 2 , s 1 )
D_1 D_2, D_1 * D_2
D 1 D 2 , D 1 D 2
Multiplication of dimensions (e.g. force M i.e. “torque”)
D_1 / D_2, D_1 // D_2
D 1 D 2 , D 1 D 2
Division of dimensions (e.g. L T , i.e. “velocity”)
D ^ x
D x
Exponentiation of dimension D , exponent x , where x R (e.g. L 2 , i.e. “area”)
q_1 + q_2, q_1 - q_2
q 1 + q 2 , q 1 q 2
Addition / Subtraction of quantities of equal dimensions (e.g. 2 kg + 3 g )
q_1 q_2, q_1 * q_2
q 1 q 2 , q 1 q 2
Multiplication of quantities (e.g. 2 m 3 N )
c q, c * q
c q , c q
Multiplication of a quantities with a scalar (e.g. 5 3 m )
q_1 / q_2
u 1 u 2
Division of quantities (e.g. 2 m 3 s )
q ^ x
q x
Exponentiation of quantity q , exponent x , where x R (e.g. 3 m 2 )
$dim u, $dim q
dim u , dim q
Dimension of unit / quantity

Statistical Distributions

Distribution Construction
Source Display Description / Comment
$!D_type(parameters)
D type parameters
Create Distribution object of type K , with parameters specific to the given type
$!D_'U(a, b)
D U a , b
Uniform Distribution (continuous) on R a , b , with a R , b R , a < b
$!D_'N(\mu, \sigma)
D N μ , σ
Normal Distribution with mean: μ R , standard deviation σ R +
$!D_'Beta(\alpha, \beta)
D Beta α , β
Beta Distribution with alpha: α R + , beta β R +
$!D_'B(n, p)
D B n , p
Binomial Distribution with n (number of trials): n Z + , p (success probability) p R 0 , 1
$!D_'Cauchy(x_0, \gamma)
D Cauchy x 0 , γ
Cauchy Distribution with parameters x 0 R and γ R +
$!D_'Chisq(k)
D Chisq k
Chi-Squared Distribution with k (degrees of freedom): k N
$!D_'Exp(\lambda)
D Exp λ
Exponential Distribution with lambda (rate): λ R
$!D_'F(d_1, d_2)
D F d 1 , d 2
Fisher–Snedecor Distribution with d_1 and d_2 (degrees of freedom): d 1 R and d 2 R
$!D_'Gamma(\alpha, \beta)
D Gamma α , β
Gamma Distribution with alpha: α R + , beta β R +
$!D_'Geom(p)
D Geom p
Geometric Distribution with p (success probability) p R 0 , 1
$!D_'Hyper(N, K, n)
D Hyper N , K , n
Hyper geometric Distribution with population size: N Z + , number of success states: K 0 , 1 , 2 , , N and number of draws: n 0 , 1 , 2 , , N
$!D_'Lnorm(\mu, \sigma)
D Lnorm μ , σ
Log-normal Distribution with mean: μ R , standard deviation σ R +
$!D_'Logis(\mu, \sigma)
D Logis μ , s
Logistic Distribution with mean: μ R , scale s R +
$!D_'NB(r, p)
D NB r , p
Negative binomial Distribution with r (number of trials until experiment stopped): r R + , p (success probability) p R 0 , 1
$!D_'Pois(\lambda)
D Pois λ
Poisson Distribution with lambda (rate): λ R
$!D_'t(v)
D t v
Student’s t Distribution with v (degreees of freedom): v R
Distribution functions
Distribution Functions
Distribution CDF[13] PDF / PMF[14] Quantile[15]
D U a , b
D N μ , σ
D Beta α , β
D Cauchy x 0 , γ
D Chisq k
D Exp λ
D F d 1 , d 2
D Gamma α , β
D Geom p
D Hyper N , K , n
D Lnorm μ , σ
D Logis μ , s
D NB r , p
D Pois λ
D t v

Notes

[13]CDF function call example (with the distribution as the first parameter): $CDF($!D_'N( 0.0, 1.0), 2.0)
[14]PDF function call example (with the distribution as the first parameter): $PDF($!D_'N( 0.0, 1.0), 2.0), PMF function call example (with the distribution as the first parameter): $PMF($!D_'Geom( 0.3), 4.0)
[15]Quantile function call example (with the distribution as the first parameter): $Quantile($!D_'N( 0.0, 1.0), 0.5)
Functions calculating distribution properties
Distribution Functions
Distribution Mean Median Mode Variance Skewness Kurtosis
D U a , b
           
D N μ , σ
           
D Beta α , β
           
D Cauchy x 0 , γ
           
D Chisq k
           
D Exp λ
           
D F d 1 , d 2
           
D Gamma α , β
           
D Geom p
           
D Hyper N , K , n
           
D Lnorm μ , σ
           
D Logis μ , s
           
D NB r , p
           
D Pois λ
           
D t v
           

Null value

Null value means “no value”. It can also be regarded an “empty list”. Some expressions may produce no result and return a null value: empty sums / products, set comprehensions like x (- S if S is the empty set, or filtered comprehensions if all values fail the filter expression, like x = 1,…,1000 : x < 0.

The null value is not an actual mathematical value, it

  • cannot be constructed directly,
  • cannot be assigned to a variable,
  • cannot be passed to / returned by a function,
  • cannot be the element of a collection (FiniteSet, Tuple, Sequence, etc.),
  • cannot be compared to another value

However, null values may exist temporarily during expression evaluation as some operators process the null value and return a meaningful result.

Operations on Null values
Source Display Description / Comment
{{ NULL }}[16]
NULL
Empty set ()
{< NULL >}
NULL
Empty Sequence
NULL ?? D
NULL D
Null-coalescing operator, D is default value

Notes

[16]In this table NULL denotes any expression that yields “nothing” (“null”)

Collections

Lists

Lists can be constructed by enumerating elements or by using a range or repeat construct.

List Construction
Source Display Description / Comment
a, b, c
a , b , c
Enumeration of list items
Ranges & Repeats
Source Display Description / Comment
1, ..., n
1 , , n
Integer Range
{k, ...} _} m
k , m
Repeat element m times ( m 0 )
{k, ... ,k} _} m
k , , k m
Repeat element (alternative notation)
{k, ...} ^} m
k , m
Repeat element (with overbrace)[17]
{k, ... ,k} ^} m
k , , k m
Repeat element (alternative, with overbrace)[17]
{f, s, ..., l}
f , s , , l
Arbitrary Range ( f : first, s : second, l :last item)[17]
{f, s, ...} _} m
f , s , m
Arbitrary Range ( f : first, s : second item, m : number of items)[17]
{f, ..., l} _} m
f , , l m
Arbitrary Range ( f : first, l : last item, m : number of items)[17]
{1,...,k}_}, {n,...,m}_}
1 , , k , n , , m
List operator with grouping underbrace[18][17]

Notes

[17](1, 2, 3, 4, 5, 6) Underbraces and overbraces are provided as typographical alternatives with the same meaning. Hint: use underbraces unless the layout is better with overbraces (e.g. above a fraction bar) Underbraces and overbraces can be used interchangably in all examples, even if not listed.
[18]When two or more lists are operands of the list operator, the sub-lists are concatenated (instead of “nesting”). If using a range as an operand, an underbrace (or overbrace) must be used for grouping the ranges construct.
List Comprehension
Source Display Description / Comment
E(x) | x = k, ... ,n
E x | x = k , , n
Map expression E x to local variable binding x = k , , n .
x = a, b, c | f(x) = 0
x = a , b , c | f x = 0
Select using local variable binding x = a , b , c , filter elements that satisfy condition f x = 0
E(x) | x = 1,...,m /\ f(x) = 0
E x | x = 1 , , m f x = 0
Map & select combined
E(x) | x = 1,...,m : f(x) = 0
E x | x = 1 , , m : f x = 0
Map & select (alternative notation)
expression | binding   Generic form of List comprehension (see below)

Bindings

Bindings
Source Display Description / Comment
x = 1, ... ,n
x = 1 , , n
Binding a single variable by iterating from a List (Range)
x (- S
x S
Binding a single variable by iterating from a Finite Set
x = a
x = a
Singleton Binding
(x, y, z) (- S
x , y , z S
Destructuring (Tuple) with Binding
{{x}} = S, T, U
x = S , T , U
Destructuring (singleton set) with Binding
{<x, y, z>} (- S
x , y , z S
Destructuring (Sequence) with Binding
x = 1, ... ,n /\ f(x)=0
x = 1 , , n f x = 0
Binding with Filter
x = 1, ... ,n : f(x)=0
x = 1 , , n : f x = 0
Binding with Filter (alternative notation)
i = 1,...,n; y (- S_i
i = 1 , , n ; y S i
Joined Binding of two distinct Variables i and y
x(-S /\ x < 3; y (- S(x) /\ y > 0
x S x > 0 ; y S x y < x
Joined Binding with filters

Tuples

Tuple Construction
Source Display Description / Comment
(a, b)
a , b
2-tuple, i.e. ordered pair
k |-> v
k v
Maplet operator.[19]
(a, b, c), (a, b, c, d)
a , b , c , a , b , c , d
3-tuple, i.e. triple, 4-tuple, i.e. quadruple etc.
(listComprehension)   Tuple constructed by List comprehension

Notes

[19]Maplets are mainly syntactic sugar for ordered pairs used as “key-value” pairs, so x y = x , y . However, Association literals treat maplets differently from ordinary ordered pairs (see below).
Tuple Operations
Source Display Description / Comment
$len T
len T
Length of a tuple T
( T )_i
T i
Member access (get i ‘th member of Tuple)

Finite Sets

Finite Set Construction
Source Display Description / Comment
{{a, b, c}}
1 , 2 , 3
Enumeration of elements
{{}}, /0
,
Empty set (literal / identifier form)
{{ listComprehension }}   Finite Set constructed by List comprehension (“Set Builder”)
Finite Set Operations
Source Display Description / Comment
$card S, {|S|}
card S , S
Cardinality of (number of elements in) S
S (_) T
S T
Union, set of elements in either S or T
S (~) T
S T
Intersection, set of element in both S and T
S \\ T
S T
Set difference, set of element in S but not in T
S ** T
S × T
Cartesian product, set of ordered pairs x , y such that x S , y T
S ** T ** U
S × T × U
Cartesian product, ternary: set of ordered triplets, etc.
S ^ n
S n
Cartesian power, set of n -tuples x 1 , , x n such that x i S , for all i
$P(S)
P S
Powerset, set of sets consisting of elements of S
Finite Set Relational Operators
Source Display Description / Comment
x (- S -) y
x S y
Element of / Contains as member
x /(- S /-) y
x S y
Not an element of / Does not contain as member
S = T /= U
S = T U
Equals / Does not equal, sets are equal if both contain the same elements
S (: T (:= U (:_ V
S T U V
Subset (Alternative forms have identical meaning)
S :) T :)= U :)_ V
S T U V
Superset (Alternative forms have identical meaning)
S (:/= T (:/_ U
S T U
Proper subset (Alternative forms have identical meaning)
S :)/= T :)/_ U
S T U
Proper superset (Alternative forms have identical meaning)
S /(: T /(:_ U
S T U
Not subset (Alternative forms have identical meaning)
S /:) T /:)_ U
S T U
Not superset (Alternative forms have identical meaning)
Associations (Maps) & Sets of Associations (Relational Tables)
Association & Relational Table Construction
Source Display Description / Comment
{{'a |-> 1, 'b |-> 2}}
a 1 , b 2
Association literal; checks uniqueness of “keys”
{{ ('a,1), ('b,2) }}
a , 1 , b , 2
Association constructed as a set of ordered pairs; constructs same object but does not check uniqueness of “keys”
{{ m_1, m_2, ... , m_n }}
m 1 , m 2 , , m n
“Relational Table” constructed from Associations m i | i = 1 , , n
Association & Relational Table Operations
Source Display Description / Comment
A(k)
A k
Function invocation: get “value” of Association A @ argument k as “key”
(A)_k
A k
Part: get “value” of Association A corresponding to “key” k
(A)_{k_1,k_2,k_3}
A k 1 , k 2 , k 3
Nested Part: same as A k 1 k 2 k 3 (any number of levels allowed).
$dom A
dom A
Domain of Association A : set of “keys”.
$ran A
ran A
Range of Association A : set of “values”.
$cod A
cod A
Codomain of Association A : target set of mapping. For maps constructed with a map literal, the codomain is the same as the range.
A (_)<- B
A B
Overriding union: add / modify “values” @ “keys” of A , based on keys/values of B .
A |\ K
A K
Restriction of Association A to the “key” set K . Drops keys _not_ in K .
A |/ K
A K
Anti-restriction of Association A . Drop keys in K .
A .. B
A B
Functional composition of Associations A and B .
$\sigma_{'a|->1, 'b|->2} T
σ a 1 , b 2 T
Select “rows” from a Relational Table T . Selection criteria is specified as subscript.
{{(r)_'b | r (- T /\ (r)_'a = 1}}
r b | r T r a = 1
Query a Relational Table T .
$head T
head T
Header of a Relational Table (union of domain of T ‘s elements, or “rows”)

Association are sets, therefore set operators can also be used.

Sequences

Sequence Construction
Source Display Description / Comment
{< a, b, c >}
a , b , c
Sequence literal
{{ 1|->a, 2|->b, 3|->c }}
1 a , 2 b , 3 c
Sequence constructed as an Association (equal to sequence above)
{< >}
Empty Sequence. Same as the empty set [20]
{< listComprehension >}   Sequence constructed by List comprehension

Notes

[20]Sequences are functions from 1 , , n to any set. Therefore the empty Sequence is the empty Association, which is the empty set.
Sequence Operations
Source Display Description / Comment
$len S
len S
Length of a sequence S
( S )_i
S i
Member acces (get i ‘th member of Sequence)
( S )_{< i_1, i_2, i_3>}
S i 1 , i 2 , i 3
Subsequence ( s : base Sequence, i 1 , i 2 , i 3 indexes into s )
( S )_{< n,...,m >}
S n , , m
Subsequence defined by a range ( n : first index, m : last index
$rndseq_I(D,l)
rndseq I D , l
Random sequence generated with distribution D , length l N , index I [21]
$sort_f( S )
sort f S
Sort a Sequence S Seq X using a comparator function f X 2 R
$order_f( S )
order f S
Order a Set S P X using a comparator function f X 2 R
$reduce_f( S )
reduce f S
Reduce a sequence using a function representing a binary operation.
$reduce_{f, id}( S )
reduce f , id S
Reduce with optional identity member id , which is returned if S is empty
$fold_{f, init}( S )
fold f , init S
Fold with processing function f

Notes

[21]Index is a user-defined value of any type (any primitive or compound object) that differentiates random sequences used in the same project. Internally, the index is used to generate a (pseudo) random, deterministic seed for the random generator that produces the values in the sequence.

Sequences are Associations (Maps), therefore Association and set operators can also be used. Some of the more useful operations are listed below.

Association and Set Operators on Sequences
Source Display Description / Comment
$card S,  {|S|}
card S , S
Cardinality of a Sequence S , same as length.
S( i )
S i
Function invocation on a Sequence, gets member @ position i
$dom S
dom S
Domain of Sequence, returns set of indices 1 , , len S
$ran S
ran S
Range of a Sequence, returns members of S as a FiniteSet.
i |-> e (- S
i e S
Test: member @ index i is e ? (true iff S i = e )
T (: S
T S
Initial Subsequence: if T is a sequence, then T S iff T is an initial subsequence of S [22]

Notes

[22]However, if T is not a sequence, then it can be a subset of S without being an initial subsequence. For example, 2 b a , b , c but it is clearly not an initial subsequence (not even a Sequence).
Operations on Numeric Sequences

Sequences containing numbers support some specific operations.

Note: most of the operations below also work on Finite Sets and Tuples containing numbers.

Operations on Numeric Sequences
Source Display Description / Comment
$min( S )
min S
Minimum of a Sequence S of real numbers.
$max( S )
max S
Maximum of a Sequence S of real numbers.
$sum( S )
sum S
Sum of a Sequence S of real numbers.
$prod( S )
prod S
Product of a Sequence S of real numbers.
$mean( S )
mean S
Mean (arithmetic) of a Sequence S of real numbers.
$mean_'a( S )
mean a S
Arithmetic Mean of a Sequence S of real numbers.
$mean_'g( S )
mean g S
Geometricic Mean of a Sequence S of positive real numbers.
$mean_'h( S )
mean h S
Harmonic Mean of a Sequence S of positive real numbers.
$mean_'q( S )
mean q S
Quadratic Mean (root-mean-square) of a Sequence S of positive real numbers.
$mean_p( S )
mean p S
Power Mean of a Sequence S of positive real numbers, for any p R .
$median( S )
median S
Median of a Sequence S of real numbers.
$var( S )
var S
Variance of a Sequence S of real numbers.
$std( S )
std S
Standard deviation of a Sequence S of real numbers.

Domains

Built-in Base Domains
Source Display Description / Comment
%P
P
Prime numbers
%N
N
Natural numbers
%Z
Z
Integer numbers
%Q
Q
Rational numbers
%R
R
Real numbers
%C
C
Complex numbers
%K
K
Keyword values
%S
S
String values
%D
D
Date values
%T
T
Date-Time values
Modified Base Domains
Source Display Description / Comment
%N^*, %Z^*, %Q^*, %R^*, %C^*
N , Z , Q , R , C
Zero exclusion, same as N 0 , Z 0 , etc.
%S^*
S
Non-empty strings
%N^^_, %Z^^_, %Q^^_, %R^^_
N , Z , Q , R
Infinity extension, same as N + , Z , + , etc.
%Z_+, %Q_+, %R_+
Z + , Q + , R +
Non-negative half, same as n Z : n 0 , etc.
%Z_-, %Q_-, %R_-
Z , Q , R
Non-positive half, same as n Z : n 0 , etc.
%R^^__+^*
R +
All 3 types of modifier combined
Constrained Base Domains
Source Display Description / Comment
%R_{<3}, %Z_{>5}, %N_{>=10}
R < 3 , Z > 5 , N 10
Relational constraints[23], same as x R : x < 3 , etc.
%R_(a,b)
R a , b
Interval (open)
%R_[a,b]
R a , b
Interval (closed)
%R_(a,b]
R a , b
Interval (left half-open)
%R_[a,b)
R a , b
Interval (right half-open)
%R^^_^*_[a,b]
R a , b
Constraint combined with modifiers

Notes

[23]All ordered numeric base domains may be used in all examples, i.e. P , N , Z , Q , R are all valid.
Domain operations
Source Display Description / Comment
D_1 (_) D_2
D 1 D 2
Union of Domains
D_1 (~) D_2
D 1 D 2
Intersection of Domains
D_1 \\ D_2
D 1 D 2
Difference of Domains
D_1 ** D_2
D 1 × D 2
Cartesian product, binary
D_1 ** D_2 ** D_3
D 1 × D 2 × D 3
Cartesian product, ternary, etc.
D ^ n
D n
Cartesian power of Domains
D ^ 00
D
Cartesian power, any length; D D 2 D 3 ,
$P(D)
P D
Powerset of Domain (valid for finite D only)
$P_{<00}(D)
P < D
Finite Powerset of Domain
$Tpl(D)
Tpl D
Set of Tuples with members in D
$Tpl_[a,b](D)
Tpl a , b D
Set of Tuples with members in D , length constrained by a and b
$Tpl_{<=n}(D)
Tpl n D
Set of Tuples with members in D , length constrained by n
$Vec(%R), $Vec(%C)
Vec R , Vec C
Set of Vectors with real / complex values
$Vec_k(%R), $Vec_k(%C)
Vec k R , Vec k C
Set of Vectors with size k
$Mat(%R), $Mat(%C)
Mat R , Mat C
Set of Matrices with real / complex values
$Mat_{m,n}(%R), $Mat_{m,n}(%C)
Mat m , n R , Mat m , n C
Set of m × n Matrices
$Qty_d(%R), $Qty_d(%R^*)
Qty d R , Qty d R
Set of Quantities with dimension d
$Seq(D)
Seq D
Set of Sequences with members in D
$Seq_[a,b](D)
Seq a , b D
Set of Sequences with members in D , length constrained by a and b
$Seq_{<=n}(D)
Seq n D
Set of Sequences with members in D , length constrained by n
$Asc(F_1, ..., F_n)
Asc F 1 , , F n
Set of Associations defined piecewise from function spaces[27]
D --> C
D C
Set of functions from domain D into codomain C [24]
D -|-> C[25]
D C
Set of partial functions[26] from domain D into codomain C [24]
D -||-> C[25]
D C
Set of finite partial functions [#fPartialFunction] from domain D into codomain C [24]
C^D
C D
Set exponentiation, set of Associations from D into C [24][28]

Notes

[24](1, 2, 3, 4) “into codomain C ” means that a function f is an element of of the result Domain iff the actual codomain of f is some C , such that C C . Note that the subset relation is generally not computable for infinite C .
[25](1, 2) The arrows used in D C and D C should be rendered longer; however, unfortunately Unicode does not offer a longer form of these operators.
[26]“partial function” means a function with an actual domain D such that D D .
[27]The F i argument(s) of the Asc operator can be any combination of the following function spaces: D C , D C , D C , or C D . The domains specified on the arguments of the Asc operator must be disjoint (non-overlapping), and finite (except D C , which allows infinite D ). The resulting Domain contains all Associations that can be constructed as the union of “pieces” taken from the argument spaces. Example: Asc a , b , c R , S S defines the set of Associations with (mandatory) keys a , b , c , whose values are real numbers, plus any (finite) number of optional string keys, whose values are strings.
[28]The notation C D is traditionally used in set theory. The meaning is the same as Asc D C .
Symbolic Domains
Source Display Description / Comment
{{ x (- D : f(x) = 0 }}
x D : f x = 0
Restriction[29] of a Domain using local variable binding x D , and condition f x = 0
{{ expression : x (- D }}
expression : x D
Replacement[30]: symbolic mapping of expression to local variable binding x D .
{{ expression : x (- D /\ f(x)=0 }}
expression : x D f x = 0
Restriction & Replacement combined
{{ expression : x (- D : f(x)=0 }}
expression : x D : f x = 0
Restriction & Replacement combined (alternative notation)
{{ expression : binding }}   Generic form of Symbolic Domain construction

Notes

[29]The term “restriction” is used in the sense of “specification” / “separation” / “restricted comprehension” / “restriction” in ZFC. Of all these terms, “restriction” seems to be the most expressive. Restriction is similar to selection, but the operator is : instead of | , and the resulting set is not computed element by element.
[30]The term “replacement” is used in the sense of “replacement” in ZFC. Replacement is similar to mapping, but the operator is : instead of | , and the resulting set is not computed element by element. Replacement is limited to l-value expressions like x , x , y , x etc.
Domain Relational Operators
Source Display Description / Comment
x (- D -) y
x D y
Element of / Contains as member
x /(- D /-) y
x D y
Not an element of / Does not contain as member
D_1 = D_2 /= D_3
D 1 = D 2 D 3
Equals / Does not equal.
D_1 (: D_2 (:= D_3 (:_ D_4
D 1 D 2 D 3 D 4
Subset[31]
D_1 :) D_2 :)= D_3 :)_ D_4
D 1 D 2 D 3 D 4
Superset[31]
D_1 (:/= D_2 (:/_ D_3
D 1 D 2 D 3
Proper subset[31]
D_1 :)/= D_2 :)/_ D_3
D 1 D 2 D 3
Proper superset[31]
D_1 /(: D_2 /(:_ D_3
D 1 D 2 D 3
Not subset[31]
D_1 /:) D_2 /:)_ D_3
D 1 D 2 D 3
Not superset[31]

Notes

[31](1, 2, 3, 4, 5, 6) Sub- / superset relational operators can only be computed if the super is finite

Vectors

Vector Construction
Source Display Description / Comment
[x_1, x_2, ..., x_n]
x 1 , x 2 , , x n
Coordinates ( x i R x i C )
[listComprehension]   Vector constructed by List comprehension
Vector Operations
Source Display Description / Comment
$size !v
size v
Size of a vector v
( !v )_i
v i
Coordinate access
!v + !w
v + w
Addition
!v - !w
v w
Subtraction
c !v
c v
Scalar multiplication
!v * !w
v w
Dot product (scalar product)

Matrices

Matrix Construction
Source Display Description / Comment
[a # b ## c # d]
a b c d
Grid construction
(a # b ## c # d)
a b c d
Grid construction (alternative notation)[32]
[x # y # z]
x y z
Row vector[33]
[x ## y ## z]
x y z
Column vector[33]
$!0_{n,m}
0 n , m
n × m Zero Matrix
$I_n
I n
n × n Identity Matrix
$I(n)
I n
n × n Identity Matrix (alternative notation)
$J_n
J n
n × n Unit Matrix (“matrix of ones”)
$J_{n,m}
J n , m
n × m Unit Matrix (“matrix of ones”)

Notes

[32]Do not use this notation for 2 × 1 matrices as x y means the binomial coefficient, not a Matrix!
[33](1, 2) Despite the name, row vectors and column vectors are not Vectors, but 1 × m ( n × 1) Matrices!
Matrix Operations
Source Display Description / Comment
$size A
size A
Size of a Matrix A , returned as a pair m , n
( A )_{i,j}
A i , j
Entry extraction: get entry of Matrix A in row i , column j
A + B
A + B
Addition
A - B
A B
Subtraction
c A
c A
Scalar multiplication
A B
A B
Matrix multiplication
{| a # b ## c # d |}
a b c d
Determinant
$det A
det A
Determinant (alternative notation)
A^{-1}
A 1
Inverse of a square matrix (if invertable)
A^n
A n
Matrix exponentiation ( n Z )
$transpose(A)
transpose A
Transpose a matrix
$conj(A)
conj A
Complex conjugate of a matrix

Functions (Morphisms)

Function construction
Source Display Description / Comment
f: D --> C, x |--> expr
f : D C , x expr
Function declaration, single argument. expr is a defining expression.
f: D --> C, (x,y) |--> expr
f : D C , x , y expr
Function declaration, two arguments[34]
f: D -) args |--> expr (- C
f : D args expr C
Function declaration, alternative form
(f: D --> C, args |--> expr)
f : D C , args expr
Named Function expression
(f: D -) args |--> expr (- C)
f : D args expr C
Named Function expression (alternative form)
(D -) args |--> expr (- C)
D args expr C
Anonymous Function expression
f .. g
f g
Composition of functions
$id_S
id S
Identity function (on S )
$\iota_{S, T}
ι S , T
Inclusion function (for S T )

Notes

[34]Actually all functions have a single argument. “Multiple” arguments work by passing a Tuple to the function.
Function Operations
Source Display Description / Comment
f(x), f(x,y)
f x , f x , y
Function invocation
$dom f
dom f
Domain of function
$cod f
cod f
Codomain of function
$ran f
ran f
Range of a function (computable for finite domain only)

Formulas

Executable operators
Source Display Description / Comment
x = expr
x = expr
Assignment of a Variable ( x ) to the value of an expression expr
x_n = expr
x n = expr
Assignment of a Slot of an indexed Variable ( x )
x_1 = x_2 = expr
x 1 = x 2 = expr
Multiple Assignment
a = 1 => x = expr
a = 1 x = expr
Conditional
x_1 = 1; x_2 = 2; x_3 = 3
x 1 = 1 ; x 2 = 2 ; x 3 = 3
Multiple executable expressions
a_i = expr | i = 1,...,n
a i = expr | i = 1 , , n
For each value of i (local Variable), do assignment
a_i := expr : i (- %N
a i expr : i N
Definition of a value (delayed evaluation / assignment)
(x_1,x_2,x_3) = expr
x 1 , x 2 , x 3 = expr
Destructuring assignment

Miscellaneous

Other forms
Source Display Description / Comment
{{0 # i(-{{0,1}} ## x_{i-1} + x_{i-2} # i>1}
0 i 0 , 1 x i 1 + x i 2 i > 1
Piecewise (switch)
{{0 # i(-{{0,1}} ## x_{i-1} + x_{i-2} # i>1)
0 i 0 , 1 x i 1 + x i 2 i > 1
Piecewise (switch) with optional closing parenthesis