After the last post, I decided that the next post should contain images. Next I decided that the time to publish another post has come. Here is an image of an acceptor finite-state machine, parsing the string “nice”.

How can we revert this machine, such that it parses the string “ecin”? An easy way is to remove state “6 Error”, revert all remaining arrows, swap state “1 Start” and state “7 Success”, then add state “6 Error” again, and add arrows to it for all yet undefined cases. This post elaborates the observation that renouncing on the state “6 Error” altogether, and instead allow undefined cases, makes everything simpler and more symmetric. This is not just relevant for the deterministic case, but also for the nondeterministic and the probabilistic case. Time reversal is significantly different for (non-)deterministic and probabilistic machines. Using partial functions, binary relations, and substochastic matrices as transitions gives deceptively simple representations of this fact.

Volker Diekert, Manfred Kufleitner, Gerhard Rosenberger: “Diskrete algebraische Methoden: Arithmetik, Kryptographie, Automaten und Gruppen” is a very nice book. Its chapter 7 *Automatentheorie* gave me the idea that non-deterministic machines arise naturally if (arbitrary) binary relations are used instead of functions. If you read that chapter, you will realize that this post is a significant step back in terms of depth and generality. So the worst is yet to come…

What is the difference between non-determinism and randomness? This question asked for clarification of the following quote

A non-deterministic machine is not the same as a probabilistic machine. In crude terms, a non-deterministic machine is a probabilistic machine in which probabilities for transitions are not known

I gave a short answer trying to highlight the fact that the probabilities on the transitions make time reversal for a probabilistic machine significantly less trivial than time reversal for a non-deterministic machine. Niel de Beaudrap commented that even non-deterministic machines are not reversible without further constraints. I agree with him in a certain complicated technical sense, but I couldn’t really judge whether he had this complicated technical sense in mind. Maybe he just doubts the basic heuristic principle according to which non-deterministic machines are much more symmetry with respect to time than deterministic machines. So I took some time to elaborate my answer, and highlight in more detail the achievable time symmetry for non-deterministic and probabilistic machines. I want to try to reblog my answer here:

### Stepping backwards during debugging as a motivation for non-determinism

The notion of a non-deterministic machine suggests itself when you wish to step backward (in time) through a program while debugging. In a typical computer, each step modifies only a finite amount of memory. If you always save this information for the previous 10000 steps, then you can nicely step both forward and backward in the program, and this possibility is not limited to toy programs. If you try to remove the asymmetry between forward steps and backward steps, then you end up with the notion of a non-deterministic machine.

### Similarities and differences between non-determinism and randomness

While probabilistic machines shares some characteristics with non-deterministic machines, this symmetry between forward steps and backward steps is not shared. To see this, let’s model the steps or transitions of a deterministic machine by (total or partial) functions, the transitions of a non-deterministic machine by (finite) relations, and the transitions of a probabilistic machine by (sub)stochastic matrices. For example, here are corresponding definitions for finite automata

- a finite set of states
- a finite set of input symbols
**deterministic:**a transition function**non-deterministic:**a transition function**non-deterministic:**a transition relation**non-deterministic:**a function**probabilistic:**a function

Here is the power set of and is the space of substochatic matrices on . A right substochastic matrix is a nonnegative real matrix, with each row summing to at most 1.

### There are many different reasonable acceptance conditions

The transitions are only one part of a machine, initial and final states, possible output and acceptance conditions are also important. However, there are only very few non-eqivalent acceptance conditions for deterministic machines, a number of reasonable acceptance conditions for non-deterministic machines (NP, coNP, #P, …), and many possible acceptance conditions for probabilistic machines. Hence this answer focuses primarily on the transitions.

### Reversibility is non-trivial for probabilistic machines

A partial function is reversible iff it is injective. A relation is always reversible in a certain sense, by taking the opposite relation (i.e. reversing the direction of the arrows). For a substochastic matrix, taking the transposed matrix is analogous to taking the opposite relation. In general, the transposed matrix is not a substochastic matrix. If it is, then the matrix is said to be *doubly substochastic*. In general , even for a doubly substochastic matrix , so one can wonder whether this is a reasonable notion of reversibility at all. It is reasonable, because the probability to reach state from state in forward steps is identical to the probability to reach state from state in backward steps. Each path from A to B has the same probability forward and backward. If suitable acceptance conditions (and other boundary conditions) are selected, then doubly substochastic matrices are an appropriate notion of reversibility for probabilistic machines.

### Reversibility is tricky even for non-deterministic machines

Just like in general , in general for a binary relation . If describes a partial function, then and . Even if relations and should be strictly reversible in this sense, this doesn’t imply that will be strictly reversible too. So let’s ignore strict reversibility now (even so it feels interesting), and focus on reversal by taking the opposite relation. A similar explanation like for the probabilistic case shows that this reversal works fine if suitable acceptance conditions are used.

### These considerations also make sense for pushdown automata

This post suggests that one motivation for non-determinism is to remove that asymmetry between forward steps and backward steps. Is this symmetry of non-determinism limited to finite automata? Here are corresponding symmetric definitions for pushdown automata

- a finite set of states
- a finite set of input symbols
- a finite set of stack symbols
**deterministic:**a partial transition function such that only if for all**non-deterministic:**a transition function**non-deterministic:**a transition relation**non-deterministic:**a function**probabilistic:**a function such that for all

Here is the empty string, and . This notation is used because it is similar to , which is used in many definitions for pushdown automata.

### Diagramed verification of reversal for (non)advancing input and stack operations

An advancing input operation with gets reversed as follows

A non advancing input operation with that doesn’t read any input can be reversed

Here is a diagram of an advancing input operation whose reversal would look bad

For a stack operation , there are the three cases , , and . The stack operation gets reversed to as follows

The stack operation gets reversed to as follows

A generalized stack operation would be reversed to

### Reversibility for Turing machines

A machine with more than one stack is equivalent to a Turing machine, and stack operations can easily be reversed. The motivation at the beginning also suggests that reversal (of a Turing machine) should not be difficult. A Turing machine with a typical instruction set is not so great for reversal, because the symbol under the head can influence whether the tape will move left or right. But if the instruction set is modified appropriately (without reducing the computational power of the machine), then reversal is nearly trivial again.

A reversal can also be constructed without modifying the instruction set, but it is not canonical and a bit ugly. It might seem that the existence of a reversal is just as difficult to decide as many other question pertaining to Turing machines, but a reversal is a local construction and the difficult questions often have a global flavor, so pessimism would probably be unjustified here.

The urge to switch to equivalent instruction sets (easier to reverse) shows that these questions are less obvious than they first appear. A more subtle switch happened in this post before, when total functions and stochastic matrices were replaced by partial functions and substochastic matrices. This switch is not strictly necessary, but the reversal is ugly otherwise. The switch to the substochastic matrices was actually the point where it became obvious that reversibility is not so trivial after all, and that one should write down details (as done above) instead of taking just a high level perspective (as presented in the motivation at the beginning). The questions raised by Niel de Beaudrap also contributed to the realization that the high level perspective is slightly shaky.

### Conclusion

Non-deterministic machines allow a finite number of deterministic transitions at each step. For probabilistic machines, these transitions additionally have a probability. This post conveys a different perspective on non-determinism and randomness. Ignoring global acceptance conditions, it focuses on local reversibility (as a local symmetry) instead. Because randomness preserves some local symmetries which are not preserved by determinism, this perspective reveals non-trivial differences between non-deterministic and probabilistic machines.

Pingback: A canonical labeling technique by Brendan McKay and isomorphism testing of deterministic finite automata | Gentzen translated