This commit is contained in:
Miloslav Ciz 2025-06-19 02:56:49 +02:00
parent f216e89f03
commit 0e12dc9efe
18 changed files with 2071 additions and 1974 deletions

View file

@ -28,7 +28,7 @@ The machine halts either when it reaches the end state, when it tries to leave t
The computation works like this: the input data we want to process (for example a [string](string.md) we want to reverse) are stored in the memory before we run the machine. Then we run the machine and wait until it finishes, then we take what's present in the memory as the machine's output (i.e. for example the reversed string). That is a Turing machine doesn't have a traditional [I/O](io.md) (such as a "[printf](printf.md)" function), it only works entirely on data in memory!
Let's see a simple **example**: we will program a Turing machine that takes a [binary](binary.md) number on its output and adds 1 to it (for simplicity we suppose a fixed number of bits so an [overflow](overflow.md) may happen). Let us therefore suppose symbols 0 and 1 as the tape alphabet. The control unit will have the following rules:
Let's view a simple **example**: we'll program a Turing machine that takes a [binary](binary.md) [number](number.md) on its input and adds 1 to it (for simplicity we assume a fixed number of bits so an [overflow](overflow.md) can occur, we don't care). Let us therefore consider symbols 0 and 1 as the tape alphabet. The control unit will have the following rules programmed:
| stateFrom | inputSymbol | stateTo | outputSymbol | headShift |
| --------- | ----------- | ------- | ------------ | --------- |
@ -40,9 +40,9 @@ Let's see a simple **example**: we will program a Turing machine that takes a [b
| add0 | 1 | add0 | 1 | left |
| end | | | | |
Our start state will be *goRight* and *end* will be the end state, though we won't need the end state as our machine will always halt by leaving the tape. The states are made so as to first make the machine step by cells to the right until it finds the blank symbol, then it will step one step left and switch to the adding mode. Adding works just as we are used to, with potentially carrying 1s over to the highest orders etc.
Our start state is going to be *goRight* and *end* will be the end state, though we won't need the end state as our machine will always halt by leaving the tape. The states are made so as to first make the machine step by cells to the right until it finds the blank symbol, then it will step one step left and switch to the adding mode. Adding works just as we are used to, with potentially carrying 1s over to the highest orders etc.
Now let us try inputting the binary number 0101 (5 in decimal) to the machine: this means we will write the number to the tape and run the machine as so:
Now let us try feeding the binary number 0101 (5 in decimal) to the machine's input: this means we'll write the number to the tape and run the machine as so:
```
goRight