MLambda Hilbert · documentation

Mathematics, written as mathematics.

Hilbert is a language for people who do mathematics, not programming. You write a formula the way it appears on paper — def radians(d) ≔ d · π / 180 — and the compiler turns it into C# for real numbers and into an ONNX graph for vectors, matrices and tensors. A standard library of nearly 1,400 definitions, the Prelude, covers statistics, linear algebra, machine learning, stochastic processes and reinforcement learning — all of it written in Hilbert, on top of one operation: Einstein summation.

open Prelude.Statistics
open Prelude.LinearAlgebra

fn average(x)       ↦ mean(x)
fn spreadOf(x)      ↦ std(x)
fn product(a, b)    ↦ einsum("ij,jk->ik", a, b)
fn solved(a, b)     ↦ solve(a, b)
Summaries.hb — four formulas, compiled at build time.
var m = Summaries.Average(new[] { 1d, 2d, 3d, 4d });   // 2.5
var p = Summaries.Product(a, b);                       // runs as ONNX
Program.cs — the generated class is ordinary C#.

Why Hilbert

Numerical code usually hides the mathematics inside loops, indices and library calls. Hilbert keeps the mathematics as the source.

  • The formula is the program

    A def is a definition, a fn is what your program calls. There are no loops to write: repetition is a definition that names itself, and the compiler makes it a bounded loop.

  • One formula, every shape

    fn sum(x, y) ↦ x + y compiles to overloads for reals, complex numbers, vectors, matrices and tensors. Shaped values run as an ONNX graph — on the calling thread when small, on ONNX Runtime when large.

  • Nothing is hidden

    The compiler knows no identities and no derivatives. sin² + cos² = 1 and the chain rule are laws in the Prelude that you can read — and every algorithm, from Cholesky to Q-learning, is a page of Hilbert.

Where to go next