Run End-to-End Tests from Your Terminal with Kane CLI

Author and Run Tests Right from the Terminal in Natural Language, with an Evidence-Backed Pass or Fail from a Real Browser.

npm install -g @testmuai/kane-cli

What Is Formal Verification? A Practical Guide for Testers

Formal verification proves code meets its spec for every input. See how it works, the main tools, real examples, AI proofs, and what tests still catch.

Published

Summarise with AI

Formal verification is the application of mathematical proof (or an exhaustive machine search) to demonstrate that a piece of software/system design conforms to a specification for all possible inputs/states. The proof is only valid in the model that it was given, so a wrong specification will still produce wrong software.

In our own runs on 30th Nov 2026, we had four example tests with 100% coverage which missed a release gate bug, whereas the Z3 solver found it in milliseconds. A model checker found a device double-book race which 10,000 threaded test runs would never have hit until we added a 0.5ms delay. The full experiment is below.

TL;DR

Formal verification is the use of mathematical proof or an exhaustive machine search to show that code or a system design meets its specification for every possible input or state. It exists because a test checks only the inputs someone picked, while a model checker, SMT solver or proof assistant checks all of them inside a model.

Main Types of Formal Verification

  • Model checking: Fully automatic: Yes. A model checker such as TLC explores every reachable state of a finite model and returns a step-by-step trace when a property fails.
  • Bounded model checking: Complete beyond its bound: No. CBMC for C and C++ and Kani for Rust check every behavior up to a set depth and say nothing past it.
  • Theorem proving: Limited by a bound: No. A proof assistant such as Rocq checks each step of a machine-checked proof that holds for all inputs, for the most human effort.
  • SMT-based verification: Works on annotated code: Yes. Dafny sends pre-conditions, post-conditions and loop invariants to the Z3 solver, which proves each one or returns a counterexample.

Formal Verification vs Testing

  • Example-based testing: Proves the absence of bugs: No. A suite can reach 100% statement and branch coverage and still pass a release gate that lets one failure in 200 tests through.
  • Formal proof: Covers every input in the model: Yes. An SMT solver such as Z3 returns either a proof or a concrete counterexample to replay as a regression test.
  • End-to-end testing: Replaced by a proof: No. Browsers, devices, network latency and UI rendering sit outside almost every formal model, so TestMu AI's Kane CLI checks the user journey in a real browser.

What Is Formal Verification?

Formal verification is the process of checking a system against a specification using logic rather than sample runs. Wikipedia describes it as the use of mathematics to prove or disprove that a hardware or software system satisfies a formal specification. Every formal verification setup has three parts:

  • A specification. A very precise statement of what must always be true, e.g. "two runners never hold the same device".
  • A model of the system. Either the actual code (Dafny, Kani, Verus and CrossHair all read real code) or a hand-written design model (TLA+, Alloy).
  • A checker. A model checker, SMT solver or proof assistant which either proves the property, returns a counterexample or gives up with a timeout or "unknown".
Diagram of formal verification: a specification and a system model go into a checker, which returns a proof, a counterexample or unknown

Formal verification is narrower than 'verification' in the QA sense of verification versus validation (that being reviews and checks against the requirements). A linter is not formal verification at all as it makes no claim about all inputs.

For a quick visual walkthrough of this concept, watch the video below from TestMu AI.

Youtube thumbnail

Subscribe to the TestMu AI YouTube channel for more tutorials on testing and automation.

Formal Methods vs Formal Verification

Formal methods are mathematically based techniques for specifying, developing and verifying software and hardware. Formal verification is the part of formal methods where you take a system and check it against its specification using a tool. A TLA+ model of a job queue is an example of a formal method; running TLC against that model is an example of formal verification.

Formal methods in software engineering show up at three points in delivery, and most teams need one or two:

  • Design time. A TLA+ or Alloy model of a protocol, scheduler or state machine, written before the code. AWS engineers learned TLA+ and got useful results in two to three weeks.
  • Code time. Contracts and proofs on a small critical core (e.g. parsers, permission rules, money arithmetic).
  • CI time. The checker runs on every PR, and a counterexample will prevent the merge.

ThoughtWorks put TLA+ in the 'Assess' ring of its Technology Radar in November 2026, citing "coding agents have changed the calculus" on the cost of using TLA+.

