bendbis · Bend, in Bend
01bendbis · 2026-11-29

Bend, written in Bend: upstream's answers, byte for byte, and its test suite in a third of the time

bendbis is Bend 2's checker ported from TypeScript to Bend itself, gated against upstream bend as its oracle. Every file upstream checks, it checks the same way, to the byte of every message; upstream's own test suite runs through it in about a third of the time.

It is built as a pair of functors: F takes Bend's programs into bendbis unchanged, G lowers what bendbis adds back to plain Bend. That shape is the whole design: it is why bendbis can be swapped in for upstream, and why its additions never fork the language.

2,161 / 2,161files answer exactly as upstream: stdout, stderr and exit code, byte for byte (upstream's 1,880 tests and base.bend, its guide's 28 examples, ana's 253 files)testedbendbis README.md, "How good is it", at fc1c158; again at 99e3d64 (gate23)
0.34×upstream's time on upstream's own test suite: 374 s against 1,091 s, 12 files at a timemeasuredbendbis README.md, "Since then" (fbad9c0, 2026-11-28, olimpo), at fc1c158
15×faster on a law summing 8,000 U32s: 0.30 s against 4.7 s, Base's U32 operations run as nativesmeasuredbendbis README.md, "Since then", at fc1c158; bendbis DESIGN.md, "U32 natives", at fc1c158
0 / 5,606,360of bendbis's F64 results differ from the machine's double (IEEE 754 binary64, in plain Bend)testedbendbis DESIGN.md, "bend and bendbis: the adjunction" (2026-11-27), at fc1c158
41laws proven by upstream's kernel, BendTT (--verdict): 34 in LAWS.bend, 7 in the start of BendTT's port to Bendprovedbendbis README.md, "How good is it", at fc1c158

claimedbendbis is a derivative work of Bend (bendlang/bend, by Victor Taelin and HigherOrderCO), under the Apache License 2.0. Without Bend there is nothing here: the next page says what bendbis takes from it.bendbis README.md, its opening and "Credits", at fc1c158; NOTICE

Keys: → and ← move between pages, a shows every page at once. Each statement is marked: proved (BendTT's kernel, --verdict), tested (a comparison, byte for byte or bit for bit), measured, claimed, done, decided, lead or open.

02Credits first

Standing on Bend

bendbis exists because of Bend, by HigherOrderCO. Bend was created by Victor Taelin and built by its team: Lorenzo W Battistela, Paulo J Cavalcanti, Nico Abril, Vanessa Ostroski, Vitor Chiarelli Neves and Alex Van de Sande, along with everyone who has contributed to bendlang/bend.

What bendbis takes from BendHow
The language and what it meansbendbis's lexer, parser, checker and error messages are a port of upstream's bend2/bend.ts, made from commit 0e2f38f7; every file under src/ says so in its header
The base librarybend2/base.bend, read as upstream reads it
The oracleupstream's bend decides what bendbis must answer; its tests/ and the Bend blocks of its guide/*.md are bendbis's gate
The proven kernelBendTT (bend2/bendtt.lean) checks bendbis's laws, and src/BendTT.bend is the start of its port to Bend
The compilerbendbis is built by upstream: bend src/Main.bend -o bendbis
bendbis README.md, "Credits", at fc1c158

claimedBend is shared under the Apache License 2.0, and so is bendbis (LICENSE, NOTICE). Mistakes in bendbis are bendbis's own: report them to bendbis, not upstream.bendbis README.md, "Credits", at fc1c158; NOTICE

03The functor approach

Two categories, F there, G back

Bend is upstream's programs (books) with the meaning upstream gives them: its checker's verdict, its run. Bendbis is those programs plus bendbis's additions (F64 first), with the meaning bendbis gives them. F : Bend → Bendbis is the inclusion: an upstream program is a bendbis program, unchanged. G : Bendbis → Bend is the lowering: every addition replaced by its definition in plain Bend.

LevelWhat it isWhat it gives bendbis
1HomomorphismG is a fold over the term algebra: the identity on every form upstream has, an addition's leaf to the library's termG commutes with every constructor and with substitution: lowering is local, never a whole-program rewrite
2FunctorG keeps identities and composition; G of an import is the import of G. F is compositional over a book's filesa file's check is fixed by it and its imports': checks can be kept under a file's digest (planned)
3Naturalityphi: native F64 → library F64 is the identity on the bits, so each square is a law: native op(x) == library op(x)every native operation is held, case by case and by law, to a definition anyone can read
4Adjunction F ⊣ Gthe unit is the identity; the counit is the squares of 3; both triangles are gatesan equivalence of meanings: an addition changes cost and convenience, never what a program means
bendbis DESIGN.md, "bend and bendbis: the adjunction", at fc1c158

decidedThe user, 11-27: "The functor should go from regular bend to bendbis (our bend version implemented in bend) and the other functor should go from bendbis to bend ... I want correctness and more speed than regular bend." And: "Any addition to regular bend, like U64 should be very well delimited by laws."bendbis DESIGN.md, "bend and bendbis: the adjunction", at fc1c158

04F, the inclusion

Correctness, as a gate: a drop-in for upstream

What F claims is bendbis's correctness: bendbis gives F(p) the meaning upstream gives p. At the level of the checker, that is a gate anyone can rerun: bendbis FILE --check-only against bend FILE --check-only, stdout, stderr and exit code, each file in its own process.

SetFilesSame as upstreamDifferentTimed out
upstream's tests/ and bend2/base.bend1,8801,88000
the Bend blocks of upstream's guide/*.md282800
ana's bend/ (d4cafc4), against Bend 2.0.3925325300
bendbis README.md, "How good is it", at fc1c158

testedThe gate is run again after every change that is kept: the last speed work (closures out of the parser's and checker's cold paths) passed it on 1,880, 28 and 253 files, η and G the same, exit 0.99e3d64, its message (gate23)

leadF is compositional over a book's files, so a check can be kept under the digest of a file and its imports, as cata's cache does: a speed lead, planned, not built.bendbis DESIGN.md, "bend and bendbis: the adjunction", at fc1c158

openF is gated at the checker's verdicts today; runs come with milestone 4, which is not started.bendbis DESIGN.md, "The gates", at fc1c158

05G, the lowering

Additions that never fork Bend

An addition is replaced by its definition in plain Bend, so a bendbis program runs on upstream bend before bendbis runs anything itself, and every addition has a meaning in Bend that a law can name. F64 is the first: import F64 and literals like 1.5d.

import Base
import F64                     # bendbis's; upstream refuses it

def area(+r: F64.F64) -> F64.F64:
  (3.141592653589793d * r * r : F64.F64)

./bendbis area.bend --check-only   # bendbis reads it as G(area.bend)
./bendbis lower area.bend          # G(area.bend): plain Bend that
                                   # upstream bend checks and runs

testedThe unit η : P → G(F(P)) is the identity: G leaves every one of the 2,161 upstream files unchanged, byte for byte.bendbis DESIGN.md, "bend and bendbis: the adjunction" (4), at fc1c158; gate/adj.sh

testedA triangle, G(ε) · η(G) = id, is G's idempotence, G(G(Q)) = G(Q): a gate.bendbis DESIGN.md, "bend and bendbis: the adjunction" (4), at fc1c158; gate/adj.sh

donelib/F64.bend is IEEE 754 binary64 over Base alone, no @unsafe: add, sub, mul, div, sqrt, neg, abs, the comparisons, from_u32, from_f32, to_f32, round to nearest, ties to even.bendbis DESIGN.md, "Every addition, delimited by laws", at fc1c158; bendbis README.md, "F64, bendbis's first addition", at fc1c158

06Naturality

Every addition, delimited by laws

An addition comes with four things: its definition in plain Bend (lib/F64.bend); its specification as the standard states it, written to be read and sharing no rounding code with the definition (lib/SPEC.bend); laws, proven (lib/LAWS.bend) or stated (lib/OPEN.bend); and gates against outside oracles, each with mutants that must fail.

Gate (2026-11-27, olimpo)CasesDiffer
F64.bend against the machine's double, N = 200,0005,606,360 lines0
OPEN.bend's laws, F64.bend against SPEC.bend, N = 20,000488,192 checks0
mutant: ties away from zero, not to even62,360 lines; 12,992 checks122; 78
mutant: the far operand stood in for from 52 bits apart, not 6062,360 lines106
mutant: the quotient one bit short62,360 lines4,993
mutant law: add.tie_down claims 1 + 2^-52--check-onlyrefused
bendbis DESIGN.md, "bend and bendbis: the adjunction", the F64 table, at fc1c158

provedbend lib/LAWS.bend --verdict: ALL PROOFS CHECK. For every input sub is add of the negation, is_ne is not is_eq, neg(neg(x)) = x, abs(abs(x)) = abs(x); and IEEE 754's rule table at 23 named inputs (signed zeros, ties to even both ways, overflow, gradual underflow, division by zero, NaN's cases), each proven by computing it.bendbis DESIGN.md, "Every addition, delimited by laws" (3), at fc1c158

openOPEN.bend's 8 laws, op(a, b) == SPEC's op(a, b) for every input, are stated and tested, not yet proven (8 TODOs).bendbis DESIGN.md, "Every addition, delimited by laws" (3), at fc1c158

07F32, delimited too

Laws for what upstream leaves opaque

Base declares its F32 operations as laws with a type and nothing else: the checker cannot compute them, and ana calls them about a thousand times. bendbis states them: SPEC.bend's s32 operations, NATIVE32.bend's laws (op(a, b) is SPEC's op on the bits), and a gate that holds upstream's own C and JS builds to them.

Gate (2026-11-28, olimpo, upstream 0e2f38f7)ChecksDiffer
C, N = 20,000486,2720
JS (node), N = 20,000486,2720
mutant: ties away from zero, not to even, C, N = 2,00054,272212
mutant: a product's exponent one too big, C, N = 20011,072843
mutant: x + -x is -0, C, N = 20011,07227
mutant: sqrt(-0) is +0, C, N = 20011,07228
mutant: -0 < +0, C, N = 20011,0725
bendbis DESIGN.md, "bend and bendbis: the adjunction", the F32 table, at fc1c158; ed3dd24

openexp, log, pow, sin, cos, tanh and the rest are each executor's libm rounded to F32 (C's, the JS engine's, CUDA's): no law holds for them today.bendbis DESIGN.md, "What ana needs that upstream Bend has but does not delimit" (1), at fc1c158

08The adjunction

Cost and convenience change; meaning never does

F ⊣ G. The unit η : P → G(F(P)) is the identity (an upstream program has no addition). The counit ε : F(G(Q)) → Q is the squares of naturality: Q's native additions agree with their definitions. The triangles: G(ε) · η(G) = id is G's idempotence, ε(F) · F(η) = id holds because ε is the identity on an upstream program.

Since F64's definition is exact, not an approximation, ε is an isomorphism and the adjunction is an equivalence of meanings. What an addition buys is cost (a native F64 is the machine's double; its definition is big-natural arithmetic) and convenience (literals, names). What it can never buy is a program that means something upstream cannot say.

