Bend: A Proof-Based Language for AI-Generated Code Verification
New programming language combines C speed, GPU parallelism, and mathematical proofs to prevent AI coding errors.
1Proof-based AI code verification
Bend introduces a novel approach to AI-generated code by incorporating mathematical proofs into its type system. Unlike traditional languages, every line of Bend code must satisfy formal laws defined in LAWS.bend files. This prevents AI agents from committing code that violates specified constraints, effectively creating a mathematical safety net around AI-generated implementations.
2Performance characteristics
The language achieves near-C performance on single cores while automatically parallelizing code across multiple cores or GPUs. Bend binaries can run up to 100x faster on GPUs compared to single-core execution. The compiler handles parallelization transparently, eliminating the need for manual thread management or lock programming that typically complicates parallel computing.
3Proof checking speed
While proof checkers in languages like Lean and Rocq can take minutes for medium-sized codebases, Bend completes verification in under a second. This near-instant feedback enables AI agents to validate each code change immediately, maintaining correctness throughout rapid iteration cycles typical in AI-assisted development workflows.
4Law enforcement mechanism
LAWS.bend files serve as formal specifications that AI agents cannot violate. When an AI attempts to commit code that breaks these laws, the proof checker forces retries until compliance is achieved. This creates a mathematical guarantee that certain classes of bugs cannot be merged, treating correct implementation as a provable theorem rather than a hopeful outcome.
5Practical implementation
Developers define laws for critical system invariants that must never break. The AI then generates code that satisfies these proofs before committing. A practical example shows how LAWS.bend prevented a game bug by requiring the AI to prove no move sequence could lead to victory before accepting the implementation.
6Development workflow
The Bend workflow includes running proof checks before commits and parallelizing code automatically. The language currently works best for backend development on Linux and macOS systems. While still evolving, it offers Python-like syntax combined with rigorous verification capabilities, lowering the barrier to proof-based programming.
7Technical foundations
Bend builds on two academic foundations: BendTT (an affine dependent type theory) as its core type system, and BendRT (a parallel runtime for CPUs and GPUs) as its execution environment. These combine to support both the language's proof capabilities and its performance characteristics across different hardware architectures.
8Future implications
As AI takes on more coding responsibilities, Bend represents a potential solution to the trust problem in AI-generated code. By mathematically verifying implementations against human-defined laws, it could enable safer adoption of AI programming assistants while maintaining precise control over system behavior in critical applications.
Original article: Hacker News — Bend: A Proof-Based Language for AI-Generated Code Verification