Expressions

Contents

Expressions#

The expression language used throughout DS — where clauses, action-argument values, emit / publish slot values, cache value, and every other position the grammar lists expression. One grammar, one type system, one set of built-in functions.

Paired with:

  • [LGRA] for the expression-production syntax and precedence layering.

  • [LFAC] and [LLOG] for how expressions interact with fact lifecycle and truth maintenance.

  • Series-aggregation call syntax: this doc covers how aggregations compose as atoms in expressions; [LSER] owns the list of aggregation names and their semantics.

What this is not#

  • Not a grammar reference for where expressions appear — [LGRA] owns that.

  • Not a compiler-implementation guide. Lowering to the runtime's expression atoms is briefly noted at the end; detailed lowering lives with the runtime docs.

  • Not a general-purpose numerical library. The built-in math set covers Python's math module minus esoterica. Things intentionally left out of the built-in set (compute them adapter-side if needed): isnan / isinf / isfinite, gcd / lcm, factorial, copysign / fmod, erf / gamma / lgamma, frexp / ldexp.


Operators and precedence [LEXP.1]#

[LEXP.1.1] Operator precedence is layered by [LGRA.9.2.1], which is canonical and is not restated here. [LEXP.1.2] through [LEXP.1.6] state the properties of that layering this document relies on.

ratified — see also: LEXP.1.2, LEXP.1.6, LGRA.9, LGRA.9.2.1

[LEXP.1.2] Comparisons bind looser than every bitwise operator and tighter than logical NOT ([LGRA.9.2.1]), as in Python: a & 0x4 != 0 parses as (a & 0x4) != 0 and not a < b parses as not (a < b).

ratified — see also: LGRA.9.2.1

[LEXP.1.3] ** binds tighter than unary on the left but accepts any expression on the right, per Python: -2 ** 3 == -(2 ** 3) == -8; 2 ** -3 == 0.125; 2 ** 3 ** 2 == 2 ** 9 == 512 (right-associative).

ratified

[LEXP.1.4] Parentheses override precedence at any level.

ratified

[LEXP.1.5] The postfix operators — member access ., index [ ], call ( ), and the conversion cast :: — bind tighter than every prefix and infix operator: they are level 17 of [LGRA.9.2.1], the tightest operator level. The :: cast is specified in [LCST.4.1]; x::Int? ?? 0 parses as (x::Int?) ?? 0.

see also: LCST.4.1, LGRA.9.2.1

[LEXP.1.6] A bare NAME in expression position resolves in the value namespace — in-scope binding → constant → builtin function ([LGRA.22.7]); a builtin function's NFC name is reserved. Type references live in the disjoint type namespace and are not expression atoms.


see also: LGRA.22.7

Comparison chains [LEXP.2]#

[LEXP.2.1] a <op1> b <op2> c … with any number of comparison operators is a comparison chain, lowered to the conjunction of pairwise comparisons on consecutive terms.

ratified

Semantics [LEXP.2.2]#

  • [LEXP.2.2.1] A chain of N comparisons produces N−1 pairwise tests, ANDed.

  • [LEXP.2.2.2] Any comparison operator may appear at any position: a < b > c is (a < b) and (b > c) — legal, Python- compatible, even if mathematically unusual.

  • [LEXP.2.2.3] Operators may be mixed: a <= b == c < d.

ratified

What chains are not [LEXP.2.3]#

  • [LEXP.2.3.1] Not an assertion of total ordering. a < b < c doesn't imply a < c; it says "a is less than b AND b is less than c." Authors who want the transitive claim write it explicitly.

  • [LEXP.2.3.2] Not a shorthand for a between primitive — chains are more general.

Length [LEXP.2.4]#

[LEXP.2.4.1] No grammar or engine cap on chain length. A 10-element chain produces 9 ANDed pairwise comparisons. Readability concerns (long chains) belong in a linter, not the grammar.


Built-in math functions [LEXP.3]#

[LEXP.3.1] abs, round, min and max are callable in any expression, with no declaration and no import. floor, ceil, trunc, sign, sqrt, pow, the angle conversions ([LEXP.3.6]) and the transcendental functions ([LEXP.3.9]) are members of the math module, reached through its import ([LIMP.3.3.4]). Names and semantics are Python's math module's where the two overlap. Type signatures follow [LEXP.7].

ratified — see also: LEXP.3.6, LEXP.3.9, LEXP.7, LIMP.3.3.4

Arithmetic / rounding [LEXP.3.2]#

Function

Meaning

abs(x)

absolute value (preserves type)

round(x)

