Skip to content
  1. Wiki
  2. Verification and evidence
  3. Formal verification

Formal verification

Formal verification checks every case of one rule, within a set scope.

An analogy

Ordinary testing spot-checks the brakes on a few cars. Formal verification proves mathematically that this brake design stops at any speed.

In pstack

Generate it with /pstack:create-formal-verification-skill. It picks a rule that's costly to break and hard for tests to reach. For example: "the same job never runs twice at once". The tool depends on the problem; for event order it uses TLA+ by default. It also builds a broken version on purpose to confirm the check catches it. A check you've never seen fail proves nothing.

If your code already breaks the rule, you get steps that make the problem happen. It won't change product code unless you ask. After the code changes, run /pstack:maintain-formal-verification-skill to update and rerun. It tells you whether the check is out of date or the code really has a bug. To show product or design folks, draw it as a state diagram with /pstack:statechart.

Common misconceptions

  • "If it passes, the whole system is fine": a pass only covers that scope. The handoff note says what was checked and what wasn't.
  • "Every project should do this": it's worth it only for concurrency, retries, state machines or parsers, where mistakes are expensive.

Try it: Full guide step 6: Verify and ship, Bugs tests can't reach: formal verification

Related: Verification skill, Evidence (not "should be fixed")

An unofficial beginner's guide to pstack, not its official docs. pstack is made by poteto; the official repo is the source of truth for commands and behavior. The original guide source is on GitHub.

Hosted by airali. Adapted from Xiaoxiaodong's MIT-licensed guide.