Binary subtraction:
Lets build a turing machine that can subtract 2 binary numbers. A subtraction is done on two inputs: in a subtraction x-y we call x the base andy the subtrahend. Before going into the turing machine details, we first have to understand how binary numbers are subtracted. This is done bit by bit,starting at the least significant bit. Lets take the example of 35-15=22:
yyy n n n- borrowed? No or yes
10 0 01 1 -base input
00 1 10 1 - subtrahend input
--------------------------------------------
nyy y n n- ‘borrowed’ value (yes or no)is
Carried over to the next bit
--------------------------------------------------
0 10 1 10 - answerRuleset:
All possible combinations of inputs with the respective actions are listed in the ruleset in table 1.
We’he designed the ruleset such that the first decimal of the state number is used as a control register and the second decimal asadata refister.The first says where we are(reading the ase input, reading the subtrahend input,sweeping back to start,etc). The second holds the actualcomputational data and has everything to do with fig.
Look at the first 2 lines of the ruleset: At positions ‘s’ the state is always 50 or 51: 2 states to see whether we borrowed or not. With 50 wesay: yes, we borrowed, with 51 we say: ‘not borrowed’.
Now look at the last 4 lines: Whenever we read a blank ,we are at the end of our tape.note that the 4 possible leafnodesmatch the 4 possible machine states at this point: the last 4 lines in our rulest (with states 20,21,22,23 respectively for leaf nodes‘0,y’,’1,y’,’0n’,’1n’).Rule set for subtracting turning machine,rrIf in state | And on symbol | Write | And move | Set next state | |
50515051 | SS!S!S | rrll | 10115051 | Start left(withBorrowed)(withoutBorrowed)Move to Start. | |
101120212223 | 0/10/10/10/10/10/1 | rrrrrr | 101120212223 | Move r and do nothing this is nobit in our interest | |
10113212223 | ##### | 00000 | rrrrr | 3031414243 | Handle # (alert ! next position is the bit of interest) |
111213 | *** | rrr | 212223 | Handle * and go from first to second input | |
20212223 | **** | rrrr | 20212223 | Left pas before answer do nothing | |
30303131 | 0101 | #### | rµM x.xÏ=iv align="center">r |
(100p) Design a Turing machine that sums two binary numbers in the tape. You are expected to start writing the result from the left (in reverse, after numbers) and then reverse this result. The numbers should be entered with the pattern: #num1#num2#For example, for input #101#110# The tape should first look like: #101#110#1101, Then you should reverse the result: #101#110#1011.Use Turing Machine Visualization online tool https://turingmachine. io./ to create and trace your Turing Machine. Please, read descriptions and usage information...
Question 8. Design a Turing machine that calculates the sum of two unary numbers. (You can assume the input consists of two unary numbers separated by a single blank space.)
5. Design a Turing machine that takes as input two numbers a and b, such that a is not equal to b and determines which number is higher. Give the transition table for the machine. Show by drawing the steps, how the machine works when a-3 and b-2. Can we use a PDA for the same problem? Give reasons for your answer (10+5+5-20).
Design a visual Turing machine to compute: (1) x+y x and y are natural numbers Design a visual Turing machine to compute: (1) x+y x and y are natural numbers
2. Let L = {hMi: M is a Turing machine that accepts at least two binary strings}. a) Define the notions of a recognisable language and an undecidable language. [5 marks] b) Is L Turing-recognisable? Justify your answer with an informal argument. [5 marks] c) Prove that L is undecidable. (Hint: use Rice’s theorem.) [20 marks] d) Bonus: Justify with a formal proof your answer to b). [20 marks] 2. Let L-M M): M is a Turing machine that accepts...
Implement a Turing machine that subtracts two from the input string corresponding a ternary number. More specifically, suppose w = an−1an−2 . . . a1a0 is the input string with ai ∈ {0, 1, 2}. Your Turing machine should subtract two from w “in-place”, i.e., at the end of the computation the tape should contain the result, w − 2 and the tape head should be at the start of that string. Upon a successful operation, halt on accept. Otherwise,...
40 points) Please design a Turing machine T to recognize the union of the languages of two Turing machines Mi and M2. That is, T accepts an input string w, if and only if either Mi or M2 or both accept string w. Please describe the high-level idea (or algorithm) of your Turing machine T. You do not need to draw the low-level state transition diagram of your Turing machine. Note that the difficulty is that Mi or M2 may...
2. Let L-M M): M is a Turing machine that accepts at least two binary strings. a) Define the notions of a recognisable language and an undecidable language. [5 marks [5 marks] b) Is L Turing-recognisable? Justify your answer with an informal argument. c) Prove that L is undecidable. (Hint: use Rice's theorem.) [20 marks] 20 marks] d) Bonus: Justify with a formal proof your answer to b). 2. Let L-M M): M is a Turing machine that accepts at...
Is a four-tape Turing Machine more powerful than a two-tape Turing Machine? Explain why Is a four-tape Turing Machine more powerful than a two-tape Turing Machine? Explain why
Give a high level description of a turing machine that performs binary addition. When started with tape contents u#V where u and v are strings in {0,1}, it should halt with a single binary string on the tape, denoting the sum of the naturals denoted by u and v