PieceWhere it is held
η = idgate: G on 2,161 upstream files, byte for byte unchanged
ε, the squaresF64.bend against the machine's double (5,606,360 lines, 0 differ); OPEN.bend's laws against SPEC (488,192 checks, 0 differ); 8 laws still open
G(ε) · η(G) = idgate: G idempotent
ε(F) · F(η) = idby construction: ε is the identity where there is no addition
bendbis DESIGN.md, "bend and bendbis: the adjunction" (3, 4), at fc1c158
09Speed

Faster on the suites, still slower on the biggest files

InputUpstreambendbisbendbis / upstream
upstream's tests and base.bend (1,880, 12 at a time)1,091 s374 s0.34
ana's 253 files (12 at a time; gate16's day, one run each)115.1 s50.5 s0.44
ana's CorpusV2/ExlawText.bend2.7 s1.3 s0.47
ana's Walk.bend2.4 s1.9 s0.78
ana's tests/SimDrive.bend9.4 s13.1 s1.4
ana's Everything.bend1.3 s2.1 s1.6
a law summing 8,000 U32s4.7 s0.30 s0.06
bendbis README.md, "Since then" (fbad9c0, 2026-11-28, olimpo, a Ryzen 7 3700X; two runs each), at fc1c158

measuredLater the same day, after the closures left the cold paths too: ana's 253 files 12 at a time in 48.9 to 49.2 s against upstream's 70.2 s; ana's Everything.bend 1.32 to 1.33 s on 16 threads against upstream's 1.30 to 1.42 s (even, not faster).99e3d64, its message

