Definition
Soundness is the property of a program analysis or verifier that every claim it makes is true of every execution the program can have, where the possible executions are fixed by a semantics: the exact definition of what each instruction does. For a verifier that accepts or rejects programs, soundness means that it never accepts a program that has an unsafe execution. A sound analysis may raise false alarms §1.22 and may reject safe programs, but it never misses a real violation of the property it checks.
Where it fits
Main entry: Abstract interpretation (§3.4).
The Abstract interpretation entry shows how a sound analysis is built. At each program point the analysis computes an abstract state, a summary that stands for a set of concrete states §3.5 (complete contents of registers and memory), and soundness means that this set contains every concrete state that some run can reach at that point. The guarantee comes from the parts: every transfer function, the rule that computes the summary after an instruction, must cover every result of the real instruction, and every join must cover both summaries it merges. A safety check made against a summary that covers every real state then holds for every real run.
A claim of soundness is relative to three things, and it must name them. The property: an analysis that is sound for memory accesses says nothing about termination. The semantics: the guarantee covers the executions that the semantics defines, so where the semantics differs from the real machine, the guarantee does not reach the machine. The environment: code the analysis does not see, such as helper functions §2.19 that the runtime provides, is assumed to keep its stated contract.
Limits and common mistakes
Soundness alone is easy to have: a verifier that rejects every program is sound. A useful verifier also accepts many safe programs; accepting every safe program is completeness §3.8 (the Completeness entry).
In logic a proof system is sound when everything it proves is true, which matches the sense above. Some authors of bug-finding tools, however, call a tool sound when every bug it reports is real, which in a verifier’s terms is completeness. Many practical analyzers are sound only for part of a language and leave out named features; a 2015 article by Benjamin Livshits and colleagues called this soundiness [256]. Ask which direction and which features a claim covers.
Questions answered
Does soundness apply to the analyzer, the interpreter §2.13, or their correspondence?
Soundness in the strict sense applies to the analyzer: it says that every program the analyzer accepts is safe in every execution that the semantics, the exact definition of the instructions, allows. Whether the interpreter executes programs exactly as that semantics says is a separate property, usually called the correctness or semantic fidelity §2.38 of the interpreter. Neither property alone ties the analyzer’s verdict to what really runs; the two together do, because both are measured against the same semantics.
The end-to-end claim, that an accepted program runs safely on the real system, needs three links: the analyzer is sound with respect to the semantics; the interpreter, or a just-in-time compiler §2.14 that translates the program to machine code, implements that same semantics; and every function the program calls but the analyzer does not analyze, and the hardware, keeps its contract. Take a 2-bit machine whose semantics keeps results modulo , so gives 0. A sound analyzer accepts a read of element of a 4-element array §14.5, because that index is 0. An interpreter that keeps the sum in a wider variable computes 4 and reads past the end: the analyzer was right about the semantics, and the interpreter broke the claim. Conversely, an analyzer that computes 4 never checks the branch taken when the sum is 0, and a faithful interpreter then runs that unchecked code.
Related entries: Interpreter semantic fidelity (§2.38), Refinement (§3.32), Completeness (§3.8), Interpreter (§2.13), Helper contract (§2.21). Further reading: [68, 256].