Skip to content

Proof of correctness

A mathematical demonstration that an algorithm satisfies a formal specification, separating partial correctness from the additional obligation to prove termination for total correctness.

Core Idea

A proof of correctness mathematically shows that an algorithm satisfies a formal specification for all admissible inputs. Partial correctness guarantees valid results when execution returns; total correctness additionally proves termination, usually through a well-founded progress argument. Partial correctness proves that if execution terminates, the returned result satisfies the postcondition. Partial correctness proves that if execution terminates, the returned result satisfies the postcondition.

How would you explain it like I'm…

Showing the Recipe Always Works

When you write steps for a recipe, you might want to be sure it always makes the cake you promised. A proof of correctness is a careful math explanation showing that a set of computer steps always gives the promised result, for every allowed starting point — not just the times you tried it.

Proving a Method Always Works

A proof of correctness is a math argument showing that an algorithm — a step-by-step method — always does what its description promises. The promise says what inputs are allowed and what the answer must look like. One kind of proof shows that if the method finishes, its answer is right; a stronger kind also shows it always finishes. Testing only tries some inputs, but a proof covers all allowed inputs. Still, the proof is about the method on paper; a real computer could still have other problems.

Correctness Relative to a Specification

A proof of correctness is a mathematical argument that an algorithm meets a formal specification: a precondition (what inputs are allowed) and a postcondition (what the result must satisfy). Correctness depends on the specification — the same algorithm can be correct for one and wrong for another. Partial correctness means: if the algorithm finishes, the answer is right. Total correctness adds that it always finishes for every allowed input. Proofs often use a loop invariant, a fact that stays true every time a loop runs, plus a quantity that keeps shrinking so the loop must end. The proof is about the abstract algorithm, so it doesn't rule out compiler bugs, running out of memory, hardware errors or a wrong specification; testing still helps but only checks some runs.

 

A proof of correctness is a mathematical argument that an algorithm satisfies a formal specification, typically a precondition and postcondition; correctness is relational, since the same algorithm can be correct with respect to one specification and incorrect with respect to another. Partial correctness establishes that whenever execution terminates, the result satisfies the postcondition; total correctness adds termination on every admissible input. A standard structure pairs loop invariants or inductive hypotheses (to carry the postcondition) with a well-founded variant that strictly decreases until the algorithm halts. The proof concerns an abstract algorithm under a formal semantics, so it does not by itself certify a particular machine implementation against compiler faults, memory exhaustion, hardware errors or an inaccurate specification. Testing remains useful but samples executions instead of quantifying over all of them.

Scope of Application

The method applies to formally specified algorithms and programs whose semantics support deductive, automated, or mechanically checked reasoning. Use it for formally modeled algorithms and implementations, with specification, semantics, proof obligations, termination status, and trusted assurance boundary explicit.

  • Algorithm design. Proves input–output properties and termination.
  • Hoare logic. Uses assertions and triples over imperative programs.
  • Proof assistants. Mechanically check formal arguments.
  • Compiler verification. Relates source and target semantics.
  • Safety-critical software. Establishes selected properties beyond testing.

Clarity

Correctness proof separates four questions: what is required, what the algorithm means, whether results satisfy the requirement, and whether computation ends. It also exposes the assurance boundary between algorithm, implementation, platform, and specification. The closest near miss sets the boundary: Model checking is the closest near miss: it can provide formal proofs for finite-state models, but the technique and scope differ from a general deductive algorithm proof.

Manages Complexity

A program has many paths and states. Invariants and compositional proof rules summarize whole families of executions, replacing exhaustive enumeration with a finite chain of obligations whose assumptions and conclusions can be checked. The central mathematical completeness–trusted implementation stack tradeoff is this: An algorithm proof may leave compilers, hardware, and resources outside its model. A second strong specification–proof cost tension matters because Richer properties improve assurance while multiplying formalization and proof obligations.

Abstract Reasoning

Use three linked moves: formalize admissible inputs, required outputs, and operational or denotational semantics; decompose the algorithm into proof obligations using invariants and contracts; prove initialization, preservation, and postcondition consequences for every path. As a collapse test, the case exits when specification or semantics is informal, a path or input class is omitted, or total correctness is claimed without termination. A fourth check is to for total correctness, provide a well-founded decreasing measure or equivalent termination proof. A final check is to audit the trusted base and confirm that the specification expresses the intended requirement.

Knowledge Transfer

Proof methods transfer literally across algorithms when semantics and specifications are restated. A proof about an abstract routine does not automatically transfer to a compiled binary or resource-bounded environment; refinement links must be proved separately. No canonical parent prime is currently asserted; broader structural comparisons remain related-prime analogies until separately adjudicated in the DAG. A preserved property bridges local program steps to a global postcondition. Termination follows from progress in an order with no infinite descent.

Relationships to Other Abstractions

Local relationship map for Proof of correctnessParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.Proof of correctnessDOMAINPrime abstraction: Argument — is a kind ofArgumentPRIME

Current abstraction Proof of correctness Domain-specific

Parents (1) — outgoing typed relations

  • Proof of correctness is a kind of Argument Prime

    Proof of correctness is a domain-specific kind of argument under the frozen identity and differentia.

Hierarchy path (1) — routes to 1 parentless root

Neighborhood in Abstraction Space

Proof of correctness sits in a crowded region of the domain-specific corpus (37th percentile for distinctiveness): several abstractions share nearly its structure, so a description that fits it tends to fit its neighbors too.

Family — Formal Models & Logical Foundations (38 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-11-14