Liking cljdoc? Tell your friends :D

RPO-Based Congruence Proofs

Formal proofs that structural congruence laws preserve bisimilarity using Relative Pushouts (RPOs).

Status: Design Documentation Last Updated: 2025-12-17


Overview

This document formalizes how each structural congruence law preserves behavioral equivalence (bisimilarity) using the Relative Pushout (RPO) framework from Wells & Stay's "Behavior in Higher-Order Languages". The key insight is that congruence laws can be proven sound by showing they preserve the LTS (Labeled Transition System) structure up to bisimulation.


Theoretical Foundation

RPO Framework (Definition 17, Behavior Paper)

The derived transition system computes transitions via IPOs (Idempotent Pushouts):

Γ ⊢ t⃗ →[c] d⟨⟨r⃗⟩⟩

where c is the minimal context (label) enabling the rewrite.

Bisimulation Preservation Theorem

Theorem: For each structural congruence law $P \equiv Q$, we prove:

  1. The transformation respects the RPO structure
  2. $P \approx Q$ (P and Q are bisimilar)
  3. For any context C, $C[P] \approx C[Q]$ (congruence property)

Proof Strategy: For each law, we:

  1. Define a bisimulation relation R containing (P, Q)
  2. Show R satisfies the bisimulation conditions
  3. Verify the law is transparent (Definition 14)

Law 1: Nil Identity

Statement: $P | 0 \equiv P$

Bisimulation Proof

Claim: For all processes P, $P | 0 \approx P$.

Bisimulation Relation:

R = {(P | 0, P) | P ∈ Proc} ∪ {(P, P) | P ∈ Proc}

Proof that R is a bisimulation:

Let $(P | 0, P) \in R$. We must show:

  1. If $P | 0 \to [\alpha ] Q'$, then $P \to [\alpha ] Q''$ for some Q'' with $(Q', Q'') \in R$
  2. If $P \to [\alpha ] Q''$, then $P | 0 \to [\alpha ] Q'$ for some Q' with $(Q', Q'') \in R$

Case 1: $P | 0 \to [\alpha ] Q'$

By the semantics of parallel composition, transitions from P | 0 arise from:

  • P's transitions: If $P \to [\alpha ] P'$, then $P | 0 \to [\alpha ] P' | 0$
  • Communication between P and 0: Impossible since 0 has no actions
  • 0's transitions: 0 has no transitions

So if $P | 0 \to [\alpha ] Q'$, then Q' = P' | 0 for some P' with $P \to [\alpha ] P'$. We have $(P' | 0, P') \in R$ by definition. ✓

Case 2: $P \to [\alpha ] P'$

Then $P | 0 \to [\alpha ] P' | 0$ by PAR-L rule. We have $(P' | 0, P') \in R$ by definition. ✓

Conclusion: R is a bisimulation, so $P | 0 \approx P. \blacksquare$

RPO Interpretation

The Nil identity law corresponds to a unit law in the RPO framework:

  • Nil (0) is the unit object for parallel composition
  • The IPO for P | 0 factors through P with identity contexts
  • No new transitions are introduced by the unit

Transparency

Nil identity is transparent (Definition 14) because:

  • Nil contributes no reactive contexts (no sends or receives)
  • For any non-reactive context C: C[P | 0] →[c̄] C' iff C[P] →[c̄] C'
  • The rule doesn't change observable behavior

Law 2: Commutativity

Statement: $P | Q \equiv Q | P$

Bisimulation Proof

Claim: For all processes P, Q: $P | Q \approx Q | P$.

Bisimulation Relation:

R = {(P | Q, Q | P) | P, Q ∈ Proc} ∪ Id

Proof that R is a bisimulation:

Let $(P | Q, Q | P) \in R$. We show the bisimulation conditions.

Transitions from P | Q:

  1. P-transition: If $P \to [\alpha ] P'$, then $P | Q \to [\alpha ] P' | Q$

    • Correspondingly: $Q | P \to [\alpha ] Q | P'$
    • We have $(P' | Q, Q | P') \in R$ ✓
  2. Q-transition: If $Q \to [\alpha ] Q'$, then $P | Q \to [\alpha ] P | Q'$

    • Correspondingly: $Q | P \to [\alpha ] Q' | P$
    • We have $(P | Q', Q' | P) \in R$ ✓
  3. Synchronization $(\tau )$: If P and Q can communicate:

    • $P \to [x̄\langle v\rangle] P'$ and Q →[x(v)] Q' gives $P | Q \to [\tau ] P' | Q'$
    • By symmetry: $Q | P \to [\tau ] Q' | P'$
    • We have $(P' | Q', Q' | P') \in R$ ✓

Conclusion: R is a bisimulation, so $P | Q \approx Q | P. \blacksquare$

RPO Interpretation

Commutativity corresponds to the symmetry of the tensor product in the RPO category:

  • The IPO construction is symmetric in its arguments
  • Labels derived from P | Q match those from Q | P
  • The derived LTS respects the symmetry

Termination Guard

To ensure termination when used as a simplification rule, apply the canonical ordering guard:

fn guard(&self, term: &Proc, _facts: &AnalysisFacts) -> bool {
    if let Proc::Par(p, q) = term {
        canonical_order(p) > canonical_order(q)
    } else {
        false
    }
}

This ensures the rule only fires in one direction, toward canonical form.


Law 3: Associativity

Statement: $(P | Q) | R \equiv P | (Q | R)$

Bisimulation Proof

Claim: For all processes P, Q, R: $(P | Q) | R \approx P | (Q | R)$.

Bisimulation Relation:

R = {((P | Q) | R, P | (Q | R)) | P, Q, R ∈ Proc} ∪ Id

Proof Sketch:

Transitions from (P | Q) | R arise from P, Q, or R independently, or from pairwise synchronizations. The same transitions exist for P | (Q | R):

From (P | Q) | RFrom P | (Q | R)Matching
$P \to [\alpha ] P'$ gives (P' | Q) | R$P \to [\alpha ] P'$ gives P' | (Q | R)
$Q \to [\alpha ] Q'$ gives (P | Q') | R$Q \to [\alpha ] Q'$ gives P | (Q' | R)
$R \to [\alpha ] R'$ gives (P | Q) | R'$R \to [\alpha ] R'$ gives P | (Q | R')
P,Q sync: τ-transitionP,Q sync: same τ-transition
P,R sync: τ-transitionP,R sync: same τ-transition
Q,R sync: τ-transitionQ,R sync: same τ-transition

Conclusion: R is a bisimulation, so $(P | Q) | R \approx P | (Q | R). \blacksquare$

RPO Interpretation

Associativity corresponds to the associativity of the tensor product:

  • The IPO construction associates naturally
  • Flattening (P | Q) | R to a list [P, Q, R] then rebuilding preserves semantics
  • The derived LTS has identical transition structure

Law 4: Scope Extrusion

Statement: $\text{new} x.(P | Q) \equiv (\text{new} x.P) | Q$ when $x \notin \text{FV}(Q)$

Bisimulation Proof

Claim: When $x \notin \text{FV}(Q)$: $\text{new} x.(P | Q) \approx (\text{new} x.P) | Q$.

Bisimulation Relation:

R = {(new x.(P | Q), (new x.P) | Q) | x ∉ FV(Q)} ∪ (bisimilarity closure)

Key Insight: Since $x \notin \text{FV}(Q)$, Q cannot interact with P on channel x. Therefore:

  • Bound outputs on x from P remain bound after extrusion
  • Free interactions of Q are unaffected by x's scope

Proof Sketch:

  1. P-transitions not involving x: Matched directly
  2. Q-transitions: Q's behavior is independent of x's scope
  3. Bound outputs on x: new x.P can still perform x̄(n) transitions
  4. Synchronization on x: Only possible between parts of P, preserved

Constraint: The free-variable check $x \notin \text{FV}(Q)$ is essential for soundness.

Counterexample without constraint: If $x \in \text{FV}(Q)$:

  • new x.(x!v | x?y.R) can synchronize internally (τ-transition)
  • (new x.x!v) | x?y.R exposes x in Q, changing behavior

Conclusion: With the constraint, R is a bisimulation. $\blacksquare$

RPO Interpretation

Scope extrusion relates to scope coherence in the RPO framework:

  • The IPO for bound names respects the independence condition
  • Labels involving x are unchanged when $x \notin$ FV(Q)
  • The pushout property ensures consistent scoping

Transparency

Scope extrusion is transparent when the constraint holds:

  • If $x \notin \text{FV}(Q)$, Q's contexts don't involve x
  • The transformation preserves the observable interface
  • No new transitions become possible

Law 5: Scope Fusion

Statement: $\text{new} x.\text{new} x.P \equiv \text{new} x.P$

Bisimulation Proof

Claim: $\text{new} x.\text{new} x.P \approx \text{new} x.P$.

Bisimulation Relation:

R = {(new x.new x.P, new x.P) | P ∈ Proc} ∪ Id

Proof Sketch:

The inner new x creates a fresh channel that shadows the outer new x. Since both bindings produce the same scoping effect (all occurrences of x in P are bound), the semantics are identical:

  1. Both produce bound outputs/inputs on a fresh channel
  2. No external interaction with x is possible in either case
  3. Internal synchronizations on x are preserved

Conclusion: R is a bisimulation, so $\text{new} x.\text{new} x.P \approx \text{new} x.P. \blacksquare$

Implementation Note

This law applies when the same variable name is used for nested scopes. With alpha-normalization, this pattern may not arise naturally, but it can appear from macro expansion or program transformation.


Law 6: Dead Scope Elimination

Statement: $\text{new} x.P \equiv P$ when $x \notin \text{FV}(P)$

Bisimulation Proof

Claim: When $x \notin \text{FV}(P)$: $\text{new} x.P \approx P$.

Bisimulation Relation:

R = {(new x.P, P) | x ∉ FV(P)} ∪ Id

Proof that R is a bisimulation:

Since $x \notin \text{FV}(P)$, P cannot perform any action involving x. Therefore:

  1. Any transition from P: $P \to [\alpha ] P'$

    • $\text{new} x.P \to [\alpha ] \text{new} x.P'$ (where $\alpha$ doesn't involve x, since $x \notin$ FV(P))
    • If $x \notin \text{FV}(P')$ (which follows from $x \notin \text{FV}(P)$), then $(\text{new} x.P', P') \in R$ ✓
  2. Any transition from new x.P: Must come from P

    • Since $x \notin$ FV(P), no bound outputs on x
    • All transitions of new x.P correspond directly to P's transitions

Conclusion: R is a bisimulation, so $\text{new} x.P \approx P$ when $x \notin \text{FV}(P). \blacksquare$

RPO Interpretation

Dead scope elimination corresponds to the unit law for scope:

  • An unused binding is semantically transparent
  • The IPO construction ignores unused channels
  • No labels involve x when $x \notin$ FV(P)

Summary: All Laws Preserve Bisimilarity

LawStatementConditionBisimilarity
Nil Identity$P \| 0 \equiv P$-✓ Proven
Commutativity$P \| Q \equiv Q \| P$-✓ Proven
Associativity$(P \| Q) \| R \equiv P \| (Q \| R)$-✓ Proven
Scope Extrusion$\text{new} x.(P \| Q) \equiv (\text{new} x.P) \| Q$$x \notin \text{FV}(Q)$✓ Proven
Scope Fusion$\text{new} x.\text{new} x.P \equiv \text{new} x.P$-✓ Proven
Dead Scope$\text{new} x.P \equiv P$$x \notin \text{FV}(P)$✓ Proven

Compositional Soundness

Theorem: Sequential Rule Application Preserves Bisimilarity

Statement: If $P_{0} \equiv P_{1} \equiv ... \equiv P_{n}$ by applying congruence laws, then $P_{0} \approx P_{n}$.

Proof: By induction on n.

Base case (n=0): $P_{0} \approx P_{0}$ by reflexivity.

Inductive case: Assume $P_{0} \approx P_{k}$. Since $P_{k} \equiv P_{k+1}$ by one congruence law, we have $P_{k} \approx P_{k+1}$ by the proofs above. By transitivity of bisimilarity, $P_{0} \approx P_{k+1}. \blacksquare$

Corollary: Simplification is Sound

If a program P is simplified to Q using only structural congruence laws (with their guards satisfied), then $P \approx Q$ - the simplified program is behaviorally equivalent to the original.


References

  1. Wells & Stay, "Behavior in Higher-Order Languages" - RPO framework, Definitions 14, 17, Theorems 20, 22
  2. Milner, "Communicating and Mobile Systems: the Pi-Calculus" - Structural congruence laws
  3. Sangiorgi & Walker, "The Pi-Calculus: A Theory of Mobile Processes" - Bisimulation theory

Related Documentation


Changelog

  • 2025-12-17: Initial RPO congruence proofs documentation

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close