「‍」 Lingenic

Refinement Calculus

(⤓.md ◇.md); γ ≜ [2026-07-17T120407.600, 2026-07-17T135416.643] ∧ |γ| = 3

Refinement Calculus

Origin. Back and Morgan developed refinement calculus (1980s). Extends Dijkstra's weakest preconditions to program derivation. Programs derived by stepwise refinement from specifications. Specification statements as primitive. Foundation for B-Method and Event-B.

Models. Deriving programs from specifications. Specification: what the program should do (relation). Implementation: how it does it (executable code). Refinement: specification ⊑ implementation means implementation meets spec. Stepwise: refine in stages, preserving correctness.

Formalism.

Specification statement: w:[pre, post] "Assuming pre, establish post, modifying only w."

Refinement ordering: S ⊑ S' — S' refines S Meaning: every behavior of S' is allowed by S.

Weakest precondition: wp(S, Q) = weakest P such that {P} S {Q} S ⊑ S' iff ∀Q. wp(S, Q) ⇒ wp(S', Q)

Refinement laws:

  • Skip: w:[pre, pre] ⊑ skip
  • Assignment: w:[pre, post] ⊑ w := e if pre ⇒ post[e/w]
  • Sequence: S ⊑ S₁; S₂ if appropriate weakest preconditions
  • Conditional: S ⊑ if b then S₁ else S₂ if both branches refine
  • Loop: S ⊑ while b do S₁ with variant and invariant

Data refinement: Change data representation. Abstraction relation R links abstract and concrete states. Simulation: concrete simulates abstract via R.

Monotonicity: If S ⊑ S' then C[S] ⊑ C[S'] for any context C. Allows local refinement.

Symbols.

SymbolUnicodeNameMeaning
U+2291RefinesImplementation relation
w:[P,Q]SpecificationFrom P establish Q
wpWeakest preconditionDijkstra's wp
:=AssignmentDeterministic
:∈ChooseNondeterministic
U+2293MeetGreatest common refinement
U+2294JoinLeast common abstraction

Metatheory. Refinement is a preorder (reflexive, transitive). Programs form a complete lattice under refinement. Nondeterminism: more nondeterministic = less refined. Miracles (wp(S,false)=true): not implementable, but allow specification. Feasibility: specification is implementable if not miraculous.

Applies to. B-Method and Event-B (safety-critical systems). Correct-by-construction development. Protocol derivation. Concurrent program development (Action Systems). Security protocol refinement. Hardware derivation.

Limitations. Requires formal specification skills. Manual refinement steps need human creativity. Proof obligations can be complex. Tool support (Atelier B, Rodin) has learning curve. Doesn't directly handle real-time or probability. Refinement strategy is not algorithmic.

© 2026 Lingenic LLC