formal-verification

Proves critical-core code properties with deductive verifiers like Verus, Dafny, SPARK, and CBMC.

Updated May 21, 2026
One-click install
npx skills add https://github.com/CagesThrottleUs/private-ai-harness --skill formal-verification-cagesthrottleus
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: formal-verification
Source: https://github.com/CagesThrottleUs/private-ai-harness/tree/main/skills/formal-verification
Command: npx skills add https://github.com/CagesThrottleUs/private-ai-harness --skill formal-verification-cagesthrottleus

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Testing only shows bugs on the inputs you try; it cannot prove a property holds for all inputs. For catastrophic-if-wrong code — cryptography, auth decisions, monetary arithmetic, consensus invariants, unsafe blocks — this Skill escalates a tested invariant into a machine-checked proof, and refuses to claim a proof the toolchain did not produce. ## Core Features & Use Cases - Eligibility gating: Runs only when the change is critical-core AND a real verifier exists for the language (Rust/Verus, Dafny, Ada/SPARK, C/Frama-C, Java/OpenJML, C++/CBMC/ESBMC); otherwise it cleanly falls back to property-based testing. - Live toolchain confirmation: Web-searches current verifier versions, solver backends, and syntax before writing contracts, since verifier syntax churns fast. - Contract writing and proof discharge: Writes requires/ensures/invariant contracts, runs the SMT-backed verifier, iterates on counterexamples, and blocks on undischarged obligations instead of shipping partial claims. - Machine-readable verdicts: Emits structured JSON proof results (tool, version, tier, bound, obligations discharged) and dispatches a reviewer that checks the specification is correct, not just that proofs closed. - Use Case: You are implementing a balance-transfer function in Rust where a rounding bug would mispay funds. The Skill writes Verus pre/postconditions proving conservation of funds for all inputs, discharges the obligations with Z3, and reports the proof verdict. ## Quick Start Use formal verification to prove the invariants of this cryptographic or monetary function with the appropriate verifier for its language.

Frequently Asked Questions about formal-verification

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I formally verify Rust code with Verus?

Write requires and ensures contracts plus loop invariants on the critical functions, then run the Verus verifier which discharges obligations through an SMT solver like Z3. Confirm the current Verus version and syntax via web search first, since the toolchain changes frequently.

When should I use formal verification instead of property-based testing?

Use formal verification only for small, stable, catastrophic-if-wrong cores such as cryptography, auth decisions, monetary arithmetic, or consensus invariants in a language with a real verifier. For everything else, property-based testing is the right tool and the natural fallback.

Which languages support deductive formal verification?

Full deductive verification is available for Rust via Verus, Dafny, Ada via SPARK, C via Frama-C-WP, and Java via OpenJML. C++ and C support bounded model checking via CBMC or ESBMC, while Kotlin, TypeScript, Python, Go, and similar languages have no deductive verifier.

Can CBMC prove C++ code correct for all inputs?

No. CBMC and ESBMC are bounded model checkers, so a pass only means no violation exists up to a stated loop or depth bound. You must state the bound explicitly and pair it with property-based testing to cover the unbounded tail.

What happens when a proof obligation cannot be discharged?

The solver's counterexample is fed back to add missing invariants or lemmas within a bounded retry budget. If obligations remain undischarged, the work escalates to a human prover or the property is downgraded to property-based testing — a partial proof is never shipped as a claim.

Why is formal verification so expensive compared to testing?

Historical data like seL4 put costs around $350-400 per line of code, with effort scaling roughly quadratically with specification size. LLM-assisted proof is improving automation rates, but many attempts still need human proof labor, so it is reserved for critical cores.