Details
The inputs shown above besides prog are all optional. Here are the default values:
| depth | 10 |
| init | {1, {0, 0}} |
| nreg | 2 |
| show | False |
| maxtokens | 10 |
A basic
register machine is a simple, deterministic abstract model of computation where information is stored in numbered registers that hold non-negative integers. Computation proceeds by executing a sequence of instructions, typically incrementing or decrementing a register and branching depending on whether the register is zero.
A multiway register machine (MRM) is a computational model similar to a standard register machine, but instead of executing a single deterministic path of instructions, it branches nondeterministically whenever there are multiple possible outcomes of an instruction. This branching generates a multiway system of states, where all possible computational paths evolve simultaneously. MRMs are especially useful for modeling probabilistic, nondeterministic or multi-branching processes like the Collatz conjecture or quantum-inspired computations. For more information about MRMs, please visit this Wolfram Community Post:
https://community.wolfram.com/groups/-/m/t/3499350?p_p_auth=DQ5Cml4K.
prog takes a list of instructions, each having the form {reg,incdec,{next1,…},{failnexti,…}}. Here, reg is an integer indicating which register to modify, incdec is 0 or 1 indicating whether to increment (0) or decrement (1) this register, the nexti are integers indicating the next instructions to complete upon success and faili are optional integers for decrement instructions. The faili indicate which instructions to move to upon failure when the register cannot be decremented because it is empty.
ResourceFunction["MultiwayRegisterMachine"]["RulePlot",prog,nreg] generates a visualization of a series of instructions, which forms a multiway register machine. Each instruction is represented as a color depicting its type, an arrow depecting an increment or decrement. There are directed edges depicted as arrows connecting various instructions. The edges above the instructions are green, used when it was a success, and the edges below the instruction are red, used when it was a failure.
ResourceFunction["MultiwayRegisterMachine"]["CirclePlot",prog,nreg] generates a visualization of a series of instructions arranged in a circle, where instructions are represented as above, which forms a multiway register machine.
ResourceFunction["MultiwayRegisterMachine"]["Complexity",prog] is defined as how often a multiway register machine creates new branches, or paths, on average. A branch is a possible simulation of the machine with a certain length. A machine with a greater number of directed edges relative to the number of instructions has a higher complexity, and vice versa. A simple machine would have a complexity of less than 1.5 and a complex machine is otherwise.
ResourceFunction["MultiwayRegisterMachine"]["EvolveGraph",prog,depth,init,show] is used to display the evolution of a multiway register machine through a graph with directed edges. Each possible branch represents a path that the register machine could have taken based on its options.
ResourceFunction["MultiwayRegisterMachine"]["ProbabilityPlot",prog,depth,init,maxTokens] outputs multiple tables. Each row of the first table has boxes that represent the instructions of the machine. The opacity of the circle in each box indicates the probability that the machine is currently on that instruction at the given depth. Each of the rest of the tables represents a register, where the opacity of each box in row i and column j represents the probability that the register has a value of at least j at depth i. These probabilities are determined by considering all possible states that the register machine could have reached at every depth.