Computer Science › Intelligence + Theory

Formal Methods

0 of 18
  1. Specifications: Preconditions, Postconditions, and Invariants

    A verifier cannot prove “the program is good” until “good” is written as predicates over the states before, after, and during execution. Preconditions, postconditions, and invariants turn informal intent into objects Hoare logic and model checking can manipulate.

    Read →6 sections13 min
  2. Logic for Specification: Propositional and First-Order

    Formal specifications are built from the connectives, predicates, and quantifiers introduced in Discrete Math and Logic. The new step is interpreting those formulas over program states, heaps, arrays, and traces.

    Read →6 sections12 min
  3. The Hoare Triple

    The Hoare triple `{P} C {Q}` is the central judgment of axiomatic program verification: if command C starts in a state satisfying P and terminates, it ends in a state satisfying Q. It separates specification from implementation while staying tied to operational semantics.

    Read →6 sections13 min
  4. Hoare Logic: Rules of Inference

    Hoare logic becomes useful because triples can be derived compositionally: assignment, sequencing, conditionals, loops, and consequence each have local rules. These rules let a proof follow the structure of the program instead of enumerating executions.

    Read →6 sections11 min
  5. Loop Invariants and the While Rule

    A loop invariant is the assertion that makes unbounded repetition finite enough to reason about. The while rule turns initialization, preservation, and exit reasoning into a proof for every number of iterations.

    Read →6 sections14 min
  6. Weakest Preconditions

    Weakest preconditions run a specification backward through code: given a desired postcondition, compute the least restrictive condition that must hold before the command. This turns proof search into calculational verification-condition generation.

    Read →6 sections10 min
  7. Total Correctness and Termination

    Total correctness strengthens partial correctness by also proving termination. Variants and ranking functions connect program loops to well-founded descent, while the Halting Problem explains why no automatic method can always find them.

    Read →6 sections11 min
  8. Boolean Satisfiability and the Cook-Levin Connection

    SAT asks whether a Boolean formula has any satisfying assignment, and Cook-Levin explains why that problem is a universal meeting point for efficient verification. Formal tools exploit SAT by reducing finite proof obligations and bounded executions to Boolean search.

    Read →6 sections11 min
  9. SMT Solvers and Decision Procedures

    SMT extends SAT with background theories such as integers, arrays, bit-vectors, and uninterpreted functions. Decision procedures make many verification conditions automatic while preserving the boundary between decidable fragments and general program behavior.

    Read →6 sections11 min
  10. Transition Systems and Kripke Structures

    Model checking begins by replacing a program or protocol with a finite graph of states and transitions. A Kripke structure adds atomic propositions to states so temporal-logic formulas can be evaluated over executions.

    Read →6 sections11 min
  11. Linear Temporal Logic (LTL)

    LTL describes properties of individual execution paths using operators such as □, ◇, ○, and 𝖴. It is the natural language for saying that bad things never happen and good things eventually happen along a run.

    Read →6 sections11 min
  12. CTL and Branching-Time Logic

    CTL adds explicit path quantifiers, separating what must hold on all possible futures from what may hold on at least one future. Branching time is especially useful when nondeterminism represents scheduling, environment choices, or underspecified components.

    Read →6 sections10 min
  13. Model Checking: Exhaustive State-Space Exploration

    Explicit-state model checking explores all reachable states of a finite model and reports either that a temporal property holds or that a counterexample trace exists. This is proof by exhaustive graph search, automated where the state space is finite enough.

    Read →6 sections10 min
  14. State-Space Explosion and Symbolic Model Checking

    State-space explosion is the central engineering obstacle in model checking: variables, components, and interleavings multiply reachable states. Symbolic model checking, abstraction, partial-order reduction, and BDDs attack that explosion by representing sets of states compactly.

    Read →6 sections13 min
  15. Theorem Proving and Proof Assistants

    Proof assistants turn mathematical proofs into checkable artifacts, often using the Curry-Howard correspondence between propositions and types. They complement automation by letting humans supply invariants, lemmas, and structure that solvers cannot discover reliably.

    Read →6 sections11 min
  16. The Limits of Verification

    Formal verification is limited not by lack of ambition but by precise theorems: the Halting Problem and Rice’s Theorem rule out a complete automatic verifier for nontrivial semantic properties of arbitrary programs. Sound tools remain valuable by making their assumptions and scope explicit.

    Read →6 sections12 min
  17. Capstone: Verifying a Small Program Two Ways

    The capstone verifies one small program both deductively and by finite-state exploration. Seeing the same requirement as a Hoare proof and as a model-checking property makes the tradeoff between symbolic reasoning and exhaustive search concrete.

    Read →6 sections13 min

