Finite-state CCS agents
DefinitionSum of prefixes#✓fully proved
For a list \(l\) of pairs \((a, q)\) of a label and a process, the process that chooses among the prefixes \(a.q\) listed in \(l\): the empty list gives the inactive process \(\mathbf{0}\), and the list with head \((a, q)\) and tail \(r\) gives the choice \(a.q + P\) between the prefix \(a.q\) and the process \(P\) built in the same way from \(r\).
def sumOf : List (Label Name × Process Name Constant) → Process Name Constant
| [] => .nil
| (a, q) :: rest => .choice (.prefix a q) (sumOf rest)
inductive Label (Name : Type*) where
| tau
| input (name : Name)
| output (name : Name)
deriving DecidableEq
CSLibExt/Languages/CCS/Parallel.lean:39
inductive Process (Name Constant : Type*) where
| nil
| constant (name : Constant)
| prefix (action : Label Name) (continuation : Process Name Constant)
| choice (left right : Process Name Constant)
| parallel (left right : Process Name Constant)
| restriction (blocked : List Name) (process : Process Name Constant)
| relabelling (rename : Relabelling Name) (process : Process Name Constant)
deriving DecidableEq
CSLibExt/Languages/CCS/Recursion.lean:45
Uses 2 · Used by 5
TheoremTransitions of a sum of prefixes#✓fully proved
For every recursive specification, every list \(l\) of pairs of a label and a process, every label \(a\) and every process \(q\), the sum of the prefixes listed in \(l\) has a transition labelled \(a\) to \(q\) exactly when \((a, q)\) belongs to \(l\).
theorem step_sumOf_iff {spec : Specification Name Constant}
(l : List (Label Name × Process Name Constant)) (a : Label Name)
(q : Process Name Constant) :
Process.Step spec (sumOf l) a q ↔ (a, q) ∈ l
abbrev Specification (Name Constant : Type*) := Constant → Process Name Constant
CSLibExt/Languages/CCS/Recursion.lean:56
inductive Label (Name : Type*) where
| tau
| input (name : Name)
| output (name : Name)
deriving DecidableEq
CSLibExt/Languages/CCS/Parallel.lean:39
inductive Process (Name Constant : Type*) where
| nil
| constant (name : Constant)
| prefix (action : Label Name) (continuation : Process Name Constant)
| choice (left right : Process Name Constant)
| parallel (left right : Process Name Constant)
| restriction (blocked : List Name) (process : Process Name Constant)
| relabelling (rename : Relabelling Name) (process : Process Name Constant)
deriving DecidableEq
CSLibExt/Languages/CCS/Recursion.lean:45
inductive Step (specification : Specification Name Constant) :
Process Name Constant → Label Name → Process Name Constant → Prop
| unfold {constant action next}
(step : Step specification (specification constant) action next) :
Step specification (.constant constant) action next
| prefix (action) (continuation) :
Step specification (.prefix action continuation) action continuation
| choiceLeft {left right action next}
(step : Step specification left action next) :
Step specification (.choice left right) action next
| choiceRight {left right action next}
(step : Step specification right action next) :
⋯
CSLibExt/Languages/CCS/Recursion.lean:63
def sumOf : List (Label Name × Process Name Constant) → Process Name Constant
| [] => .nil
| (a, q) :: rest => .choice (.prefix a q) (sumOf rest)
CSLibExt/Algorithms/CCS/FiniteState.lean:58
Uses 9 · Used by 1
DefinitionRealization of a code-level transition system#✓fully proved
Fix a recursive specification. A family of processes \(P_x\) indexed by codes \(x\) realizes a function \(s\) that lists, for each code \(x\), labelled transitions \((a, y)\) with \(a\) a label and \(y\) a code, when for every code \(x\), every label \(a\) and every process \(q\), the process \(P_x\) has a transition with label \(a\) to \(q\) exactly when \(s(x)\) contains an entry \((a, y)\) with \(P_y = q\).
def Realizes (spec : Specification Name Constant) {α : Type*}
(realize : α → Process Name Constant) (steps : α → List (Label Name × α)) : Prop :=
∀ x a q, Process.Step spec (realize x) a q ↔ ∃ y, (a, y) ∈ steps x ∧ realize y = q
abbrev Specification (Name Constant : Type*) := Constant → Process Name Constant
CSLibExt/Languages/CCS/Recursion.lean:56
inductive Process (Name Constant : Type*) where
| nil
| constant (name : Constant)
| prefix (action : Label Name) (continuation : Process Name Constant)
| choice (left right : Process Name Constant)
| parallel (left right : Process Name Constant)
| restriction (blocked : List Name) (process : Process Name Constant)
| relabelling (rename : Relabelling Name) (process : Process Name Constant)
deriving DecidableEq
CSLibExt/Languages/CCS/Recursion.lean:45
inductive Label (Name : Type*) where
| tau
| input (name : Name)
| output (name : Name)
deriving DecidableEq
CSLibExt/Languages/CCS/Parallel.lean:39
inductive Step (specification : Specification Name Constant) :
Process Name Constant → Label Name → Process Name Constant → Prop
| unfold {constant action next}
(step : Step specification (specification constant) action next) :
Step specification (.constant constant) action next
| prefix (action) (continuation) :
Step specification (.prefix action continuation) action continuation
| choiceLeft {left right action next}
(step : Step specification left action next) :
Step specification (.choice left right) action next
| choiceRight {left right action next}
(step : Step specification right action next) :
⋯
CSLibExt/Languages/CCS/Recursion.lean:63
Uses 4 · Used by 16
TheoremConstants listing their transitions realize them#✓fully proved
Fix a recursive specification, a map \(\iota\) from codes to process constants and a function \(s\) listing labelled transitions for each code. Suppose that for every code \(x\), writing \((a_1, y_1), \dots, (a_n, y_n)\) for the entries of \(s(x)\) in order, the body of the constant \(\iota(x)\) is \(a_1.\iota(y_1) + (a_2.\iota(y_2) + \dots + (a_n.\iota(y_n) + 0))\), which is \(0\) when \(n = 0\). Then the processes \(\iota(x)\), indexed by codes \(x\), realize \(s\).
theorem Realizes.constant {α : Type*} (inj : α → Constant)
(steps : α → List (Label Name × α))
(hspec : ∀ x, spec (inj x) =
sumOf ((steps x).map fun y => (y.1, Process.constant (inj y.2)))) :
Realizes spec (fun x => Process.constant (inj x)) steps
inductive Label (Name : Type*) where
| tau
| input (name : Name)
| output (name : Name)
deriving DecidableEq
CSLibExt/Languages/CCS/Parallel.lean:39
def sumOf : List (Label Name × Process Name Constant) → Process Name Constant
| [] => .nil
| (a, q) :: rest => .choice (.prefix a q) (sumOf rest)
CSLibExt/Algorithms/CCS/FiniteState.lean:58
inductive Process where
| nil
| prefix (action : Action) (continuation : Process)
| choice (left right : Process)
| parallel (left right : Process)
deriving DecidableEq
CSLibExt/Languages/CCS/Choice.lean:38
def Realizes (spec : Specification Name Constant) {α : Type*}
(realize : α → Process Name Constant) (steps : α → List (Label Name × α)) : Prop :=
∀ x a q, Process.Step spec (realize x) a q ↔ ∃ y, (a, y) ∈ steps x ∧ realize y = q
CSLibExt/Algorithms/CCS/FiniteState.lean:76
Uses 11 · Used by 11
DefinitionCode-level parallel composition#✓fully proved
Given functions \(s\) and \(t\) listing the labelled transitions of codes \(x\) and \(y\), the transitions of the pair \((x, y)\) are listed in three blocks: \((a, (x', y))\) for each entry \((a, x')\) of \(s(x)\); then \((a, (x, y'))\) for each entry \((a, y')\) of \(t(y)\); then \((\tau, (x', y'))\) for each entry \((a, x')\) of \(s(x)\) and each entry \((b, y')\) of \(t(y)\) whose labels are complementary, that is, one is the input and the other the output on the same name.
def parSteps {α β : Type*} (s : α → List (Label Name × α)) (t : β → List (Label Name × β))
(z : α × β) : List (Label Name × (α × β)) :=
(s z.1).map (fun y => (y.1, (y.2, z.2))) ++ (t z.2).map (fun w => (w.1, (z.1, w.2))) ++
(s z.1).flatMap fun y =>
(t z.2).filterMap fun w => (Label.synchronize y.1 w.1).map fun c => (c, (y.2, w.2))
inductive Label (Name : Type*) where
| tau
| input (name : Name)
| output (name : Name)
deriving DecidableEq
CSLibExt/Languages/CCS/Parallel.lean:39
def synchronize [DecidableEq Name] : Label Name → Label Name → Option (Label Name)
| .input left, .output right => if left = right then some .tau else none
| .output left, .input right => if left = right then some .tau else none
| _, _ => none
CSLibExt/Languages/CCS/Parallel.lean:74
Uses 2 · Used by 13
TheoremParallel composition preserves realization#✓fully proved
Fix a recursive specification. If the processes \(P_x\) realize \(s\) and the processes \(Q_y\) realize \(t\), then the parallel compositions \(P_x \mid Q_y\), indexed by pairs \((x, y)\), realize the code-level parallel composition of \(s\) and \(t\).
theorem Realizes.parallel {α β : Type*} {f : α → Process Name Constant}
{g : β → Process Name Constant} {s : α → List (Label Name × α)}
{t : β → List (Label Name × β)} (hf : Realizes spec f s) (hg : Realizes spec g t) :
Realizes spec (fun z => .parallel (f z.1) (g z.2)) (parSteps s t)
inductive Process (Name Constant : Type*) where
| nil
| constant (name : Constant)
| prefix (action : Label Name) (continuation : Process Name Constant)
| choice (left right : Process Name Constant)
| parallel (left right : Process Name Constant)
| restriction (blocked : List Name) (process : Process Name Constant)
| relabelling (rename : Relabelling Name) (process : Process Name Constant)
deriving DecidableEq
CSLibExt/Languages/CCS/Recursion.lean:45
inductive Label (Name : Type*) where
| tau
| input (name : Name)
| output (name : Name)
deriving DecidableEq
CSLibExt/Languages/CCS/Parallel.lean:39
def Realizes (spec : Specification Name Constant) {α : Type*}
(realize : α → Process Name Constant) (steps : α → List (Label Name × α)) : Prop :=
∀ x a q, Process.Step spec (realize x) a q ↔ ∃ y, (a, y) ∈ steps x ∧ realize y = q
CSLibExt/Algorithms/CCS/FiniteState.lean:76
def parSteps {α β : Type*} (s : α → List (Label Name × α)) (t : β → List (Label Name × β))
(z : α × β) : List (Label Name × (α × β)) :=
(s z.1).map (fun y => (y.1, (y.2, z.2))) ++ (t z.2).map (fun w => (w.1, (z.1, w.2))) ++
(s z.1).flatMap fun y =>
(t z.2).filterMap fun w => (Label.synchronize y.1 w.1).map fun c => (c, (y.2, w.2))
CSLibExt/Algorithms/CCS/FiniteState.lean:99
Uses 11 · Used by 8
DefinitionBoolean restriction test#✓fully proved
For a list \(L\) of blocked names, the test returns true on a label exactly when the label is the silent action \(\tau\), or an input or an output on a name that does not occur in \(L\). It is the Boolean form of the condition that restriction by \(L\) allows the label.
def allowedB (blocked : List Name) : Label Name → Bool
| .tau => true
| .input n => !blocked.contains n
| .output n => !blocked.contains n
inductive Label (Name : Type*) where
| tau
| input (name : Name)
| output (name : Name)
deriving DecidableEq
CSLibExt/Languages/CCS/Parallel.lean:39
Uses 1 · Used by 2
DefinitionCode-level restriction#✓fully proved
For a list \(L\) of blocked names and a function \(s\) listing the labelled transitions of each code, the restricted transitions of a code \(x\) are the entries \((a, y)\) of \(s(x)\), in order, whose label \(a\) is the silent action \(\tau\) or an input or an output on a name that does not occur in \(L\).
def restrictSteps {α : Type*} (blocked : List Name) (s : α → List (Label Name × α)) (x : α) :
List (Label Name × α) :=
(s x).filter fun y => allowedB blocked y.1
inductive Label (Name : Type*) where
| tau
| input (name : Name)
| output (name : Name)
deriving DecidableEq
CSLibExt/Languages/CCS/Parallel.lean:39
def allowedB (blocked : List Name) : Label Name → Bool
| .tau => true
| .input n => !blocked.contains n
| .output n => !blocked.contains n
CSLibExt/Algorithms/CCS/FiniteState.lean:129
Uses 2 · Used by 5
TheoremRestriction preserves realization#✓fully proved
Fix a recursive specification and a list \(L\) of blocked names. If the processes \(P_x\) realize \(s\), then the restricted processes \(P_x \setminus L\) realize the code-level restriction of \(s\) by \(L\).
theorem Realizes.restriction {α : Type*} {f : α → Process Name Constant}
{s : α → List (Label Name × α)} (blocked : List Name) (hf : Realizes spec f s) :
Realizes spec (fun x => .restriction blocked (f x)) (restrictSteps blocked s)
inductive Process (Name Constant : Type*) where
| nil
| constant (name : Constant)
| prefix (action : Label Name) (continuation : Process Name Constant)
| choice (left right : Process Name Constant)
| parallel (left right : Process Name Constant)
| restriction (blocked : List Name) (process : Process Name Constant)
| relabelling (rename : Relabelling Name) (process : Process Name Constant)
deriving DecidableEq
CSLibExt/Languages/CCS/Recursion.lean:45
inductive Label (Name : Type*) where
| tau
| input (name : Name)
| output (name : Name)
deriving DecidableEq
CSLibExt/Languages/CCS/Parallel.lean:39
def Realizes (spec : Specification Name Constant) {α : Type*}
(realize : α → Process Name Constant) (steps : α → List (Label Name × α)) : Prop :=
∀ x a q, Process.Step spec (realize x) a q ↔ ∃ y, (a, y) ∈ steps x ∧ realize y = q
CSLibExt/Algorithms/CCS/FiniteState.lean:76
def restrictSteps {α : Type*} (blocked : List Name) (s : α → List (Label Name × α)) (x : α) :
List (Label Name × α) :=
(s x).filter fun y => allowedB blocked y.1
CSLibExt/Algorithms/CCS/FiniteState.lean:139
Uses 11 · Used by 8
DefinitionForward certificate check#✓fully proved
Let \(s\) list the labelled transitions \((a, x')\) of each implementation code \(x\), let \(t\) list those of each specification code \(y\), and let \(R\) be a finite list of code pairs. The forward check succeeds when for every pair \((x, y)\) in \(R\) and every entry \((a, x')\) of \(s(x)\), either \(a = \tau\) and \((x', y)\) is in \(R\), or some entry \((a, y')\) of \(t(y)\) with the same label has \((x', y')\) in \(R\).
def forwardCheck (s : α → List (Label Name × α)) (t : β → List (Label Name × β))
(rel : List (α × β)) : Bool :=
rel.all fun p => (s p.1).all fun step =>
(step.1 == .tau && rel.contains (step.2, p.2)) ||
(t p.2).any fun spec => spec.1 == step.1 && rel.contains (step.2, spec.2)
inductive Label (Name : Type*) where
| tau
| input (name : Name)
| output (name : Name)
deriving DecidableEq
CSLibExt/Languages/CCS/Parallel.lean:39
Uses 1 · Used by 2
DefinitionBackward certificate check#✓fully proved
Let \(s\) list the labelled transitions \((a, x')\) of each implementation code \(x\), let \(t\) list those of each specification code \(y\), and let \(R\) be a finite list of code pairs. The backward check succeeds when for every pair \((x, y)\) in \(R\) and every entry \((a, y')\) of \(t(y)\), at least one of the following holds: \(a = \tau\) and \((x, y')\) is in \(R\); some entry \((a, x')\) of \(s(x)\) with the same label has \((x', y')\) in \(R\); or some entry \((\tau, x'')\) of \(s(x)\) has \((x'', y)\) in \(R\), and the first occurrence of \((x'', y)\) in \(R\) comes strictly before the first occurrence of \((x, y)\).
def backwardCheck (s : α → List (Label Name × α)) (t : β → List (Label Name × β))
(rel : List (α × β)) : Bool :=
rel.all fun p => (t p.2).all fun spec =>
(spec.1 == .tau && rel.contains (p.1, spec.2)) ||
((s p.1).any fun step => step.1 == spec.1 && rel.contains (step.2, spec.2)) ||
(s p.1).any fun step =>
step.1 == .tau && rel.contains (step.2, p.2) && rel.idxOf (step.2, p.2) < rel.idxOf p
inductive Label (Name : Type*) where
| tau
| input (name : Name)
| output (name : Name)
deriving DecidableEq
CSLibExt/Languages/CCS/Parallel.lean:39
Uses 1 · Used by 2
DefinitionWeak-bisimulation certificate check#✓fully proved
For transition lists \(s\) of implementation codes and \(t\) of specification codes and a finite list \(R\) of code pairs, the certificate check succeeds when both the forward check and the backward check succeed on \(s\), \(t\) and \(R\).
def certCheck (s : α → List (Label Name × α)) (t : β → List (Label Name × β))
(rel : List (α × β)) : Bool :=
forwardCheck s t rel && backwardCheck s t rel
inductive Label (Name : Type*) where
| tau
| input (name : Name)
| output (name : Name)
deriving DecidableEq
CSLibExt/Languages/CCS/Parallel.lean:39
def forwardCheck (s : α → List (Label Name × α)) (t : β → List (Label Name × β))
(rel : List (α × β)) : Bool :=
rel.all fun p => (s p.1).all fun step =>
(step.1 == .tau && rel.contains (step.2, p.2)) ||
(t p.2).any fun spec => spec.1 == step.1 && rel.contains (step.2, spec.2)
CSLibExt/Algorithms/CCS/FiniteState.lean:164
def backwardCheck (s : α → List (Label Name × α)) (t : β → List (Label Name × β))
(rel : List (α × β)) : Bool :=
rel.all fun p => (t p.2).all fun spec =>
(spec.1 == .tau && rel.contains (p.1, spec.2)) ||
((s p.1).any fun step => step.1 == spec.1 && rel.contains (step.2, spec.2)) ||
(s p.1).any fun step =>
step.1 == .tau && rel.contains (step.2, p.2) && rel.idxOf (step.2, p.2) < rel.idxOf p
CSLibExt/Algorithms/CCS/FiniteState.lean:174
Uses 3 · Used by 8
TheoremCertificate checks give weak bisimilarity#✓fully proved
Let \(f\) realize the code-level transition function \(s\) and \(g\) realize \(t\) for a recursive specification, and let \(R\) be a list of code pairs on which the certificate check of \(s\), \(t\) and \(R\) succeeds. Then for every pair \((x, y)\) in \(R\), the processes \(f(x)\) and \(g(y)\) are weakly bisimilar in the labelled transition system of the specification.
theorem weaklyBisimilar_of_certCheck (hf : Realizes spec f s) (hg : Realizes spec g t)
(hcheck : certCheck s t rel = true) {x : α} {y : β} (hxy : (x, y) ∈ rel) :
(Process.lts spec).HomWeakBisimilarity (f x) (g y)
def Realizes (spec : Specification Name Constant) {α : Type*}
(realize : α → Process Name Constant) (steps : α → List (Label Name × α)) : Prop :=
∀ x a q, Process.Step spec (realize x) a q ↔ ∃ y, (a, y) ∈ steps x ∧ realize y = q
CSLibExt/Algorithms/CCS/FiniteState.lean:76
def certCheck (s : α → List (Label Name × α)) (t : β → List (Label Name × β))
(rel : List (α × β)) : Bool :=
forwardCheck s t rel && backwardCheck s t rel
CSLibExt/Algorithms/CCS/FiniteState.lean:183
def lts (specification : Specification Name Constant) :
Cslib.LTS (Process Name Constant) (Label Name) :=
⟨Step specification⟩
CSLibExt/Languages/CCS/Recursion.lean:98
Uses 11 · Used by 4
DefinitionDirect check of the root condition#✓fully proved
Given code-level transition functions \(s\) on codes \(\alpha\) and \(t\) on codes \(\beta\), each listing labelled steps to codes, a relation \(R\) given as a list of code pairs, and codes \(x\) and \(y\), the root check succeeds exactly when every listed step \((a, x')\) of \(s(x)\) is matched by some listed step \((a, y')\) of \(t(y)\) with the same label and \((x', y') \in R\), and every listed step \((a, y')\) of \(t(y)\) is matched by some listed step \((a, x')\) of \(s(x)\) with the same label and \((x', y') \in R\).
This is a sufficient check of the root condition of observation congruence at \((x, y)\). Rooted weak bisimilarity also allows silent steps around the matching step, so the check is incomplete.
def rootCheck (s : α → List (Label Name × α)) (t : β → List (Label Name × β))
(rel : List (α × β)) (x : α) (y : β) : Bool :=
((s x).all fun step => (t y).any fun spec =>
spec.1 == step.1 && rel.contains (step.2, spec.2)) &&
(t y).all fun spec => (s x).any fun step =>
step.1 == spec.1 && rel.contains (step.2, spec.2)
inductive Label (Name : Type*) where
| tau
| input (name : Name)
| output (name : Name)
deriving DecidableEq
CSLibExt/Languages/CCS/Parallel.lean:39
Uses 1 · Used by 4
TheoremCertificate checks give rooted observation congruence#✓fully proved
Let \(f\) realize the code-level transition function \(s\) and \(g\) realize \(t\) for a recursive specification, and let \(R\) be a list of code pairs on which the certificate check of \(s\), \(t\) and \(R\) succeeds. If the root check of \(s\), \(t\) and \(R\) succeeds at codes \(x\) and \(y\), then the processes \(f(x)\) and \(g(y)\) are rooted weakly bisimilar (observation congruent) in the labelled transition system of the specification (Milner, Chapter 7).
theorem rootedWeaklyBisimilar_of_certCheck (hf : Realizes spec f s) (hg : Realizes spec g t)
(hcheck : certCheck s t rel = true) {x : α} {y : β} (hroot : rootCheck s t rel x y = true) :
(Process.lts spec).RootedWeaklyBisimilar (f x) (g y)
def Realizes (spec : Specification Name Constant) {α : Type*}
(realize : α → Process Name Constant) (steps : α → List (Label Name × α)) : Prop :=
∀ x a q, Process.Step spec (realize x) a q ↔ ∃ y, (a, y) ∈ steps x ∧ realize y = q
CSLibExt/Algorithms/CCS/FiniteState.lean:76
def certCheck (s : α → List (Label Name × α)) (t : β → List (Label Name × β))
(rel : List (α × β)) : Bool :=
forwardCheck s t rel && backwardCheck s t rel
CSLibExt/Algorithms/CCS/FiniteState.lean:183
def rootCheck (s : α → List (Label Name × α)) (t : β → List (Label Name × β))
(rel : List (α × β)) (x : α) (y : β) : Bool :=
((s x).all fun step => (t y).any fun spec =>
spec.1 == step.1 && rel.contains (step.2, spec.2)) &&
(t y).all fun spec => (s x).any fun step =>
step.1 == spec.1 && rel.contains (step.2, spec.2)
CSLibExt/Algorithms/CCS/FiniteState.lean:241
def lts (specification : Specification Name Constant) :
Cslib.LTS (Process Name Constant) (Label Name) :=
⟨Step specification⟩
CSLibExt/Languages/CCS/Recursion.lean:98
Uses 12 · Used by 3
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.