4

The documentation for TuringMachine gives the following example of a machine specified by explicit transitions:

t = TuringMachine[
    {{state_,color_?EvenQ}:>{state,color/2,-1},{state_,color_?OddQ}:>{state,3 color+1,1}},
    {1,{1,2,3,4,5}},5];

But attempting to plot this with RulePlot[t] results in:

{{{1, 1, 0}, {1, 2, 3, 4, 5}}, {{1, 2, 1}, {4, 2, 3, 4, 5}}, {{1, 1, 
   0}, {4, 1, 3, 4, 5}}, {{1, 5, -1}, {2, 1, 3, 4, 5}}, {{1, 1, 
   0}, {2, 1, 3, 4, 16}}, {{1, 5, -1}, {1, 1, 3, 4, 16}}}

Why doesn't RulePlot understand the explicit transitions TuringMachine in the documentation?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
orome
  • 12,819
  • 3
  • 52
  • 100

1 Answers1

1

Unfortunately the following is not a solution, but an observation that grew too long for a comment. At first, I thought that the problem may be the fact that the initialization and number of steps should be given as arguments to RulePlot rather than to TuringMachine, so I tried:

Clear[separate]

separate := RulePlot[ TuringMachine[ {{state_, color_?EvenQ} :> {state, color/2, -1}, {state_, color_?OddQ} :> {state, 3 color + 1, 1}} ], {1, {1, 2, 3, 4, 5}}, 5 ]

... but that failed as well.

Reading through the results of Trace@separate, it appears to me that the following check returning False causes RulePlot to decide to fail and return unevaluated:

NKSSpecialFunctions`RulePlot`Dump`ValidTuringMachineRulesQ[{
   {state_, color_?EvenQ} :> {state, color/2, -1}, 
   {state_, color_?OddQ} :> {state, 3 color + 1, 1}
}]

(* Out: False *)

None of these checks appear when one executes Trace@t using your definition of the TuringMachine.

MarcoB
  • 67,153
  • 18
  • 91
  • 189
  • 1
    So what's happening here? Is this another failure of the documentation, or another bug? – orome Jun 28 '20 at 19:07
  • The TuringMachine expression works, and RulePlot works with other forms of TuringMachine expressions, but not with this one, so I am leaning towards bug here. Unless somebody else comes up with a better explanation, I'd report it to WRI Support. – MarcoB Jun 28 '20 at 19:09
  • 5
    I'm weary of reporting bugs. Nearly every single thing I've ever tried as a simple experiment in Mathematica has uncovered a fundamental bug. I just got notification that one I uncovered in 2012 was finally fixed — 8 years later. – orome Jun 28 '20 at 19:48