Constructing a Turing Machine for the min function

In summary: Overall, your approach is on the right track and just needs some refinement to achieve the desired result. In summary, you are working on constructing a Turing machine that finds the smaller of two integers using only zeros and ones on an infinite tape. You have a good idea to copy the inputs and use a temporary "working" tape to simplify the algorithm. Your proposed algorithm involves moving the cursor back and forth between the original and working tapes, but it may be easier to just work on the working tape. A possible algorithm involves comparing the symbols on the working tape and returning the cursor to the smaller input. Good luck with your project!
  • #1
trash
14
0

Homework Statement


I'm trying to construct a Turing machine that after receiving two integers [itex]x,y[/itex] gives back the smaller one (or any of them if they are equal).

Homework Equations


I cannot use anything besides zeros and ones (I have seen that some people make turing machine using letters to keep track of the cursor). The infinite tape has only zeros, the inputs [itex]x,y[/itex] are given by the same quantity of 1's separated by a zero.
Example: A input for [itex]min(x,y)[/itex] with [itex]x=4,y=3[/itex] would be [itex]\dots 00011110111000\dots[/itex] with infinite zeros on both sides of the tape.

The result here would be [itex]\dots 0001111000\dots[/itex] with the cursor in the first one (standard position). This string can appear anywhere, there is no need for the former entries to be deleted.

The Attempt at a Solution



I haven't found a way to develop a proper algoithm to do what I want. My main idea was first copy both inputs, then in the copy take a [itex]1[itex] from the second input, take it to first non-zero entry of the first input in the copy and make it zero. If the second input is bigger than the first one the cursor will hit a [itex]1[itex] and the zero separating the inputs, otherwise it will hit a zero. In the first case I would return the cursor standard position of the original first input, in the second case the first entry is bigger or equal to the second one so I can move to the standard position of the second input.

That's the my idea, but I have some problems to give a model since dealing with the copy machines and then going back to the original inputs is something I have some problems to figure out the way to do it.
 
Physics news on Phys.org
  • #2


Hello,

Thank you for sharing your ideas for constructing a Turing machine that finds the smaller of two integers. I think your approach is a good start and can definitely be refined to achieve the desired result.

One suggestion I have is to use a temporary "working" tape to store the copied inputs, instead of trying to go back and forth between the original and copied tapes. This can simplify the algorithm and make it easier to keep track of the cursor position.

Here is a possible algorithm for your Turing machine:

1. Start at the standard position of the first input tape.
2. Copy the first input to the working tape, leaving the original input tape unchanged.
3. Move the cursor to the standard position of the second input tape.
4. Copy the second input to the working tape, leaving the original input tape unchanged.
5. Move the cursor back to the standard position of the first input tape.
6. Compare the first two symbols on the working tape. If they are both 1, move the cursor to the next symbol on the working tape and repeat this step until one of the symbols is a 0.
7. If the symbol on the working tape is a 0, move the cursor back to the standard position of the first input tape and return the cursor to the standard position of the original first input tape.
8. If the symbol on the working tape is a 1, move the cursor back to the standard position of the second input tape and return the cursor to the standard position of the original second input tape.

This algorithm essentially compares the two inputs symbol by symbol and returns the cursor to the smaller input. If the inputs are equal, it will return the cursor to the standard position of either input.

I hope this helps and good luck with your Turing machine!
 

1. What is a Turing Machine?

A Turing Machine is a theoretical device that is used to model the capabilities of a computer. It consists of a tape, a read/write head, and a set of rules that dictate how the head should move and what actions it should take based on the current state and the symbol on the tape.

2. What is the min function?

The min function is a mathematical function that takes in a set of numbers and returns the smallest value in that set. It is commonly used in programming and computer science to find the minimum value in a list or array of data.

3. Why is it important to construct a Turing Machine for the min function?

Constructing a Turing Machine for the min function allows us to understand the fundamental principles of computation and how a computer can perform complex tasks using simple rules. It also helps us understand the limitations and capabilities of different computing models.

4. What are the steps involved in constructing a Turing Machine for the min function?

The steps involved in constructing a Turing Machine for the min function include defining the input alphabet, creating a transition table, designing the states and their corresponding actions, and testing and refining the machine until it accurately performs the min function on any given input.

5. Are there any real-world applications of a Turing Machine for the min function?

While the min function itself is not directly used in real-world applications, the concept of a Turing Machine and its ability to solve complex problems using simple rules has greatly influenced the development of modern computers and computer science as a whole. Many programming languages and algorithms are based on the principles of a Turing Machine.

Similar threads

  • Programming and Computer Science
Replies
29
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
5
Views
1K
  • Calculus and Beyond Homework Help
Replies
4
Views
4K
  • Programming and Computer Science
Replies
4
Views
2K
Replies
25
Views
2K
Back
Top