openStill slower: parsing, most of all where a match on strings over two columns flattens to millions of term nodes (SimDrive: 3.7M nodes), and the single biggest files (Everything.bend).bendbis README.md, "Since then", at fc1c158

10How

The same output, at another cost

Every change below keeps the gate's 2,161 files byte for byte; what differs is only what an answer costs.

  • Names as numbers, compared lent and never counted (nm.eq).
  • A checker with no closures: a rule's rest after a premise is a frame, plain data; then the parser's hot readers and both cold paths, the same way.
  • Share cells only inside one comparison, in a store dropped when it answers, and as a flat array.
  • Base's U32 operations on literals run as natives.
  • Match flattening makes no substitution that nothing reads; an error's message is built only when it is reported.
  • A def body's normal form read in one walk; Base checked once a process, and only when imported.
  • Parallel where the meaning allows: the files of each level of the import graph parsed at once, and the book's events validated at once, then kept in book order.

doneEach in a commit of its own, each through the gate before it was kept.bendbis README.md, "Since then", at fc1c158; bendbis DESIGN.md, "What bendbis does differently", at fc1c158; 51c3e1d, 2025545, 99e3d64, 5843167, 06009fb

11No proof of False

What is proven, and about what

provedLean v4.34.0 checks upstream's bend2/bendtt.lean (3,861 lines): its theorems halts, consistent and adequate rest only on Lean's standard axioms (propext, Classical.choice, Quot.sound), with no sorry, no axiom of the file's own and no native_decide. consistent: if a book checks, none of its defs has a type that converts to Empty.bendbis DESIGN.md, "No proof of False", at fc1c158; gate/axioms.sh

