Find a tool · C

Proving that your C code always terminates or progresses

Every run finishes, or the system keeps making progress (liveness).

Change the question

I have code and want to prove

Effort
My code uses

Ranked by: support for this property, stage, coverage of the features you pick, and trust. Tools that work on compiled code rank lower. Ranking as JSON.

  1. Write ACSL contracts and loop invariants as comments in your C code; Frama-C's WP plug-in turns them into proof goals for SMT solvers.

    Supported.terminates and decreases clauses and loop variants generate termination goals, including for (mutually) recursive functions.
    Source
    Supported — terminates and decreases clauses and loop variants generate termination goals, including for (mutually) recursive functions.

    Effort
    Auto-active
    Covers
    4 of 17 C features
    Relies on
    Alt-Ergo or another SMT solver via Why3 is trusted; no proof certificates. C model built into Frama-C and WP's memory models; no published validation found.
    Stage 1 · Usable Trust: Checker partial, Semantics partial, Frontend partial, Binary gap weak, Escape hatches partial 0/5 strong
  2. Write a test-like harness for your C code; CBMC checks every execution up to a loop bound, giving a counterexample or a bounded proof.

    Partial.Unwinding assertions show that loops finish within the given bound. Proving termination of unbounded loops needs loop contracts with a decreases clause.
    Source
    Partial — Unwinding assertions show that loops finish within the given bound. Proving termination of unbounded loops needs loop contracts with a decreases clause.

    Effort
    Push-button
    Covers
    8 of 17 C features
    Relies on
    A SAT or SMT solver decides; its answer is trusted and no proof certificate is kept. C model built into CBMC; tested by its own regression suite.
    Stage 1 · Usable Trust: Checker partial, Semantics partial, Frontend partial, Binary gap weak, Escape hatches partial 0/5 strong
  3. s2n-bignum on compiled code: x86-64

    Prove hand-written x86-64 or Arm64 assembly correct in HOL Light, on the exact bytes of the built object file; used for AWS's cryptography code.

    Supported.Specifications state that execution eventually reaches the postcondition (total correctness).
    Source
    Supported — Specifications state that execution eventually reaches the postcondition (total correctness).

    Effort
    Interactive
    Covers
    0 of 0 common features
    Relies on
    Hand-written instruction models; random co-simulation against real CPUs in CI.
    Stage 1 · Usable Trust: Checker strong, Semantics partial, Frontend strong, Binary gap strong, Escape hatches strong 4/5 strong
  4. LNSym on compiled code: AArch64

    Prove Armv8 (AArch64) machine code correct in Lean 4 by symbolic simulation over a hand-written model; aimed at AWS-LC cryptographic routines.

    Unknown

    Effort
    Interactive
    Covers
    0 of 0 common features
    Relies on
    Hand-written AArch64 subset; random co-simulation against real Arm CPUs in CI. Opcodes are pasted from objdump into Lean; not linked to the binary by a proof.
    Stage 0 · Research Trust: Checker strong, Semantics partial, Frontend partial, Binary gap strong, Escape hatches partial 2/5 strong

Or write new verified code that compiles to C

You write the code in a verification language; its compiler produces the C code.

Verify C, but not this property

  • Verified Software Toolchain (Verifiable C) — Partial correctness only: a proof says the code does not crash and, if it terminates, ends in a state satisfying the postcondition.
  • Alive2 — Termination is not checked. Only paths that reach a return are compared, and infinite loops without the mustprogress attribute are unsupported.
  • CN — Specifications have preconditions, postconditions and loop invariants but no termination measures, so proofs say nothing about termination.
  • Islaris — The adequacy theorem gives a safety property; it does not show that the code finishes.

Ask something else about C

New to this? Start with the glossary: auto-activeAuto-active verification. You write specifications and hints in the code; an automatic solver does the proving., interactiveInteractive theorem prover. A proof assistant where you write proofs step by step and the system checks each step., trusted computing baseTrusted computing base (TCB). Everything that must be correct for a proof to mean what it says..

esc