Jump to content

Formal verification

From Tilcayo Cats, the lean encyclopaedia by Tilcayo Knowledge Systems

Formal verification uses mathematically defined models and logical reasoning to establish that a system satisfies stated properties. In computer science, it is applied to software, hardware and protocols. A verification result concerns an explicit specification and assumptions, rather than an unrestricted claim that a product cannot fail. Techniques include deductive program proofs, model checking and automated reasoning about logical constraints. They can complement testing by examining properties that would be difficult to establish from a collection of test executions alone.[1][2]

Specifications and correctness

A formal specification makes the property to be checked precise. For a program fragment, Hoare logic relates a precondition, a command and a postcondition. A triple of the form {P} C {Q} states that, when command C begins in a state satisfying P and terminates, its resulting state satisfies Q. This separates what is assumed about the starting state from what the command must establish.[3]

Such a statement expresses partial correctness. It does not, by itself, show that the command terminates. Total correctness adds termination to the required result. Proofs of loops commonly use invariants: assertions that hold initially and are preserved by each iteration. Together with the condition under which the loop stops, an invariant can support the desired postcondition. Finding an appropriate invariant is consequently part of constructing the proof, not merely running the program on example inputs.[3]

Model checking

Model checking investigates whether a formally represented system satisfies a specified property. A system can be described through states and transitions, while a temporal logic expresses requirements about its possible executions. This permits questions about sequences of events, including systems designed to continue running rather than terminate with a single answer.[4]

The number of states can make direct exploration impractical. Abstraction reduces the model by suppressing distinctions that are unnecessary for the property being investigated. With a suitable over-approximation, the abstract system includes every concrete behaviour but may also include extra ones. For properties preserved by that abstraction, a successful check transfers to the concrete system; a reported counterexample may instead arise from the extra behaviours. Counterexample-guided abstraction refinement examines such failures and refines an abstraction that is too coarse. The connection between the abstract model and the concrete system is therefore essential to interpreting the result.[5]

Deductive verification

Deductive verification turns the required properties into statements to be proved. Automated tools may discharge some obligations, while an interactive theorem prover allows a person to supply proof steps or guidance and have the reasoning checked mechanically. The balance between automation and expressiveness varies: a specialised decision procedure can settle a restricted class of questions, whereas a more expressive logic may require substantial human assistance. Libraries of established results can be reused across proofs, including the mathematics needed to verify numerical algorithms.[1]

Model checking and theorem proving need not be competing alternatives. They can be combined, for example by having a theorem prover justify the steps of a model-checking calculation. This adds a logical account of why the calculation establishes the claimed property, although the integration has its own computational costs.[5]

Verified implementations

Compiler verification addresses the gap between source code and the executable produced from it. CompCert's semantic-preservation theorem relates its formal source-language representation to its assembly-language output. Successful compilation preserves the allowed observable behaviour in the sense stated by the theorem; the compiler can select an allowed behaviour where the source permits alternatives. The theorem also allows compilation to fail rather than produce code. Its scope must be read precisely: the documented theorem starts after preprocessing, parsing, type checking and elaboration, and ends before assembling and linking. It is not a proof that an arbitrary source program meets its user's requirements.[6]

Operating-system verification provides another example. The seL4 project states functional-correctness results connecting the C implementation of verified kernel configurations to a formal specification. For configurations with binary correctness, the proof also connects machine code to that implementation. These are claims about identified configurations and properties, rather than every possible configuration or every application running above the kernel.[7]

Assumptions and limits

A proof does not eliminate the need to examine its foundations. A model can depend on assumptions about the processor, initialisation, low-level code or interactions with the surrounding system. The seL4 documentation, for example, explicitly identifies assumptions concerning hardware behaviour, handwritten assembly, hardware management and boot code. It also distinguishes information channels represented in the model from channels outside it, including timing effects.[2]

These boundaries explain why formal verification and other assurance work remain connected. The mathematical result establishes a relationship between formal objects; evidence is still needed that the relevant physical system behaves as those objects and assumptions describe. Explicitly recording that boundary makes the result usable and reviewable. It does not justify extending a proved property to omitted behaviours or to a changed system without examining the connection again.[2]

References

  1. ↑ 1.0 1.1 Portoraro, Frederic (2024-02-10). "4.4–4.5". Automated Reasoning. Stanford Encyclopedia of Philosophy. Retrieved 2026-10-16.
  2. ↑ 2.0 2.1 2.2 "What the Proofs Assume". seL4. Retrieved 2026-10-16.
  3. ↑ 3.0 3.1 "Hoare: Hoare Logic, Part I". Software Foundations: Programming Language Foundations. University of Pennsylvania. Retrieved 2026-10-16.
  4. ↑ Goranko, Valentin; Rumberg, Antje (2024-05-03). "Temporal Logic". Stanford Encyclopedia of Philosophy. Retrieved 2026-10-16.
  5. ↑ 5.0 5.1 Amjad, Hasan (September 2004). Combining model checking and theorem proving (PDF) (Report). University of Cambridge, Computer Laboratory. pp. 12–14, 53–55. doi:10.48456/tr-601. Retrieved 2026-10-16.
  6. ↑ "CompCert C: a trustworthy compiler". CompCert C User's Manual. Sections 1.2–1.3. Retrieved 2026-10-16.
  7. ↑ "seL4 Proofs". seL4. Retrieved 2026-10-16.