openbendbis has no --verdict of its own yet: its checker, like upstream's --check-only, is exact against upstream on the gate's files and is not claimed sound. Its own laws are checked by upstream's kernel.bendbis README.md, "Not done yet", at fc1c158

openTrusted, not proven: safe.ts's translation of a book for the kernel (a wrong one would have the kernel check another statement), the kernel's text parser, Lean's compiler, and Lean's kernel with its three axioms. And by Gödel's second theorem BendTT cannot prove its own consistency, so that port is not tried.bendbis DESIGN.md, "No proof of False", at fc1c158

12What holds

Proved, tested, measured, open: pick a kind

Three levels of checks are never one label: --check-only (a checker accepts the file), a comparison (byte for byte against upstream, or bit for bit against a machine), and --verdict (BendTT's kernel, which has a proof in Lean).

Show

14 of 14

testedbendbis --check-only answers as upstream on 2,161 of 2,161 files, byte for byte: 1,880 of upstream's tests and base.bend, 28 guide examples, 253 of ana's files.bendbis README.md, "How good is it", at fc1c158

testedG leaves every upstream file unchanged (η = id), and G is idempotent.bendbis DESIGN.md, "bend and bendbis: the adjunction", at fc1c158

testedF64.bend against the machine's double: 5,606,360 lines, 0 differ; three mutants caught.bendbis DESIGN.md, the F64 table, at fc1c158

testedUpstream's F32 natives against SPEC's s32 operations, on C and on JS: 486,272 checks each, 0 differ; five mutants caught.bendbis DESIGN.md, the F32 table, at fc1c158; ed3dd24

provedLAWS.bend's 34 laws and BendTT.bend's 7 by upstream's kernel: ALL PROOFS CHECK.bendbis README.md, "How good is it", at fc1c158

provedlib/LAWS.bend (F64): sub, is_ne, neg, abs laws for every input, and IEEE 754's table at 23 named inputs.bendbis DESIGN.md, "Every addition, delimited by laws", at fc1c158

provedBendTT's halts, consistent and adequate rest only on Lean's standard axioms.bendbis DESIGN.md, "No proof of False", at fc1c158

measuredUpstream's test suite: 374 s against 1,091 s (0.34).bendbis README.md, "Since then", at fc1c158

measuredA law summing 8,000 U32s: 0.30 s against 4.7 s.bendbis README.md, "Since then", at fc1c158

measuredana's Everything.bend: 2.1 s against 1.3 s (1.6, slower).bendbis README.md, "Since then", at fc1c158

openOPEN.bend's 8 laws (each F64 operation equals SPEC's for every input) are stated, not proven.bendbis DESIGN.md, "Every addition, delimited by laws", at fc1c158

openNo --verdict of its own; no running programs (milestone 4), no C (5), no GPU (6).bendbis README.md, "Not done yet", at fc1c158

leadChecks kept under a file's digest, as F's compositionality allows.bendbis DESIGN.md, "bend and bendbis: the adjunction", at fc1c158

decidedEvery addition is delimited by laws: a definition, a specification, laws and gates with mutants.bendbis DESIGN.md, "Every addition, delimited by laws" (the user, 11-27), at fc1c158

13Not done yet

What bendbis does not claim

  • No --verdict of its own: its checker is exact against upstream on the gate's files, not claimed sound.
  • It does not yet run programs (milestone 4), emit C (5) or run on a GPU (6).
  • It is slower than upstream on the biggest single files (Everything.bend, SimDrive).
  • F64's 8 delimiting laws are stated and tested, not proven; F32's transcendental functions have no law.
  • The port of BendTT to Bend has its first lemmas, not its theorems.

Source: bendbis README.md, "Not done yet", and DESIGN.md, "The gates", at fc1c158.

14This site

Made with bend-frp

The pages are data in Bend (Deck.bend); bend-frp runs the page, Nav.bend moves between pages, and "What holds" is sorted by Doc.bend's pick. Its frame is cata-site's (cata.hhefesto.dev).

provedIts laws: moving never changes the number of pages, next then back returns where you were, going to page k from anywhere lands on k, the keys and addresses mean what this page says, "all" shows every fact and a kind shows only facts of that kind, and every claim, table, card and fact names a source. bend PROOF.bend --verdict prints ALL PROOFS CHECK.bendbis-site's LAWS.bend and PROOF.bend