Counter Machines vs Turing Machines
- 19Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the primary difference between a Turing machine and a counter machine in terms of their memory storage?
19 questions
- 1
What is the primary difference between a Turing machine and a counter machine in terms of their memory storage?
Model answer
A Turing machine uses an infinite tape with cells for reading and writing symbols, while a counter machine utilizes individual, opaque counters that can hold an arbitrary number of undifferentiated units.
Explanation
Turing machines are characterized by their infinite tape, which allows them to store and access information in a sequential manner. The tape head can move left or right, reading and writing symbols. In contrast, counter machines do not have a tape. Instead, they rely on 'counters' (analogous to 'bags' of pebbles), which can only store non-negative integers. The operations are limited to adding one, subtracting one, and checking if a counter is empty, without knowing the exact count.
- 2
What are the allowed operations for a counter in a counter machine?
Model answer
The allowed operations for a counter are adding one unit, subtracting one unit, and checking whether the counter is empty.
Explanation
Unlike a Turing machine's ability to read and write any symbol, a counter machine's counters are restricted to three basic operations. You can increment a counter by one, decrement it by one, or test if it currently holds zero units. You cannot 'peek' inside to see the exact number of units stored.
- 3
Why is it not possible to instantaneously know the exact number of counters in a bag within a counter machine?
Model answer
Knowing the exact number of counters instantaneously is considered a computational task itself, especially if there were a very large number of counters, making it not an instantaneous operation.
Explanation
The design of a counter machine aims to model fundamental computational limits. If a counter could hold 'three billion' items, instantaneously counting them all would not be a primitive, instantaneous operation. Thus, the model restricts operations to only basic additions, subtractions, and emptiness checks.
- 4
Despite its seemingly simpler operations, how does the computational power of a counter machine compare to that of a Turing machine?
Model answer
A counter machine is just as powerful as a Turing machine, meaning it can compute anything that a modern computer or a Turing machine can.
Explanation
The initial impression might be that a counter machine is less powerful due to its restricted operations. However, through clever constructions and algorithms, it can be demonstrated that a counter machine can simulate all the operations of a Turing machine, establishing their equivalent computational power.
- 5
Describe the 'Hello World' operation for a counter machine: resetting a counter.
Model answer
To reset a counter, one repeatedly subtracts one unit from the counter and checks if it is empty, looping until the counter becomes empty.
Explanation
Since you cannot directly set a counter to zero, the process involves a loop. In each iteration, one unit is removed from the counter. The loop continues as long as the counter is not empty. Once it is empty, the loop terminates, and the counter is effectively reset.
- 6
Explain how to add the contents of counter C2 to counter C1 using only counter machine operations. What happens to C2 in this process?
Model answer
To add C2 to C1, one repeatedly subtracts one from C2 and adds one to C1, continuing until C2 is empty. In this process, the original contents of C2 are destroyed.
Explanation
This operation simulates moving pebbles from one bag to another. Each time a pebble is removed from C2, it is immediately added to C1. This continues until C2 has no pebbles left. As a result, C1 contains the sum of its original contents and C2's original contents, and C2 is left empty.
- 7
When adding two counters, if the value of one counter is needed after the addition, what additional step is required?
Model answer
If the value of a counter that is being added (and thus destroyed) needs to be preserved, it must first be copied into a temporary store before the addition operation.
Explanation
The direct addition process empties the source counter. To retain its original value, a copy operation is necessary. This involves moving its contents to a separate temporary counter while also moving them to the destination counter during the 'copy' phase, and then restoring the original counter from the temporary one.
- 8
Describe the process of copying the contents of counter C2 to counter C4 while preserving the original contents of C2, using an additional temporary counter T.
Model answer
First, subtract from C2 and add to both C4 and T until C2 is empty. Then, subtract from T and add back to C2 until T is empty, thus restoring C2 and copying its original value to C4.
Explanation
This two-phase process ensures both copying and preservation. In the first phase, each unit removed from C2 is simultaneously added to C4 (the destination) and to T (the temporary storage). This empties C2 and fills C4 and T with C2's original value. In the second phase, units are moved from T back to C2, restoring C2 to its original state.
- 9
How can you double the contents of counter C1, ensuring the result is stored back in C1?
Model answer
To double C1, subtract one from C1 and add two to a temporary counter T, repeating until C1 is empty. Then, move all contents from T back to C1.
Explanation
The doubling process requires using a temporary counter. Each time a unit is removed from C1, two units are added to T. This continues until C1 is empty, at which point T holds double the original amount of C1. Finally, T's contents are moved back to C1.
- 10
Explain how to halve the contents of counter C1, considering both even and odd numbers of counters.
Model answer
To halve C1, subtract two units from C1 and add one to a temporary counter T, repeating until C1 is empty or only one unit remains. If one unit remains, it is disregarded (for integer division) or stored as a remainder in another counter.
Explanation
The halving operation involves removing two units from C1 for every one unit added to a temporary counter T. If C1 is even, this process completes perfectly, and T will hold half the original value. If C1 is odd, after all possible pairs are removed, one unit will remain. This remainder can either be ignored (standard integer division) or explicitly moved to a separate counter to preserve the information.
- 11
What is the purpose of storing the remainder when halving an odd number of counters, and how can it be achieved?
Model answer
Storing the remainder allows the counter machine to retain information about the original number's parity. It can be achieved by incrementing a third counter when the halving loop terminates with one counter remaining in the source.
Explanation
When halving an odd number, the final remaining unit in the source counter indicates an odd number. To keep this information, instead of simply discarding it, this single remaining unit can trigger an increment in a dedicated 'remainder' counter. This mechanism effectively stores the modulo 2 result.
- 12
How can the contents of a counter be multiplied by an arbitrary constant (e.g., tripling or quadrupling)?
Model answer
To multiply by a constant N, one repeatedly subtracts one from the source counter and adds N units to a temporary counter, then moves the contents back to the source.
Explanation
This generalizes the doubling operation. For each unit removed from the source counter, N units are added to a temporary counter. Once the source is empty, the temporary counter holds N times the original value. The contents are then transferred back to the original counter.
- 13
How does a counter machine represent the state of a Turing machine tape, particularly for binary symbols (0s and 1s)?
Model answer
The Turing machine tape is conceptually split into three parts: the section to the left of the tape head, the symbol under the tape head, and the section to the right of the tape head. These parts are represented using binary numbers stored in separate counters.
Explanation
To simulate a Turing machine, its state needs to be encoded. The infinite tape, using binary digits (0s and 1s), is divided. The left part is represented by a binary number in one counter (C1), the symbol under the head by another (C2, holding 0 or 1), and the right part by a reversed binary number in a third counter (C3). Reversing the right part ensures that symbols closer to the head are the least significant bits.
- 14
Given a tape configuration '100011' with the tape head on the first '0' (reading from left), how would the three counters C1, C2, and C3 represent this state?
Model answer
C1 would store the binary number '1', which is 1. C2 would store '0', which is 0. C3 would store the reversed binary number '110', which is 6.
Explanation
If '100011' is the tape, and the head is on the first '0':
- Left of head: '1' (binary for 1) -> C1 = 1
- Under head: '0' (binary for 0) -> C2 = 0
- Right of head: '011' reversed is '110' (binary for 6) -> C3 = 6 This representation ensures that bit shifts correspond to simple arithmetic operations on the counter values.
- 15
When a Turing machine's tape head moves one square to the right, how do the values in counters C1, C2, and C3 change arithmetically?
Model answer
C1 is doubled and has C2 added to it. C2 becomes the remainder of C3 divided by two. C3 becomes the quotient of C3 divided by two.
Explanation
Moving right means the current head symbol moves to the right part of C1, and the leftmost symbol of C3 moves under the head. This translates to:
- C1 (left part): Shift left (multiply by 2) and append the old head symbol (add old C2).
- C2 (head symbol): Becomes the least significant bit of the old C3, i.e., C3 modulo 2.
- C3 (right part): Shift right (divide by 2, discarding remainder) as its leftmost symbol moves away.
- 16
Why is adding the contents of C2 to C1 during a 'move right' operation acceptable even if C2 becomes empty or destroyed?
Model answer
It is acceptable because C2 represents the symbol under the tape head, which is 'moved' into the left part of the tape, so its original value is no longer needed in C2's counter after the shift.
Explanation
When the tape head moves right, the symbol that was under the head (represented by C2) now becomes the new least significant bit of the 'left' portion of the tape (represented by C1). Its role shifts from 'current symbol' to 'part of the left tape'. Therefore, destroying C2's content in the process of adding it to C1 accurately reflects this conceptual movement.
- 17
How are the write operations ('write 0' and 'write 1') of a Turing machine simulated using counter machine operations?
Model answer
To write a '0', counter C2 (representing the tape head symbol) is reset to empty. To write a '1', C2 is first reset to empty and then incremented by one.
Explanation
Since C2 holds either 0 or 1, writing a '0' simply means ensuring C2 contains zero. This is done by repeatedly subtracting from C2 until it's empty. To write a '1', C2 is first cleared, and then a single unit is added, ensuring it holds exactly one.
- 18
How can a counter machine 'read' the symbol under the tape head (represented by C2), given that it cannot directly 'peek' inside counters?
Model answer
To read C2, one attempts to subtract one from it. If successful, C2 originally contained '1'. If subtraction fails (C2 is empty), it originally contained '0'. The removed unit must then be returned to C2 to preserve its value.
Explanation
The only way to 'know' if C2 contains '1' is to try and remove a unit. If a unit can be removed, it must have contained '1'. If it's already empty, it contained '0'. To preserve the counter's state after this 'read', if a unit was removed, it must immediately be added back to C2, possibly using a temporary counter to facilitate the check and restore.
- 19
What is the computational implication of being able to simulate a Turing machine with a counter machine?
Model answer
It implies that counter machines are computationally universal, capable of performing any computation that a Turing machine or a modern computer can.
Explanation
The Church-Turing thesis posits that any effective algorithm can be computed by a Turing machine. By demonstrating that a counter machine can simulate a Turing machine, it shows that counter machines also satisfy this universality, meaning they have the same theoretical computational power as any other known universal model of computation.

Ask anything
We've read this whole study set, so questions about it get the best answers.