2. Pattern Calculus
The pattern calculus is inspired by the join calculus [
2], a calculus proposed to underlie programming languages for distributed systems. A presentation of the join calculus can also be found in [
3]. The specific construction of the new calculus is the definition of communication channels:
. To elucidate the simplicity of this syntactical construction, let us say that it could be expressed in the
-calculus [
4] by using several syntactical constructions:
.
The syntax of the pattern calculus is defined by using a countable set of names ranging over , together with ranging over finite strings of names. We use ranging over the set of processes. The set of processes contains an empty process 0, as well as an output message sending v by using a channel u. The process describes the parallel composition of processes P and Q. The communication between processes is achieved by the channel definition indicating that the interaction of processes P and Q is realized by the channel u (which is created only for the communication between them).
Definition 1. The processes of our calculus are defined by the following syntax:
P ::= .
In , both u and v are bound. The scope of v is P, while the scope of u is given by the whole definition. It is worth noting that only this definition binds names. The free names are defined inductively by , and .
A substitution replaces all the free occurrences of name x in P by name y; name-capture is avoided by using the -conversion (defined in the standard way).
Definition 2. A structural congruence is defined as the smallest congruence satisfying the following axioms:
, if
if and
if
if , , and
.
The evolution of the processes is given by a reduction relation → .
For the specific construct , the reduction is described mainly by:
.
More exactly, process Q can send a name v along the channel u, while process P waits at the other end of channel u to receive certain channel names. When the name v is received, process Q continues its execution in parallel with process P in which all free occurrences of y are replaced by v, i.e., . Then, channel u remains open to receive other names. The formal definition is given below.
Definition 3. The reduction relation is defined as the smallest relation satisfying:
- r1:
if with and
- r2:
- r3:
.
It is worth noting that there is no rule for parallel composition in the definition of this reduction. The following (easy-to-prove) results show that such a rule for parallel composition is just a consequence.
Lemma 1. Considering any substitution ,
implies , and implies .
Proposition 1. implies .
4. Control Structure for Pattern Calculus
Milner proposed the control structures and action calculi as a unifying framework for the models of concurrent systems in [
8]. A control structure defines the static aspects of a process calculus, while the corresponding action calculus describes various models of interactive behaviours. Regarding the behaviour, distinct action calculi differ only in their generators (called controls). Thus, the previously mentioned Petri nets and
-nets, as well as our hypergraph model, differ only in their generators. Analyzing these generators, it is possible to compare and classify the formal models for concurrent systems. Moreover, by selecting some specific generators, it is possible to combine existing models in order to obtain a new desired model.
The control structures presented here follow the definitions of [
9]. Essentially, a control structure is defined by a set of terms, an equational theory, and a reduction relation over terms. This fact is condensed in the following expression:
From an algebraic viewpoint, a control structure is a symmetric strict monoidal category with an additional structure [
10]. The morphisms of the symmetric strict monoidal category correspond to the terms of the control structure; they are denoted by
and called
actions.
The control structure uses an enumerable set of names together with a signature in which P is a set of prime arities and is a set of control operators. Every name has a prime arity , and this is denoted by . Each control has an arity rule. In addition to the specific control operators, every control structure contains a datum operator (where ) and a discard operator , as well as an abstractor operator (where and ). The equational theory is the same for all control structures. To express the evolution, a set R of reaction rules is used; reaction rules are ordered pairs of terms with the same arity.
Each action a possesses a surface .
The equality = between actions is valid whenever the equation could be proved by using the axioms of the control structure; otherwise .
We present here some results used later in the proofs of our results.
Proposition 2. The following properties hold in any control structure: The following properties hold in any control structure, whenever : Additionally,1. | | |
2. | | |
3. | | |
4. | | |
5. | | |
6. | | |
Proposition 3. The following properties are provable in any control structure:1. | ; | |
2. | ; | |
3. | | if; |
4. |
| if and . |
We define the control structure for our pattern calculus, emphasizing on its actions. We also present a graphical representation for its processes. The monoid
of the natural numbers provides the arity monoid of the control structure, with
ranging over natural numbers, and
denoting the first
n natural numbers. The (unique) prime arity 1 is associated with each name
. For a number
k and a function
, we define
by
. Following [
9], the control structure is defined over the set
of names using
as meta-variables.
Regarding the actions of the control structure for our calculus, they are given by enriched hypergraphs called shortly pattern nets. An action with arity is given by a hypergraph H together with its decoration consisting of:
- -
An input function given by an injective function ;
- -
An output function given by a function ;
- -
A label function given by an injective function , where ;
- -
A transition relation ;
- -
A resource function .
We can look at these functions as multisets over . We denote by a multiset over such that , and ; we use the standard multiset operations over these functions: ().
We extend in a straightforward way the isomorphism and contraction introduced for hypergraphs. Considering with (), the nets and are isomorphic if there is a hypergraph isomorphism between and such that , , , and if and only if , together with for all and .
For the graphical representations of the pattern nets, let us consider a generic net
with
; the hypergraph
H is presented by assuming that its lines are of length zero (see
Figure 1):
- -
Whenever , and , an input label is assigned to vertex v, an output label to vertex , and a name labelx to vertex w;
- -
Whenever , an arc is drawn outside any oval from vertex v to vertex ;
- -
Whenever , v and lie on the same hyperedge s: ; more exactly, whenever , we have k arcs inside the oval s from vertex v to vertex .
As for hypergraphs, isomorphic nets are not distinguished. The names of vertices and hyperedges do not play any role in the isomorphic nets, and so the graphical representation of an isomorphic (equivalence) class of pattern nets is given by any net of the class after removing the names of vertices and hyperedges.
The
control structure operators for our pattern nets are:
- datum defined by | |
and
| |
- discard defined by | |
and
| |
The three
controls generating the pattern nets are:
– defined by | |
and
| |
– defined by | |
and
| |
– If and
, then | |
, where | |
,
for fresh | |
and , and | |
. | |
The equational theory is defined by the following operators.
Let us consider the nets
with
and
, where
. Without loss of generality, we consider
.
and
, as well as
.
– Identity defined by | |
and
| |
– Symmetry defined by | |
| |
–
Tensorial product of two nets
and
is obtained by combining them as follows: in
, the input labels are incremented by
m and the output labels are incremented by
n; then overlap the two roots and the vertices of
and of
with the same name. Formally,
, where
– Composition of two nets and is obtained by combining them as follows: overlap the two roots and vertices of and with the same name; for every , overlap the vertex labelled in with the vertex labelled in , and then remove the labels and .
Formally,
, where
– Abstractor. Let us consider a net with .
Then
is obtained from
a in the following steps: increment all the input and output labels by 1; assign both the input label
and the output label
to vertex
x, and then remove the label
x. Formally,
, where
In general, these operators over the pattern nets are well-defined. However, the abstractor
is not well-defined if a vertex labelled by
x is not contained in the net
a. To avoid such a situation, we adjust the definition of the above operators by
where
op stands for each operator defined above, and
is the pattern net
Following [
9], it is not difficult to prove the following result.
Proposition 4. The operators , ω, ν, , , , , ·, ⊗ and define a control structure.
The actions of this control structure determine the
hypergraph model for the pattern calculus. We actually use the derived control operators:
The reaction ↘ is the smallest relation over the pattern nets closed under equality, composition, tensorial product and abstraction which satisfies the control rule
The corresponding graphical description of the reaction rule is given by:
In this diagram, the scope of the operator is represented as a gray patch; due to the properties derived from the syntax of our calculus, this patch can actually be determined from the hypergraph structure.
The operators, actions and reaction complete the definition of our nets.
It is worth noting that the def operator can be generalized, namely we can have a more general control operator by . Moreover, the corresponding graphical representation is extended by using m external arcs to connect the new root hyperedge to the old one. The corresponding reaction is generalized in the following way:
We present some proprieties of the pattern nets. The proofs of these properties are tedious (but easy), based mainly on definitions and the structure of the nets.
Lemma 2. We have the following properties:
- 1.
and .
- 2.
For any substitution , and .
- 3.
If , then there exists such that and .
- 4.
iff and .
- 5.
iff
either there exists such that and , or
there exist such that and , where .
- 6.
Whenever , iff and .
- 7.
iff and .
5. Fully Abstract Hypergraph Model of the Pattern Calculus
This section presents the main results of the paper. These results reveal the hypergraphs as a fully abstract model for the pattern calculus. According to [
11], a model is fully abstract if all observationally equivalent terms in the object language represent the same object in the model. This means that processes with different behaviour are not mapped to the same hypergraph. Moreover, we prove a correspondence between the reduction of the processes and the reduction of their hypergraph representation.
Definition 4. The semantic relationship between the pattern calculus processes and the pattern nets is defined by structural induction as follows:
- 1.
;
- 2.
;
- 3.
;
- 4.
.
We prove some results involving this semantic relationship .
Lemma 3. For every process , we have .
Proof. A simple induction on the structure of P. In the case of our nets, 0 is the neutral element of the arity monoid . For case of the previous definition, we use the discard operator instead of . Since 1 is the only prime arity p of the monoid , we omit the index without any risk of confusion. □
Lemma 4. For every process , we have .
Proof. By induction on the structure of P (the proof uses Lemma 2). □
Lemma 5. For two names and a process , we have .
Proof. Induction on the definition of the substitution over processes (and Lemma 5). □
Proposition 5. If , then .
Proof. Induction on the definition of structural congruence. Let us consider the relation
Proof is reduced to the equality between ∼ and ≡. Obviously, . We show that ∼ satisfies the axioms from the definition of ≡. Since ≡ is the smallest relation satisfying these axioms, it follows that , and so . Thus, to prove that , it is enough to verify that ∼ satisfies the axioms from the definition of ≡.
The cases , and are rather trivial, based on the fact that is neutral for tensor product, together with the commutativity and associativity of tensor product ⊗ in the equational theory (of the control structures).
Let us consider the other cases.
– , if .
Assume . By Lemma 4, it follows that . Then,
– if , .
Assume and ; then, and . By Lemma 4, . If , then the result is trivial.
Let us assume that .
– if .
Assume . By Lemma 4, . Then,
–
if , , and .
Assume , and . By Lemma 4, it follows that and . Furthermore, by Lemma 2, .
In a similar way, we obtain
To complete the proof, it remains to prove that X = Y.
□
Theorem 1. If , then .
Proof. By induction on the definition of .
, , and . According to Lemma 2 and Lemma 4, . According to Proposition 2 and using the compatibility of ↘ with composition, tensorial product and abstraction,
* r2: is with .
By induction,
. Since ↘ is closed under composition, tensor and abstraction, it follows that
* r3: with , and .
By the induction hypothesis, . By Proposition 5, we have and . Since ↘ is closed under equality, then . □
Lemma 6. iff and .
Proof. A consequence of the fact that the reaction is closed under tensorial product and equality.
Induction on the structure of P.
- –
If P is the empty process or a message, then . Therefore, the statement of the lemma is obviously true because its premise is not satisfied.
- –
If P is a parallel composition , then . Since , it follows (Lemma 2) that one of the following cases remains possible:
- (1)
and ;
- (2)
and ;
- (3)
and , where .
Note that by Proposition 2, we have .
In case , , and we consider . In case , we take . In case , by induction, we have and . Thus, , considering .
- –
If P is a definition , then we may assume without losing generality that . It follows from Lemma 2 together with Proposition 2 that . By Lemma 2, and . Since , and , it follows (according to Lemma 2) that one of the following cases remains possible:
- (1)
and ;
- (2)
and ;
- (3)
and .
In case , . Considering , it satisfies the requirements (according to Proposition 2). In case , we have , and consider . In case , by induction hypothesis, and . Thus, , and consider . □
Lemma 7. iff one of the following conditions holds:
- 1.
and ;
- 2.
and .
Proof. A consequence of the fact that the reaction is closed under tensorial product and equality.
Induction on the structure of P.
- –
If P is the empty process 0, then condition 2 holds obviously.
- –
If P is a message, then condition 2 holds by Lemma 6.
- –
If P is a parallel composition , then .
By Lemma 2, it follows that one of the following cases is possible:
and ;
and ;
and ;
and , where .
According to Proposition 2, . In case , condition 2 holds by taking . In case , we have . Then, condition 1 holds by taking . In case , condition 1 holds by taking .
In case , by induction, we distinguish two sub-cases:
and ;
and .
For , we obtain , and condition 1 holds for . For , condition 2 holds for . In both sub-cases, some action commutations are required; they are possible according to Proposition 2.
- –
If P is a definition , then we may assume without losing generality that . By Lemma 4, . According to Proposition 2, we have . By Lemma 2, and . Since , it follows from Lemma 2 that one of the following cases remains possible:
and ;
and ;
and ;
and .
In case , condition 1 holds for .
In case , by Lemma 2, there exists b such that and ; condition 2 holds for this b. In case , condition 1 holds for .
In case , we distinguish two sub-cases:
and ;
and .
For , condition 1 holds for . For , there exists b such that and (by Lemma 2); condition 2 holds for this b. Proposition 2 is used in all cases and sub-cases. □
Lemma 8. iff one of the following conditions holds:
- 1.
and ;
- 2.
and ;
- 3.
, and
where for every .
Proof. If condition 1 holds, then the implication follows as a consequence of the fact that the reaction is closed under tensorial product and equality. If condition 2 holds, then we have
by Proposition 5
If condition 3 holds, it follows by Lemma 2 and Lemma 4 that for every . Then,
by Propositions 5 and 2
Induction on the structure of P.
– If P is the empty process 0 or a message with , then . The statement of the lemma is obviously true as its premise is not satisfied. On the other hand, if P is a message , then
by Lemma 2
Furthermore, . Consequently, condition 2 holds.
– If P is a parallel composition , then . Since , it follows from Lemma 2 that one of the following cases remains possible:
and ,
and ,
and , where .
According to Proposition 2, we obtain . In case , we obtain , and condition 1 holds for . In case , condition 1 holds for . In case , we distinguish three sub-cases:
and ;
and ;
and
where for every .
In sub-case , we obtain . Therefore, condition 1 holds for . For , we have . By Proposition 2, . Thus, condition 2 holds. For sub-case , we may assume (without losing generality) that for every . By Lemma 4, it follows that for every . Then , and
by Proposition 2
Thus, condition 3 holds.
– If P is a definition , then we can assume without losing generality that . By Lemma 4 and Lemma 2, . It follows from Proposition 2 that . By Lemma 2, and . Since and , then (according to Lemma 2). It follows that one of the following cases remains possible:
and ;
and ;
and .
In case , condition 1 holds for . In case , condition 1 holds for . In case , by induction, we distinguish three sub-cases:
and ,
and ,
and
where for every .
In sub-case , condition 1 holds for . In sub-case , we have . We distinguish two situations:
- •
. Then . It is easy to see that , and so . By Proposition 2, . Thus, condition 2 holds.
- •
. Then . Moreover, . Thus, condition 3 holds.
In sub-case , . Using Proposition 2, we obtain
Thus, condition 3 holds. □
Theorem 2. If , then there exists a process Q such that and .
Proof. Induction on the structure of P.
– If P is the empty process or a message, then . Therefore, the statement of the theorem is obviously true because the premise is not satisfied.
– If P is a parallel composition , then . By Lemma 7, one of the following cases holds:
- (1)
and ;
- (2)
and .
It is sufficient to consider the case , the other one being similar (symmetric).
By induction, we have and . According to Proposition 1, and . Thus, the result of the theorem holds for .
– If P is a definition , then . It follows from Lemma 2 that and . By Lemma 8, only one of the following cases holds:
- (i)
and ;
- (ii)
and ;
- (iii)
and
where for every .
In case , by the induction hypothesis, and . It follows that and Thus, the result of the theorem holds for .
In case , we have and . Thus, the result of the theorem holds for .
In case , it follows that for any (Lemmas 2 and 4).
□