How Does Formal Verification Work?

Formal verification takes both the system and the requirement and turns them into logic, then uses a machine to search or prove. The steps are the same regardless of which tool you use:

  • Write the property. A safety property is one that says something bad never happens (a "no double booking" type of property). A liveness property is one that says something good eventually happens (a "every queued job eventually runs" type of property).
  • Model the system. Point the tool at the code or write a small design model.
  • Run the checker. It will explore all reachable states (model checking), build a proof from the rules (theorem proving) or ask a solver whether or not a counterexample exists (SMT).
  • Read the result. A proof means there's no counterexample in the model. A counterexample would be a concrete input or trace that you could just replay as a regression test. A timeout means the question was simply too big as it was originally posed.

The trusted base is everything that has to be correct for a proof to mean anything at all: the specification, the model of the machine or language, the checker and any assume lines. Proof assistants keep their checking kernels very small; the specification is the bit that people most often get wrong.

Types of Formal Verification: Model Checking, Theorem Proving and More

Formal verification covers five main techniques, trading automation for the strength of the guarantee.

  • Model checking requires exploring every reachable state of a finite model and checking a property in each one. TLC (the TLA+ model checker) and the Alloy Analyzer are the most common examples. It's completely automatic, will give you a step-by-step trace if a property fails and is ideal for concurrency. The downside, of course, is that the state space explodes as you add more processes.
  • Bounded model checking looks at all the behaviors up to a certain depth (e.g. a certain number of loop iterations). CBMC does this for C and C++ and Kani (from AWS) does it for Rust, checking for panics, overflows and undefined behavior in unsafe code. A bounded result is complete within the bound and silent outside of it.
  • Theorem proving produces a machine-checked proof which is valid for all inputs (i.e. there is no bound). Proof assistants such as Rocq (Coq until Rocq 9.0 in March 2025), Lean, and Isabelle all have a small kernel which checks every step. Theorem proving is the one that gives the strongest guarantee for the most human effort.
  • SMT-based verification allows you to annotate your code with pre-conditions, post-conditions and loop invariants as well as then pass the proof obligations off to a solver such as Z3. That's how Dafny and Verus work.
  • Abstract interpretation over-approximates every value that a variable can take and so can prove the absence of runtime errors such as overflow. Astrée and the Eva plug-in for Frama-C are both sound analyzers of this type. Most of the tools that a QA team would use for static testing are not sound and so can in fact miss bugs.

Property-based testing sits next to these techniques without being one of them: it checks a rule on generated inputs instead of proving it, and that rule is often the first draft of a formal specification.

Formal Verification vs Testing: One Bug, Five Checks

Formal verification and testing are answering quite different questions. A test is asking "did this input behave?" A proof is asking "is there any input that misbehaves?"

Dijkstra in his 1972 Turing Award lecture referred to testing as "hopelessly inadequate for showing their absence" (i.e. the absence of bugs).

Hillel Wayne makes the mirror image observation: tests can miss bugs; they won't report a false positive. A prover can generate a false positive, but won't miss a bug in its model.

We ran one realistic bug through five checks. All of the code below is the exact code we ran, on a 2 vCPU Intel Xeon (2.10GHz) Linux VM with 7.8GiB RAM, Python 3.13.18, pytest 9.1.1, pytest-cov 7.1.0, Hypothesis 6.170.26, z3-solver 5.4.1, CrossHair 0.0.115, OpenJDK 21 and TLC build 2026.11.28. Timings are ranges over repeated runs.

The Bug: A Pass-Rate Badge That Opens the Release Gate

Test dashboards tend to display a whole-number pass rate, and some teams will actually gate their releases on that being 100%. Python's round() function rounds halves to the nearest even number, and 100 is even, so round(99.5) will return 100. Any run with at most one failure per 200 tests (i.e. 199 passed and 1 failed, or 398 passed and 2 failed) will show 100%.

# report.py
def pass_rate(passed: int, failed: int) -> int:
    """Whole-number pass rate shown on the run badge and used by the CI gate."""
    total = passed + failed
    if total == 0:
        return 100
    return round(passed * 100 / total)

def ci_gate(passed: int, failed: int) -> bool:
    """Release is allowed only when the pass rate is 100."""
    return pass_rate(passed, failed) == 100

