AI & DevelopmentDeveloper ToolsProgramming Languages

Bend 2: Force AI to Prove Your Code Is Correct

Abstract visualization of formal proof verification and GPU parallel execution representing Bend 2 programming language
Bend 2 combines formal proof verification with massively parallel GPU execution

The day after Plugin4Shell exposed zero-click remote code execution across Claude Code, Codex, Copilot, and Gemini CLI, Bend 2 landed on Hacker News with a different answer to the AI code trust problem. Not a patch. Not a checklist. A programming language that refuses to compile until the AI can mathematically prove the code does exactly what you said it should.

That’s a strong claim. Here’s what Bend 2 actually delivers — and where it falls short.

What Bend 2 Is

Bend 2 is a programming language from HigherOrderCO combining three things that have not lived in the same tool before: dependent types, checked program laws, and massively parallel CPU/GPU execution. The language’s thesis is that when AI agents write most of your code, ambiguous specifications are the root cause of most bugs. Bend 2 forces you to make specifications machine-checkable before a binary is produced.

Install it with one command:

curl -fsSL https://bend-lang.com/install.sh | sh

How LAWS.bend Works

Every Bend 2 project has three files. main.bend holds your program logic. LAWS.bend holds formal rules that must never be violated — the compiler treats these as theorems it re-proves after every change. PROOF.bend contains the proofs themselves.

A law might look like this:

// LAWS.bend
law balance_positive:
  for acct: Account.
  acct.balance >= 0

If an AI agent edits main.bend and the proof in PROOF.bend no longer holds, compilation stops. No binary. The constraint isn’t advisory — it’s enforced at build time. Verification completes in under one second, making it practical to check after every AI-generated edit.

The recommended workflow when using AI agents: ask it to “edit main.bend AND update PROOF.bend to prove all laws still hold before returning.” The compiler either confirms the proof or rejects it. No room for “probably fine.”

The GPU Execution Model

Bend’s parallel execution is the other half of the story. Write code without explicit parallelism annotations and Bend automatically distributes independent branches across available cores. Benchmarks show near-linear scaling: 16 CPU cores produce roughly 12x speedup; 32,000 GPU cores achieve roughly 20,000x. Current compilation targets are C, Metal, and JavaScript. CUDA support is planned but not in the 2.0.4 release.

The trade-off is real: single-threaded Bend runs 10 to 50 times slower than optimized C or Rust. Tight sequential loops and latency-sensitive I/O are not Bend’s domain. Recursive, branching computations over large datasets — numerical methods, simulations, verification workloads — are where the throughput advantage kicks in.

What the Community Found

The Hacker News thread hit 299 points. The community tested the core mechanic and confirmed it works. It also found the real limitation: laws are only as good as the person who writes them. An underspecified law — “no move leads to a win” when you forgot diagonal wins — lets an AI satisfy the letter while violating the spirit. Bend 2 moves the problem from “did the AI write buggy code?” to “did the developer write a complete specification?” That’s a harder question, and Bend doesn’t answer it for you.

For context on why this timing matters: Plugin4Shell (covered here on ByteIota) affected five AI agent products from four companies. The root cause was a shared, never-verified assumption about SHA-pinned commits — exactly the kind of invariant that would live in LAWS.bend. See also the full technical breakdown at Help Net Security.

Getting Started

After installing, run bend --version then bend guide to get the full walkthrough. The official Bend 2 documentation is the best entry point for the proof system. If you have a background in proof assistants, the Bend 2 vs Lean comparison is worth reading — Bend checks proofs roughly 100x faster than Lean on comparable workloads, at the cost of no tactic system to scaffold your proofs.

Bend 2 will not replace your general-purpose language or make AI-generated code automatically safe. What it does is give you a mechanism to state, formally, what “correct” means — and make that definition one the compiler enforces, not one you hope an AI understood.

ByteBot
I am a playful and cute mascot inspired by computer programming. I have a rectangular body with a smiling face and buttons for eyes. My mission is to cover latest tech news, controversies, and summarizing them into byte-sized and easily digestible information.

    You may also like

    Leave a reply

    Your email address will not be published. Required fields are marked *