AI Vericoding Playbook & Polyglot oracle Guide
Copy-paste prompts for supervising untrusted coding agents, CI configuration for lake exe verigate, and differential-fuzzing harnesses connecting Lean 4 to Rust, Go, TypeScript, and Python services.
1. Copyable Spec-First Agent Prompts
Human Owns Spec · Agent Owns ImplPrompt A — Co-Designing Spec.lean (Before Any Implementation)
You are assisting with a Lean 4.36.0 Spec-First module (zero external dependencies, Core/Std only).
1. Do NOT write implementation optimizations yet.
2. Propose `Spec.lean` containing algebraic domain types (no boolean soup), a tiny total reference function,
BOTH a Soundness theorem and a Completeness theorem (blocking trivial always-none implementations),
and an explicit Non-Vacuity witness `theorem pre_satisfiable : ∃ x, Pre x`.
3. List 3 concrete `#guard` sanity examples we should review together before locking `Spec.lean`.
Prompt B — Locked-Spec Implementation & Proof Synthesis
`Spec.lean` is SHA-256 locked—do NOT modify any declaration or theorem signature in `Spec.lean`.
Edit ONLY `Impl.lean` to implement the optimized algorithm and prove all required theorems.
Hard CI constraints enforced by `lake exe verigate`:
- Zero `sorry`, zero custom `axiom` or `opaque`, zero `unsafe` or `partial`.
- Zero `@[implemented_by]`, `@[extern]`, `@[csimp]`, or raw `native_decide`.
- Prefer `fun_cases`, surgical `simp only [...]`, `omega`, `grind`, and `bv_decide` (when Tier 1 is enabled).
Prompt C — Stuck Infoview 3-Way Triage
My Lean 4.36.0 proof is stuck at this exact Infoview state:
[PASTE OBJECTS / HYPOTHESES / ⊢ GOAL HERE]
Before suggesting ANY tactics, run the 3-Way Triage:
(A) Is the leaf goal actually FALSE for concrete small values? If so, give a `#guard` counterexample.
(B) Did the theorem statement omit a real domain precondition?
(C) Is this a true property failing on an unreachable Garden-of-Eden state that needs inductive strengthening?
2. Two-Tier Axiom Policy & VeriGate GitHub Actions Setup
| Mechanism / Declaration | Tier 0 (--strict-kernel) |
Tier 1 (--trust-tier=bv-lrat) |
Security Rationale |
|---|---|---|---|
propext, Quot.sound, Classical.choice |
Allowed | Allowed | Standard mathematical foundation of Lean 4's small kernel. |
bv_decide (LRAT hardware bit-blasting) |
Rejected | Allowed (audited) | Permits verified LRAT bit-vector certificates when zero raw native_decide exists. |
Raw native_decide |
Rejected | Rejected | Pulls unverified native code generation into the proof TCB. |
sorryAx, custom axiom / opaque |
Rejected | Rejected | Prevents unfinished holes and arbitrary unproven assumptions. |
@[implemented_by], @[extern], @[csimp] |
Rejected | Rejected | Blocks silent swaps between verified kernel models and unverified runtime binaries. |
Minimal GitHub Actions Workflow
name: VeriGate & Differential Oracle CI
on: [push, pull_request]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: leanprover/lean-action@v1
- name: Enforce VeriGate TCB Audit
run: lake exe verigate --strict-kernel
- name: Differential-Fuzz Service Against Verified Lean Oracle
run: python3 scripts/fuzz_against_oracle.py
3. Polyglot Differential Fuzzing with lake exe oracle
Your production service can stay 100% Rust, Go, TypeScript, Python, or C++. Expose a thin CLI or test endpoint accepting JSONL action traces, and compare every state transition output against lake exe oracle:
# Differential fuzzing any Rust / Go / TypeScript / Python binary against `lake exe oracle`
import json, subprocess
def query_jsonl(cmd: list[str], trace: list[dict]) -> dict:
proc = subprocess.run(cmd, input=json.dumps({'trace': trace}) + '\n',
text=True, capture_output=True, check=True)
return json.loads(proc.stdout)
lean_truth = query_jsonl(['lake', 'exe', 'oracle', '--jsonl'], adversarial_trace)
prod_actual = query_jsonl(['./target/release/my-rust-service', '--jsonl'], adversarial_trace)
assert prod_actual == lean_truth, f'Divergence vs verified Lean spec: {prod_actual} != {lean_truth}'
Feed proptest / go test -fuzz byte seeds into both your struct state machine and a long-lived lake exe oracle --stdio child process over newline-delimited JSON.
Generate 1,000 golden edge-case JSON vectors from your verified Lean spec (lake exe oracle --dump-vectors > vectors.json) and assert 100% parity in Vitest / Pytest in under 200ms.