Check 1: Example-Based Tests Pass With 100% Coverage

# test_examples.py
from report import pass_rate, ci_gate

def test_all_green():
    assert pass_rate(40, 0) == 100
    assert ci_gate(40, 0)

def test_one_failure_blocks_release():
    assert pass_rate(9, 1) == 90
    assert not ci_gate(9, 1)

def test_half():
    assert pass_rate(1, 1) == 50

def test_empty_run():
    assert pass_rate(0, 0) == 100

pytest --cov=report --cov-branch reported 4 passed with 100% statement and branch coverage, in 0.11 to 0.13s. The coverage records which lines ran, not which inputs were tried.

Terminal output showing example tests passing with 100 percent coverage while Z3 finds the counterexample 199 passed, 1 failed

Check 2: Property-Based Testing Depends on the Input Strategy

The property: if any test failed, the gate stays shut.

# test_properties.py
from hypothesis import given, strategies as st
from report import ci_gate

counts = st.integers(min_value=0, max_value=100)   # "a suite has up to 100 tests"

@given(passed=counts, failed=counts)
def test_gate_never_passes_a_run_with_failures(passed, failed):
    if failed > 0:
        assert not ci_gate(passed, failed)

The small bounds test passes. We then ran the same property 200 times per strategy (each with a different fixed seed, 0 to 199) and Hypothesis's default of 100 examples:

Input strategyRuns that found the bugMinimal failing case
Small suites: 0 to 100 passed, 0 to 100 failed0 / 200none
Unbounded integers (min 0)200 / 200(199 passed, 1 failed)
0 to 5,000 each96 / 200(199, 1)
Targeted: 0 to 5,000 passed, 1 to 3 failed200 / 200(199, 1)

The small-suite strategy simply can't find the bug as it requires at least 200 tests. The unbounded and directed strategies found it every time and reduced it down to the minimal case, in a median of 37 to 52ms per run.

Bar chart: Hypothesis found the pass-rate bug in 0 of 200 runs with small bounds and 200 of 200 with unbounded or targeted inputs

Check 3: A Bounded Exhaustive Check Is Complete Only up to Its Bound

Bounded checking tries every input up to a limit (which is what tools such as Kani and CBMC do symbolically). A brute-force loop over every suite of up to 5,000 tests checked 12,502,500 inputs in about 3.5 seconds and found 60,025 that opened the gate; the same loop with a limit of 100 tests found none.

Check 4: An SMT Solver Finds the Bug and Proves the Fix

Z3 reasons about unbounded integers. We manually translated both gates into formulae and then asked Z3 for any run which results in a failure that still opens the gate:

# prove_z3.py
"""Ask Z3 for any (passed, failed) with failed >= 1 that still opens the release gate.
Z3 reasons over unbounded integers, so 'unsat' means no such input exists at any suite size.
The formulas are a hand translation of report.py and report_fixed.py."""

import time
from z3 import Ints, Solver, And, sat, get_version_string

p, f = Ints("passed failed")
t = p + f

def check(label, gate_open):
    s = Solver()
    s.add(p >= 0, f >= 1, gate_open)          # a run with at least one failure...
    start = time.perf_counter()
    r = s.check()                             # ...that the gate still lets through?
    ms = (time.perf_counter() - start) * 1000
    print(f"{label}: {r} in {ms:.1f} ms", s.model() if r == sat else "-> proved: no such run exists")

# report.py: round(100*p/t) == 100. Python rounds half to even, so 99.5 becomes 100.
# For 0 <= p <= t that is exactly 100*p/t >= 99.5, i.e. 200*p >= 199*t.
check("buggy gate ", And(t > 0, 200 * p >= 199 * t))

# report_fixed.py: gate is failed == 0 and passed > 0
check("fixed gate ", And(f == 0, p > 0))

# fixed badge: floor(100*p/t) == 100, i.e. 100*p >= 100*t
check("fixed badge", And(t > 0, 100 * p >= 100 * t))
print("z3", get_version_string())
buggy gate : sat in 2.6 ms [passed = 199, failed = 1]
fixed gate : unsat in 0.9 ms -> proved: no such run exists
fixed badge: unsat in 1.4 ms -> proved: no such run exists
z3 5.4.1

