Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in matlab please help with this function for reference (do not do part 2 just 3) please help with the runTuring function in matlab syntax

in matlab please help with this function
image text in transcribed
for reference (do not do part 2 just 3)
image text in transcribed
please help with the runTuring function in matlab syntax
3 Turing Machine Part III: Run the Turing Machine function output = run Turing (input.tape) Input Type Description input-tape 1x char The char array that represents the input tape, consisting of a's, b's, c's, and B's Description Output Type output 1xl logical A logical that represents whether the in- put tape is in the awe format Details Now that everything is prepared, you will program the function runTuring that does the follow- ing: 1. Call create Table() to construct the transition table. 2. Create a variable to represent the current state of the Turing Machine. Since the Turing Machine starts at state '90, set this variable initially equal to 90. This variable will take on different states as the Turing Machine runs. 3. Create a variable to represent the position within input.tape. We assume the Turing Machine starts at the leftmost element of input-tape, you could set this variable initially equal to 1. This variable should change as the Turing Machine moves along input.tape. 4. Implement the transitions of the Turing Machine using a while loop. Within the while loop. your function should utilize the transition function you wrote in Problem 2 to read instructions from the transition table, write onto the tape, transition to the next state, and move along the tape. 5. You will output a logical value which represents whether the Turing Machine accepts (true) or rejects (false) the input. Tips There are only 2 cases where the Turing Machine will halt: - If the current symbol and the current state refer to an empty element in the transition table, move = '0' and the Turing Machine halts. - If the Turing Machine gets to the final state, the Turing Machine will also halt. If Turing Machine halts in the final state, it will accept the input. Otherwise, it will reject the input. You might find the built-in MATLAB function strcmp useful. Think about how to use each of the inputs and outputs of your transition function. Think about how the index changes as the Turing Machine moves right or left. The following chart will give you a sense of what you are going to build in this function. You will need to fill out the ... part with either a char array or leaving it empty empty XY 90 GL.X.R . 2 Turing Machine Part II: Look Up the Transition Table function (new.state, new.value, move] - transition (table, now.state, now.value) Input Type Description table 6x8 cell The transition table you made in the last problem now.state 1x2 char Current state of the Turing Machine: 0 "q1', '22', '3' or 'q now.value 1x1 char Value read from the tape: 'a', 'b', 'e', X 'Y', 'Z', or B Output new.state 1x2 char New state of the Turing Machine: 0 q1', '2', '3', '94. or '5'. See Tips. Value to be written to the tape: 'a', 'b', 'c', 'X', 'Y', Z. See Tips new.value 1xl char move 1xl char The direction of the next movement on tape: L', 'R', or 0'. See Tips Details This function figures out the next step the Turing Machine will take based on now.state and now.value. Tips . If the input tape is not in the form a"b", the transition table will eventually reference an empty element. In this case, new.state should be the current state (now.state). new.value should be now.value. And move should be a 1x1 char equal to '09 . You may find the built-in MATLAB function isempty() useful As you might have already noticed, now.state doesn't contain the state'' but new.state does. This is because once the Turing machine obtains '5', it will halt because it has 3 Turing Machine Part III: Run the Turing Machine function output = run Turing (input.tape) Input Type Description input-tape 1x char The char array that represents the input tape, consisting of a's, b's, c's, and B's Description Output Type output 1xl logical A logical that represents whether the in- put tape is in the awe format Details Now that everything is prepared, you will program the function runTuring that does the follow- ing: 1. Call create Table() to construct the transition table. 2. Create a variable to represent the current state of the Turing Machine. Since the Turing Machine starts at state '90, set this variable initially equal to 90. This variable will take on different states as the Turing Machine runs. 3. Create a variable to represent the position within input.tape. We assume the Turing Machine starts at the leftmost element of input-tape, you could set this variable initially equal to 1. This variable should change as the Turing Machine moves along input.tape. 4. Implement the transitions of the Turing Machine using a while loop. Within the while loop. your function should utilize the transition function you wrote in Problem 2 to read instructions from the transition table, write onto the tape, transition to the next state, and move along the tape. 5. You will output a logical value which represents whether the Turing Machine accepts (true) or rejects (false) the input. Tips There are only 2 cases where the Turing Machine will halt: - If the current symbol and the current state refer to an empty element in the transition table, move = '0' and the Turing Machine halts. - If the Turing Machine gets to the final state, the Turing Machine will also halt. If Turing Machine halts in the final state, it will accept the input. Otherwise, it will reject the input. You might find the built-in MATLAB function strcmp useful. Think about how to use each of the inputs and outputs of your transition function. Think about how the index changes as the Turing Machine moves right or left. The following chart will give you a sense of what you are going to build in this function. You will need to fill out the ... part with either a char array or leaving it empty empty XY 90 GL.X.R . 2 Turing Machine Part II: Look Up the Transition Table function (new.state, new.value, move] - transition (table, now.state, now.value) Input Type Description table 6x8 cell The transition table you made in the last problem now.state 1x2 char Current state of the Turing Machine: 0 "q1', '22', '3' or 'q now.value 1x1 char Value read from the tape: 'a', 'b', 'e', X 'Y', 'Z', or B Output new.state 1x2 char New state of the Turing Machine: 0 q1', '2', '3', '94. or '5'. See Tips. Value to be written to the tape: 'a', 'b', 'c', 'X', 'Y', Z. See Tips new.value 1xl char move 1xl char The direction of the next movement on tape: L', 'R', or 0'. See Tips Details This function figures out the next step the Turing Machine will take based on now.state and now.value. Tips . If the input tape is not in the form a"b", the transition table will eventually reference an empty element. In this case, new.state should be the current state (now.state). new.value should be now.value. And move should be a 1x1 char equal to '09 . You may find the built-in MATLAB function isempty() useful As you might have already noticed, now.state doesn't contain the state'' but new.state does. This is because once the Turing machine obtains '5', it will halt because it has

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions