Goto Chapter: Top 1 2 3 4 5 6 7 Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

7 Machine
 7.1 Example
 7.2 Constructor
 7.3 Stepping and Running
 7.4 Inspection

7 Machine

We finally have everything in play to start using a turing machine. We need a Tapeand a Program and we are set to run or step through the operations of the turing machine.

7.1 Example

In this example we will step throught a turing machine that keeps writing a series of I to the its tape.

gap> LoadPackage("turing");;
gap> tape := TmTape();
<tape empty>
gap> program := TmProgram(TmState(1));
<program empty>
gap> TmAddRule(program, TmState(1), TmBlank(), TmState(1), TmSymbol('I'), TmRight());
gap> machine := TmMachine(tape, program);
<machine q1 <tape empty>>
gap> TmStep(machine);
gap> machine;
<machine q1 <tape |_I[_]__|>>
gap> TmStep(machine);
gap> machine;
<machine q1 <tape |II[_]__|>>

7.2 Constructor

7.2-1 TmMachine
‣ TmMachine( tape, program )( operation )

Returns: a turing machine

This returns a turing machine that uses program on tape.

7.3 Stepping and Running

7.3-1 TmStep
‣ TmStep( machine )( operation )

let the machine take a single step through its program.

7.3-2 TmRun
‣ TmRun( machine )( operation )

let the machine run its course.

7.3-3 TmTrace
‣ TmTrace( machine )( operation )

let the machine run its course, displaying each step.

7.4 Inspection

7.4-1 TmStepCount
‣ TmStepCount( machine )( operation )

Returns: the number of steps taken.

The number of steps this turing machine has taken during its computation.

 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 5 6 7 Ind

generated by GAPDoc2HTML