Question: We want a Turing machine that capitalises a string: the first letter of every word is changed to uppercase. There can only be six different

We want a Turing machine that capitalises a string: the first letter of every word is changed to uppercase.
There can only be six different symbols on the tape: a, A ,0,"(double quote), space and None (blank symbol). The input tape consists of a double quote, followed by zero or more spaces, a, A and 0, followed by a double quote. The rest of the tape is blank. Write the transition table for the Turing machine. Use descriptive state names.
The list constructor used in the test below was introduced in Section 4.6.2: list('"A"') evaluates to ['"','A','"']
When the Turing machine stops, every a at the start of the string or preceded by a space has been replaced with A. The rest of the string must remain unchanged. For example, if the tape is initially
['"','a','A','','0','a','','a','a','"']
then the final tape is
['"','A','A','','0','a','','A','a','"']
The head begins and must end%run -i m269_util
%run -i m269_tm
capitalise ={
# Write the transitions here in the form
# (state, symbol): (new_symbol, LEFT or RIGHT or STAY, new_state),
('start','"'): ('"', RIGHT, '')
}
capitalise_tests =[
# case, TM, input tape, debug, output tape
('example', capitalise, list('"aA 0a aa"'), True, list('"AA 0a Aa"')),
]
test(run_TM, capitalise_tests) on the first (left-most) double quote. Here is some incomplete code: %run -i m269_util
%run -i m269_tm
capitalise ={
# Write the transitions here in the form
# (state, symbol): (new_symbol, LEFT or RIGHT or STAY, new_state),
('start','"'): ('"', RIGHT, '')
}
capitalise_tests =[
# case, TM, input tape, debug, output tape
('example', capitalise, list('"aA 0a aa"'), True, list('"AA 0a Aa"')),
]
test(run_TM, capitalise_tests).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!