# Lumbda — feedback as a primitive
Lumbda — a Lisp/Scheme-derived language with four execution backends (Python, Python bytecode VM, C + x86_64 JIT, pure x86_64 GNU asm), full first-class continuations, portal-based state migration, and a formally verified universality proof.

Lumbda names a Lisp/Scheme-derived language carrying four independently implemented execution backends — one surface syntax, one test suite. A Python tree-walker with an optional bytecode VM, a C implementation that adds an x86_64 JIT, and a pure x86_64 GNU asm interpreter (~6,600 lines, ~23 KB stripped, zero external dependencies). Every backend runs a shared `.lsp` source byte-identically, with full first-class continuations, exact rationals, records, and hygienic macros.

## Get it

    git clone https://git.unturf.com/engineering/unturf/lumbda.git
    cd lumbda
    make test-all

Run a program in any tier:

    python3 lumbda.py --fast examples/fibonacci.lsp
    ./c/lumbda examples/fibonacci.lsp
    ./asm/lumbda < examples/fibonacci.lsp

## Four tiers, one language

Tier | Lines | Binary | What a tier buys
--- | --- | --- | ---
Python interpreter + bytecode VM | 3,743 | — | REPL hackability, debugging, reference
C tree-walker + bytecode VM | 9,164 | ~215 KB | deep recursion, production workloads
C + x86_64 JIT | +patches | ~215 KB | 7–10× faster than CPython on recursive workloads
Pure x86_64 GNU asm | 6,645 | ~23 KB | zero-dependency boot, auditability, embedded
GNU asm + naive mark-sweep GC + meta-GC arena | (same source, `GC_NAIVE=1`) | ~27 KB | bounded memory without manual arena discipline

## Portal: feedback across time

A continuation carries feedback within a process. A portal carries feedback across processes. Same primitive, different scope: capture machine state, serialize, reload elsewhere, resume. Lumbda ships three portal formats with distinct trade-offs:

- S-expression portal — Scheme source as a wire protocol. 16 of 16 producer×consumer cells green across Python, C, asm no-GC, and asm GC.
- JSON portal — graph-aware, preserves closures and live continuations (Python, C).
- Binary heap dump — asm only. 1.5 ms save+resume between two processes.

## bend: dispatch to a GPU without rewriting your code

Wrap any registered GPU-able form in `(bend …)` and lumbda decides per call whether to run it locally or ship it to a CUDA worker over our wire protocol. Tiny inputs stay local; heavy inputs bend to a worker that holds a warm CUDA context across requests.

    (bend (cuda-shake-fanout one-million-inputs 32))   ; → 157 ms on a 3090
                                                       ;   12× faster than host hashlib

Real workloads from the catalog: SHAKE256 fan-out (12× over host hashlib at 1 M inputs), secp256k1 batched point-mul (13.6 Mkeys/s on a 3090, ~309× coincurve CPU), tableau stabilizer sim (186× over Stim CPU, surveyed), and a quantum-reversible circuit simulator wired live to internal ECDSA research.

Read the full bend page — protocol, benchmarks, form catalog

## EML universality proof

A single operator `eml(x, y) = exp(x) − ln(y)` with a constant 1 generates all elementary functions: `exp`, `ln`, arithmetic, negation, complex-plane access, trigonometry. Verified numerically in Python, verified in Lumbda's own bytecode, proven formally in Lean 4 with zero `sorry`. Lumbda's native symbolic-rewrite checker runs five theorems in 46 ms cold or 7 ms cached — roughly 16× faster than Lean's cold rebuild on identical hardware.

## Whitepaper

Full language reference, tier-by-tier architecture, benchmarks, meta-GC design, universality proof.

Read in browser (HTML) Download PDF (~2.7 MB)

## License

AGPL-3.0-only. Public domain for whitepapers, proofs, and disclosures through undefect.com. Companion to unturf.com’s permacomputer project.

## Try it in your browser

All three tiers compiled to WebAssembly — Python (Pyodide hosting `lumbda.py`), C (Emscripten), and a hand-written WAT parallel to `asm/lumbda.s`. Pick a demo, pick a tier (or run all three side by side), and watch the same Lisp source evaluate three different ways.

Open the playground →