Change the program. Keep the promise.

Watch the code
become a proof.

Edit C. Inspect the Wasm. Watch AI write a Lean proof.
Then watch Lean check it.

Try a preset or make your own edit. The claim stays fixed:
both programs must return the right price for every input.

The fixed rule 9¢ per item after discount + 2¢ fee. Add 1¢ for odd orders. How does that work? ↓

Start at 12¢ per item. Apply a 25% discount. Add 2¢ for an even item count, 3¢ for an odd count. Return 0 for orders over 1,000 items. Arithmetic uses unsigned 32-bit values.

price(n) = n ≤ 1000 ? 9 × n + 2 + (n & 1) : 0

3 items → 30¢. 4 items → 38¢. The proof must cover every input, including the bounds.

Under the hood

Edit C

The left program uses a loop. Change the right program. Both must meet the fixed price rule.

A Original programC · uint32_t
Repeated addition → discount → fee
B Your editC · uint32_t
Remove the loop, simplify the discount, remove the fee branch.

Start with “Build & inspect” to explore without calling AI. “Watch the proof” runs the whole process.

03 / What must be proved?

Every repeat.
Every input.

A few test runs cannot prove the edit works for every input. A loop invariant lets us reason about any repeat, without running them all.

1 At the start: the counter and total are zero.

2 After each repeat: the total still matches the number of items counted.

3 At the end: the total gives the required price. The counter cannot run forever.

Show me the loop argument in plain words

After counting i items, the total is 12 × i. That is the invariant.

It holds at zero items. One repeat adds 12 to the total and 1 to the counter, so it still holds. When the counter reaches n, the total is 12 × n.

The number of items left decreases each time, so the loop finishes. With at most 1,000 items, the discount calculation cannot overflow. Paying three quarters of 12 cents gives 9 cents per item.

Clang may move the multiplication by 3 into the loop, so the actual Wasm invariant can use 36 × i and divide by 4 at the end. The AI has to follow those actual instructions.

For the per-item discount edit, Clang precomputes the price but keeps a counting loop. Its invariant records the saved price and the counter bound; the proof must still show the loop stops.

What is new from Jad’s work?

This uses his newer program verifier: loop rules, a sound verification-condition generator, function-call rules and a verified Wasm decoder.

The verifier turns the program and the proposed invariant into proof obligations. Lean must prove the invariant starts true, stays true, gives the right answer on exit, and has a decreasing quantity that establishes termination.

This replaces the earlier expression-only demo. The full Wasm model is broader than the automatic proof path used here.

Is AI writing the whole proof?

AI writes the parts that depend on your edit: loop invariants, decreasing quantities and Lean proof steps for each program. It receives worked tactic examples, sees Lean’s errors, and can revise its attempt.

A fixed template states the price rule and exact files, then connects the new proofs to Jad’s execution rules. Keeping the claim fixed stops the AI from weakening it to make the job easier.

generate.py prepares that file. It does not decide whether the edit is correct. Lean makes that decision.

What are ring, bv_omega and omega?

They are Lean tactics: tools that build proofs.

ring checks algebra such as 12 × i + 12 = 12 × (i + 1). It expands and collects terms on both sides.

bv_omega converts fixed-width arithmetic to integer facts. omega builds proofs about bounds, constant multiplication, division and remainders. Bit-level facts, such as an even/odd test, can be reduced to those facts. Lean checks every proof.

Can I try a new rewrite?

Yes. Edit either C function. It does not have to match a preset or an existing optimizer pass. Both must still meet the fixed price rule.

This demo accepts one i32 input and result, local variables, integer arithmetic, branches and up to two loops. Calls, memory access, floating point and many other instructions are outside this proof path. Unsupported code gets an explicit error.

An equivalent edit can still be too hard for the current agent or time limit. “Not established” means no accepted proof was found.

Where does checking happen? What can I share?

The browser runs the Wasm examples. Clang, AI requests and Lean checking run through the server. Jad’s compiled library is reused; each edit gets a new proof.

You can download the proof source, helper, exact Wasm files, checker log and all attempts. The newer library is currently private. Independent rechecking needs access to that pinned source and its small lint-only patch.

The proof starts at the Wasm bytes. It does not prove Clang itself is correct, full module loading, or equal speed and memory use.

Exact formal claim and trust boundaries

LiveDemoProof.binaries_same_result checks that Jad’s decoder reads the exact two binaries as the annotated function bodies. It proves actual Core.Steps executions of both function calls to LiveDemo.price n for every i32 input, under any numerical profile and host, in the one-function instances built by the helper. Both return and preserve their stores. return_values_unique uses Jad’s determinism bridge to show that every returning execution agrees.

Separate checked metadata establishes the i32 → i32 type, absence of imports and the compute export. This is a function-call theorem. It does not prove full module instantiation, full ExportEquiv, C compiler correctness or equal resource use. Browser execution is a separate test.

Private Silmaril revision fc6be8f5e6f6de4c7795776842608dc9795c728f, with lint-only fixes; Lean 4.35.0-rc4. Only standard propext, Classical.choice, Quot.sound axioms are accepted. No sorry, native_decide or unproved SMT facts. The library model, toolchain and I/O are trust boundaries.

Native jobs use containers with no network, read-only libraries, and time and resource limits. A failed, busy or unavailable checker establishes no equivalence claim.

Live demo access

Enter the demo code.

The code protects native proof jobs and live agent usage. Submitted programs are sent to OpenAI; the API key stays on the server.