public TuringMachineDefinition <int, int> ToTuringMachineDefinitionById() { int newTapeAlphabetSize = AlphabetSize + 1; // the FSM alphabet + the blank symbol int blank = AlphabetSize; int[,] newTransitions = new int[NumberOfStates, newTapeAlphabetSize *3]; for (int l = 0; l < AlphabetSize; l++) { for (int s = 0; s < NumberOfStates; s++) { newTransitions[s, 3 * l] = TransitionById(s, l); newTransitions[s, 3 * l + 1] = l; // Do not change tape content. newTransitions[s, 3 * l + 2] = 1; // Go to the right. } } for (int s = 0; s < NumberOfStates; s++) { newTransitions[s, 3 * blank] = IsFinalById(s) ? -2 : -1; newTransitions[s, 3 * blank + 1] = blank; newTransitions[s, 3 * blank + 2] = 1; } var tm = new TuringMachineDefinition <int, int>(null, blank, null, null, InitialStateId, new FrozenMatrix <int>(newTransitions)); return(tm); }
// You are expected to build objects of this class using the NewExecution // methods of TuringMachineDefinition. internal TuringMachineExecution(TuringMachineDefinition <TAlphabet, TState> machineDefinition) { definition = machineDefinition; executionById = new TuringMachineExecutionById(machineDefinition.definitionById); }