AI writes the code. Mathematics proves it.
VeriGraph (VG-IR) is an AI-native programming system. Instead of fragile text files tested on a handful of examples, programs are canonical dataflow graphs identified by BLAKE3 hashes and paired with formal contracts. SMT solvers prove every contract for all possible inputs before a single native ARM64, x86_64 or WebAssembly binary is emitted.
examples/quickstart.vgs
Hover or focus any highlighted clause below to inspect what the compiler checks and proves.
NODE @add_sat [intent: "Add two bytes, saturating at 255"] {
SIGNATURE: (a: u8, b: u8) -> (u8);
EFFECTS: [];
CONTRACT {
POST: result >= a && result >= b && (a + b <= 255 ==> result == a + b);
}
BODY {
%0 = ADD.sat(a, b);
RETURN(%0);
}
}
Select any underlined token in @add_sat to see how VG-Sym eliminates implicit overflow and proves behavior across all 65,536 byte pairs.
- SMT obligations proven for this site
- 740 / 740
- verified VG-Sym nodes in 8 modules
- 95
- WebAssembly binaries running in your browser
- 18
- residual runtime checks in proven binaries
- 0
Why unit tests are not enough for AI code.
Language models generate plausible code in seconds, including subtle edge-case bugs that slip past dozens of unit tests. VeriGraph replaces hope with mathematical refutation and proof.
Driving five trucks across a bridge only shows it did not collapse under those five trucks. Writing equations of structural mechanics proves the bridge holds every load up to its rated limit—or pinpoints the exact beam that buckles first.
Classic LLM code + unit tests
Sampled confidence- 5 tests check 5 points out of 18,446,744,073,709,551,616 pairs of 32-bit integers.
- Silent integer wraparound, division by zero, and IEEE-754 NaN propagation hide in extreme inputs.
- Compiler errors are unstructured prose; failed runs dump stack traces without minimal root causes.
- Packages are pulled by name: a version bump can silently alter behavior.
VeriGraph + SMT solvers (Z3, Bitwuzla, cvc5)
Universal proof- vg verify proves obligations across 100% of inputs satisfying PRE—or returns a concrete counterexample.
- Every counterexample is replayed bit-for-bit in vg-interp (ADR 0006): zero solver hallucinations.
- vg explain narrows failures to a ≤5-op causal slice plus the exact condition needed to fix it.
- Once proven, vg build erases runtime assertions (0 residual guards) and emits LLVM machine code.
Interactive proof sandbox · Overflow-free midpoint vs naive average
Classic binary search had a famous bug for twenty years: (a + b) / 2 overflows 32-bit integers when a + b ≥ 2³². Test VeriGraph's verified WASM binary (midpoint.wasm) against naive 32-bit arithmetic right here:
midpoint.wasm · 5/5 obligations proven by Z3 in 19 ms · POST: result == (a + b) / 2 · 0 runtime guards
Move both u8 sliders (0..255) to verify saturating byte addition in real WASM:
add_sat.wasm · 5/5 obligations proven by Z3 · BLAKE3 df7cb4d95efea306…
Inside a VeriGraph module: every line has a formal role.
VG-Sym is the prefix-checkable text projection that AI agents write and humans review; VG-IR is its canonical binary DAG. Click or tab through the 8 annotated regions of examples/audio_limiter.vgs to see how contracts, capabilities, learnable parameters and Mesh queries fit together.
module audio_limiter;
@MESH_QUERY @sha256 {
signature: (Slice<u8>) -> (Array<u8, 32>);
effects: [];
post: result == spec:sha256(arg0);
}
NODE @limit_frame [intent: "Limit a 512x2 stereo frame and digest it", export] {
SIGNATURE: (frame: Tensor<f32, [512, 2]>) -> (Tensor<f32, [512, 2]>, Array<u8, 32>);
EFFECTS: [];
CONTRACT {
PRE: forall(i in 0..512, c in 0..2) { is_finite(frame[i, c]) };
POST: forall(i in 0..512, c in 0..2) {
result.0[i, c] >= -1.0 && result.0[i, c] <= 1.0
&& ((frame[i, c] >= 0.0) == (result.0[i, c] >= 0.0))
} && result.1 == spec:sha256(as_bytes(result.0));
COST: heap_bytes == 0 && arena_bytes == 0;
BUDGET: latency_p99_us <= 500;
}
LEARNABLE {
knee: f32 in [0.5, 0.99];
}
BODY {
%0 = SIMD_MAP(@soft_knee, frame, knee);
%1 = AS_BYTES(%0);
%2 = CALL_HASH(@sha256, %1);
RETURN(%0, %2);
}
}
From a plain-English request to three verified binaries.
Watch how an AI agent and the vg toolchain collaborate. Every box position and Bezier edge below is computed live in your browser by layout.wasm (@layout, 196/196 obligations proven). Click any step—or pause the animation at any moment.
When a proof fails: the soft-knee NaN story.
Here is a real bug that passes ordinary unit tests yet fails in production. In examples/soft_knee_draft.vgs, the author wrote u = t / (1 + t) to compress audio peaks smoothly into [-1, 1]. Algebraically, t / (1 + t) is always in [0, 1). In 32-bit IEEE-754 floating point, it is a trap.
-
Input x = -3.4028235e38, knee = 0.5→ PRE holds (x is finite!)
-
%0 FABS(x)→ 3.4028235e38
-
%4 FDIV(%2, %3) // (|x| - 0.5) / 0.5→ +inf ← IEEE-754 overflow!
-
%6 FDIV(%4, %5) // +inf / (1 + inf)→ NaN ← inf / inf is undefined!
-
%12 FCLAMP(%11, -1.0, 1.0)→ NaN ← IEEE minimum/clamp propagates NaN!
Synthesized vg-telemetry condition: “the obligation holds iff %4 is finite” · Replayed in vg-interp: concrete
The one-line mathematical repair
Rewrite u = t / (1 + t) as u = 1.0 - 1.0 / (1.0 + t). When %4 overflows to +inf, 1.0 + inf is +inf, 1.0 / +inf is 0.0 (exact IEEE-754!), and 1.0 - 0.0 = 1.0. Bitwuzla then proves all 6/6 obligations across all 4.29 billion f32 bit patterns in 111 ms.
// Buggy draft (examples/soft_knee_draft.vgs):
%6 = FDIV(%4, %5); // +inf / +inf => NaN!
// Proven repair (examples/audio_limiter.vgs):
%6 = FDIV(1.0:f32, %5); // 1.0 / +inf => 0.0
%7 = FSUB(1.0:f32, %6); // 1.0 - 0.0 => 1.0 (proven!)
Live Dual-WASM Lab · Break knee_draft.wasm vs proven knee.wasm
Both curves below are computed live by real VeriGraph WebAssembly binaries: knee.wasm (proven, 16/16 obligations) and knee_draft.wasm (compiled with --unverified). Drag knee or click an extreme f32 input:
grid.wasm (12/12 proven) + knee.wasm (16/16 proven, 0 guards) vs knee_draft.wasm (--unverified)
One graph, every tool around it.
VeriGraph is not just a verifier: it is a complete 12-crate Rust workspace, a 15-command CLI, an 8-tool MCP server for AI agents, an Antigravity IDE / VS Code extension, a contract-indexed package registry (VG-Mesh) and a C/Rust lifter (OmniLift).
Interactive 12-crate architecture map (laid out live by @layout)
Click or hover any crate in the DAG to highlight its dependencies and inspect what it owns:
Encodes graphs and contracts into SMT-LIB2 bitvectors, IEEE-754 floats and arrays over long-lived solver pipes. Includes concrete pre-screening, content-addressed proof caching, non-vacuity and well-definedness (.wd) checks.
One Rust binary (`vg`) orchestrates assembling, hashing, static checking, multi-solver verification, causal explanation, reference execution, cross-compilation, registry queries and legacy lifting.
| Command | What it does |
|---|---|
vg asm FILE.vgs [--root DIR] [--keep-debug] |
assemble into DIR/.vg/objects and pin labels in DIR/vg.lock |
vg disasm (HASH | FILE.vgir) [--root DIR] |
print VG-Sym for a node and everything it calls |
vg hash FILE... |
print node, body and contract hashes (.vgs or .vgir) |
vg check FILE.vgs |
parse, canonicalize, type- and effect-check (JSON) |
vg verify FILE.vgs [--mode edit|ci|release] [--timeout MS] |
[--detail 0|1|2] prove every obligation; release needs two solvers (JSON) |
vg explain FILE.vgs OBLIGATION [--timeout MS] |
the failure report of one obligation, and its prose |
vg run FILE.vgs @NODE JSON |
run a node in vg-interp; JSON maps parameter names to values |
vg build FILE.vgs @NODE [--target TRIPLE]... [-o DIR] [--timeout MS] |
[--unverified] [--emit-llvm] verify, then compile (default target: aarch64-apple-darwin) |
vg lift FILE FUNCTION [--lang c|rust] [--root DIR] |
lift a C or Rust function with Alive2 and fuzzing (JSON) |
vg mesh publish FILE.vgs [--root DIR] |
publish the module's nodes to DIR/.vg/mesh (ingestion gate) |
vg mesh query QUERY.json [--root DIR] |
candidates for a docs/09 MeshContractQuery |
vg mesh resolve FILE.vgs [--root DIR] |
bind each @MESH_QUERY, pin it in vg.lock, fetch its nodes |
vg mesh serve [--root DIR] [--addr HOST:PORT] |
the registry's HTTP API (default 127.0.0.1:7878) |
vg loop (DIR | PROMPT.md) [--model M] [--rounds N] [--replay SCRIPT] [-o DIR] |
the hosted loop: a model writes nodes, a grader judges them |
vg mcp |
serve the eight docs/15 tools over MCP stdio |
Run `vg mcp` to expose 8 structured JSON tools over Model Context Protocol (`2025-06-18`, stdio). Paired with `skills/verigraph-synthesis/SKILL.md`, any hosted LLM (Gemini, Claude, GPT) writes, verifies and repairs VG-Sym autonomously—and `vg_build` over MCP strictly refuses `--unverified`.
vg_check
Parse, validate, canonicalize, type- and effect-check a VG-Sym module.
vg_verify
Prove every obligation of every node with the SMT solver; counterexamples are replayed in vg-interp.
vg_explain
The failure report of one obligation (its failing slice, counterexample and diff) and a plain-language account.
vg_mesh_query
Find verified nodes in the project's Mesh registry by contract (docs/09 MeshContractQuery); source and path are not used.
vg_mesh_publish
Publish every node of a module to the project's Mesh registry through the six-check ingestion gate.
vg_run
Run one node in vg-interp on docs/15 JSON inputs keyed by parameter name.
vg_build
Verify a root node and everything it calls, then compile it to native code.
vg_lift
Lift a C or Rust function through OmniLift with Alive2 bounded refinement and 1e6-input differential fuzzing (docs/08, docs/15).
- 1. Contract card first — state Inputs, Outputs, EFFECTS, PRE, POST, COST and BUDGET; confirm with the user before coding.
- 2. Mesh first — call vg_mesh_query for hashing, codecs, sorting or linear algebra instead of reinventing them.
- 3. Pure kernels first — keep EFFECTS: [] everywhere except a thin root node.
- 4. Act on verdicts — fix the body on `counterexample`, strengthen a callee's POST on `contract_gap`, split or add an INVARIANT on `unknown`, weaken PRE on `vacuous`. Never weaken POST silently.
The repository ships `editors/antigravity/`, a reproducible VS Code / Antigravity IDE extension (`verigraph-0.1.0.vsix`) plus a one-command installer (`editors/antigravity/install.sh`) that builds `vg`, installs `.vgs` syntax highlighting and editor commands, and registers the `verigraph` agent plugin (`mcp_config.json` + synthesis skill).
Click the IDE title-bar actions to preview what happens inside Antigravity IDE:
NODE @soft_knee {
SIGNATURE: (x: f32, knee: f32) -> (f32);
EFFECTS: [];
CONTRACT {
PRE: is_finite(x) && knee >= 0.5 && knee <= 0.99;
POST: result >= -1.0 && result <= 1.0;
}
// checkOnSave: true · 6/6 obligations proven
}
vg verify examples/audio_limiter.vgs → ok: true · @soft_knee (6/6 proven), @limit_frame (13/13 proven) in Bitwuzla & Z3 · 0 squiggles.
VG-Mesh · Search by proven behavior, never by package name
Two implementations of SHA-256—one hand-written in VG-Sym, one lifted from Rust's `sha2` crate—have completely different structures and BLAKE3 node hashes. Yet once each is proven to refine `SPEC @sha256`, both join the same **spec class**. Agents query by signature, effect mask and `POST`, and every published node passes a 6-check re-verifying ingestion gate signed with Ed25519 (`421 µs` p99 over 100,000 nodes).
OmniLift · Import C and Rust with bounded equivalence proofs
`vg lift` compiles legacy C or Rust at `-O1` (no unrolling/vectorization) to LLVM IR, turns counted loops into `FOLD_BOUNDED` over explicit state, cures undefined behavior via strengthened `PRE` or `ASSERT_GUARD`, and checks refinement with Alive2 plus 1,000,000 differential fuzz runs.
Three more verified programs running live in your browser.
JavaScript on this page computes none of the signals, hashes, checksums or fractals below: it packs your inputs into little-endian bytes, runs the real wasm32-wasip1 binaries compiled by `vg build`, and renders their stdout.
Lab 1 · Stereo Audio Limiter + WebAudio synthesis (tone.wasm → limiter.wasm)
Adjust input drive (up to 6× clipping!) and the learnable knee. `tone.wasm` synthesizes a 512-sample stereo A-major chord, `peak.wasm` measures its peak, and `limiter.wasm` (`examples/audio_limiter.vgs`) clamps every sample smoothly into [-1, 1] while computing the frame's 32-byte SHA-256 digest.
Lab 2 · VG-Mesh SHA-256 (sha256.wasm) & OmniLift zlib CRC-32 (crc32.wasm)
Type any UTF-8 text or pick a standard test vector. `sha256.wasm` (55/55 obligations proven against FIPS 180-4) and `crc32.wasm` (lifted directly from `zlib/crc32.c` by `vg lift`, 59/59 obligations proven) compute both digests in WebAssembly:
Lab 3 · Compositional contracts: Safe Mandelbrot Explorer (zoom.wasm → render.wasm)
Click anywhere on the fractal to zoom in (Shift+click to zoom out). `@zoom`'s POST proves the returned view stays inside `[-2.5, 1.5] × [-1.5, 1.5]` with bounded positive scale—the exact PRE `@render` demands. Try the red button to bypass `@zoom` and send `scale = 0.05` directly to `render.wasm`!
—
This website is itself a verified VeriGraph program.
Every easing curve (`@motion`), diagram layout (`@layout`), donut wedge (`@donut`) and bar chart (`@bar_chart`) on this page is computed by VeriGraph nodes compiled to WebAssembly. Inspect the proof ledger recorded by `build-wasm.sh`:
Proven obligations by kind (@donut)
- POST217
- CALL110
- NONVACUOUS95
- FOLD70
- INDEX60
- GEN49
- PRE30
- other109
By SMT solver & evidence (@bar_chart)
Inspect all 18 WebAssembly binaries, BLAKE3 hashes and proof closures
| Binary | Root node | Closure | Proven | BLAKE3 (artifact) | Size | Guards |
|---|---|---|---|---|---|---|
aurora.wasm |
@aurora |
9 | 86/86 | 981e634726a3d8… |
29 KB | 0 |
motion.wasm |
@motion |
14 | 117/117 | 2330741b27d4f2… |
25.9 KB | 0 |
bar_chart.wasm |
@bar_chart |
7 | 44/44 | 42d3f17ab515ce… |
27.2 KB | 0 |
donut.wasm |
@donut |
9 | 60/60 | 0a1eafb7d7a6c7… |
29.8 KB | 0 |
zoom.wasm |
@zoom |
2 | 13/13 | bb710b9d95468e… |
26 KB | 0 |
render.wasm |
@render |
5 | 26/26 | 4d0d4cdcd47131… |
26.1 KB | 0 |
layout.wasm |
@layout |
19 | 196/196 | 71f303f052390c… |
30 KB | 0 |
grid.wasm |
@grid |
2 | 12/12 | d26718bee08b17… |
26 KB | 0 |
knee.wasm |
@knee_curve |
2 | 16/16 | 07c71e77c55619… |
26.3 KB | 0 |
tone.wasm |
@tone |
4 | 22/22 | 006705b11c820a… |
26.5 KB | 0 |
peak.wasm |
@peak |
2 | 10/10 | ae2697f94d4cb4… |
25.7 KB | 0 |
knee_draft.wasm |
@draft_curve |
— | --unverified | 1e8cc229bb2efb… |
40.9 KB | 0 |
sha256.wasm |
@sha256_impl |
8 | 55/55 | d2c89310b66341… |
32.1 KB | 0 |
limiter.wasm |
@limit_frame |
3 | 19/19 | 161eabc2203954… |
28.7 KB | 0 |
crc32.wasm |
@crc32_z |
10 | 59/59 | 2a27c83f7e0a66… |
28.3 KB | 0 |
add_sat.wasm |
@add_sat |
1 | 5/5 | bbfa58d39c5336… |
25.3 KB | 0 |
midpoint.wasm |
@midpoint |
1 | 5/5 | dc21ad60dd5def… |
25.3 KB | 0 |
sum4.wasm |
@sum4 |
2 | 10/10 | 9b266fe756776c… |
25.3 KB | 0 |
Honest engineering status (ROADMAP gates G0–G8)
VeriGraph's non-negotiable rule (AGENTS.md §2): never fake a result or mark a gate passed without owner approval. Here is the exact status recorded in the repository:
| Gate | Scope | Recorded status |
|---|---|---|
| G0 · Scaffold | 12-crate workspace, macOS ARM64 & Linux x86_64 CI, spec & errata | Criteria hold · awaiting owner approval |
| G1 · Core IR | .vgir round-trip, 56 alpha-equivalence families, 1h fuzzing | Criteria hold · awaiting owner approval |
| G2 · Types & Interp | 87 negative type/effect tests, 28,398 conformance vectors | Criteria hold · awaiting owner approval |
| G3 · Verification | Known-good/bad suites, 0 surviving mutants, audio limiter | Criteria hold · awaiting owner approval |
| G4 · Codegen & RT | 1,000 diff programs pass; blend 0.78× & crc32 1.00× C | Open: 3 kernel ratios > 1.20× & Linux sandbox host run |
| G5 · Agent Loop | vg mcp (8 tools), vg-decode (23 µs p99), 30 tasks ready | Open: paid API 30-task benchmark run |
| G6 · Telemetry | ≤5-op causal slices on 60/60 seeded bugs, vg explain | Criteria hold · awaiting owner approval |
| G7 · VG-Mesh | 421 µs p99 query on 100,000 nodes, tamper rejection | Criteria hold · awaiting owner approval |
| G8 · OmniLift | zlib crc32 & adler32, C & Rust SHA-256 in one spec class | Criteria hold · awaiting owner approval |
Check your understanding · 3 quick questions
1. What can you conclude when `vg check module.vgs` returns `"ok": true`?
`vg check` is the fast deterministic structural, type and capability gate; SMT proof happens in `vg verify` (and `vg build`).
2. Why did `u = t / (1 + t)` fail verification in `@soft_knee` while `1 - 1 / (1 + t)` succeeded?
In VeriGraph, `FCLAMP` propagates `NaN` (IEEE-754 minimum/maximum semantics), catching the `inf / inf` overflow that ordinary unit tests miss.
3. What happens if an AI agent calls `vg_build` over `vg mcp` on a node with an `unknown` solver obligation?
Soundness first: `unknown` or a solver timeout is never accepted as a proof, and the MCP agent interface forbids `--unverified` builds.