Reference

The Prelude

Hilbert's standard library — 46 modules written in Hilbert itself, from ring identities to reinforcement learning.

The Prelude ships with the compiler. Nothing in it is special: every module is a .hb file of defs and laws built from the intrinsics — einsum, a few elementwise maps, two reductions, triangle and the extents rows and columns. Bring a module into a document with open:

open Prelude.Statistics
open Prelude.Regression

Opening a module also brings in the modules it opens. All names share one namespace, so a doorway you write must not reuse a Prelude name (see The language).

How to read a reference page

Every definition is stated the way a mathematician states it: first each symbol is introduced — let \(x \in \mathbb{R}^n\) be a column of \(n\) values — then the result is given as a formula, derived from what the definition actually computes (including guards, floors and the number of iterations). The notation is shared across all pages:

Notation Meaning
\(x \in \mathbb{R}^n\), \(x_i\) a vector of length n and its components
\(A \in \mathbb{R}^{n \times p}\), \(A_{ij}\) a matrix and its entries; a data matrix has one row per observation
\(A \odot B\) the elementwise product
\([P]\) the Iverson bracket: 1 if \(P\) is true, 0 otherwise — how Hilbert writes a comparison mask
\(\mathbf{1}_n\), \(I_p\), \(e_k\) the vector of ones, the identity matrix, a basis vector
\(d + [d = 0]\) a guarded divisor (safe): a zero is replaced by one
\(u \in [0, 1)^n\) independent uniform draws supplied by the caller
  • Each customer-facing definition has its own entry: the signature with the meaning and shape of every parameter, its mathematical statement, what it is for, and its definition copied from the source.
  • Beside each entry, a why note gives the intuition (how to picture the quantity and why it is shaped that way) and use it when (the problems it solves, practical tips, and which sibling to use instead). The tags at the foot of the note name the kinds of problems it helps with, such as outlier-detection or credit-assignment.
  • Building blocks — helpers, loop bodies and intermediate terms — are listed at the end of each section, each with its own mathematical statement. They can be used, but they exist to serve the entries above them.
  • Examples at the end of each page were compiled with the Hilbert compiler and run; the outputs shown are the real outputs.
  • Shapes use n for observations (rows of a data matrix), p for features, k for classes or clusters, s and a for states and actions.

Randomness is an argument. No Prelude definition draws random numbers by itself. Samplers, bootstraps and simulations take their uniform or Gaussian draws as tensors, so every result is reproducible from its inputs. Models and processes generate seeded draws for you.

Chemistry

Materials

Agents

Reference

Foundations

Statistics

Machine learning

Stochastic processes

Evolution

Graphs

Reinforcement learning