Formal Methods

Part of the Computer Science curriculum.

Sort
1

Testing Shows the Presence of Bugs; Proof Shows Their Absence

Testing can find concrete failures, but formal verification asks for a mathematical argument that every behavior allowed by the model satisfies a specification. This frames the discipline by connecting software testing to logic and to the Halting Problem limits already proved in Computability and Complexity.

2

Specifications: Preconditions, Postconditions, and Invariants

A verifier cannot prove “the program is good” until “good” is written as predicates over the states before, after, and during execution. Preconditions, postconditions, and invariants turn informal intent into objects Hoare logic and model checking can manipulate.

3

Logic for Specification: Propositional and First-Order

Formal specifications are built from the connectives, predicates, and quantifiers introduced in Discrete Math and Logic. The new step is interpreting those formulas over program states, heaps, arrays, and traces.

4

The Hoare Triple

The Hoare triple `{P} C {Q}` is the central judgment of axiomatic program verification: if command C starts in a state satisfying P and terminates, it ends in a state satisfying Q. It separates specification from implementation while staying tied to operational semantics.

5

Hoare Logic: Rules of Inference

Hoare logic becomes useful because triples can be derived compositionally: assignment, sequencing, conditionals, loops, and consequence each have local rules. These rules let a proof follow the structure of the program instead of enumerating executions.

6

Loop Invariants and the While Rule

A loop invariant is the assertion that makes unbounded repetition finite enough to reason about. The while rule turns initialization, preservation, and exit reasoning into a proof for every number of iterations.

7

Weakest Preconditions

Weakest preconditions run a specification backward through code: given a desired postcondition, compute the least restrictive condition that must hold before the command. This turns proof search into calculational verification-condition generation.

8

Total Correctness and Termination

Total correctness strengthens partial correctness by also proving termination. Variants and ranking functions connect program loops to well-founded descent, while the Halting Problem explains why no automatic method can always find them.

9

Boolean Satisfiability and the Cook-Levin Connection

SAT asks whether a Boolean formula has any satisfying assignment, and Cook-Levin explains why that problem is a universal meeting point for efficient verification. Formal tools exploit SAT by reducing finite proof obligations and bounded executions to Boolean search.

10

SMT Solvers and Decision Procedures

SMT extends SAT with background theories such as integers, arrays, bit-vectors, and uninterpreted functions. Decision procedures make many verification conditions automatic while preserving the boundary between decidable fragments and general program behavior.

11

Transition Systems and Kripke Structures

Model checking begins by replacing a program or protocol with a finite graph of states and transitions. A Kripke structure adds atomic propositions to states so temporal-logic formulas can be evaluated over executions.

12

Linear Temporal Logic (LTL)

LTL describes properties of individual execution paths using operators such as □, ◇, ○, and 𝖴. It is the natural language for saying that bad things never happen and good things eventually happen along a run.

13

CTL and Branching-Time Logic

CTL adds explicit path quantifiers, separating what must hold on all possible futures from what may hold on at least one future. Branching time is especially useful when nondeterminism represents scheduling, environment choices, or underspecified components.

14

Model Checking: Exhaustive State-Space Exploration

Explicit-state model checking explores all reachable states of a finite model and reports either that a temporal property holds or that a counterexample trace exists. This is proof by exhaustive graph search, automated where the state space is finite enough.

15

State-Space Explosion and Symbolic Model Checking

State-space explosion is the central engineering obstacle in model checking: variables, components, and interleavings multiply reachable states. Symbolic model checking, abstraction, partial-order reduction, and BDDs attack that explosion by representing sets of states compactly.

16

Theorem Proving and Proof Assistants

Proof assistants turn mathematical proofs into checkable artifacts, often using the Curry-Howard correspondence between propositions and types. They complement automation by letting humans supply invariants, lemmas, and structure that solvers cannot discover reliably.

17

The Limits of Verification

Formal verification is limited not by lack of ambition but by precise theorems: the Halting Problem and Rice’s Theorem rule out a complete automatic verifier for nontrivial semantic properties of arbitrary programs. Sound tools remain valuable by making their assumptions and scope explicit.

18

Capstone: Verifying a Small Program Two Ways

The capstone verifies one small program both deductively and by finite-state exploration. Seeing the same requirement as a Hoare proof and as a model-checking property makes the tradeoff between symbolic reasoning and exhaustive search concrete.