Concurrency Theory: Lecture 18, 29 March 2018 --------------------------------------------- Message passing systems: communicating finite-state machines, undecidability of reachability, message-passing languages and context-dependent commutability of actions ---------------------------------------------------------------------- A network of communicating finite-state machines (CFSM), or message passing automata (MPA), consists of finite-state automata connected by point-to-point channels. For each pair of processes i,j, there is a channel (i,j) from i to j. The actions of an individual component i can now be: - q --a--> q', for a local action a, a in Act - q --i!j(m) -> q', i sends message m to j, m in Msg - q --i?j(m) -> q', i receives message m from j, m in Msg Messages come from a finite alphabet Msg, local actions from a finite alphabet Act. A global configuration of n agents consists of a global state tuple of the n agents and a tuple of channel contents of the m channels, where m = n(n-1) --- there is one channel for each pair (i,j), i =/= j. The semantics is the obvious one. (,) --x--> (,) if -- x is a in Act, for some component j, qj --a-->q'j, qi = q'i for all i =/=j, and ci = c'i for all i. -- x is j!i(m) performed by j and in component j, qj --j!i(m)--> q'j qk = q'k for all k =/= j, for cl = (j,i), c'l = cl.m (concatenation), ck = c'k for all k =/= l -- x is j?i(m) performed by j and in component j, qj --j?i(m)--> q'j for cl = (i,j), cl is of the form m.c'l qk = q'k for all k =/=j, ck = c'k for all k =/= l Initially, each component j is in its initial state q^j_in and all channels are empty. Note that an action i!j(m) is always enabled whereas i?j(m) requires m to be present in the head of the message queue. This semantics models perfectly channels which act like queues and are reliable --- no message is ever lost or duplicated. ---------------------------------------------------------------------- Reachability ------------ One could ask several kinds of reachability questions in this setting: 1. Is an exact configuration (,) reachable? 2. Is the tuple of control states in some context (,) ? "Control state reachability" 3. Is the tuple of control states with all channels empty --- i.e. is the configuration (,) reachable? It turns out that all these questions are undecidable because we can model Turing Machines with a network of 2 CFSMs. We assume the TM moves as follows: if the control state is q and head is reading a cell with contents a, the move delta(q,a) is one of the following: - change q to q', replace a by a', leave the head on the same cell - change q to q', leave a untouched, move the head one cell left - change q to q', leave a untouched, move the head one cell right From this, it follows that the configuration of the TM from one move to the next changes only in a 3 cell neighbourhood around the current head position. We simulate the tape of a TM by a message queue. Component 1 simulates the TM, component 2 merely serves to recycle the tape back to Component 1. In fact, if we allow channels of the form (i,i) with the same source and destination, we need only one component. Each message in the queue corresponds to one cell of the tape. If the head is not on that cell, the message is just the letter from the tape alphabet that is currently on that cell. If the head is on the cell, the content is where q is the state and a is the letter on the cell. We add two markers # and ? to denote the start and end of the tape. Component 2 just reads each incoming message from component 1 and passes it back. Component 1 reads its messages and maintains, internally, a 3 cell window of tape contents. If the window is not in the neighbourhood of the head, it just passes on the message untouched. When the window comes to the head position, it simulates one move of the TM and updates the window appropriately before passing the messages one. If the head moves to one end of the tape, the special markers # and ? allow Component 1 to insert new messages corresponding to extending the tape. In this way, the tape contents cycle between the two components. In each cycle, Component 1 simulates one move of the TM. From this, it follows that any reasonable question about CFSM reachability is undecidable. Otherwise, we can reduce halting problems for TMs to CFSM reachability questions and answer them. ---------------------------------------------------------------------- Message passing languages ------------------------- An interesting sub-class of CFSMs is the one in which we have a global upper bound b on the size of each channel. This makes the set of configurations bounded. Overall, the system behaves like a finite-state automaton. We get a language over the alphabet of local actions, send actions and receive actions. In a channel-bounded system, this language will be regular. There is some independence of actions in the system, but it is not global, unlike in Mazurkiewicz traces. Consider a channel with bound 2 between i and j. If we have the action sequence i!j(m) j?i(m) i!j(m) j?i(m) i!j(m) j?i(m), we can commute the first read and the second send to get i!j(m) i!j(m) j?i(m) j?i(m) i!j(m) j?i(m). However, we cannot move the third i!j(m) ahead to get i!j(m) i!j(m) i!j(m) j?i(m) j?i(m) j?i(m) because of the channel bound. Hence i!j(m) and j?i(m) can commute depending on the channel contents in the current configuration. Like Zielonka's theorem, we can ask if a regular language can be implemented by a CFSM network. One can adapt the proof of Zielonka's theorem to achieve this. There are two main technical complications. 1. In the protocol for time-stamping and updating latest information, we now have asynchronous communication. In the original protocol, we exploited the fact that when information was updated, all participants shared their current state and came away with the same shared updated information. In an asynchronous setting, updates flow from i to j and i needs to get acknowledgments from j to know when j has got the information that it sent. This complicates the protocol. 2. The proof of Zielonka's theorem uses a distributed simulation of the minimum DFA for a given language. The minimum DFA has the nice property that delta(q_in,w) = delta(q_in,w') whenever w and w' are trace equivalent. Because indepdences is context-sensitive in message-passing languages, this property does not hold, making the simulation more complicated. ======================================================================