An Algebraic Definition of Simulation Between Programs

Robin MilnerIJCAI 1971

In this seminal 1971 paper, Robin Milner addresses a fundamental question in computer science: how can we formally prove that two different programs are "doing the same thing"? Milner introduces the algebraic concept of simulation, providing a mathematical bridge between a concrete program and the abstract algorithm it implements.

The Problem: Defining the "Algorithm"

In the early 1970s, the field lacked a formal way to prove that two programs—perhaps one using a while loop and another using recursion—were functionally equivalent. Programs often contain "unimportant" details like auxiliary variables or specific memory management that don't change the core logic. Milner sought a mathematical relation to "abstract away" these details, allowing one to say: "Program A simulates Program B if every important step B takes is mirrored by A," even if A takes several smaller steps to achieve the same state.

Methods: An Algebraic Framework

Milner models a program as a quadruple $(D_{in}, D_{comp}, D_{out}, F)$, where $D$ represents domains (input, computation, and output) and $F$ is a transition function moving the program between states.

The algebraic definition of simulation, showing the relationship between input/output domains of two programs.

Key components of this framework include:

  • Weak Simulation: A relation $R$ between the states of two programs. If Program A is in a state related to Program B, and Program B takes a step, Program A must be able to reach a state that restores the relation. This acts as a weak homomorphism between algebraic structures.
  • Strong Simulation: A more rigid, reflexive, and transitive relation (a quasi-ordering). When two programs simulate each other strongly, they belong to the same equivalence class.
  • Cycle-Breaking Sets: To handle complex flowcharts, Milner identifies a subset of "important" nodes so that every loop passes through at least one. This simplifies the transition function $F$ for formal proofs.

Key Insights and Results

Milner’s most profound suggestion is that an algorithm is not a specific piece of code, but rather an equivalence class of programs under the mutual simulation relation. This allows for "Factoring Correctness": instead of proving a complex, optimized program correct, a developer can prove a simpler, "natural" version correct and then prove that the optimized version simulates the simple one.

Flowcharts of two programs (a and a') with dashed lines representing the simulation relations between their respective nodes.

Theorem 5.1 (The Weak Simulation Theorem)

Milner provides the necessary and sufficient conditions for a simulation to exist based on computation sequences. He demonstrates this using detailed flowchart examples, such as comparing programs with different loop structures or different data representations (e.g., direct string manipulation vs. integer-indexed arrays).

Limitations and Future Work

While groundbreaking, Milner acknowledges several boundaries to this framework:

  • Decidability: For programs handling complex data like integers, determining if a simulation relation exists is undecidable, requiring human-guided proofs.
  • Determinism: The paper focuses on deterministic programs. Milner notes that real-world applications often involve non-determinism and parallelism, which would require comparing "computation trees" rather than linear sequences.
  • Termination: The framework primarily deals with partial functions, suggesting that further refinement is needed to handle program termination more elegantly within the algebraic definition.

Summary updated

BibTeX
@inproceedings{milner1971algebraic,
  author = {Robin Milner},
  title = {{An Algebraic Definition of Simulation Between Programs}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {1971},
}
Figure