Calculation of Communication with Open Terms
We recall the definition of the communication function of [vW04].
Notation
We use the following notation throughout:
— the set of all parameterised actions
— the set of action names
— the set of finite bags (multisets) over a set
— a multiaction (bag of parameterised actions); the empty bag is written
,
— multiset union and difference
— the bag of action names in multiaction
; e.g.
— the cardinality of bag
— bags of action names with at least two elements
— the set of open boolean terms
— the set of parameterised actions with open (symbolic) data parameters
— a communication function, satisfying
The χ Function
Definition (χ). Let and
.
Also, let
.
The function
is true if,
and only if, all actions of the multiaction parameter have the given data vector as parameter, i.e.
is defined as follows:
The Communication Function γ
Definition (γ). Let ,
and
.
Also let
with
.
The communication function
is defined by the following definition:
But first we reformulate to
as follows, because the definition
of
above is not really suitable from an implementation point of view. Note that we
somewhat ignore the possibility of right hand sides that are
, but this is not directly
relevant for the algorithms. If one desires, one can consider
to be equal
to
to make things fit.
Definition (γ’). Let ,
and
. Also let
with
.
The communication function
is defined by the following definition:
Lemma. Definitions γ and γ’ define equivalent functions. That is, , for all
and
.
Proof. The defining equations of are complete, so we only need to show that
is sound (with respect to
). We do this by induction on
.
Case :
Case . We do case distinction on the possibility of
to participate in a communication.
Case :
Case ,
with
and
such that
and
:
Extension to Open Terms
Taking as basis the new definition, we now define the function we are really interested in.
That is, the communication function on open terms. We use the set of
(open) boolean terms and assume that expressions depending on action arguments
are such terms.
Let be the set of bags of actions with open data parameters.
Definition (). The extension of the communication operator over open data terms,
is defined as:
Theorem. Let and
an assignment
of variables to closed terms. Then:
Simplification
Note that we can rewrite as follows:
Definition ().
Lemma.
The ϕ Helper Function
We now concentrate on .
Definition (φ).
Lemma. .
And finally with :
Here can be in
or in
. Assume it is in
.
Now assume it is in .
To conclude:
Algorithms
To conclude, we write an algorithm that uses what we have proven.
Algorithm:
Algorithm:
Complexity and Optimisation
If we analyse this algorithm focussing on the length of input , we see that it is
. It basically takes the first action in
and computes the result
given that this action participates in a communication and the result given that it does not.
However, looking at , we can see that the algorithm needlessly tries to find a part
in
, such that
with this part can communicate, if
is not even a
subbag of a left hand side of a communication in
. So, we propose to add an extra
check to
to prevent this behaviour and making the algorithm more (or precisely) in
the order of
, with
and
contains actions that occur in a left hand side of a communication in
and
actions that do not.
Algorithm: (optimised)
Extended Algorithms with Accumulator
Another problem with the above code is that it can generate a lot of negative conditions to indicate that certain communications do not happen. This appears to be at least exponential.
We solve this by removing the problematic in
. Instead
we add an extra parameter to
and
indicating which actions
will not communicate. Then, in the final case of
, where
,
we use a new function
to calculate a more reasonable condition indicating that the
remaining actions do not communicate.
Note that the following algorithm deviates in a significant way from the previous version, which means that its validity is not guaranteed and additional proofs will be needed.
Algorithm:
Algorithm:
The ψ Functions
Algorithm: (recursive)
Algorithm: (recursive)
Algorithm:
Non-recursive Implementations
Naturally, functions and
can easily be transformed to the following
non-recursive implementation.
Algorithm: (iterative)
Algorithm: (iterative)
Correctness
Theorem.
Proof. By induction on .
Case :
Case :
Corollary. .
Proof.
References
M.J. van Weerdenburg. GenSpect Process Algebra. Master’s thesis, Eindhoven University of Technology, 2004.