nearest integer, ties-to-even (Python banker's rounding)

math.floor(x)

largest integer ≤ x

math.ceil(x)

smallest integer ≥ x

math.trunc(x)

truncate toward zero

math.sign(x)

−1, 0, or 1, as an Int: 1 when x > 0, −1 when x < 0, else 0. So -0.0 and a NaN give 0; no sign bit is read ([LEXP.4.3])

math.sqrt(x)

√x — IEEE correctly-rounded, EXACT; NaN for a negative x ([LDET.3.6.2])

math.fma(x, y, z)

$x \times y + z$, rounded once — EXACT ([LEXP.3.2.2])

math.pow(x, y) / x ** y, non-negative integer exponent

Int: xʸ by repeated × — EXACT

math.pow(x, y) / x ** y, any other exponent

Float: the correctly-rounded pow ([LEXP.3.9.2]) — EXACT, with [LEXP.3.9.3]'s special values (0 ** negative is +Inf). Result type per [LEXP.7.3a]

ratified — see also: LEXP.7.3a, LDET.3.6.2, LEXP.3.2.2, LEXP.3.9.2, LEXP.3.9.3, LEXP.4.3

[LEXP.3.2.1] A rounding whose result does not fit Int traps. math.floor, math.ceil, math.trunc and round of a Float return an Int. When the mathematical result lies outside $[-2^{63}, 2^{63})$, or the argument is not finite, the engine must raise a ComputationError of kind NOT_REPRESENTABLE ([LERR.1.4.10]) and abandon the activation, as Float :: Int does ([LCST.4.5.4]). It must not wrap, saturate, or answer what the host's conversion happens to give.

ratified — see also: LCST.4.5.4, LERR.1.4.10

[LEXP.3.2.2] math.fma(x, y, z) is IEEE 754's fused multiply-add. The engine computes $x \times y + z$ as if with unbounded range and precision and rounds it once to binary64, in [LDET.3.6.1]'s mode. It must not compute a rounded product and then a rounded sum. A compile-time fold must give the same value ([LDET.3.3a.8]).

Its operands are those x * y + z admits, under that expression's unit rules ([LUNI.8]). An Int operand converts to Float first ([LEXP.7.3]), and the result is a Float. Its special values are IEEE 754's: an infinite or NaN operand, or $0 \times \infty$, gives the infinity or NaN that operation defines, and nothing traps ([LERR.1.4.1]). It lowers to FN_FMA (proto/builtin_fn.proto#BuiltinFn).

It keeps the expression's null handling. A null operand yields null ([LNUL.4.1]), a Json leaf's included, and raises no fault. So a T? operand is admitted as it is by x * y + z, and the call is nullable where an operand is ([LNUL.5.1]).

ratified — defined in: proto/builtin_fn.proto#BuiltinFn — see also: LDET.3.3a.8, LDET.3.6.1, LERR.1.4.1, LEXP.7.3, LNUL.4.1, LNUL.5.1, LUNI.8

Angle conversion [LEXP.3.6]#

Both are members of math ([LIMP.3.3.4]).

Function

Meaning

degrees(x)

radians → degrees

radians(x)

degrees → radians

see also: LIMP.3.3.4

[LEXP.3.6.1] degrees and radians are this composition, and no other. With $\hat\pi$ the Float math.pi ([LIMP.3.3.4]) and $\circ(\cdot)$ the binary64 nearest a real value, ties to even:

$$\operatorname{degrees}(x) = \circ!\left(x \times \circ!\left(\frac{180}{\hat\pi}\right)\right), \qquad \operatorname{radians}(x) = \circ!\left(x \times \circ!\left(\frac{\hat\pi}{180}\right)\right)$$

Each factor is the exact quotient rounded once, a constant of the language; the engine must evaluate each function as one correctly rounded multiplication by it ([LDET.3.6.1]), and the compiler must fold a constant operand the same way ([LEXP.8.8]). An Int argument is converted to Float first ([LEXP.7.3]). At a non-finite or NaN argument the result is the IEEE 754 product's ([LDET.3.6.2]).

ratified — see also: LDET.3.6.1, LDET.3.6.2, LEXP.7.3, LEXP.8.8, LIMP.3.3.4

Integer utility [LEXP.3.7]#

[LEXP.3.7.1] Members of an Int value ([LGRA.9.6.2]). Each reads x as its 64-bit two's-complement pattern ([LEXP.7.13.1]), bit 0 being the least significant.

Member

Meaning

x.bit_count

the number of 1 bits in the pattern; -1 has 64

x.bit_length

the number of bits $\lvert x \rvert$ needs, as Python's int.bit_length; 0 for 0

x.leading_zeros

the number of 0 bits above the highest 1 bit; 64 for 0, and 0 for a negative x ([LEXP.3.7.3])

x.trailing_zeros

the number of 0 bits below the lowest 1 bit; 64 for 0 ([LEXP.3.7.3])

x.bits(lo, width)

the width bits from bit lo upward ([LEXP.3.7.3])

x.sign_extend(width)

the low width bits, read as a two's-complement number ([LEXP.3.7.3])

x.swap_bytes(width)

the low width / 8 bytes, in reverse order ([LEXP.3.7.3])

ratified — see also: LEXP.3.7.3, LEXP.7.13.1, LGRA.9.6.2

[LEXP.3.7.2] Only an Int has these members: on any other receiver type they are unknown members ([LGRA.9.6.2]). A Json leaf is cast to Int first, and that cast is where a wrong-typed leaf fails ([LEXP.7.12.1]).

ratified — see also: LEXP.7.12.1, LGRA.9.6.2

[LEXP.3.7.3] Five of these members are this arithmetic and no other. Let $p = x \bmod 2^{64}$, the pattern read as an unsigned number, and let $\mathrm{int}(v)$, for $0 \le v < 2^{64}$, be the Int whose pattern is $v$: $v$ when $v < 2^{63}$, else $v - 2^{64}$.

Member

Domain

Result

x.bits(lo, w)

$0 \le lo$, $1 \le w$, $lo + w \le 64$

$\mathrm{int}(\lfloor p / 2^{lo} \rfloor \bmod 2^{w})$

x.sign_extend(w)

$1 \le w \le 64$

$u - 2^{w}$ when $u \ge 2^{w-1}$, else $u$, where $u = p \bmod 2^{w}$

x.swap_bytes(w)

$w \in {16, 32, 64}$

$\mathrm{int}\big(\sum_{i=0}^{n-1} b_i , 2^{8(n-1-i)}\big)$, where $n = w / 8$ and $b_i = \lfloor p / 2^{8i} \rfloor \bmod 2^{8}$

x.leading_zeros

every x

$64 - \lceil \log_2 (p + 1) \rceil$

x.trailing_zeros

every x

the largest $k \le 64$ with $2^{k} \mid p$

The bits of x above the field do not reach the result. bits and swap_bytes are non-negative unless $w = 64$; x.bits(0, 64) and x.sign_extend(64) are x. Every argument is an Int, and a null receiver or argument yields null ([LNUL.4.1]).

The compiler must lower each of these members to its own builtin, the receiver first: FN_BITS, FN_SIGN_EXTEND, FN_SWAP_BYTES, FN_LEADING_ZEROS and FN_TRAILING_ZEROS (proto/builtin_fn.proto#BuiltinFn).

ratified — defined in: proto/builtin_fn.proto#BuiltinFn — see also: LEXP.3.7.1, LNUL.4.1

[LEXP.3.7.4] An argument outside its domain has no answer. For a bits, sign_extend or swap_bytes call whose arguments lie outside the domain [LEXP.3.7.3] gives, the engine must raise a ComputationError of kind DOMAIN ([LERR.1.4.1]) and abandon the activation, as it does for a negative shift count ([LEXP.7.14.1]).

The compiler must refuse the call with DS_VALIDATE_BIT_FIELD_RANGE when its compile-time constant arguments ([LEXP.8.8]) place it outside the domain whatever its other arguments hold: x.bits(70, w) and x.swap_bytes(24) are refused, and x.bits(lo, 8) with a run-time lo is not.

ratified — see also: LERR.1.4.1, LEXP.3.7.3, LEXP.7.14.1, LEXP.8.8

Binary min(a, b) / max(a, b) [LEXP.3.8]#

[LEXP.3.8.1] Scalar pairwise min(a, b) / max(a, b) over two numeric operands. The names are shared with the series aggregations min(cursor) / max(cursor), which take the cursor alone ([LSER.6.11.3]); the compiler resolves the two by argument count — one argument, a cursor, is the aggregation (lowered to FN_SERIES_MIN / FN_SERIES_MAX), and two are the scalar form. The scalar result preserves the winning operand's Int / Float kind: max(5, 3.0) → 5 (Int), max(2, 3.5) → 3.5 (Float). Primary use is clamping in the absence of a ternary, e.g. max(min(x, hi), lo).


ratified — see also: LSER.6.11.3

[LEXP.3.8.2] A tie goes to the first operand. When the scalar min(a, b) or max(a, b) compares its operands equal, the engine must return a, kind and sign included: max(2, 2.0) is 2 (Int), min(2.0, 2) is 2.0 (Float), and min(0.0, -0.0) is 0.0. Two Int operands compare exactly; an Int beside a Float compares as it does in a comparison, promoted to Float first ([LEXP.7.3]). A compile-time fold of the same call gives the same value ([LDET.3.3a.8]).

ratified — see also: LDET.3.3a.8, LEXP.7.3

Transcendental functions [LEXP.3.9]#

[LEXP.3.9.1] Each function below is a member of math ([LIMP.3.3.4]). Each takes Float arguments, an Int argument being converted to Float, and returns a Float. An angle argument is its value in radians ([LUNI.4.2]).

Function

Meaning

exp(x)

$e^x$

ln(x)

$\ln x$, the natural logarithm

log2(x)

$\log_2 x$

log10(x)

$\log_{10} x$

sin(x) cos(x) tan(x)

the trigonometric functions of x radians

asin(x) acos(x) atan(x)

the inverse trigonometric functions, in radians

atan2(y, x)

the angle of the point $(x, y)$ from the positive $x$ axis, in radians, in $[-\pi, \pi]$

sinh(x) cosh(x) tanh(x)

the hyperbolic functions

math.pow(x, y) and ** are [LEXP.3.2]'s and [LEXP.7.3a]'s; with a Float result they are a transcendental function of this section too.

checks: alloy — see also: LUNI.4.2, LEXP.3.2, LEXP.7.3a, LIMP.3.3.4

[LEXP.3.9.2] Correctly rounded. For every operand, the engine must return the function's exact mathematical value rounded once to the nearest float64, ties to even ([LDET.3.6.1]): an overflowing value rounds to an infinity and an underflowing one to a subnormal or a zero, as any rounding does. The compiler must do the same wherever it evaluates one ([LDET.3.3a.7]). An implementation whose result differs from that value at any operand must not be used.

The rounded value is unique, so every conforming engine returns the same bits at every operand that has one ([LDET.3.4.1]). At the operands where the function has no real value, or its value is a limit, the result is [LEXP.3.9.3]'s.

ratified — see also: LDET.3.6.1, LDET.3.3a.7, LDET.3.4.1, LEXP.3.9.3

[LEXP.3.9.4] Special values. At the operands [LEXP.3.9.3] lists, the engine must return the result it states. A NaN operand gives NaN, except in the pow rows that say otherwise. Where a row's operand and result both carry ±, the result takes the operand's sign; for atan2 it takes the sign of y. "π/2 rounded" is the float64 nearest π/2, and likewise for the other multiples of π.

An operand class includes the infinities on its side: |x| > 1 includes ±Inf, x < 0 includes −Inf, and y < 0 and y > 0 include −Inf and +Inf. Where two rows both cover an operand, they give the same result.

These are the IEEE 754 values. A NaN result flows on through the expression; [LEXP.4.2] keeps it out of working memory and every payload.

see also: LEXP.3.9.3, LEXP.4.2

[LEXP.3.9.3]

Function

Operand

Result

exp

±0

1

exp

−Inf

+0

exp

+Inf

+Inf

ln log2 log10

±0

−Inf

ln log2 log10

1

+0

ln log2 log10

+Inf

+Inf

ln log2 log10

x < 0, −Inf included

NaN

sin tan

±0

±0

cos

±0

1

sin cos tan

±Inf

NaN

asin

±0

±0

acos

1

+0

asin acos

|x| > 1, ±Inf included

NaN

atan

±0

±0

atan

±Inf

±π/2 rounded

atan2(y, x)

y ±0, x −0

±π rounded

atan2(y, x)

y ±0, x +0

±0

atan2(y, x)

y ±0, x < 0

±π rounded

atan2(y, x)

y ±0, x > 0

±0

atan2(y, x)

y < 0, x ±0

−π/2 rounded

atan2(y, x)

y > 0, x ±0

+π/2 rounded

atan2(y, x)

y finite and nonzero, x −Inf

±π rounded

atan2(y, x)

y finite and nonzero, x +Inf

±0

atan2(y, x)

y ±Inf, x finite

±π/2 rounded

atan2(y, x)

y ±Inf, x −Inf

±3π/4 rounded

atan2(y, x)

y ±Inf, x +Inf

±π/4 rounded

sinh tanh

±0

±0

sinh

±Inf

±Inf

cosh

±0

1

cosh

±Inf

+Inf

tanh

±Inf

±1

pow(x, y)

x +1, any y, NaN included

1

pow(x, y)

any x, NaN included, y ±0

1

pow(x, y)

x ±0, y a negative odd integer

±Inf

pow(x, y)

x ±0, y < 0 and not an odd integer, −Inf included

+Inf

pow(x, y)

x ±0, y a positive odd integer

±0

pow(x, y)

x ±0, y > 0 and not an odd integer, +Inf included

+0

pow(x, y)

x −1, y ±Inf

1

pow(x, y)

|x| < 1, y −Inf

+Inf

pow(x, y)

|x| > 1, y −Inf

+0

pow(x, y)

|x| < 1, y +Inf

+0

pow(x, y)

|x| > 1, y +Inf

+Inf

pow(x, y)

x −Inf, y a negative odd integer

−0

pow(x, y)

x −Inf, y < 0 and not an odd integer

+0

pow(x, y)

x −Inf, y a positive odd integer

−Inf

pow(x, y)

x −Inf, y > 0 and not an odd integer

+Inf

pow(x, y)

x +Inf, y < 0

+0

pow(x, y)

x +Inf, y > 0

+Inf

pow(x, y)

x finite and < 0, y finite and not an integer

NaN

ratified — checks: alloy×31

Constants [LEXP.4]#

[LEXP.4.1] Reserved identifiers; authors cannot bind them as variable or slot names. Each is a row of [LLEX.9.6].

Identifier

Value

inf

floating-point infinity (a permitted value)

nan

reserved; not a usable value — see [LEXP.4.2]

The constants pi, e and tau are members of math ([LIMP.3.3.4]).

ratified — see also: LEXP.4.2, LIMP.3.3.4, LLEX.9.6

[LEXP.4.2] Non-finite floats. inf is a permitted Float value (Inf == Inf holds, so it dedups and joins in Rete). nan is not: NaN must never enter working memory — NaN != NaN breaks fact identity, joins, and refraction. A NaN is a Float an expression may compute ([LDET.3.6.2]); what is refused is storing one in a slot, on every path into one:

  • the compiler must reject the nan constant in a value position — a slot value, a let / const, a :: cast target — as a compile error (DS_VALIDATE_NAN_VALUE);

  • a NaN Float arriving at runtime via a host assert is a hard error (DS_ERR_NAN_REJECTED, −216);

  • a NaN a rule's activation would put into a slot is a TypeError, and the engine abandons the activation ([RARC.5.2.7]).

A Float call argument whose value is NaN refuses the call with DS_ERR_NAN_REJECTED, and the engine does not issue it; a ±Inf argument passes.

No Float operation checks for NaN, and NaN needs no division by zero: inf is an author-writable constant and overflow yields one, so inf - inf, inf / inf and 0.0 * inf are NaN. The refusal at the slot is what keeps it out of working memory.

A non-finite Float (±Inf, or a NaN an expression produced) forced into a JSON data-plane body is a separate NOT_REPRESENTABLE trap at the verb ([LDET.3.2.7]), and a host call that would build such a value is refused with DS_ERR_JSON_NONFINITE ([LGRA.5.8.10]); rendered as text (Float::String, display) ±Inf is "inf" / "-inf" ([LCST.4.5.6]).


ratified — checks: alloy×4 — see also: LCST.4.5.6, LDET.3.2.7, LDET.3.6.2, LGRA.5.8.10, RARC.5.2.7

[LEXP.4.3] A NaN's sign and payload are not observable. IEEE 754 leaves them to the hardware, so conforming engines produce NaNs that differ in both from the same operands. The engine must not canonicalise them, and nothing a rule, a recording or an integrator can read may depend on them: a NaN never reaches working memory or a payload ([LEXP.4.2]), every NaN renders as "nan" ([LCST.4.5.6]), and is NaN tests the class alone ([LNUL.4.9]). A path that would expose a computed NaN's bits must not be added.

see also: LEXP.4.2, LCST.4.5.6, LNUL.4.9

Distance functions [LEXP.5]#

[LEXP.5.1] First-class set of distance, vector-length, and similarity primitives. Three sub-families: geometric distances, string distances, vector similarity. Folded in with the rest of the expression language so authors have one reference for all expression-level math. Every function in this section is a member of the distance module, reached through its import ([LIMP.3.3.4]).

ratified — see also: LIMP.3.3.4

[LEXP.5.2] Operands are named slot values. Higher-dimensional distances (N-D cosine over ML embeddings, etc.) are adapter-computed and emitted as a slot.

Geometric distances (Minkowski family) [LEXP.5.3]#

[LEXP.5.3.1] Overloaded by arity: 2D takes 4 operands, 3D takes 6.

Function

Arity

Meaning

euclidean(x1, y1, x2, y2)

2D

L₂ distance

euclidean(x1, y1, z1, x2, y2, z2)

3D

L₂ distance

manhattan(x1, y1, x2, y2)

2D

L₁ distance (taxicab)

manhattan(x1, y1, z1, x2, y2, z2)

3D

L₁ distance

chebyshev(x1, y1, x2, y2)

2D

L∞ distance (chessboard)

chebyshev(x1, y1, z1, x2, y2, z2)

3D

L∞ distance

ratified

Vector length (from origin) [LEXP.5.5]#

Function

Arity

Meaning

hypotenuse(x, y)

2D

√(x² + y²)

hypotenuse(x, y, z)

3D

√(x² + y² + z²)

String distances [LEXP.5.6]#

Function

Operands

Meaning

hamming(a, b)

int or equal-length string

bit-differing count (ints) or codepoint-differing count (strings)

levenshtein(s1, s2)

string

minimum edit distance

Deferred: not binding in this edition.

[LEXP.5.6.1] hamming on strings requires equal length; runtime error on unequal-length strings when the mismatch isn't statically knowable. levenshtein handles unequal lengths natively.

Vector similarity (cosine distance) [LEXP.5.7]#

[LEXP.5.7.1] Overloaded by arity; returns distance, not similarity (matching scipy.spatial.distance.cosine). Range [0, 2]. Authors who want similarity subtract it from 1.

Function

Arity

Meaning

cosine(ax, ay, bx, by)

2D

1 - cos(θ) between 2D vectors

cosine(ax, ay, az, bx, by, bz)

3D

1 - cos(θ) between 3D vectors

ratified

[LEXP.5.7.3] cosine is this composition, and no other. For vectors $a$ and $b$, each sum taken left to right over the components in argument order and every operation rounded once ([LDET.3.6.1]):

$$\operatorname{cosine}(a, b) = 1 - \frac{a \cdot b}{\sqrt{a \cdot a} \times \sqrt{b \cdot b}}$$

The two norms are taken separately and then multiplied. The result is IEEE 754's at every operand ([LDET.3.6.2]): when either vector is zero the quotient is 0.0 / 0.0, and the result is NaN, which [LEXP.4.2] keeps out of working memory.

checks: k — see also: LDET.3.6.1, LDET.3.6.2, LEXP.4.2

[LEXP.5.7.2] N-dimensional cosine (ML embeddings etc.) stays adapter-side — compute the scalar in an adapter and emit it as a slot.

Arity dispatch [LEXP.5.8]#

[LEXP.5.8.1] euclidean, manhattan, chebyshev, hypotenuse and cosine are overloaded by argument count. Only the declared arities are legal; any other count is a compile error. great_circle is fixed-arity.

Return types [LEXP.5.9]#

[LEXP.5.9.1] The geometric and vector-similarity functions return Float. great_circle returns a length in meter ([LEXP.5.11.1]).

see also: LEXP.5.11.1

Great-circle distance [LEXP.5.11]#

[LEXP.5.11.1] great_circle(lat1, lon1, lat2, lon2) is the distance along the surface of a sphere of radius $R$ between the point at latitude lat1, longitude lon1 and the point at latitude lat2, longitude lon2, as a length in meter ([LUNI.4.1.2]). $R$ is the binary64 nearest 6 371 008.8 m, the mean radius of the Earth. The engine must compute it by [LEXP.5.11.2]'s composition.

Each argument is a Float in degrees, an Int argument being converted to Float; an angle argument ([LUNI.4.2]) is first converted to degree by its unit. Latitude is in $[-90, 90]$, positive north; longitude is in $[-180, 180]$, positive east. An argument outside its range gives NaN ([LEXP.5.11.3]). An adapter that delivers longitudes from 0 to 360 should convert them to −180 to 180 before it asserts them.

The sphere is a model of the Earth. The result differs from the geodesic distance on the WGS 84 ellipsoid by up to 0.6% of the distance. A distance that needs more is computed by an adapter and asserted as a slot.

ratified — see also: LEXP.5.11.2, LEXP.5.11.3, LUNI.4.1.2, LUNI.4.2

[LEXP.5.11.2] great_circle is this composition, and no other. Every operation is rounded once, and no two are fused ([LDET.3.6.1]). $\operatorname{rad}$ is radians ([LEXP.3.6.1]); $\sin$, $\cos$, $\operatorname{atan2}$ and $\sqrt{\cdot}$ are the correctly rounded functions of [LEXP.3.9] and [LEXP.3.2]; $\hat R$ is [LEXP.5.11.1]'s radius:

$$\phi_1 = \operatorname{rad}(\mathit{lat}_1), \quad \phi_2 = \operatorname{rad}(\mathit{lat}_2), \quad \Delta\phi = \operatorname{rad}(\mathit{lat}_2 - \mathit{lat}_1), \quad \Delta\lambda = \operatorname{rad}(\mathit{lon}_2 - \mathit{lon}_1)$$

$$s = \sin(\Delta\phi / 2), \qquad t = \sin(\Delta\lambda / 2)$$

$$a = s \times s + (\cos\phi_1 \times \cos\phi_2) \times (t \times t)$$

$$a' = \min(\max(a, 0), 1)$$

$$d = \hat R \times \bigl(2 \times \operatorname{atan2}(\sqrt{a'}, \sqrt{1 - a'})\bigr)$$

The terms are associated as written. The clamp to $[0, 1]$ chooses $a$, $0$ or $1$ and rounds nothing.

ratified — see also: LDET.3.6.1, LEXP.3.2, LEXP.3.6.1, LEXP.3.9, LEXP.5.11.1

[LEXP.5.11.3] A coordinate that is not one gives NaN. When either latitude lies outside $[-90, 90]$ degrees, either longitude outside $[-180, 180]$ degrees, or any argument is NaN or infinite, the engine must return NaN without evaluating [LEXP.5.11.2]'s composition. A <, <=, >, >= or == comparison with a NaN is false ([LDET.3.6.2]), so a rule that compares the result with a distance does not match it, and [LEXP.4.2] keeps it out of working memory.

ratified — see also: LDET.3.6.2, LEXP.4.2, LEXP.5.11.2

Json introspection [LEXP.6]#

[LEXP.6.1] Two built-ins specific to Json-typed slots (see [LGRA]):

Function

Meaning

Returns

len(<Json>)

array length at runtime

Int

has(<Json path>)

whether the path resolves

Bool

ratified — checks: idris×4

[LEXP.6.2] len raises a TypeError at runtime if the Json value isn't an array, abandoning the activation ([LEXP.7.12.1]). has is the intended guard for a path that may not resolve, which is absence and reads as null ([LNUL.8.4]) rather than a fault.

ratified — checks: idris×2 — see also: LEXP.7.12.1, LNUL.8.4

[LEXP.6.3] Neither iterates; both answer one-shot questions. DS rules do not iterate over collections — see [LSCO] and the no-List/Map commitment in [LGRA].

[LEXP.6.4] json() takes a string literal. The argument must be a literal; a runtime expression is a compile error (DS_VALIDATE_JSON_NOT_LITERAL). The value is parsed at compile time, so it cannot depend on anything the rule reads.


Deferred: not binding in this edition.

Type rules [LEXP.7]#

[LEXP.7.1] Numeric operators follow Python-style implicit promotion:

ratified

  • [LEXP.7.1a] The arithmetic operators require numeric operands. +, -, *, /, // and % take Int or Float. The compiler must refuse a String operand with DS_VALIDATE_BAD_OPERAND_TYPE, wherever the expression stands, a const right-hand side included ([LEXP.8.8]): there is no string +, between two literals or any other operands. Build strings with interpolation ([LGRA.2.9.6]), which is the one surface for it — a second spelling would be two paths that have to agree on every edge, the shape [RTIM.14.8] exists to prevent.

    Stated because the alternative is silent: an accepted s.a + s.b evaluates to an absent value, and an absent value in a predicate never fires ([LNUL.4.3]), so where s.a + s.b == "xy" is false for every input including the one it was written for. A compile error costs the author one edit and says where.

ratified — see also: LEXP.8.8, LGRA.2.9.6, LNUL.4.3, RTIM.14.8

  • [LEXP.7.2] All operands Int → result Int.

checks: k idris×5

  • [LEXP.7.3] Any operand Float → result Float. Int operands promote automatically.

checks: idris×7

  • [LEXP.7.3a] ** with an integer exponent is an exception to [LEXP.7.2]. Int ** Int is Int only when the exponent is a compile-time-known non-negative integer (a literal, or a const that folds to ≥ 0); the result is xʸ computed by binary exponentiation, which agrees bit-for-bit with linear repeated multiplication because ds_i64_mul's wrap contract makes integer multiplication associative modulo 2⁶⁴ — the grouping is therefore not observable and the spec does not have to pick one. When the exponent is a negative integer, or an Int whose sign is not known at compile time, the result is Float, computed by the correctly-rounded pow ([LEXP.3.9.2]) — so 2 ** -3 == 0.125 ([LEXP.1.3]), and 0 ** negative is +Inf, ±Inf for an odd exponent ([LEXP.3.9.3]). A non-integer exponent, or a Float operand, gives Float by the same pow. Correct rounding determines that result uniquely, and that is what makes every form EXACT and cross-platform bit-identical ([LDET.3.3a.4]) rather than merely reproducible. This keeps the static type sound: an integer power that can go fractional is typed Float, never silently Int.

ratified — see also: LDET.3.3a.4, LEXP.1.3, LEXP.7.2, LEXP.3.9.2, LEXP.3.9.3

  • [LEXP.7.3a.1] Chained ** consequence. Because ** is right-associative ([LGRA.9.5], [LEXP.1.3]), a ** b ** c is a ** (b ** c), and [LEXP.7.3a] types each power on its own. The outer power is Int only when b ** c is a compile-time-known non-negative integer, and is otherwise Float, computed by [LEXP.7.3a]'s correctly rounded pow. So a ** b ** 2 with a runtime b is Float, and every chain compiles.

see also: LEXP.1.3, LEXP.7.3a, LGRA.9.5

  • [LEXP.7.3b] Promotion is an OPERATOR rule and stops at a slot. The automatic Int → Float promotion of [LEXP.7.3] applies where an operator combines operands. It does not apply where a value is assigned into a declared slot: an emit / publish kwarg whose expression types Int and whose slot declares Float is a compile error ([RLOW.1.4]), not a widening. The author writes the cast — value: count :: Float ([LCST.4.1]) — and the widening becomes visible where it happens.

    The distinction is legibility at the site, not type purity. In count + 2.5 both operands and the operator are in front of the reader, the promotion is a property of the operation being performed, and the result type follows from what is written. In emit R value: count the reader sees the value and not the slot's type: R is declared elsewhere in the file, or in another file entirely through an import ([LGRA.8]). The obviousness that earns [LEXP.7.3] its escape hatch is absent at a destination.

    So this is not an inconsistency with [LEXP.7.3] to be reconciled — the two rules govern positions that differ in exactly the property the escape hatch rests on.

    And the direction does not soften it. Int → Float is lossless only below 2^53; DS slots are int64, so a large integer promoted at a slot boundary loses precision silently and permanently, in the one position where the value stops being transient. [LEXP.7.3] carries the same hazard for transient operands and that is where it stays.

ratified — see also: LEXP.7.3, LCST.4.1, RLOW.1.4, RARC.5.2.6, LGRA.8

  • [LEXP.7.4] The / operator always produces Float (Python 3 semantics), even on two Int values. Two integer literals, INT_LIT / INT_LIT, are a Rational literal — not an application of / — reduced at parse time ([LUNI.2.2]); any non-literal operand makes it the / operator → Float.

ratified — checks: k idris×4 — see also: LUNI.2.2

  • [LEXP.7.5] // is floor-division, rounding toward negative infinity. 7 // 2 == 3, -7 // 2 == -4 (not -3). Result type follows the operand rule. Distinct from math.trunc(a / b), which rounds toward zero. -7.5 // 2 == -4.0.

    With a Float operand the Int one promotes ([LEXP.7.3]), and for a nonzero divisor $b$ the result is this composition and no other, $r$ being step 1's exact remainder in [LEXP.7.6]:

    1. $q = (a - r) / b$, the subtraction and the division each rounded once.

    2. If [LEXP.7.6]'s step 2 adjusted $r$, $q \leftarrow q - 1$, rounded once.

    3. If $q = 0$, the result is a zero with the sign of $a / b$.

    4. Otherwise $f = \lfloor q \rfloor$, and the result is $f + 1$ if $q - f > \tfrac{1}{2}$, else $f$. A NaN $q$ gives NaN.

    A zero divisor is [LEXP.7.15.1]'s.

ratified — checks: k idris×6 — see also: LEXP.7.15.1, LEXP.7.3, LEXP.7.6

  • [LEXP.7.6] % follows the operand rule: Int % Int is Int, Float % Float or mixed is Float. A nonzero result takes the divisor's sign: 5.5 % 2 == 1.5, -7 % 3 == 2, -7.5 % 2 == 0.5.

    With a Float operand the Int one promotes ([LEXP.7.3]), and for a nonzero divisor $b$ the result is this composition and no other:

    1. $r = a - b \cdot \operatorname{trunc}(a / b)$, computed exactly: the remainder of the quotient truncated toward zero, which always has a representable value and carries $a$'s sign. It is NaN when $a$ is infinite or either operand is NaN, and $a$ when $b$ is infinite and $a$ finite.

    2. If $r \ne 0$ and its sign differs from $b$'s, $r \leftarrow r + b$, rounded once.

    3. If $r = 0$, the result is a zero with $b$'s sign; otherwise it is $r$.

    A zero divisor is [LEXP.7.15.1]'s.

ratified — checks: k idris×10 — see also: LEXP.7.15.1, LEXP.7.3

  • [LEXP.7.7] Bitwise operators (&, |, ^, ~, <<, >>) require integer operands. Applying them to a Float is a compile- time error when the type is known statically.

ratified

  • [LEXP.7.8] Shift amounts must be non-negative integers. Negative literal shifts are a compile-time error.

ratified

  • [LEXP.7.9] Unary ~ is bitwise not; integers only (DS_VALIDATE_BITWISE_TYPE).

ratified

  • [LEXP.7.10] Unary - is arithmetic negation; Int or Float. A unit-typed Int or Float is negated as [LUNI.3.3] says. The compiler must refuse it on an operand of any other kind, a Duration among them ([LTIM.1.3.1]), with DS_VALIDATE_BAD_OPERAND_TYPE.

see also: LTIM.1.3.1, LUNI.3.3

  • [LEXP.7.11] Unary + is a no-op on numeric operands; included for stylistic parallelism with -.

  • [LEXP.7.19] Bytes and whole Json values admit equality and no ordering.

    • The engine must answer == and != on two Bytes operands by content: they are equal iff they have the same length and the same octet at every position ([LSTR.4.1]).

    • The engine must answer == and != on two Json operands by the deep structural equality [LFAC.2.5.1] applies to a Json slot, so a comparison and a no-op reassertion agree on whether two values are the same.

    • The compiler must refuse <, <=, > and >= when either operand is a Bytes value or a whole Json value, with DS_VALIDATE_UNORDERED_TYPE, at the operator. In a comparison chain each step is judged on its own two operands.

    A whole Json value is a Json slot read without a path. A path into a Json slot reads a leaf whose type is known only at run time, and its comparison is [LEXP.7.12.1]'s. A null operand propagates ([LNUL.4.1]). The refusal holds whatever the other operand's type. Equality between a Bytes or whole Json operand and an operand of another type is outside this clause.

ratified — checks: idris×2 — see also: LEXP.7.12.1, LFAC.2.5.1, LNUL.4.1, LSTR.4.1

  • [LEXP.7.20] Two fact references are equal exactly when they name the same fact, and admit no ordering. A fact reference is one of these:

    • a pattern binding read as a value, with no slot, which is the whole fact its pattern bound ([LGRA.8.6]);

    • a let whose right-hand side is a fact reference, because a let is its right-hand side inlined ([LLET.12.5]);

    • a read of a schema-typed slot, whose value is the fact the slot was set to ([LGRA.5.7a.2]).

    The rules:

    • The engine must answer a == b, where a and b are fact references, true when the two name the same fact and false otherwise, and a != b as its negation. Inside a negated pattern's where, that pattern's binding is the candidate fact it is tested against. A null operand, such as an unset nullable schema-typed slot, propagates ([LNUL.4.1]).

    • The same fact is one fact, not two facts with equal keys or equal slots. A no-op reassertion leaves a fact the same fact ([LFAC.2.5.1]), and a meaningful change replaces it with another ([LFAC.2.5.3]). Two references to facts of different schemas are therefore never equal.

    • The compiler must refuse <, <=, > and >= when either operand is a fact reference, with DS_VALIDATE_UNORDERED_TYPE, at the operator, as [LEXP.7.19] does for Bytes. In a comparison chain each step is judged on its own two operands.

    Two patterns may bind the same fact in one activation, so Reading a, Reading b where a != b matches each ordered pair of two different Reading facts and never a fact paired with itself, and Child c, Parent p where c.parent == p matches each child with the parent its slot names. The answer depends only on which facts the operands name. Equality between a fact reference and an operand that is not one is outside this clause.

ratified — see also: LEXP.7.19, LFAC.2.5.1, LFAC.2.5.3, LGRA.5.7a.2, LGRA.8.6, LLET.12.5, LNUL.4.1

Json-slot type mismatches [LEXP.7.12]#

A wrong-typed Json leaf raises a TypeError and abandons the activation ([LEXP.7.12.1], [IRET.9.6]). No operation yields a sentinel that takes part in further computation as though it were data.

Absence is a separate condition and reads as null ([LNUL.8.4]).

see also: IRET.9.6, LEXP.7.12.1, LNUL.8.4

[LEXP.7.12.1] The only slot type that carries runtime type variation is Json ([LEXP.7.12.5], [LADP.5.5.3]). When a leaf access on a Json path evaluates in an arithmetic or comparison operator and the runtime leaf type doesn't match the operator's expectation, the operation raises a TypeError. Unless a deciding operand absorbs it ([LNUL.4.2]), the activation is abandoned ([IRET.9.6]) and the fault reaches the fault surfaces, a TypeError fault fact among them ([LERR.9.1]). An absorbed TypeError reaches none ([LERR.1.4.11]).

The operation does not evaluate to false, and nothing propagates. A wrong-typed leaf is data — expected in normal operation and attributable to a node — which is why it is a TypeError and not an EngineError; the same operation on a value that was schema-committed means the artefact lied ([IRET.9.6]).

Absence is a different question and is not this clause's: an unresolved path reads as null and propagates under Kleene ([LNUL.8.4]).

checks: idris×2 — see also: IRET.9.6, LADP.5.5.3, LERR.1.4.11, LERR.9.1, LEXP.7.12.5, LNUL.4.2, LNUL.8.4

[LEXP.7.12.3] A TypeError reaches the integrator through the fault surfaces of [LERR.9.1] and nothing else: no metric counts it, and the engine writes no log entry for it.

see also: LERR.9.1

[LEXP.7.12.4] Rule authors who need hard-fail on a particular path can guard with has(...) and explicit type-checking expressions.

[LEXP.7.12.5] For non-Json slots (String, Int, Float, Bool), type is committed at schema time; runtime type surprises don't arise. A Float slot evaluating in a string comparison is a compile error (DS_VALIDATE_TYPE_MISMATCH), not a runtime fallback.

ratified

Integer overflow [LEXP.7.13]#

[LEXP.7.13.1] DS integers are 64-bit signed. Overflow wraps silently (two's complement). The spec does not guard against it — rules doing arithmetic on values near INT64_MAX are author responsibility. Documented; no runtime overflow check.

ratified — checks: k idris×2

Shift semantics [LEXP.7.14]#

[LEXP.7.14.1] >> is arithmetic shift (sign-preserving): $a \gg n = \lfloor a / 2^n \rfloor$. << is the shift the other way, $a \ll n = a \cdot 2^n$ under the Int wrap of [LEXP.7.13.1].

The count is never reduced modulo 64. A count of 64 or more therefore gives 0 or -1 for >> (by the sign of a) and 0 for <<. A count that is negative at run time is a trap, a ComputationError of kind DOMAIN ([LERR.1.4.1]); a negative literal count is refused at compile time ([LEXP.7.8]).

ratified — checks: saw×2 — see also: LERR.1.4.1, LEXP.7.13.1, LEXP.7.8

[LEXP.7.14.2] Authors who need zero-fill right shift mask with & 0xFF… first.

Division by zero [LEXP.7.15]#

[LEXP.7.15.1] A division, floor-division or modulo whose operands are all Int is a runtime error when the divisor is zero ([LERR.1.4.3]). That includes /, though its result is Float ([LEXP.7.4]). Authors who can't rule out zero denominators guard explicitly. With a Float operand, the Int one promotes ([LEXP.7.3]) and the operation is IEEE 754's ([LDET.3.6.2]). / and // give ±Inf for a nonzero dividend and NaN for a zero one, and % gives NaN.

ratified — checks: k idris×9 — see also: LERR.1.4.3, LEXP.7.4, LEXP.7.3, LDET.3.6.2

[LEXP.7.15.2] A false guard decides an and wherever it stands ([LNUL.4.2]), so the capacity guard protects the division on either side of it: x != 0 and y / x > 1 is false when x is 0, and so is y / x > 1 and x != 0.

ratified — see also: LNUL.4.2

Modulo by zero [LEXP.7.16]#

[LEXP.7.16.1] Runtime error. Same guard pattern.

ratified

Distance-function type rules [LEXP.7.17]#

[LEXP.7.17.1] Geometric / spherical / vector-length / cosine functions accept numeric operands (Int or Float); Int promotes to Float. Non-matching operand types are compile errors; a wrong-typed Json leaf raises a TypeError ([LEXP.7.12.1]); an unresolved path reads as null ([LNUL.8.4]).

see also: LEXP.7.12.1, LNUL.8.4

[LEXP.7.18] A method is a member. A .NAME call on a receiver whose type is statically known is a member read: [LGRA.9.6.2] resolves it by the receiver's type and refuses, with DS_VALIDATE_UNKNOWN_MEMBER, a name the type does not carry. DS_VALIDATE_UNKNOWN_METHOD stays allocated and is not raised in this edition.


ratified — see also: LGRA.9.6.2

Expression positions (scope) [LEXP.8]#

[LEXP.8.1] Expressions are legal in:

ratified

  • [LEXP.8.2] where clauses on patterns.

  • [LEXP.8.3] Action-argument values in every action head that accepts value kwargs — call, emit, publish, cache. Expression grammar is uniform across LHS and RHS.

ratified

  • [LEXP.8.4] Slot values in emit / publish — which are kwarg values.

[LEXP.8.5] Not legal in:

  • [LEXP.8.6] Pattern slot values. Patterns match against asserted facts; they don't compute. A pattern cannot say "match facts where slot equals (a + b)"; use a where clause on the pattern binding instead.

  • [LEXP.8.7] Schema declarations, series declarations, configuration. Compile-time literals only; no bindings available.

  • [LEXP.8.8] const RHS. Compile-time-constant expressions — the exact, runtime-free foldable subset over literals, earlier consts, and imported consts: arithmetic, comparison, bitwise/shift, and/or/not, unit literals + same-dimension conversion + unit assertions, the global math builtins ([LEXP.3.1]), the math, distance and calendar members over constant operands ([LIMP.3.3.4]), each by the composition its clause fixes. A String is folded only as a literal: + over a String is refused here as everywhere ([LEXP.7.1a]). A member call whose fold would raise has no value to fold to and is not foldable ([LTIM.14.3]). =-introduced, optionally : type-annotated (a scalar builtin type, or a canonical unit; checked against the folded value — [LGRA.4.1]). Any construct requiring a runtime value — including a runtime-Json leaf read — is a compile error naming it ([LGRA.13.3]).

ratified — see also: LEXP.3.1, LEXP.7.1a, LGRA.13.3, LGRA.4.1, LIMP.3.3.4, LTIM.14.3

Strings vs expressions in action args [LEXP.8.9]#

[LEXP.8.9.1] The log action head takes a single string argument (a literal or interpolated string). The grammar treats the string as the full action-arg; an expression like log info (2 + 2) is a parse error — use interpolation: log info "result is {x.level}".

ratified

[LEXP.8.9.2] Value kwargs on other actions (call foo level: (5 * t.mult)) take expressions freely. A duration position takes a time_expr ([LGRA.2.8.1]), not an expression.


see also: LGRA.2.8.1

Interactions [LEXP.9]#

With logical emit [LEXP.9.1]#

[LEXP.9.1.1] Expressions in where clauses under logical re-evaluate when their pattern's bindings change and on each pump (per [LLOG.3]). Transitions from true to false end the activation; the logical fact retracts.

see also: LLOG.3

With series aggregations [LEXP.9.2]#

[LEXP.9.2.1] Series aggregations behave as function-call atoms in expressions, and compose freely.

[LEXP.9.2.2] An aggregation's VALUE is recomputed at each test, rather than cached under the cursor, so an author who repeats one many times pays for each. Factor it by emitting it once from a preceding rule as a derived fact, then pattern-matching that.

This says nothing about how often the TEST runs. A where spanning two positive patterns is a join test, and the network retains its outcome in a beta memory — so "re-evaluates on every test" is true of the aggregation and false of the rule containing it. An aggregation in a multi-pattern where is forbidden for that reason ([LEXP.9.6.1]).

see also: LEXP.9.6.1

[LEXP.9.2.3] Explicit factoring, visible cost, no hidden optimisation surface.

With string interpolation [LEXP.9.3]#

[LEXP.9.3.1] Interpolation ("{x.slot}") takes bound paths only, not expressions. Authors wanting arithmetic in a message pre- compute the value as a fact slot (via an earlier rule's emit) and interpolate the slot.

ratified

With the ::Json cast [LEXP.9.4]#

[LEXP.9.4.1] <binding>::Json in a call action serialises a whole schema-typed fact to JSON-on-wire for outbound web API calls. The cast — its form, totality, and the fact-only rule (any fact-typed source; scalar → Json rejected) — is specified in [LCST.4.5.10]; [LCST.4.6] governs the Json(<binding>) call form. See [LGRA.9.6] for the postfix grammar.

Deferred: not binding in this edition.

see also: LCST.4.5.10, LCST.4.6, LGRA.9.6

With the dwell alias [LEXP.9.5]#

[LEXP.9.5.1] t.dwell is a compile-time alias for the time t's fact has been in working memory: monotonic_ns() minus the fact's entry stamp ([LTIM.2.8.6]), a Duration. t is a logical-schema binding. It composes with arithmetic. It reads no slot of the fact — ts included — so neither an adapter's timestamp nor a wall-clock change moves it.

ratified — checks: idris×19 — see also: LTIM.2.8.6

[LEXP.9.5.2] Alias expansion happens before arithmetic; the entry stamp has no author syntax, so dwell is the only way a rule reads it.

[LEXP.9.5.3] Because t.dwell reads monotonic_ns() ([LEXP.9.5.1]), a condition reading t.dwell is time-dependent per [LTIM.2.4.1] and is re-evaluated and edge-fired under [LTIM.2.4] / [LTIM.2.5].


ratified — checks: idris — see also: LEXP.9.5.1, LTIM.2.4, LTIM.2.4.1, LTIM.2.5

With the join: reads that are not a function of the matched facts [LEXP.9.6]#

[LEXP.9.6.1] A where on a rule with more than one positive pattern must not read state that is not a function of the matched facts. Two kinds of read are excluded, each with its own code:

  • A time-dependent read ([LTIM.2.4.1]): a clock read (now(), monotonic_ns(), dwell), a series read ([LEXP.9.2]) or a zone read. [LTIM.2.6.2] refuses it with DS_VALIDATE_NOW_MULTIPATTERN_UNSUPPORTED.

  • A cache read, cached(key) ([LGRA.9.8.4]), which is not time-dependent. The compiler must refuse it with DS_VALIDATE_NONFACT_WHERE_MULTIPATTERN, naming the read and offering the two repairs: a let on the right-hand side, or splitting the gated check into its own single-positive-pattern rule.

Why the restriction exists. On a rule with more than one positive pattern the where clauses become join tests, and a join test's result is retained: that retention is what a Rete beta memory is. Retention is sound exactly when the test is a function of the facts, because then "these facts are mutually consistent" holds for as long as those facts are present, and fact presence is the one thing the network tracks — the memo's validity condition and its invalidation mechanism are the same event. A test that reads the clock, the cache or a series has a validity condition the network does not track, so the memo can go stale with no fact changing and nothing propagates to notice.

The scope is the RULE, not the individual where. A where attached to one pattern is refused just as a where naming bindings from two is, on a rule that has more than one positive pattern. Which clause a test is written beside does not decide where the compiler places it, so a per-where reading would let an author move an impure test onto a single pattern and keep the defect.

The effect is not a stale value but a rule that never fires. Write a cache key from one rule's RHS and gate a two-pattern rule on cached(...) in its where: if the key is set before the join is attempted the gated rule fires, and if it is set afterwards the gated rule never fires, through any number of further pumps, with the key set and nothing else changing.

One rule, two codes. The reasoning — a single-positive-pattern rule has no join, so its where never sits in a beta memory — is about the join and not about the clock, and it applies to cached() unchanged. The code says which state the read depends on: time, for [LTIM.2.6.2]'s, and the cache, for this clause's.

The restriction keeps work per pump bounded ([LSCO.5.1]). Re-driving the network on non-fact events would re-test broadly enough to give back most of what a beta memory holds.

Single-positive-pattern rules are unaffected. They have no join, so these reads stay available where authors mostly write them, and the let surface ([LGRA.9.8.4]) is outside this restriction: a binding made once per activation on the RHS is held in no beta memory.

ratified — see also: LEXP.9.2, LEXP.9.2.2, LGRA.9.8.4, LSCO.5.1, LTIM.2.4.1, LTIM.2.6.2, RDSC.5a.1a

Error handling [LEXP.10]#

[LEXP.10.1] Expressions use the standard DS error-handling meta-policy — the rungs of [LERR.1], distinguished by decision rule. Feature-level error behaviour here:

see also: LERR.1

Compile-time errors (caught before runtime) [LEXP.10.2]#

  • [LEXP.10.2.1] Type mismatch on bitwise op when the operand type is statically known (state & 0x04 where state: String).

  • [LEXP.10.2.2] Division or modulo of Int operands by literal zero (a / 0, b % 0 with a and b Int). A Float division by a zero literal is not an error ([LDET.3.6.2]).

ratified — see also: LDET.3.6.2

  • [LEXP.10.2.3] Negative literal shift amount (a << -1).

  • [LEXP.10.2.4] Wrong-arity call to an overloaded distance function (distance.euclidean with 3 arguments, not a legal arity): DS_VALIDATE_BAD_ARITY.

  • [LEXP.10.2.5] Arithmetic in a disallowed position (pattern slot value, schema declaration): DS_PARSE_GENERIC, since no production admits it there.

  • [LEXP.10.2.6] Malformed expression (unclosed parens, missing operand, dangling operator).

Runtime errors (halt the rule fire) [LEXP.10.3]#

  • [LEXP.10.3.1] Int division by zero on a computed denominator ([LEXP.7.15.1]).

see also: LEXP.7.15.1

  • [LEXP.10.3.2] Modulo by zero on a computed denominator.

  • [LEXP.10.3.3] Negative computed shift amount.

  • [LEXP.10.3.4] distance.hamming on strings of observed-unequal length.

Deferred: not binding in this edition.

TypeError (activation abandoned; cycle continues) [LEXP.10.4]#

  • [LEXP.10.4.2] len(...) on a Json value that isn't an array at runtime.

Errors-as-values (observable facts) [LEXP.10.5]#

[LEXP.10.5.1] No expression-level cases; this kind of error applies to adapter-surface failures (CallError, etc.) rather than expression semantics.

[LEXP.10.6] The decision rule is pinned by [LERR.1] and its decision tree ([LERR.2]); this section cites the categories.


see also: LERR.1, LERR.2

Lowering (brief) [LEXP.11]#

[LEXP.11.1] Expressions lower to engine-level test forms in the compiled output. The compiler rewrites infix DS expressions into the substrate engine's primitives; DS-level operator symbols (+, &, **, <<, …) do not appear in the lowered form. Aggregations become function calls the engine resolves against its series registry at compile time.

[LEXP.11.2] Detailed lowering — native-engine specifics, naming of engine primitives, performance characteristics of specific operators — lives with the runtime docs, not the language spec.


Expression commitments [LEXP.12]#

  • [LEXP.12.1] One expression grammar across all positions. where clauses, action-arg values, slot values on emit / publish, cache values — same grammar, same precedence, same type rules.

ratified

  • [LEXP.12.2] Python-style arithmetic and promotion. Matches Python 3 exactly for the arithmetic levels' precedence ([LGRA.9.2.2]), comparison chaining, / always producing float, // floor-division, % Python semantics including float modulo.

see also: LGRA.9.2.2

  • [LEXP.12.3] Bitwise ops integer-only. Static type error when known; a wrong-typed Json leaf raises a TypeError at runtime ([LEXP.7.12.1]).

see also: LEXP.7.12.1

  • [LEXP.12.4] >> is arithmetic shift (sign-preserving). Restates [LEXP.7.14.1].

see also: LEXP.7.14.1

  • [LEXP.12.5] Comparison chains with no grammar cap on length.

ratified

  • [LEXP.12.6] Exact-math built-in set in v1 (arithmetic, rounding, sqrt, pow, angle conversion, integer utility, the transcendental functions, constants, the distance functions) — all EXACT and cross-platform bit-identical ([LDET.3.4.4]).

ratified — see also: LDET.3.4.4

  • [LEXP.12.7] Distance family first-class with 2D/3D arity dispatch for Minkowski and cosine. Higher-dimensional stays adapter-side. Cosine returns distance (scipy convention), not similarity.

ratified

  • [LEXP.12.8] len / has built-ins for Json-introspection — non- iterative, one-shot queries.

ratified

  • [LEXP.12.9] An aggregation is recomputed at each test ([LEXP.9.2.2]). Factor expensive repeated aggregations into derived facts via preceding rules.

see also: LEXP.9.2.2

  • [LEXP.12.10] Integer overflow wraps silently. 64-bit signed; documented, no runtime guard.

  • [LEXP.12.11] Binary min/max supported per [LEXP.3.8]. The series aggregations min / max take a cursor ([LSER.6.10]), so the two are distinguished by arity: a number pair is the binary form, a single cursor the aggregation.

see also: LEXP.3.8, LSER.6.10

Series aggregations [LEXP.16]#

[LEXP.16.1] Series aggregation calls are first-class expression atoms. The first argument to any series aggregation is a series cursor — a compile-time designator of the form binding, binding.label, binding.slot, or binding.slot.label per [LSER.6.10]. The cursor carries the time model, accuracy, and identity key from the matching series declaration. The full aggregation vocabulary and per-type applicability are normative at [LSER.16].

see also: LSER.16, LSER.6.10

[LEXP.16.3] The companion-slot form cursor.<agg> is syntactic sugar for <agg>(cursor) — both are equivalent and legal in any expression position. Value-argument aggregations (count_of, contains) have no companion-slot form; use the expression form count_of(cursor, value) / contains(cursor, value) exclusively. Full cursor resolution at [LSER.6].

see also: LSER.6

The builtin function registry [LEXP.17]#

[LEXP.17.1] The builtin functions are a closed registry. The names an author may call as a function without declaring one are the rows of [LEXP.17.2], and no others. A row named math.<name>, distance.<name> or calendar.<name> is a member of that module ([LIMP.3.3.4]), called through the module's import by its qualified name or by the bare <name> a selective import binds; every other row is global. Each row states:

  • Arities — the argument counts the function accepts. It is a set, not a range: a call with any other count is a compile error ([LEXP.5.8.1]). A series aggregation takes its cursor and, for count_of and contains, the value, and nothing more ([LSER.6.11.3]). min and max give their scalar form's count; called with a cursor alone they are the aggregation.

  • Tier — the purity tier a call belongs to, pure or sync-impure ([LGRA.9.8.4]).

  • Signature — each form's parameters and result, ? marking a nullable result and ; separating the forms. A Float parameter takes an Int, converted ([LEXP.7.3]). cursor is a series cursor ([LSER.6.10]), and T the type of the slot it reads. A parameter is a value: a builtin demands one, so the compiler refuses a T? argument ([LNUL.5.1]), and a null that reaches one at runtime raises a TypeError ([IRET.9.6]). Two rows' defining clauses say otherwise, and the column does not repeat them: has, whose argument is a Json path it tests for resolution rather than a value ([LNUL.8.4]), and math.fma, which takes its operands as x * y + z does, so that a null operand yields null ([LEXP.3.2.2]).

  • Summary — one line saying what the call answers, for an author's tools.

  • Defined by — the clause that defines the function. Where the Signature or Summary and that clause differ, the clause is right.

p1 … p99 are the quantile aggregations ([LSER.17.6]), one row each.

A spelling [LGRA.9.6.3] or [LSTR.4.6] refuses is not a row, and it names no builtin.

Every global row's name is a reserved word ([LLEX.9.6]): a binding or constant is resolved before a builtin, so a const abs left nameable would shadow the builtin it spells ([LGRA.22.7]). A module member's name is not reserved; [LGRA.22.9] keeps a binding from shadowing one the file imports bare.

The registry is the single statement of the set, and every compiler's view of it must agree with it, row for row ([STYL.2.15.6.1]). It does not travel, so it is a table and not a protobuf ([STYL.5.9.7]). The operation a call lowers to is a separate enumeration, proto/builtin_fn.proto#BuiltinFn; that one holds what the artefact carries, this one the source spellings and the facts about them that never leave the compiler.

ratified — see also: LEXP.17.2, LEXP.5.8.1, LGRA.22.7, LGRA.22.9, LGRA.9.6.3, LIMP.3.3.4, LGRA.9.8.4, LLEX.9.6, LEXP.7.3, LEXP.3.2.2, IRET.9.6, LNUL.5.1, LNUL.8.4, LSER.17.6, LSER.6.10, LSER.6.11.3, LSTR.4.6

[LEXP.17.2]

Name

Arities

Tier

Signature

Summary

Defined by

abs

1

pure

(x: Int) → Int; (x: Float) → Float

Absolute value, of the argument's type.

LEXP.3.2

math.acos

1

pure

(x: Float) → Float

Inverse cosine, in radians.

LEXP.3.9.1

math.asin

1

pure

(x: Float) → Float

Inverse sine, in radians.

LEXP.3.9.1

math.atan

1

pure

(x: Float) → Float

Inverse tangent, in radians.

LEXP.3.9.1

math.atan2

2

pure

(y: Float, x: Float) → Float

Angle of the point (x, y) from the positive x axis, in radians, in [−π, π].

LEXP.3.9.1

cached

1

sync-impure

(key: String) → String?

The cache's value for the key, as JSON text; null on a miss.

LSTO.4.3.1

math.ceil

1

pure

(x: Int) → Int; (x: Float) → Int

Smallest integer not less than x; a Float with no Int answer traps.

LEXP.3.2

distance.chebyshev

4, 6

pure

(x1, y1, x2, y2: Float) → Float; (x1, y1, z1, x2, y2, z2: Float) → Float

L∞ (chessboard) distance between two points, 2D or 3D.

LEXP.5.3.1

contains

2

pure

(cursor, value: T) → Bool

Whether the value is among the series' samples in its window.

LSER.16.7.1

math.cos

1

pure

(x: Float) → Float

Cosine of x radians.

LEXP.3.9.1

math.cosh

1

pure

(x: Float) → Float

Hyperbolic cosine.

LEXP.3.9.1

distance.cosine

4, 6

pure

(ax, ay, bx, by: Float) → Float; (ax, ay, az, bx, by, bz: Float) → Float

Cosine distance, 1 − cos θ, between two vectors, in [0, 2].

LEXP.5.7.1

count

1

pure

(cursor) → Int

Number of samples in the series' window.

LSER.16.2

count_distinct

1

pure

(cursor) → Int

Number of distinct sample values in the series' window.

LSER.16.5.1

count_of

2

pure

(cursor, value: T) → Int

Number of samples in the series' window equal to the value.

LSER.16.6.1

calendar.date

3

pure

(year: Int, month: Int, day: Int) → Date

The Date of that calendar day.

LTIM.14.1

math.degrees

1

pure

(x: Float) → Float

Radians to degrees.

LEXP.3.6.1

direction

1

pure

(cursor) → Int?

Sign of the difference of the two newest samples: −1, 0 or 1.

LSER.16.9

distance.euclidean

4, 6

pure

(x1, y1, x2, y2: Float) → Float; (x1, y1, z1, x2, y2, z2: Float) → Float

L₂ distance between two points, 2D or 3D.

LEXP.5.3.1

math.exp

1

pure

(x: Float) → Float

e to the power x.

LEXP.3.9.1

math.floor

1

pure

(x: Int) → Int; (x: Float) → Int

Largest integer not greater than x; a Float with no Int answer traps.

LEXP.3.2

math.fma

3

pure

(x: Float, y: Float, z: Float) → Float

x × y + z, rounded once.

LEXP.3.2.2

distance.great_circle

4

pure

(lat1, lon1, lat2, lon2: Float) → meter

Distance along the Earth's surface between two points given in degrees.

LEXP.5.11.1

has

1

pure

(path: Json path) → Bool

Whether the Json path resolves.

LEXP.6.1

distance.hypotenuse

2, 3

pure

(x, y: Float) → Float; (x, y, z: Float) → Float

Length of a vector from the origin, 2D or 3D.

LEXP.5.5

len

1

pure

(j: Json) → Int; (s: String) → Int; (b: Bytes) → Int

A Json array's length, a String's code points, or a Bytes value's bytes.

LEXP.6.1, LSTR.2.1, LSTR.4.2

math.ln

1

pure

(x: Float) → Float

Natural logarithm.

LEXP.3.9.1

math.log10

1

pure

(x: Float) → Float

Base-10 logarithm.

LEXP.3.9.1

math.log2

1

pure

(x: Float) → Float

Base-2 logarithm.

LEXP.3.9.1

distance.manhattan

4, 6

pure

(x1, y1, x2, y2: Float) → Float; (x1, y1, z1, x2, y2, z2: Float) → Float

L₁ (taxicab) distance between two points, 2D or 3D.

LEXP.5.3.1

max

2

pure

(a, b: Int | Float) → Int | Float; (cursor) → T?

The larger of a and b, of the winning operand's type, a tie giving a; with a cursor alone, the series' maximum.

LEXP.3.8.1

mean

1

pure

(cursor) → Float?

Arithmetic mean of the series' window.

LSER.16.2

median

1

pure

(cursor) → Float?

Median of the series' window, as p50.

LSER.16.2

min

2

pure

(a, b: Int | Float) → Int | Float; (cursor) → T?

The smaller of a and b, of the winning operand's type, a tie giving a; with a cursor alone, the series' minimum.

LEXP.3.8.1

monotonic_ns

0

sync-impure

() → Duration

The monotonic clock's reading.

LGRA.9.8.10

now

0

sync-impure

() → Time

The wall-clock instant.

LGRA.9.8.10

p1

1

pure

(cursor) → Float?

Percentile 1 of the series' window, interpolated.

LSER.16.4.1

p2

1

pure

(cursor) → Float?

Percentile 2 of the series' window, interpolated.

LSER.16.4.1

p3

1

pure

(cursor) → Float?

Percentile 3 of the series' window, interpolated.

LSER.16.4.1

p4

1

pure

(cursor) → Float?

Percentile 4 of the series' window, interpolated.

LSER.16.4.1

p5

1

pure

(cursor) → Float?

Percentile 5 of the series' window, interpolated.

LSER.16.4.1

p6

1

pure

(cursor) → Float?

Percentile 6 of the series' window, interpolated.

LSER.16.4.1

p7

1

pure

(cursor) → Float?

Percentile 7 of the series' window, interpolated.

LSER.16.4.1

p8

1

pure

(cursor) → Float?

Percentile 8 of the series' window, interpolated.

LSER.16.4.1

p9

1

pure

(cursor) → Float?

Percentile 9 of the series' window, interpolated.

LSER.16.4.1

p10

1

pure

(cursor) → Float?

Percentile 10 of the series' window, interpolated.

LSER.16.4.1

p11

1

pure

(cursor) → Float?

Percentile 11 of the series' window, interpolated.

LSER.16.4.1

p12

1

pure

(cursor) → Float?

Percentile 12 of the series' window, interpolated.

LSER.16.4.1

p13

1

pure

(cursor) → Float?

Percentile 13 of the series' window, interpolated.

LSER.16.4.1

p14

1

pure

(cursor) → Float?

Percentile 14 of the series' window, interpolated.

LSER.16.4.1

p15

1

pure

(cursor) → Float?

Percentile 15 of the series' window, interpolated.

LSER.16.4.1

p16

1

pure

(cursor) → Float?

Percentile 16 of the series' window, interpolated.

LSER.16.4.1

p17

1

pure

(cursor) → Float?

Percentile 17 of the series' window, interpolated.

LSER.16.4.1

p18

1

pure

(cursor) → Float?

Percentile 18 of the series' window, interpolated.

LSER.16.4.1

p19

1

pure

(cursor) → Float?

Percentile 19 of the series' window, interpolated.

LSER.16.4.1

p20

1

pure

(cursor) → Float?

Percentile 20 of the series' window, interpolated.

LSER.16.4.1

p21

1

pure

(cursor) → Float?

Percentile 21 of the series' window, interpolated.

LSER.16.4.1

p22

1

pure

(cursor) → Float?

Percentile 22 of the series' window, interpolated.

LSER.16.4.1

p23

1

pure

(cursor) → Float?

Percentile 23 of the series' window, interpolated.

LSER.16.4.1

p24

1

pure

(cursor) → Float?

Percentile 24 of the series' window, interpolated.

LSER.16.4.1

p25

1

pure

(cursor) → Float?

Percentile 25 of the series' window, interpolated.

LSER.16.4.1

p26

1

pure

(cursor) → Float?

Percentile 26 of the series' window, interpolated.

LSER.16.4.1

p27

1

pure

(cursor) → Float?

Percentile 27 of the series' window, interpolated.

LSER.16.4.1

p28

1

pure

(cursor) → Float?

Percentile 28 of the series' window, interpolated.

LSER.16.4.1

p29

1

pure

(cursor) → Float?

Percentile 29 of the series' window, interpolated.

LSER.16.4.1

p30

1

pure

(cursor) → Float?

Percentile 30 of the series' window, interpolated.

LSER.16.4.1

p31

1

pure

(cursor) → Float?

Percentile 31 of the series' window, interpolated.

LSER.16.4.1

p32

1

pure

(cursor) → Float?

Percentile 32 of the series' window, interpolated.

LSER.16.4.1

p33

1

pure

(cursor) → Float?

Percentile 33 of the series' window, interpolated.

LSER.16.4.1

p34

1

pure

(cursor) → Float?

Percentile 34 of the series' window, interpolated.

LSER.16.4.1

p35

1

pure

(cursor) → Float?

Percentile 35 of the series' window, interpolated.

LSER.16.4.1

p36

1

pure

(cursor) → Float?

Percentile 36 of the series' window, interpolated.

LSER.16.4.1

p37

1

pure

(cursor) → Float?

Percentile 37 of the series' window, interpolated.

LSER.16.4.1

p38

1

pure

(cursor) → Float?

Percentile 38 of the series' window, interpolated.

LSER.16.4.1

p39

1

pure

(cursor) → Float?

Percentile 39 of the series' window, interpolated.

LSER.16.4.1

p40

1

pure

(cursor) → Float?

Percentile 40 of the series' window, interpolated.

LSER.16.4.1

p41

1

pure

(cursor) → Float?

Percentile 41 of the series' window, interpolated.

LSER.16.4.1

p42

1

pure

(cursor) → Float?

Percentile 42 of the series' window, interpolated.

LSER.16.4.1

p43

1

pure

(cursor) → Float?

Percentile 43 of the series' window, interpolated.

LSER.16.4.1

p44

1

pure

(cursor) → Float?

Percentile 44 of the series' window, interpolated.

LSER.16.4.1

p45

1

pure

(cursor) → Float?

Percentile 45 of the series' window, interpolated.

LSER.16.4.1

p46

1

pure

(cursor) → Float?

Percentile 46 of the series' window, interpolated.

LSER.16.4.1

p47

1

pure

(cursor) → Float?

Percentile 47 of the series' window, interpolated.

LSER.16.4.1

p48

1

pure

(cursor) → Float?

Percentile 48 of the series' window, interpolated.

LSER.16.4.1

p49

1

pure

(cursor) → Float?

Percentile 49 of the series' window, interpolated.

LSER.16.4.1

p50

1

pure

(cursor) → Float?

Percentile 50 of the series' window, interpolated; the median.

LSER.16.4.1

p51

1

pure

(cursor) → Float?

Percentile 51 of the series' window, interpolated.

LSER.16.4.1

p52

1

pure

(cursor) → Float?

Percentile 52 of the series' window, interpolated.

LSER.16.4.1

p53

1

pure

(cursor) → Float?

Percentile 53 of the series' window, interpolated.

LSER.16.4.1

p54

1

pure

(cursor) → Float?

Percentile 54 of the series' window, interpolated.

LSER.16.4.1

p55

1

pure

(cursor) → Float?

Percentile 55 of the series' window, interpolated.

LSER.16.4.1

p56

1

pure

(cursor) → Float?

Percentile 56 of the series' window, interpolated.

LSER.16.4.1

p57

1

pure

(cursor) → Float?

Percentile 57 of the series' window, interpolated.

LSER.16.4.1

p58

1

pure

(cursor) → Float?

Percentile 58 of the series' window, interpolated.

LSER.16.4.1

p59

1

pure

(cursor) → Float?

Percentile 59 of the series' window, interpolated.

LSER.16.4.1

p60

1

pure

(cursor) → Float?

Percentile 60 of the series' window, interpolated.

LSER.16.4.1

p61

1

pure

(cursor) → Float?

Percentile 61 of the series' window, interpolated.

LSER.16.4.1

p62

1

pure

(cursor) → Float?

Percentile 62 of the series' window, interpolated.

LSER.16.4.1

p63

1

pure

(cursor) → Float?

Percentile 63 of the series' window, interpolated.

LSER.16.4.1

p64

1

pure

(cursor) → Float?

Percentile 64 of the series' window, interpolated.

LSER.16.4.1

p65

1

pure

(cursor) → Float?

Percentile 65 of the series' window, interpolated.

LSER.16.4.1

p66

1

pure

(cursor) → Float?

Percentile 66 of the series' window, interpolated.

LSER.16.4.1

p67

1

pure

(cursor) → Float?

Percentile 67 of the series' window, interpolated.

LSER.16.4.1

p68

1

pure

(cursor) → Float?

Percentile 68 of the series' window, interpolated.

LSER.16.4.1

p69

1

pure

(cursor) → Float?

Percentile 69 of the series' window, interpolated.

LSER.16.4.1

p70

1

pure

(cursor) → Float?

Percentile 70 of the series' window, interpolated.

LSER.16.4.1

p71

1

pure

(cursor) → Float?

Percentile 71 of the series' window, interpolated.

LSER.16.4.1

p72

1

pure

(cursor) → Float?

Percentile 72 of the series' window, interpolated.

LSER.16.4.1

p73

1

pure

(cursor) → Float?

Percentile 73 of the series' window, interpolated.

LSER.16.4.1

p74

1

pure

(cursor) → Float?

Percentile 74 of the series' window, interpolated.

LSER.16.4.1

p75

1

pure

(cursor) → Float?

Percentile 75 of the series' window, interpolated.

LSER.16.4.1

p76

1

pure

(cursor) → Float?

Percentile 76 of the series' window, interpolated.

LSER.16.4.1

p77

1

pure

(cursor) → Float?

Percentile 77 of the series' window, interpolated.

LSER.16.4.1

p78

1

pure

(cursor) → Float?

Percentile 78 of the series' window, interpolated.

LSER.16.4.1

p79

1

pure

(cursor) → Float?

Percentile 79 of the series' window, interpolated.

LSER.16.4.1

p80

1

pure

(cursor) → Float?

Percentile 80 of the series' window, interpolated.

LSER.16.4.1

p81

1

pure

(cursor) → Float?

Percentile 81 of the series' window, interpolated.

LSER.16.4.1

p82

1

pure

(cursor) → Float?

Percentile 82 of the series' window, interpolated.

LSER.16.4.1

p83

1

pure

(cursor) → Float?

Percentile 83 of the series' window, interpolated.

LSER.16.4.1

p84

1

pure

(cursor) → Float?

Percentile 84 of the series' window, interpolated.

LSER.16.4.1

p85

1

pure

(cursor) → Float?

Percentile 85 of the series' window, interpolated.

LSER.16.4.1

p86

1

pure

(cursor) → Float?

Percentile 86 of the series' window, interpolated.

LSER.16.4.1

p87

1

pure

(cursor) → Float?

Percentile 87 of the series' window, interpolated.

LSER.16.4.1

p88

1

pure

(cursor) → Float?

Percentile 88 of the series' window, interpolated.

LSER.16.4.1

p89

1

pure

(cursor) → Float?

Percentile 89 of the series' window, interpolated.

LSER.16.4.1

p90

1

pure

(cursor) → Float?

Percentile 90 of the series' window, interpolated.

LSER.16.4.1

p91

1

pure

(cursor) → Float?

Percentile 91 of the series' window, interpolated.

LSER.16.4.1

p92

1

pure

(cursor) → Float?

Percentile 92 of the series' window, interpolated.

LSER.16.4.1

p93

1

pure

(cursor) → Float?

Percentile 93 of the series' window, interpolated.

LSER.16.4.1

p94

1

pure

(cursor) → Float?

Percentile 94 of the series' window, interpolated.

LSER.16.4.1

p95

1

pure

(cursor) → Float?

Percentile 95 of the series' window, interpolated.

LSER.16.4.1

p96

1

pure

(cursor) → Float?

Percentile 96 of the series' window, interpolated.

LSER.16.4.1

p97

1

pure

(cursor) → Float?

Percentile 97 of the series' window, interpolated.

LSER.16.4.1

p98

1

pure

(cursor) → Float?

Percentile 98 of the series' window, interpolated.

LSER.16.4.1

p99

1

pure

(cursor) → Float?

Percentile 99 of the series' window, interpolated.

LSER.16.4.1

math.pow

2

pure

(x: Int, y: Int) → Int; (x: Float, y: Float) → Float

x to the power y; an Int only for an Int base and a statically non-negative Int exponent.

LEXP.3.2

pstdev

1

pure

(cursor) → Float?

Population standard deviation of the series' window.

LSER.16.3.1

pvariance

1

pure

(cursor) → Float?

Population variance of the series' window.

LSER.16.3.1

math.radians

1

pure

(x: Float) → Float

Degrees to radians.

LEXP.3.6.1

rate

1

pure

(cursor) → Float?

(last − first) / elapsed seconds over the series' window.

LSER.16.9

round

1

pure

(x: Int) → Int; (x: Float) → Int

Nearest integer, ties to even; a Float with no Int answer traps.

LEXP.3.2

math.sign

1

pure

(x: Int) → Int; (x: Float) → Int

1 when x > 0, −1 when x < 0, else 0.

LEXP.3.2

math.sin

1

pure

(x: Float) → Float

Sine of x radians.

LEXP.3.9.1

math.sinh

1

pure

(x: Float) → Float

Hyperbolic sine.

LEXP.3.9.1

math.sqrt

1

pure

(x: Float) → Float

Square root, correctly rounded; NaN for a negative x.

LEXP.3.2

stdev

1

pure

(cursor) → Float?

Sample standard deviation of the series' window.

LSER.16.3.1

math.tan

1

pure

(x: Float) → Float

Tangent of x radians.

LEXP.3.9.1

math.tanh

1

pure

(x: Float) → Float

Hyperbolic tangent.

LEXP.3.9.1

calendar.time

3, 6, 7

pure

(year, month, day: Int) → Time; (year, month, day, hour, minute, second: Int) → Time; (year, month, day, hour, minute, second, nanosecond: Int) → Time

The UTC instant of that calendar day and wall-clock time.

LTIM.14.1

math.trunc

1

pure

(x: Int) → Int; (x: Float) → Int

x truncated toward zero; a Float with no Int answer traps.

LEXP.3.2

variance

1

pure

(cursor) → Float?

Sample variance of the series' window.

LSER.16.3.1

ratified