Warm runs took 2.4 to 5.1ms for the counterexample and 0.8 to 3.0ms per proof; a cold first run can take about 0.2s. The fixed code decides the gate on counts and badges it down:

# report_fixed.py
def pass_rate(passed: int, failed: int) -> int:
    """Whole-number pass rate for the badge. Rounds down, so it never shows 100 with a failure."""
    total = passed + failed
    if total == 0:
        return 0
    return passed * 100 // total

def ci_gate(passed: int, failed: int) -> bool:
    """Release only when tests ran, and none failed. Decided on counts, not on the rounded badge."""
    return failed == 0 and passed > 0

The fixed gate proof is trivial on purpose (the gate-on-counts decision removes the arithmetic that needed to be proved). The badge proof is the one with the actual arithmetic in it.

Check 5: CrossHair Checks the Python Itself

The Z3 proof is based on a hand translation which could be incorrect, so we also ran CrossHair, which reads the Python directly. With the contracts "on failure the gate returns False" and "the badge stays below 100", CrossHair produced a counterexample at (199,1) for the faulty gate and "Confirmed over all paths" for the fixed badge, at 0.27 to 0.54s per run.

What the Five Checks Tell You

CheckFound the bugCovers every inputTime per run
Example tests (100% coverage)NoNo0.11-0.13 s
Property test, small boundsNo (0/200)No~39 ms
Property test, unbounded or targetedYes (200/200)No37-52 ms
Bounded exhaustive check, ≤ 5,000 testsYesOnly up to 5,0003.5 s
Z3 (hand-translated) / CrossHair (on the code)Yes, plus proof of the fixYes, within the model2.4-5.1 ms / 0.27-0.54 s

Our first property ("never release with a failure") also accepted a run of zero tests which the earlier code would have released at "100%". The act of writing that property forced a decision about what to do with empty runs, and the fixed gate now blocks them.

Note

Note: The proof is for ci_gate; the dashboard that invokes it still needs an end-to-end check. The Kane CLI end-to-end testing agent will run that test for you from your terminal or from your coding agent in a real browser and will save the screenshots and logs of what the badge showed. Install it via npm install -g @testmuai/kane-cli.

Model Checking a Race Condition: Two Test Runners, One Device

Model checking is the only way to find those concurrency bugs that tests will only reach by luck. We modeled test runners claiming a free phone from a device pool.

The buggy claim reads the pool then writes ownership in a second step. The fixed claim does both in one atomic compare-and-set.

---------------------------- MODULE DeviceClaim ----------------------------
\* Test runners claim devices from a shared pool, run a job, release the device.
EXTENDS Naturals

CONSTANTS Runners, Devices, Atomic

VARIABLES owner, pc, dev

vars == <<owner, pc, dev>>

Free == "free"

Init == /\ owner = [d \in Devices |-> Free]
        /\ pc    = [r \in Runners |-> "idle"]
        /\ dev   = [r \in Runners |-> Free]

\* Buggy claim, step 1: read the pool and see a free device.
Look(r, d) == /\ ~Atomic /\ pc[r] = "idle" /\ owner[d] = Free
              /\ pc'  = [pc  EXCEPT ![r] = "claiming"]
              /\ dev' = [dev EXCEPT ![r] = d]
              /\ UNCHANGED owner

\* Buggy claim, step 2: write ownership without re-checking.
Take(r) == /\ pc[r] = "claiming"
           /\ owner' = [owner EXCEPT ![dev[r]] = r]
           /\ pc'    = [pc EXCEPT ![r] = "running"]
           /\ UNCHANGED dev

\* Fixed claim: check and write in one atomic compare-and-set.
Claim(r, d) == /\ Atomic /\ pc[r] = "idle" /\ owner[d] = Free
               /\ owner' = [owner EXCEPT ![d] = r]
               /\ pc'    = [pc  EXCEPT ![r] = "running"]
               /\ dev'   = [dev EXCEPT ![r] = d]

Release(r) == /\ pc[r] = "running"
              /\ owner' = [owner EXCEPT ![dev[r]] = Free]
              /\ pc'    = [pc  EXCEPT ![r] = "idle"]
              /\ dev'   = [dev EXCEPT ![r] = Free]

Next == \E r \in Runners :
          \/ \E d \in Devices : Look(r, d) \/ Claim(r, d)
          \/ Take(r)
          \/ Release(r)

Spec == Init /\ [][Next]_vars

\* Safety rule: two runners never run on the same device at the same time.
NoDoubleBooking == \A r1, r2 \in Runners :
    (r1 /= r2 /\ pc[r1] = "running" /\ pc[r2] = "running") => dev[r1] /= dev[r2]

=============================================================================
ModelTLC resultDistinct states
Buggy two-step claim, 3 runners, 2 devicesInvariant NoDoubleBooking is violated61
Atomic claim, 3 runners, 2 devicesNo error, full state space13
Atomic claim, 5 runners, 3 devicesNo error, full state space136

Each TLC run took 0.7 to 2.1 seconds (including JVM start-up) on two machines. The counterexample is a 5-state trace: runner1 sees pixel9 as free, runner2 sees pixel9 as free, runner1 takes it, runner2 takes it, and both run on one phone.

TLC error trace showing two test runners both claiming the same Pixel 9 device

We then ran the identical two-step claim in Python with two threads released by a barrier, 10,000 trials per case; the script was repeated 7 times across two machines:

ClaimDelay between read and writeDouble bookings in 10,000 trials
Two-stepnone (pure in-memory)0 in every rerun
Two-step0.5 ms (time.sleep)9,896 to 10,000
Lockednone or 0.5 ms0 in every rerun

