Skip to content

whichroot/traveler

Traveler

A general-purpose systems language for analytical and algebraic computation.

Traveler began as a single observation about compression: data generated by arithmetic processes is polynomial over the integers, and standard compressors measure its entropy in a different coordinate system.

Many arithmetic and physical data streams are exactly or locally well modeled by low-degree polynomial regimes under an appropriate sampling and representation contract. A counter is degree 1. An accelerometer under constant acceleration is degree 2.

That observation turned out to be not just a compression trick but algebra: four operations over a prime field.

Traveler is the language built by taking that algebra seriously: promoting the field, the polynomial register, the regime to first-class types, and letting a compiler reason about them directly.

field F = Field<251>;          // the prime is part of the type, think of it as "memory allocation but for arenas"

fn main() {
    let a: F = 200;
    let b: F = 100;
    print(a + b);              // 49   (300 mod 251) — branchless, exact, no floats
    print(a * b);              // 171  (20000 mod 251)
    print(a / b);              // 2    (200 * inv(100) mod 251)
    print(1 / 100);            // 123  (inverse via Fermat — a theorem of the axioms)
}

What makes it different

  • The prime field is a type. Field<p> is checked, monomorphized, and compiled to branchless modular arithmetic. Fields runs over a compile-time prime or a runtime prime (field(p)).

  • Dispatch is over data, never code. Traveler has generics, traits, operator overloading, function pointers, and closures but every call target is statically known. A runtime-chosen field defers a value, never the structure.

  • Auto-parallelization A loop over field elements parallelizes when the compiler can prove the iterations are independent. The soundness is defined by default-deny.

  • Self-hosting The compiler (src/tvc_self.tv) is written in Traveler. The first binary is built from a checked-in Traveler-produced snapshot of itself (src/bootstrap/tvc_self.boot.ll); llc plus a linker.

  • Crypto over a runtime prime. NTT, Poseidon2, Merkle, FRI, and PLONK are all in the library, all generic over the field, all working over a prime chosen at runtime.

The four operations

The kernel everything else is built on (src/lib/core/poly_core.tv) is four operations. libc-free, allocation-free, target-agnostic:

Operation What it does
forward_diff recover a polynomial's coefficients from its values
forward_sum reconstruct the values from the coefficients
regime_detect find where one polynomial regime ends and the next begins
eval_at evaluate the polynomial at a point

p > 0 gives field arithmetic; p = 0 gives raw integers;

Where the field is the right tool

The question is which coordinate fits, not whether the field wins. Your imagination is the only limitation to building with Traveler.

Build

You need LLVM 15+ (llc) and any C toolchain's cc (used only as a linker). Then:

export LLC=/opt/homebrew/opt/llvm@21/bin/llc   # your llc path
src/bootstrap/build.sh
# -> src/bootstrap/out/stage1 is the canonical compiler. No C source compiled.

Compile and run a program:

src/bootstrap/out/stage1 examples/field_basics.tv -o /tmp/fb.ll
$LLC -filetype=obj /tmp/fb.ll -o /tmp/fb.o && cc /tmp/fb.o -o /tmp/fb
/tmp/fb          # 49 100 171 2 123 1

Full build details are in BUILD.md.

Repository layout

src/
  tvc_self.tv          the compiler. a straight read through of compiler theory 101
  bootstrap/           boot IR + build.sh + refresh.sh
  tools/               tvfmt (formatter), tvdoc (doc generator)
  lib/                 the standard library, by subsystem:
    core/              polynomial kernel
    collections/       Vec<T>, Str, HashMap<K,V>
    crypto/            NTT, Poseidon2, Merkle, FRI, PLONK
    zk/                #[zk] circuits
    codec/             piecewise polynomial compression
    regime/            regime segmentation + ZK composition
    genus/             shape / genus classification
    features/          relational + turning descriptors
    dsp/               DSP
    observe/           Topology observation
    nt/                Required library for O(N^2)
    net/               Networking support (thin as of now)
    ecc/               Reed-Solomon erasure + error decode (GF(2^8), GF(2^16))
    float/             IEEE-754 -> dyadic rationals (exact at rest)
    fmt/               JSON support
    rns/               exact auto-parallel NN matmul
    util/              math helpers, streaming protocol
    time/              Monotonic/Wall Clock
    fs/                buffered file I/O
    net/               TCP sockets + minimal HTTP over POSIX
    time/              monotonic + wall clock, sleep
src-legacy/            the original C bootstrap seed (optional, frozen)
spec/                  the language specification
examples/              things you can do with traveler, alternative test suite before promote
tools/tv-lsp/          Language Server (diagnostics, hover, go-to-def (incomplete))
tests/                 test suite (regression, parity, pfor, dynfield, bootstrap)

Tooling

  • LSP (tools/tv-lsp/) — inline diagnostics, hover signatures, scope-aware go-to-definition. The intelligence lives in the compiler itself (--diagnostics, --symbols, --references modes); the server is a thin transport.
  • Formatter (src/tools/tvfmt.tv) — idempotent, meaning-preserving.
  • Doc generator (src/tools/tvdoc.tv) — Markdown API docs from source.

Tests

tests/run_dual.sh    # the full gate: regression + pfor + dynfield + bootstrap,
                     # then Stage 1 build + dual-compiler parity

Stage 2 (the compiler compiling itself) must be byte-identical to Stage 3 (Stage 2 compiling itself).

Status

v0.1.0 - Early Alpha. For research purposes only.

Developed privately pre-0.2; public history begins at the v0.2.0 root commit and proceeds as tagged release drops.

Disclaimer

Traveler is an [alpha] product; ZK-proof infra is unverified by a third party at this time.
Use at your own risk or verification.

Contributing

Contributions are welcome — bug reports, tests, examples, stdlib work, and compiler changes. Traveler carries a few strict invariants (a byte-identical self-hosting fixed point, a module size cap, dual-compiler parity), so please read CONTRIBUTING.md before opening a PR. In short:

  • Discuss first for anything large or compiler-touching (src/tvc_self.tv); small fixes can go straight to a PR.
  • The full gate is tests/run_dual.sh, and it must be green.
  • Commits use Conventional Commits and a DCO sign-off (git commit -s).

By participating you agree to our Code of Conduct. To report a vulnerability, see SECURITY.md.

License

Apache License 2.0. See LICENSE.

About

General-purpose systems language for algebraic and analytic computation.

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages