跳转到内容

Bend2 for verified parallel agents

Related: 2026-09-27 Formal verification in agent-driven development · 2026-09-27 Lean 4 agents for verified software · 2026-09-27 Agent FV toolbox and DIY playbook · Cloud agent orchestrator


ClaimConfidenceNote
Bend2 is a real public Apache-2.0 language with laws/proofs + BendRTHighbendlang/bend README + GUIDE
Bend2 = Bend1 / HVM2FalseExplicit: “Bend 1 programs and HVM do not carry over”
Production-ready metatheory-certified compilerLowCompiler ~99% AI-written / unaudited; checker unproven except --safe; documented Lean formalization mismatches (what-is-bend2)
Checker speed ⇒ better agent proof economicsLowCheck 0.295s vs Lean 36s on synthetic 12.8k defs — not mathlib port; missing tactics can raise LLM repair cost (bend2-vs-lean)

ArtifactOrg / repoRuntimeProof storyParallelism
Bend 1HigherOrderCO/BendHVM2No dependent law language in published Bend1 syntaxAutomatic parallel reduction; run-cu CUDA
Bend 2bendlang/bend · bend-lang.comBendRT (C; Metal/CUDA via f!)Dependent types + law / proof def; LAWS.bend + PROOF.bendExplicit balanced fork/join a b = f(x) g(y); no work stealing

Bend2 = Bend version 2, not a separate product name. Do not conflate when choosing a fleet stack (README extract).

Status pin in independent notes: Bend 2.0.5 / limits as of 2026-09-20 (what-is-bend2).


Upstream framing: ambiguity-free intents for AI builders — laws more precise than NL, proofs that edits obey them, fast CPU/GPU execution.

LAWS.bend # human claims (AI must not edit)
PROOF.bend # AI proofs: def Laws.<name> mirrors law <name>
bend PROOF.bend # CI gate — "All terms check."
bend PROOF.bend --safe # + BendTT Lean kernel recheck

From bend2.dev/learn/proofs (half_ok worked example):

  1. Predicate as type (IsEven(n): Type via match; odds → Empty).
  2. Executable half by structural match.
  3. law half_ok with for x: Nat / for e: IsEven(x) / {Nat.double(half(x)) == x : Nat}.
  4. def half_ok proves the law: {==} when sides compute equal; Empty elim via empty match; recursive IH with rewrite motive %ih : motive where _ marks the replaced slot.
  5. Recursion must use structurally smaller arguments; @unsafe bypasses and leaves proof discipline.

Agent repair target: emit matching law+def, use {==}, %ih : motive, Empty-elim — no tactics to lean on (learn/proofs extract).

  • Fork/join: programmer splits; fixed assignment, no work stealing — uneven trees are the author’s problem.
  • f!(x) marks GPU (Metal/CUDA); IO stays on host.
  • Affine ownership independent of app laws: plain Array<T> one owner; + / is Data for reuse.
  • Numbers: Nat, U32, F32 only (no U64/I64/F64; Metal has no f64). F32 axiomatic — nothing about FP can be proven.
  • Effects (print, env, files, TCP/UDP, …): foreign C/JS outside source proofs. “A source-level proof over Order does not verify that foreign implementation, the database… or the network.” (what-is-bend2)

Upstream M4 Max pins (Bend modes only): Game of Life 7.803s → 0.647s parallel CPU → 0.063s GPU; Lexer 2.144s → 0.198s / 1.075s GPU.


DimensionLean 4Bend 2
Proof constructionTerms or tactics; huge automationExplicit proof terms; no tactics (2.0.5 notes)
Proof reusemathlib + packagesBase + demos; small
Native parallelTasks / RCBalanced fork/join
GPUForeign / externalMarked ! on Metal/CUDA
Agent maturityMany harnesses + benches (Vero, CLEVER, …)Young; community reports agent proof effort can be harder than Lean for same claim (seed cites yalexey)
Trust storyMature kernel + public compilerChecker/compiler evolving; --safe → BendTT Lean kernel (bendtt.lean, Lean v4.34.0)
Checker synth bench (M4 Max, 12.8k defs)36.177 s0.295 s

Hybrid (engineering, not prescribed by notes): Lean for hard theory / audit of BendTT; Bend for shipping parallel app with LAWS gate — mismatch disclosure supports treating Bend checker as engineering trust, not drop-in Lean substitute.


From README + what-is-bend2:

  1. Compiler ~99% AI-written, not fully audited.
  2. Checker has no proof and may have bugs; --safe uses a proven kernel — but translation to .bendtt itself is unproven.
  3. Mismatches between checker and its Lean formalization are documented.
  4. “A correct source proof cannot compensate for a compiler bug that changes the program’s meaning.”
  5. Young ergonomics: verbose (no inference), no typeclasses/traits/macros beyond templates, no if-then-else (match Bool), strings = char linked lists, one C file / no incremental builds, no Windows (WSL ok), no TLS/HTTP/JSON/regex yet, terse errors, no debugger/REPL/test framework beyond guide.
  6. Weak laws are easy to “prove” and useless — same failure mode as every FV stack; Bend’s agent-facing UX makes overclaim more tempting.
  7. Game demo LAWS/PROOF cover model properties (e.g. safe-position) — not unmentioned requirements, JS renderer, or compiler correctness.

Victor Taelin proof-economics framing (seed): “1 line of code, tens of lines of proof” — AI shifts cost calculus but doesn’t erase it (x.com/VictorTaelin/status/2102764825231470862).


  • Greenfield numerical / parallel backends where agents should own both speedups and a small set of invariants.
  • Product is the parallel program (affine + fork/join + ! GPU).
  • Team accepts explicit proofs + young tooling; can pin SHAs; can keep laws human-owned.
  • CI can run bend PROOF.bend fail-closed; release gates prefer --safe + review .bendtt.
  • Need mathlib/tactics, existing verified artifacts, or industry analyzers.
  • Agent already strong on Lean harnesses (Vero-style).
  • Domain needs FP64, HTTP/TLS stacks, Windows-native, or large library ecosystems.
  • You need mature agent benches and repair literature.

DIY gate sketch (Herdr / Cloud agent orchestrator)

Section titled “DIY gate sketch (Herdr / Cloud agent orchestrator)”
Human writes / reviews LAWS.bend
→ coding agent edits code + PROOF.bend
→ bend PROOF.bend (fail → repair ≤ N)
→ bend PROOF.bend --safe (release / merge)
→ measure runtime separately (CPU/GPU) — checker throughput ≠ program speed ≠ proof effort