The zero-delay result is in part a CPython artifact (the GIL doesn't tend to switch threads between the read and the write so the window almost never opens). A free-threaded Python/Java/Go would probably have a different rate, and in our reruns the rate did vary with machine load.

Either way, the threaded test is just looking at the timings it happened to get in that test, whereas TLC looks at every possible ordering of the model's steps.

At AWS, for a DynamoDB data loss bug found using TLA+, "the shortest error trace exhibiting the bug included 35 high-level steps".

Formal Verification in Hardware and Safety Standards

Formal verification is the norm in chip design (a missed bug in that context can mean a recall). There are two main uses. The first is formal equivalence checking, which proves that the gate-level netlist that's been synthesized behaves in exactly the same way as the RTL it came from, without any simulation test cases being required.

The second is formal property checking, which proves assertions (typically written as SystemVerilog Assertions) against the RTL. The commercial tools in that space are Cadence Jasper and Conformal, Synopsys VC Formal and Formality and Siemens Questa One.

Formal equivalence checking compares RTL with the synthesized gate-level netlist

At Intel the Pentium FDIV division bug resulted in a $475m pretax charge in Jan '95. By the Core i7 (Nehalem) the validation of the execution engine had moved from coverage-driven testing to formal verification (Kaivola et al., CAV 2009).

Safety and security standards also name formal methods:

StandardDomainWhat it says about formal methods
DO-178C with the DO-333 supplementAvionics softwareDO-333 is the formal methods supplement; formal methods complement testing and do not replace it
ISO 26262-6Automotive softwareRecommends formal notations at every ASIL, without "highly recommending" them (traceability summary)
Common Criteria EAL7Security productsHighest assurance level; practical only for products whose security functions can undergo extensive formal analysis

Formal Verification Tools Compared

Formal verification tools vary in what they read and how much they actually prove. Learning curve is our assessment of an SDET new to formal methods.

ToolTechniqueWhat it readsBest forLearning curve
TLA+ (TLC, TLAPS)Model checking, proofsDesign modelsDistributed systems, queues, retriesMedium (2-3 weeks at AWS)
QuintExecutable specs with TLA+-style semanticsDesign models in programmer-style syntaxTeams put off by TLA+ notationLow to medium
AlloyBounded model findingData and relation modelsPermissions, data models, config rulesLow to medium
DafnySMT-basedDafny code, compiled to C#, Java, JavaScript, Go, PythonVerified business logic you shipMedium
Lean 4Theorem provingLean code and maths (Mathlib has over 297,000 theorems)Verified software and proofsHigh
RocqTheorem provingRocq code, extracted to OCamlCompilers and deep correctnessHigh
Isabelle/HOLTheorem provingIsabelle modelsOS kernels, protocolsHigh
KaniBounded model checkingRustPanics, overflow, unsafe codeLow
VerusSMT-basedA subset of RustFull proofs of Rust codeMedium to high
CBMCBounded model checkingC and C++Memory safety, undefined behaviorLow to medium
Z3SMT solverFormulas via Python and other bindingsRules, configs, arithmeticLow for simple queries
CrossHairSymbolic executionPython with contractsCounterexamples in Python functionsLow
Frama-CAbstract interpretation, deductive proofC with ACSL specsEmbedded and safety-critical CMedium to high
SPARKDeductive proofSPARK dialect of AdaNo runtime errors in high-integrity codeMedium
Certora ProverFormal verification with CVL specsSmart contractsDeFi invariantsMedium

For a QA team starting from scratch, the easiest entry points into software verification are Z3 or CrossHair for Python code (Z3 and CrossHair being the two most popular), Kani for Rust and then TLA+ or Quint for anything concurrent.

Kane CLI - Testing Agent in Your Terminal

Formal Verification Examples in Software

Formal verification software has a long production track record in which bugs are very expensive.

  • Airbus flight control. In November 2003 Astrée proved the absence of runtime errors in approximately 132,000 lines of C in the Airbus A340 primary flight control software, with zero false alarms.
  • seL4. The functional correctness proof of seL4 was published at SOSP in 2009, and the proofs now extend all the way from specification to binary. Martin Kleppmann puts the cost at about 200k lines of Isabelle and 20 person-years for 8.7k lines of C.
  • CompCert. The CompCert C compiler comes with a machine-checked correctness proof. The Csmith random tester (which found over 325 bugs in other compilers) reported that "Csmith cannot find wrong-code errors" in the verified middle end, although it did find wrong-code bugs in the unverified front end of CompCert.
  • AWS policies and authorization. Zelkova uses SMT solvers to determine whether an IAM or S3 policy permits public access. AWS reports that its formally verified IAM authorization engine is 50% faster than the previous one, at over 1.2 billion requests per second (Oct 2024).
  • Firecracker. Kani found five bugs in Firecracker's I/O rate limiter, one of which was a rounding error that allowed guests to go over their bandwidth limits by as much as 0.01%.
  • Cedar. The Cedar authorization language team found 4 bugs as part of their proofs and 21 more via differential random testing and property-based testing. Cedar's formal models are now proved in Lean.

Formal Verification and AI: Can AI Write Proofs?

AI models now write formal proofs at scale.

On Oct 22, 2026, Anthropic's Frontier Red Team reported that Claude formally proved a no-crash property for 239 OSS-Fuzz entry points across 123 open-source libraries: for any input under 64 MB, the compiled RISC-V binary does not crash, including memory-safety errors caught by AddressSanitizer and failed assertions. The proofs are in Rocq and total about 180 million lines. Along the way Claude found and patched hundreds of bugs (Anthropic gives no exact count) in code that OSS-Fuzz had already exercised with trillions of test runs.

In January 2026 Anthropic also published a property-based testing agent run over 100+ Python packages. The agent produced 984 bug reports; of 50 reviewed by hand, 56% were valid. Of the five bugs the post highlights, three had patches merged, including a fix for numpy.random.wald returning negative numbers.

Kleppmann was predicting as far back as December 2025 that formal verification was "likely to go mainstream in the foreseeable future" given that LLMs have reduced the cost of proof and that AI-written code will require checks which don't rely on human review.

Daniel Moka's Formal Verification 101 (30th Nov 2026) makes the test side argument: an agent's tests will tend to pass because the agent wrote them to pass.

Why No Model Checks Its Own Work

A proof is considered valid because it's checked by something other than the model itself (in Anthropic's case the Rocq checker either accepts or rejects it). Tests need to be analogous in that respect as an agent which writes the code and then writes the tests and reports "all green" has effectively checked its own work under one set of assumptions.

Once the checker is independent, the spec is the weak point. Anthropic points out the obvious exploit: just keep changing the program until it's impossible to crash, and the proof is trivial.

They penalized patches and audited them, and the section on limitations explicitly states "'Formally verified' does not mean 'bug-free'." Steps 2 and 3 of the playbook below are in place to ensure the spec is out of the agent's reach.

Limitations of Formal Verification

Formal verification proves what the specification and model say and nothing else.

  • The specification can be wrong. Hillel Wayne: "You do not prove something's correct. You prove conformance to specification." Our own first property accepted an empty test run.
  • The model is not the machine. Anthropic's proofs assume RISC-V, Linux and musl semantics, while most users run x86 or ARM with glibc. seL4's proofs assume that assembly code, boot code, the machine interface, hardware and DMA behave as modeled. CompCert's unverified front end still had bugs.
  • The environment is almost never modeled. Browsers, real devices, OS updates, network latency, third-party APIs and UI rendering all sit outside of almost every proof. In our experiment a single 0.5ms delay in the environment moved a threaded race test from 0 to nearly 10k failures in 10k runs.
  • Cost is front-loaded. seL4 and Intel's Core i7 execution engine each took about 20 person-years to develop. AI reduces the proof cost, but someone still has to write and review the spec.
  • Performance and the user experience are not in scope. 'Never double book' is a verifiable rule. 'Every job completes in under 30 seconds on a Pixel 9 over 4G' is a measurable outcome.

When to Use Formal Verification vs Property-Based Testing vs End-to-End Testing

Formal verification, property-based testing and end-to-end testing all answer different questions, so you pick the right one by considering the question at hand and the cost of being wrong.

What you are checkingUseWhy
Arithmetic, rounding, limits, quotas, billing, pass/fail gatesSMT proof (Z3, Dafny, CrossHair) plus a few example testsSmall input spaces with sharp edges; proofs take milliseconds
Locks, leases, retries, queues, device or job claimingTLA+, Quint or another model checker on the designBugs hide in orderings that tests hit by luck
Rust or C with unsafe, parsers, decodersKani or CBMC harnesses in CIBounded proofs of no panic, overflow or memory error
Pure functions where a full proof costs too muchProperty-based testing with targeted strategies, plus mutation testingCheap and fast, as long as strategies reach the edges
State machines you want test cases generated fromModel-based testingTurns a behavior model into executable tests
User journeys across browsers, devices, APIs and UIEnd-to-end testing on real browsers and devicesThe environment is the thing under test
Chat, voice, phone, image and video agents; agents acting on tools and APIsSimulated-user testing and evidence-based agent verificationBehavior depends on language, audio, model output and side effects

How to Adopt Formal Verification on a QA Team With Coding Agents

Formal verification on a QA team is most effective as a very narrow, enforced layer on the most risky code, and is something that really only makes sense for a team whose developers are using coding agents of some sort (Claude Code, Cursor, Codex, etc.).

  • Pick a function where a bug would be expensive. A release gate, a discount/quota rule, a retry/lease protocol or a permission check would be good examples (ideally under 100 lines).
  • Have a human write the rule. The property (whether that's a TLA+ invariant or a Dafny postcondition) originates with the person who owns the requirement. An agent can write it, but a human has to approve it.
  • Lock the rule files. Keep the specs in their own folder, list them in CODEOWNERS so that any changes require a named reviewer and block agent edits at the local level. We've tested this Claude Code PreToolUse hook: it returns an exit code of 0 for src/report.py and an exit code of 2 (i.e. blocked) for files in verification/ or specs/, .tla and .dfy files and a NotebookEdit call under verification/.
  • Run the checker in CI (separately from the agent). CI runs Z3, TLC, Kani or Dafny on every PR and fails the build if there's a counterexample or a timeout; an agent's report that a proof has passed is not evidence of anything.
  • Plant the bugs to test the rule. Of the three bugs we planted in the fixed gate, the weak rule ("the gate returns a boolean") caught none at all, whereas the real rule ("release only if tests ran and none failed") caught all three and passed the correct code. Mutation testing tools do all of that for you.
  • Turn every counterexample into a regression test. (199, 1) becomes a permanent example test.
  • Keep end-to-end evidence for what the proof omits. The proof says ci_gate is correct. A run in a real browser will show whether the dashboard calls ci_gate, renders the badge and blocks the deploy button.

The hook from step 3:

#!/bin/bash
# .claude/hooks/protect-specs.sh: the agent may change code, never the rules that judge it.

FILE=$(jq -r '.tool_input.file_path // .tool_input.notebook_path // empty' <&0)

case "$FILE" in
  */verification/*|*/specs/*|*.dfy|*.tla|*/tla/*.cfg)
    echo "Blocked: $FILE is a verification rule. A human edits rules; ask in the PR." >&2
    exit 2 ;;
esac

exit 0

Register it under hooks.PreToolUse with matcher Edit|Write|NotebookEdit (add MultiEdit if your Claude Code version has it) in .claude/settings.json as per the Claude Code hooks docs. The hook is file edit tools only as a shell command can still go and change files, so CODEOWNERS and CI remain the real gate. Ban new assume statements in the same review rule.

Where TestMu AI Fits

TestMu AI doesn't sell a formal verification or proof tool per se. For the core logic you're specifying you can use the open-source tools mentioned above.

TestMu AI covers the layer that proofs don't, in the same way that proofs are trusted. The principle is that no model ever checks its own work and the verdict comes from an independent check of the evidence.

What you need to checkTestMu AI productWhat it does
Web and mobile user journeys, for developers, SDETs and coding agentsKane CLIRuns plain-English tests from the terminal, Claude Code, Cursor or Codex on real Chrome, emulators, simulators or real devices; saves screenshots and console and network logs in a .evidence file. A separate verification step decides the verdict, and saved tests replay unchanged steps from cache with no LLM cost.
Chat, voice, phone, video and image agentsAgent TestingSimulated users with varied personas and accents, hallucination checks against your source documents, and a Green, Yellow or Red verdict per suite
Agents acting on tools, files and APIsAgent Assurance, delivered by Rook CLIObserves what an AI agent actually changed in tools, files and APIs; verdicts are Pass, Fail or Unable to Verify, with unverifiable criteria kept out of the pass rate

KaneAI, TestMu AI's end-to-end testing agent, can plan, author, run and evolve tests across web and mobile apps. Its tests can also run from the Kane CLI. HyperExecute can run existing Selenium, Playwright and Cypress suites as an AI Test Orchestration platform.

For the definitions of this approach, see what AI verifiability means, verification-driven development and how .evidence files prove agentic test runs.

Note

Note: Try it on your own app. Proofs cover the logic you can specify. Kane CLI checks what your users actually see, from the same terminal your coding agent uses: npm install -g @testmuai/kane-cli. Get started with Kane CLI.

Conclusion

Start with one function where a wrong answer is expensive, such as a release gate or a device claim, and write its rule before you choose a formal verification tool. Check it with Z3 or CrossHair for Python, Kani for Rust or TLC for a concurrent design, run the checker in CI apart from the agent, and turn each counterexample into a regression test. Then cover the browser, the device and the UI, which the proof leaves out, with an end-to-end run.

Testing from the terminal? Kane CLI by TestMu AI lets SDETs and developers plan, write, run and debug tests from the command line.

To run your first test, start free, or
for a full walkthrough of the product.

Was this helpful?

Authors

Asad Khan

Asad Khan

Author · 03 hubs

Asad Khan is the Co-Founder and CEO of TestMu AI, with over 15 years of experience in software testing, product strategy, and leadership. Under his leadership, TestMu AI has grown into an AI-native software testing platform trusted by 2.5M+ users across 132 countries, including startups, enterprises, and Fortune 500 companies. He is a member of the Forbes Technology Council and is followed by 39,000+ professionals on LinkedIn from the software testing and quality assurance community. Before TestMu AI, Asad co-founded 360logica, a software testing company that he grew into a multi-million-dollar business before its acquisition by Saksoft. Earlier, he began his career at GlobalLogic as a Lead Engineer serving top Wall Street banks. He holds a Bachelor of Technology from JSS Academy of Technical Education, Noida.

Maneesh Sharma

Maneesh Sharma

Reviewer

Maneesh Sharma is Chief Operating Officer at TestMu AI, where he leads the company's revenue functions across go-to-market, sales, RevOps, customer success, and the partner ecosystem, driving its global expansion. He brings over 28 years of experience across product, go-to-market, and business operations. Before TestMu AI he was Managing Director and General Manager for GitHub across India and APAC, Head of Partner Sales and Ecosystem at Adobe, Chief Revenue Officer at WizIQ, and Head of Products and Solutions at SAP India. Maneesh holds an MBA from IIM Bangalore and a B.E. in Electronics and Communications from NIT Surat.

Formal Verification FAQs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests