locus · bigraph tutorial · Chapter IV
How a behavioural equivalence is derived from reaction rules alone, why the derivation needs bigraphs whose nodes have identity, and a small example, two agents with one atom each in different places, which shows that a label must also say where the reaction happens. The last section, §7, carries the theory to bigraphs with links and back to the library's abstract bigraphs, where the source's hypothesis on rules turns out to be too weak. Every figure is computed from a Lean term and every result is kernel-checked.
Chapter II, Rules, Reactions and CCS, gave bigraphs reaction rules; Chapter III,
Mobile Processes, encoded the π-calculus with them. Both compared agents only by what
they can become. This chapter asks when two agents behave alike, in every context. Leifer
and Milner's answer is to read labels off the rules: a label for an agent a is a
context F just large enough that F ∘ a can react
[LM00, p. 1]. Bisimilarity on these labels is then a
congruence, provided enough relative pushouts exist. Jensen and Milner carry this over to
bigraphs, with one refinement: a label records the place at which the reaction occurs
[JM04, p. 30]. Their Example 6 shows why the place is
needed, and it is the example of this chapter.
How this chapter is made. As in the other chapters, no figure is drawn by hand. The
agents and contexts are concrete place graphs, terms of Bigraph/Concrete/Example6.lean.
lake exe bigraphdraw maps each one into the library's bigraphs by
PlG.toBg, reads it off with Bg.describe, and labels it with its Lean
source. Each node is labelled with its control and its identity: K₀ is node
0, with control K. Every block of Lean is cut from its source file by
name.
The theory is the library Bigraph/Concrete/: precategories, place
graphs with node identities, their relative pushouts, wide reactive systems and their
bisimilarity. It follows Jensen and Milner's report [JM04],
whose definitions it transcribes.
Numbering is separate for definitions, figures and theorems, and the generator checks every reference and every citation.
Take an agent a and a rule with redex r. A context L
is a label for a if some active context D makes
L ∘ a = D ∘ r: in L ∘ a there is a redex, and D is the
rest. Most such L are too large, and add material that plays no part in the
reaction. Leifer and Milner's idea is to keep only the squares that add nothing unnecessary.
The categorical form of "nothing unnecessary" is the relative pushout.
Definition 1 (Precategory). A category whose composition may be
undefined [JM04, Def 3.1]. Here composition is a relation:
Comp g f h says that g ∘ f is defined and equals h.
Composition with an identity is always defined, and the two ways of composing three arrows
are defined together and agree.
structure PreCat where
Obj : Type u
Hom : Obj → Obj → Type v
id : (a : Obj) → Hom a a
/-- `g ∘ f` is defined and is `h`. -/
Comp : {a b c : Obj} → Hom b c → Hom a b → Hom a c → Prop
comp_fun : ∀ {a b c : Obj} {g : Hom b c} {f : Hom a b} {h h' : Hom a c},
Comp g f h → Comp g f h' → h = h'
id_left : ∀ {a b : Obj} (f : Hom a b), Comp (id b) f f
id_right : ∀ {a b : Obj} (f : Hom a b), Comp f (id a) f
assoc : ∀ {a b c d : Obj} (f : Hom a b) (g : Hom b c) (h : Hom c d) (x : Hom a d),
(∃ gf, Comp g f gf ∧ Comp h gf x) ↔ (∃ hg, Comp h g hg ∧ Comp hg f x)
Definition 2 (Bound, RPO, IPO). A bound for a span
(f₀, f₁) is a cospan (g₀, g₁) with g₀ ∘ f₀ = g₁ ∘ f₁.
A relative pushout (RPO) of the span relative to a bound (g₀, g₁) is a smaller
bound (h₀, h₁) with an arrow h back to (g₀, g₁),
through which every other such bound factors uniquely
[JM04, Def 3.8]. A bound is an idem pushout (IPO) when it
is its own RPO, with h the identity
[JM04, Def 3.9].
def IsBound {H I₀ I₁ K : 𝒞.Obj} (f₀ : 𝒞.Hom H I₀) (f₁ : 𝒞.Hom H I₁)
(g₀ : 𝒞.Hom I₀ K) (g₁ : 𝒞.Hom I₁ K) : Prop :=
∃ x, 𝒞.Comp g₀ f₀ x ∧ 𝒞.Comp g₁ f₁ x
structure RelBound {H I₀ I₁ K : 𝒞.Obj} (f₀ : 𝒞.Hom H I₀) (f₁ : 𝒞.Hom H I₁)
(g₀ : 𝒞.Hom I₀ K) (g₁ : 𝒞.Hom I₁ K) where
obj : 𝒞.Obj
h₀ : 𝒞.Hom I₀ obj
h₁ : 𝒞.Hom I₁ obj
h : 𝒞.Hom obj K
bound : 𝒞.IsBound f₀ f₁ h₀ h₁
c₀ : 𝒞.Comp h h₀ g₀
c₁ : 𝒞.Comp h h₁ g₁
def IsRPO {H I₀ I₁ K : 𝒞.Obj} {f₀ : 𝒞.Hom H I₀} {f₁ : 𝒞.Hom H I₁}
{g₀ : 𝒞.Hom I₀ K} {g₁ : 𝒞.Hom I₁ K} (b : 𝒞.RelBound f₀ f₁ g₀ g₁) : Prop :=
∀ k : 𝒞.RelBound f₀ f₁ g₀ g₁, ∃ j, 𝒞.Mediates b k j ∧ ∀ j', 𝒞.Mediates b k j' → j' = j
def IsIPO {H I₀ I₁ J : 𝒞.Obj} (f₀ : 𝒞.Hom H I₀) (f₁ : 𝒞.Hom H I₁)
(h₀ : 𝒞.Hom I₀ J) (h₁ : 𝒞.Hom I₁ J) : Prop :=
∃ hb : 𝒞.IsBound f₀ f₁ h₀ h₁,
𝒞.IsRPO (⟨J, h₀, h₁, 𝒞.id J, hb, 𝒞.id_left h₀, 𝒞.id_left h₁⟩ : 𝒞.RelBound f₀ f₁ h₀ h₁)
A transition a —L▷ a' is then an IPO square L ∘ a = D ∘ r, with
a' the reactum D ∘ r'. The IPO makes L minimal: it adds
what the redex needs and no more.
The bigraphs of §1–§3 are abstract: two bigraphs that differ only in the
names of their nodes are the same bigraph. In that setting RPOs do not exist in general. Jensen
and Milner's Example 10 has a pair of abstract bigraphs with two candidate RPOs, one keeping
two K-nodes apart and one merging them. Abstract bigraphs cannot properly tell
these apart, and the pair has no RPO [JM04, p. 58]. Abstract bigraphs "do not cater for the
notion of occurrence of one bigraph in another"
[JM04, p. 18]. The remedy is to give nodes identity, and
to compose two bigraphs only when their nodes are disjoint. Concrete bigraphs then form a
precategory, not a category [JM04, p. 22].
Definition 3 (Concrete place graph). The nodes are natural numbers,
finitely many: ctrl v is the control of node v, or nothing.
prnt sends each site and node to a node or a root. The least bound on the nodes
is stored with the graph, and is determined by them, so two place graphs are equal exactly when
their controls and parent maps are
[JM04, Def 7.1]. Composition B ∘ A takes a
proof that A and B share no node.
structure PlG (m n : Nat) where
ctrl : Nat → Option Ctrl
prnt : Fin m ⊕ Nat → Nat ⊕ Fin n
/-- Finitely many nodes: none at or beyond `bound`… -/
bound : Nat
bound_spec : ∀ v, bound ≤ v → ctrl v = none
/-- …and `bound` is the least such, so it is determined by the nodes. -/
bound_tight : bound = 0 ∨ ctrl (bound - 1) ≠ none
/-- A non-node is its own parent. -/
junk : ∀ v, ctrl v = none → prnt (.inr v) = .inl v
/-- A site or node has a node or a root as its parent. -/
closed : ∀ (w : Fin m ⊕ Nat) (u : Nat), (∀ v, w = .inr v → ctrl v ≠ none) →
prnt w = .inl u → ctrl u ≠ none
/-- `prnt` is acyclic: a depth strictly decreases towards the roots. -/
acyclic : ∃ d : Nat → Nat, ∀ v u, ctrl v ≠ none → prnt (.inr v) = .inl u → d u < d v
/-- An atomic node is not a parent. -/
atomic : ∀ (w : Fin m ⊕ Nat) (u : Nat) (c : Ctrl), (∀ v, w = .inr v → ctrl v ≠ none) →
prnt w = .inl u → ctrl u = some c → S.atomic c = false
def Disjoint {m n n' p : Nat} (A : PlG S m n) (B : PlG S n' p) : Prop :=
∀ v, ¬ (A.IsNode v ∧ B.IsNode v)
Theorem 1 (Place graphs have RPOs). Whenever two place graphs with
a common domain have a bound, they have an RPO relative to it
[JM04, Thm 7.8]. The proof builds Jensen and Milner's
candidate [JM04, Construction 7.7]. Its roots are classes
of an equivalence generated by a decidable relation on a finite set, computed in Lean
without choice (Bigraph/Concrete/Classes.lean).
theorem plg_rpo {Ctrl : Type} {S : Sig Ctrl} {ℓ m₀ m₁ p : Nat} (A₀ : PlG S ℓ m₀)
(A₁ : PlG S ℓ m₁) (D₀ : PlG S m₀ p) (D₁ : PlG S m₁ p) (hD : (PLG S).IsBound A₀ A₁ D₀ D₁) :
∃ b : (PLG S).RelBound A₀ A₁ D₀ D₁, (PLG S).IsRPO b
Theorem 2 (IPO pasting). Two IPO squares side by side make an IPO
rectangle, given an RPO for the left-hand span
[JM04, Prop 3.10]. The source supposes that "the diagram
commutes", as Leifer and Milner do [LM00, p. 6]. In a
category that follows from the two squares. In a precategory it does not, because the
rectangle's composite need not be defined. The first Lean statement left the hypothesis out
and was refuted by a six-object countermodel in which every other hypothesis holds; the
statement proved carries it as hrc.
theorem ipo_paste {k m m₂ m' n' n : 𝒞.Obj} {a : 𝒞.Hom k m} {l : 𝒞.Hom k m'}
{C : 𝒞.Hom m m₂} {F' : 𝒞.Hom m n'} {F : 𝒞.Hom m₂ n} {D' : 𝒞.Hom m' n'} {E : 𝒞.Hom n' n}
{FC : 𝒞.Hom m n} {ED' : 𝒞.Hom m' n} {Ca : 𝒞.Hom k m₂}
(hFC : 𝒞.Comp F C FC) (hED : 𝒞.Comp E D' ED') (hCa : 𝒞.Comp C a Ca)
(hrc : 𝒞.IsBound Ca l F ED')
(P : 𝒞.RelBound a l FC ED') (hP : 𝒞.IsRPO P)
(hleft : 𝒞.IsIPO a l F' D') (hright : 𝒞.IsIPO C F' F E) :
𝒞.IsIPO Ca l F ED'
The refutation of the first statement:
theorem ipo_paste_needs_commuting : ¬ ∀ (𝒞 : PreCat.{0, 0}) {k m m₂ m' n' n : 𝒞.Obj}
{a : 𝒞.Hom k m} {l : 𝒞.Hom k m'}
{C : 𝒞.Hom m m₂} {F' : 𝒞.Hom m n'} {F : 𝒞.Hom m₂ n} {D' : 𝒞.Hom m' n'} {E : 𝒞.Hom n' n}
{FC : 𝒞.Hom m n} {ED' : 𝒞.Hom m' n} {Ca : 𝒞.Hom k m₂},
𝒞.Comp F C FC → 𝒞.Comp E D' ED' → 𝒞.Comp C a Ca →
∀ (P : 𝒞.RelBound a l FC ED'), 𝒞.IsRPO P →
𝒞.IsIPO a l F' D' → 𝒞.IsIPO C F' F E → 𝒞.IsIPO Ca l F ED'
A wide reactive system is a supported precategory whose arrows have a width map, sending each site to the root it lies in, and an activity map, saying at which sites reaction may happen; its ground rules are closed under renaming of nodes [JM04, Def 4.3]. Place graphs are one, for any set of ground rules closed under renaming.
Definition 4 (Active at a site). A place graph is active at a site when every node above the site has an active control [JM04, Def 7.3].
def ActiveAt {m n : Nat} (A : PlG S m n) (s : Fin m) : Prop :=
∀ v c, A.Above (.inl s) v → A.ctrl v = some c → S.passive c = false
Definition 5 (Transition).
a —L▷λ a' when some ground rule (r, r') and
some context D, active at every site, make L ∘ a = D ∘ r an IPO.
The location λ is the set of roots of L ∘ a that hold the redex, the
image of D's sites, and a' is D ∘ r' up to renaming
of nodes [JM04, Def 5.1]. These are the minimal
transitions, which Jensen and Milner call the standard transition system.
def Trans {I J : W.Obj} (a : W.Hom W.origin I) (L : W.Hom I J) (loc : Fin (W.width J) → Prop)
(a' : W.Hom W.origin J) : Prop :=
∃ (K : W.Obj) (r r' : W.Hom W.origin K) (D : W.Hom K J) (y : W.Hom W.origin J),
W.Rule r r' ∧ W.Active D ∧ W.IsIPO a r L D ∧ loc = (fun j => ∃ i, W.wid D i = j) ∧
W.Comp D r' y ∧ W.SuppEquiv a' y
Definition 6 (Wide bisimilarity). A bisimulation is a symmetric
relation on agents of one interface in which every transition
a —L▷λ a' is answered, whenever L ∘ b is
defined, by a transition b —L▷λ b' with the same label
and the same location, and a' related to b'
[JM04, Def 5.3].
def IsBisim (S : W.ARel) : Prop :=
(∀ {I : W.Obj} (a b : W.Hom W.origin I), S a b → S b a) ∧
∀ {I J : W.Obj} (a b : W.Hom W.origin I) (L : W.Hom I J) (loc : Fin (W.width J) → Prop)
(a' : W.Hom W.origin J), S a b → W.Trans a L loc a' → (∃ x, W.Comp L b x) →
∃ b', W.Trans b L loc b' ∧ S a' b'
def Bisim {I : W.Obj} (a b : W.Hom W.origin I) : Prop := ∃ S : W.ARel, W.IsBisim S ∧ S a b
Theorem 3 (Wide bisimilarity is a congruence). In a wide reactive
system with RPOs, if a₀ ∼ a₁ then C ∘ a₀ ∼ C ∘ a₁ for every
context C [JM04, Thm 5.5]. The proof is
theirs, along the lines of Leifer's [Lei01, Thm 3.9], as
they say [JM04, p. 32]: the pairs (C ∘ a₀, C ∘ a₁) form a bisimulation up to renaming of nodes. A
transition of C ∘ a₀ is split by an RPO into a transition of a₀ and
an IPO for C; a₁ answers the first, and IPO pasting
(Theorem 2) puts the answer back together. TR-580 does not define "with RPOs" separately;
here it is HasRPOs, every pair with a bound has an RPO relative to it.
def HasRPOs : Prop :=
∀ {H I₀ I₁ K : W.Obj} (f₀ : W.Hom H I₀) (f₁ : W.Hom H I₁) (g₀ : W.Hom I₀ K)
(g₁ : W.Hom I₁ K), W.IsBound f₀ f₁ g₀ g₁ → ∃ b : W.RelBound f₀ f₁ g₀ g₁, W.IsRPO b
theorem bisim_congr (hR : W.HasRPOs) {I J : W.Obj} {a₀ a₁ : W.Hom W.origin I}
(C : W.Hom I J) {x₀ x₁ : W.Hom W.origin J} (h : W.Bisim a₀ a₁) (h₀ : W.Comp C a₀ x₀)
(h₁ : W.Comp C a₁ x₁) : W.Bisim x₀ x₁
Theorem 4 (For place graphs). Theorem 1 supplies the RPOs, so wide bisimilarity of place-graph agents is a congruence, for every set of ground rules closed under renaming.
theorem plg_bisim_congr (R : {J : Nat} → PlG S 0 J → PlG S 0 J → Prop)
(hR : ∀ {J : Nat} {r r' : PlG S 0 J} (π σ : Perm), R r r' → R (r.tr π) (r'.tr σ))
{I J : Nat} {a₀ a₁ : PlG S 0 I} (C : PlG S I J) {x₀ x₁ : PlG S 0 J}
(h : (PLGW S R hR).Bisim a₀ a₁) (h₀ : (PLGW S R hR).Comp C a₀ x₀)
(h₁ : (PLGW S R hR).Comp C a₁ x₁) : (PLGW S R hR).Bisim x₀ x₁
Jensen and Milner's Example 6 has three controls, no ports and one rule
[JM04, p. 30]. K and L are
atomic. M is not atomic, and it is passive: nothing inside an M can
react. The rule turns a K into an L, in any active context.
Definition 7 (Example 6). The signature, and the rule as the set of
its ground instances: a K-atom becomes an L-atom, whatever their
node numbers. The set is closed under renaming of nodes, as a wide reactive system
requires.
def sig : Sig Ctl where
ar := fun _ => 0
atomic := fun
| .M => false
| _ => true
active := fun _ _ => false
def rule {J : Nat} (r r' : PlG sig 0 J) : Prop := ∃ v w, IsAtom r .K v ∧ IsAtom r' .L w
K₀ reacts to the atom L₀.The two agents have two regions each, one atom in each region. In a the
K is in region 0; in b it is in region 1.
def a : PlG sig 0 2 := pair .K .L def b : PlG sig 0 2 := pair .L .K
a = K ⊗ L and
b = L ⊗ K, each with two regions.Each agent can react without any help from a context, so its label is the identity. The
square is an IPO because a is already Da ∘ K₀ for a context
Da, and a K-atom can be cancelled on the right: a context is
determined by what it makes of the atom.
a = Da ∘ K₀. The context
Da has the L-node of a, and a site in region 0 where the
redex goes. Composition keeps the node numbers, so the redex's K₀ is
a's own.Theorem 5 (The same reaction, in different places). Both agents
turn their K into an L under the identity label: a in
region 0, b in region 1. Every identity-labelled transition of b is
in region 1.
theorem a_trans : W.Trans a (PlG.id 2) (fun (j : Fin 2) => j = 0) a₁
theorem b_trans : W.Trans b (PlG.id 2) (fun (j : Fin 2) => j = 1) b₁
theorem b_trans_loc (loc : Fin 2 → Prop) (b' : PlG sig 0 2)
(h : W.Trans b (PlG.id 2) loc b') : loc = fun j => j = 1
L is node 5, the number the instance of the rule chose.a₁ and b₁ are both
L ⊗ L.Theorem 6 (a and b are not bisimilar). The transition of
a in region 0 has no answer from b in region 0.
theorem a_not_bisim : ¬ W.Bisim a b := by rintro ⟨S, ⟨_, hS⟩, hab⟩ obtain ⟨b', hb, _⟩ := hS a b (PlG.id 2) _ a₁ hab a_trans ⟨b, W.id_left b⟩ have h01 : (0 : Fin 2) = 1 := (congrFun (b_trans_loc _ b' hb) 0).mp rfl exact nomatch congrArg Fin.val h01
Theorem 6 could look like pedantry: the two agents do the same thing, in places that
differ only in their number. The context C = M | id₁ shows that the place
matters. It wraps region 0 in a passive M and merges the two regions into
one.
def ctx : PlG sig 2 1 where
ctrl := fun u => if u = 2 then some .M else none
prnt := fun
| .inl s => if s.val = 0 then .inl 2 else .inr 0
| .inr u => if u = 2 then .inr 0 else .inl u
bound := 3
bound_spec := fun
| 0, h => absurd h (by decide)
| 1, h => absurd h (by decide)
| 2, h => absurd h (by decide)
| _ + 3, _ => rfl
bound_tight := .inr (fun h => nomatch h)
junk := fun
| 0, _ => rfl
| 1, _ => rfl
| 2, h => nomatch h
| _ + 3, _ => rfl
closed := fun
| .inl ⟨0, _⟩, _, _, h => by cases h; exact fun h => nomatch h
| .inl ⟨1, _⟩, _, _, h => nomatch h
| .inl ⟨_ + 2, hs⟩, _, _, _ => absurd hs (Nat.not_lt.mpr (Nat.le_add_left 2 _))
| .inr 0, _, hw, _ => (hw _ rfl rfl).elim
| .inr 1, _, hw, _ => (hw _ rfl rfl).elim
| .inr 2, _, _, h => nomatch h
| .inr (_ + 3), _, hw, _ => (hw _ rfl rfl).elim
acyclic := ⟨fun _ => 0, fun
| 0, _, hv, _ => (hv rfl).elim
| 1, _, hv, _ => (hv rfl).elim
| 2, _, _, h => nomatch h
| _ + 3, _, hv, _ => (hv rfl).elim⟩
atomic := fun
| .inl ⟨0, _⟩, _, _, _, h, hc => by cases h; cases hc; rfl
| .inl ⟨1, _⟩, _, _, _, h, _ => nomatch h
| .inl ⟨_ + 2, hs⟩, _, _, _, _, _ => absurd hs (Nat.not_lt.mpr (Nat.le_add_left 2 _))
| .inr 0, _, _, hw, _, _ => (hw _ rfl rfl).elim
| .inr 1, _, _, hw, _, _ => (hw _ rfl rfl).elim
| .inr 2, _, _, _, h, _ => nomatch h
| .inr (_ + 3), _, _, hw, _, _ => (hw _ rfl rfl).elim
C: site 0 inside the passive
M₂, site 1 beside it, in one region.C ∘ a and C ∘ b. In
C ∘ a the K is inside the M, where nothing can react; in
C ∘ b it is outside.Theorem 7 (One reacts, the other is stuck). C ∘ b
reacts under the identity label. C ∘ a has no identity-labelled transition at
all: its only K lies under the passive M, and the context of any
redex would have to be active there.
theorem ctx_b_trans : W.Trans cb (PlG.id 1) (fun (j : Fin 1) => j = 0) cb₁ theorem ctx_a_stuck (loc : Fin 1 → Prop) (y : PlG sig 0 1) : ¬ W.Trans ca (PlG.id 1) loc y
C ∘ a cannot do this.Theorem 8 (The context separates them). C ∘ a and
C ∘ b are not bisimilar. With Theorem 4 this gives Theorem 6 a second time,
from transitions of C ∘ a and C ∘ b only: were a ∼ b,
the congruence would give C ∘ a ∼ C ∘ b.
theorem ctx_not_bisim : ¬ W.Bisim ca cb := by rintro ⟨S, ⟨hsymm, hS⟩, h01⟩ obtain ⟨b', hb', _⟩ := hS cb ca (PlG.id 1) _ cb₁ (hsymm _ _ h01) ctx_b_trans ⟨ca, W.id_left ca⟩ exact ctx_a_stuck _ b' hb' theorem a_not_bisim_of_ctx : ¬ W.Bisim a b := fun h => ctx_not_bisim (plg_bisim_congr rule rule_tr ctx h ⟨disj_ca, rfl⟩ ⟨disj_cb, rfl⟩)
So the two facts agree, as the congruence says they must. Wide bisimilarity sees the
difference between a and b before any context is applied, because
the location of the transition records the region a context could later wrap.
Leifer and Milner's transitions carry no location
[LM00, p. 7]. Jensen and Milner state that, on such
transitions, a and b are bisimilar, written a ∼̇ b,
while C ∘ a and C ∘ b are not; so bisimilarity without locations is
not a congruence [JM04, p. 30]. The second half is proved
here, and so is the first.
def UTrans {I J : W.Obj} (a : W.Hom W.origin I) (L : W.Hom I J) (a' : W.Hom W.origin J) : Prop :=
∃ loc, W.Trans a L loc a'
def UBisim {I : W.Obj} (a b : W.Hom W.origin I) : Prop := ∃ S : W.ARel, W.IsUBisim S ∧ S a b
Theorem 9 (Without locations, bisimilarity is not a congruence).
Forgetting the location does not help C ∘ a, which has no identity-labelled
transition anywhere. And a and b are bisimilar on unlocated
transitions. The proof relates agents whose K-nodes sit directly in roots, the
same number in each, and classifies every IPO of such an agent with a redex. Both members of
each such pair have no barren root, so an IPO is a pushout followed by an iso, the case TR-580
singles out after its characterisation of place-graph IPOs
[JM04, p. 42]. If the redex's node is the agent's
K, the labels are the permutations of the regions; if it is fresh, they add a region
holding a K. Either way the other agent has a transition with the same label.
theorem ctx_not_ubisim : ¬ W.UBisim ca cb := by
rintro ⟨S, ⟨hsymm, hS⟩, h01⟩
obtain ⟨b', ⟨_, hb'⟩, _⟩ :=
hS cb ca (PlG.id 1) cb₁ (hsymm _ _ h01) ⟨_, ctx_b_trans⟩ ⟨ca, W.id_left ca⟩
exact ctx_a_stuck _ b' hb'
theorem ubisim_not_congr : W.UBisim a b ∧ ¬ W.UBisim ca cb :=
⟨a_ubisim_b, ctx_not_ubisim⟩
So far the bigraphs have had places only. Jensen and Milner build RPOs for link graphs the same way, and pair the two [JM04, Thm 8.9]. Here names, nodes and edges are all numbers, and nodes and edges come from one supply, so that the support of a link graph is a single set: two link graphs compose exactly when their supports are disjoint. A point (an inner name, or a port of a node) is linked to an edge or an outer name; a number that is not a point has no link.
Definition 8 (Concrete link graph). Its interfaces are finite sets of names, stored with their least bound so that two sets with the same members are equal [JM04, Def 8.1].
structure LiG (X Y : NSet) where ctrl : Nat → Option Ctrl edge : Nat → Bool link : Pt → Option Lk /-- Finitely many nodes and edges: none at or beyond `bound`… -/ bound : Nat bound_spec : ∀ v, bound ≤ v → ((ctrl v).isSome || edge v) = false /-- …and `bound` is the least such, so it is determined by them. -/ bound_tight : bound = 0 ∨ ((ctrl (bound - 1)).isSome || edge (bound - 1)) = true /-- One supply: no number is both a node and an edge. -/ node_edge : ∀ v, ctrl v ≠ none → edge v = false /-- An inner name is linked iff it is in `X`… -/ dom_name : ∀ x, (link (.name x)).isSome = X.mem x /-- …and a port iff it is one. -/ dom_port : ∀ v i, (link (.port v i)).isSome = portB S ctrl v i /-- A point is linked to an edge… -/ cod_edge : ∀ p e, link p = some (.edge e) → edge e = true /-- …or to a name in `Y`. -/ cod_name : ∀ p y, link p = some (.name y) → Y.mem y = true
Definition 9 (Concrete bigraph). A place graph and a link graph on the same nodes, with the same controls [JM04, Def 9.1]. With any ground rules closed under renaming, bigraphs form a wide reactive system, whose widths and activity are the place graph's.
structure Big (I J : Face) where /-- The place graph `G^P : m → n`. -/ P : PlG S I.width J.width /-- The link graph `G^L : X → Y`. -/ L : LiG S I.names J.names /-- The same nodes, with the same controls. -/ ctrl_eq : P.ctrl = L.ctrl
Theorem 10 (RPOs for links and for bigraphs). Link graphs have RPOs
[JM04, Thm 8.9]. The construction gives the legs the nodes
and edges of the other side outside the shared part, and the top the rest of the bound, just as
for place graphs; so a place-graph RPO and a link-graph RPO for the two halves of a bigraph pair
into an RPO of bigraphs [JM04, Cor 9.6]. By Theorem 3,
bisimilarity of bigraph agents is a congruence, for any ground rules
[JM04, Cor 12.4]. The source prints the interface of the
link-graph construction with the ports of the bound, P₃, where its proofs use the
edges, E₃; the edges are what is formalised.
theorem lig_rpo {Ctrl : Type} {S : Sig Ctrl} {W X₀ X₁ Z : NSet} (A₀ : LiG S W X₀)
(A₁ : LiG S W X₁) (D₀ : LiG S X₀ Z) (D₁ : LiG S X₁ Z) (hD : (LIG S).IsBound A₀ A₁ D₀ D₁) :
∃ b : (LIG S).RelBound A₀ A₁ D₀ D₁, (LIG S).IsRPO b
theorem big_rpo {I I₀ I₁ K : Face} (A₀ : Big S I I₀) (A₁ : Big S I I₁) (D₀ : Big S I₀ K)
(D₁ : Big S I₁ K) (hD : (BIG S).IsBound A₀ A₁ D₀ D₁) :
∃ b : (BIG S).RelBound A₀ A₁ D₀ D₁, (BIG S).IsRPO b
theorem big_bisim_congr (R : {J : Face} → Big S Face.origin J → Big S Face.origin J → Prop)
(hR : ∀ {J : Face} {r r' : Big S Face.origin J} (π σ : Perm), R r r' → R (r.tr π) (r'.tr σ))
{I J : Face} {a₀ a₁ : Big S Face.origin I} (C : Big S I J) {x₀ x₁ : Big S Face.origin J}
(h : (BIGW S R hR).Bisim a₀ a₁) (h₀ : (BIGW S R hR).Comp C a₀ x₀)
(h₁ : (BIGW S R hR).Comp C a₁ x₁) : (BIGW S R hR).Bisim x₀ x₁
The abstract bigraphs of the earlier chapters forget which number each node and edge has, and forget idle edges, edges that no point is linked to. They are the classes of lean-support equivalence [JM04, Def 9.12].
Definition 10 (Lean-support equivalence). Two bigraphs are equivalent when, after their idle edges are discarded, one is a renaming of the other.
def lean (A : Big S I J) : Big S I J := ⟨A.P, A.L.lean, A.ctrl_eq⟩ def LeanEquiv (A B : Big S I J) : Prop := ∃ π, A.lean.tr π = B.lean
Theorem 11 (Behaviour passes to abstract bigraphs). Suppose every redex is lean and has no idle names. Then lean-support equivalence respects the transitions: equivalent agents have equivalent transitions, with the same labels and locations. Hence two agents are bisimilar iff their abstract classes are, and bisimilarity of abstract classes is a congruence [JM04, Cor 12.6]. The proof is Jensen and Milner's: a quotient that respects the transitions reflects and preserves bisimilarity [JM04, Thm 5.7], and adding fresh idle edges to one side of an IPO and to the opposite leg gives an IPO again [JM04, Prop 9.11].
theorem lean_transfer
(hRl : ∀ {J} {r r' : Big S Face.origin J}, R r r' → r.IsLean ∧ r.NoIdleNames)
{I : Face} (a b : Big S Face.origin I) :
(BIGW S R hR).Bisim a b ↔
(BIGW S R hR).QBisim (leanCong R hR) ((BIGW S R hR).cls (leanCong R hR) a)
((BIGW S R hR).cls (leanCong R hR) b)
theorem lean_congr (R : {J : Face} → Big S Face.origin J → Big S Face.origin J → Prop)
(hR : ∀ {J : Face} {r r' : Big S Face.origin J} (π σ : Perm), R r r' → R (r.tr π) (r'.tr σ))
(hRl : ∀ {J} {r r' : Big S Face.origin J}, R r r' → r.IsLean ∧ r.NoIdleNames)
{I J : Face} {p q : (BIGW S R hR).Q (leanCong R hR) Face.origin I}
(G : (BIGW S R hR).Q (leanCong R hR) I J) {x y : (BIGW S R hR).Q (leanCong R hR) Face.origin J}
(h : (BIGW S R hR).QBisim (leanCong R hR) p q) (hx : (BIGW S R hR).QComp (leanCong R hR) G p x)
(hy : (BIGW S R hR).QComp (leanCong R hR) G q y) : (BIGW S R hR).QBisim (leanCong R hR) x y
The hypothesis is stronger than the source's. Jensen and Milner ask only that every redex be lean [JM04, p. 79]. That is not enough, and Milner's book asks more: a redex "must have no idle roots or names" [Mil08, p. 84]. The book makes the change without comment, and this chapter follows it. The reason is elision. An IPO may link an idle name of the redex to an edge of the agent [JM04, Construction 8.12], and if that edge is idle, the agent has a transition which the same agent without the edge lacks.
Theorem 12 (Lean redexes alone are not enough). Take two atomic
controls K and L with no ports, and the rule that turns a
K-atom into an L-atom under the outer face ⟨1, {0}⟩,
with the name 0 idle. Every redex is lean. Let b be a
K-node and a the same with one idle edge. The context that links the
name 0 to that edge makes a react under the identity label, and
b has no such transition, since it has no edge to link the name to. So
a and b are lean-support equivalent, and not bisimilar.
theorem redex_lean : ∀ {J : Face} {r r' : Big sig Face.origin J}, R r r' → r.IsLean
theorem leanEquiv_not_bisim : Big.LeanEquiv a b ∧ ¬ W.Bisim a b
Concrete bigraphs are not a second theory either. The library's abstract bigraphs, the type
Abstract of Chapter I, are exactly the classes of lean-support equivalence. A
concrete bigraph maps into the library, and its class there is abs. Two concrete
bigraphs with the same faces have the same class iff they are lean-support equivalent; the
class determines the faces, composition goes across, and every abstract bigraph is the class of
a concrete one. So Theorem 11 holds of the library's own type: bisimilarity on
Abstract, over the transitions the map induces
[JM04, Def 5.6], matches bisimilarity of concrete agents
and is a congruence.
Theorem 13 (Abstract bigraphs are the library's). The map's kernel,
and the transfer to Abstract, under the hypothesis of Theorem 11.
theorem abs_eq_iff {I J : Face} (A B : Big S I J) : A.abs = B.abs ↔ Big.LeanEquiv A B
theorem cor_12_6 (R : {J : Face} → Big S Face.origin J → Big S Face.origin J → Prop)
(hR : ∀ {J : Face} {r r' : Big S Face.origin J} (π σ : Perm), R r r' → R (r.tr π) (r'.tr σ))
(hRl : ∀ {J} {r r' : Big S Face.origin J}, R r r' → r.IsLean ∧ r.NoIdleNames)
{I : Face} (a b : Big S Face.origin I) :
(BIGW S R hR).Bisim a b ↔ WRS.RBisim (absRep R hR) a.abs b.abs
theorem cor_12_6_congr (R : {J : Face} → Big S Face.origin J → Big S Face.origin J → Prop)
(hR : ∀ {J : Face} {r r' : Big S Face.origin J} (π σ : Perm), R r r' → R (r.tr π) (r'.tr σ))
(hRl : ∀ {J} {r r' : Big S Face.origin J}, R r r' → r.IsLean ∧ r.NoIdleNames)
{p q G x y : Abstract S Nat} (h : WRS.RBisim (absRep R hR) p q)
(hx : Abstract.comp G p = some x) (hy : Abstract.comp G q = some y) :
WRS.RBisim (absRep R hR) x y
The place graphs of this chapter's figures are drawn through the place-graph half of the same map.
Theorem 14 (Composition of place graphs is preserved).
toPlace is the library's place graph of a concrete one, and toBg the
library's bigraph, with no edges, when the signature has no ports.
theorem toPlace_comp {m n p : Nat} (B : PlG S n p) (A : PlG S m n) (h : A.Disjoint B) :
Nonempty (PlaceGraph.Iso (B.comp A h).toPlace (PlaceGraph.comp B.toPlace A.toPlace))
def toBg {m n : Nat} (A : PlG S m n) (har : ∀ c, S.ar c = 0) :
Bg S (Iface.ofWidth m : Iface Nat) (Iface.ofWidth n) where
V := A.Node
E := Empty
finV := A.toPlace.fin
finE := PlaceGraph.emptyFin
ctrl := A.toPlace.ctrl
prnt := A.toPlace.prnt
link := fun
| .inl x => absurd x.property List.not_mem_nil
| .inr ⟨_, i⟩ => (Fin.cast (har _) i).elim0
acyclic := A.toPlace.acyclic
atomic_childless := A.toPlace.atomic_childless
PROVED means sorry-free in Lean, with the axioms checked: every result below rests on
propext and Quot.sound at most. REFUTED means a kernel-checked
countermodel. The gate LocusGate/Behaviour.lean fixes the congruence theorems,
Example 6, the transfer to Abstract and the refutation; it was watched failing with
the hypothesis of Theorem 11 cut to the source's.
| What | Where | Status |
|---|---|---|
| Precategories, bounds, RPOs, IPOs (Definitions 1, 2) | Concrete/PreCat | PROVED |
| Concrete place graphs with node identities form a precategory (Definition 3) | Concrete/Place | PROVED |
| Place graphs have RPOs (Theorem 1) | Concrete/PlaceRPO*, Concrete/Classes | PROVED |
| An RPO gives an IPO; IPO pasting and its converse, with the diagram commuting (Theorem 2) | Concrete/Paste | PROVED |
| IPO pasting with the commuting hypothesis left out (a first transcription; the source has the hypothesis) | Concrete/Paste | REFUTED |
| Supported precategories, renaming of nodes, IPOs preserved by renaming | Concrete/Support | PROVED |
| Wide reactive systems, transitions, wide bisimilarity; congruence (Theorem 3) | Concrete/Wide | PROVED |
| Place graphs as a wide reactive system; congruence for them (Theorem 4) | Concrete/PlaceWide | PROVED |
Example 6: the located transitions, a ≁ b, C ∘ a ≁ C ∘ b, and a ≁ b again by congruence (Theorems 5 to 8) | Concrete/Example6 | PROVED |
Example 6 without locations: C ∘ a ≁̇ C ∘ b | Concrete/Example6 | PROVED |
Example 6 without locations: a ∼̇ b, so that ∼̇ is not a congruence (Theorem 9) | Concrete/Example6Unloc | PROVED |
| Concrete link graphs and bigraphs (Definitions 8, 9); RPOs for link graphs and bigraphs; bisimilarity of bigraph agents a congruence (Theorem 10) | Concrete/Link*, Concrete/Big* | PROVED |
| With redexes lean and without idle names: lean-support equivalence respects the transitions; bisimilarity passes to abstract classes and is a congruence there (Theorem 11) | Concrete/BigRespect, Concrete/BigCongr, Concrete/Transfer | PROVED |
| The same with lean redexes only, as TR-580 states it (Theorem 12) | Concrete/IdleNameCounter | REFUTED |
The abstract classes are exactly the library's Abstract; Theorem 11 holds there (Theorem 13) | Concrete/BigBridge, Concrete/Cor126, LocusGate/Behaviour | PROVED |
| Concrete place graphs map into the library's, preserving composition (Theorem 14) | Concrete/Bridge | PROVED |
Binding bigraphs, with the scope rule repaired: RPOs, the congruence and the transfer to the quotient by ≎ | Concrete/Binding* | PROVED |
| The engaged transitions of TR-580 Part III and the adequacy theorem: REFUTED as stated, by Jensen's counterexample, and PROVED for linear rules, mechanising Jensen's and Milner's repair, in Chapter V | Concrete/AdequacyCounter, Concrete/AdequacyLinear | see Chapter V |
The quotations are checked against transcriptions of the sources in
docs/sources/.