Simulating a modern computer by a Turing machine and vice versa
Download
Report
Transcript Simulating a modern computer by a Turing machine and vice versa
Simulating a modern computer by
a Turing machine and vice versa
CS 6800
Instructor: Dr. Elise de Doncker
By
Shweta Gowda
Saikiran Ponnam
Outline
Introduction.
Components of Turing Machine.
Simulating Computer by Turing Machine.
Simulating Turing Machine by Computer.
Examples.
References.
Introduction
The Turing machine was introduced in 1936 by Alan
M. Turing to solve computable problems, and is the
foundation of modern computers.
Let us compare TM and the modern computer
While both if this model appear to be different but
they can accept exactly the same language - the
“recursive enumerable languages”.
Components of Turing
machine
1. A Tape
2. Controller
3. Read/Write Head
Continue…
Tape
The tape, at any one time, holds a sequence of characters
from the set of characters accepted by the machine.
Here we assume that the machine can accept only two
symbols a) blank b) digit1.
Continue…
Read/Write Head
The read/write head reads and writes one symbol at a time
from the tape and accordingly moves to right or left based
on the design on the Turing machine
Controller
The controller is the theoretical counterpart of the central
processing unit (CPU) in modern computers. It is a finite
state automaton i.e., with finite number of states.
Simulating computer by
Turing machine
Example (1): Increment Operation[ incr(x) ]
Continue…
Step by step operation which shows how the TM can
increment x when x=2
Continue…
Example (2): Decrement Operation[ decr(x) ]
Continue…
Step by step operation which shows how the TM can
decrement x when x=2
Simulating Turing machine by
computer
Simulation of the Turing Machine on a Digital
Computer is a useful and practical tool not only for
problem solving and validation of algorithms but also
in the field of programming.
TM are as powerful as the most sophisticated realworld programming languages. which is great,
because formally proving any thing about C , java
would be difficult
Here we describe simple Turing machine examples…
Example (1): The Identify
Function
•
Let A={0,1} and S={s0}. Let M={} be the empty set,
the set containing no elements. M is a set of
quintuples of the right type with the right
requirements.
•
Here M is a TM which computes the identity function,
f(n)=n
•
Run M on input n.
•
The tape is initially configured to (s0,0,”111…1″),
where the string contains n 1’s.
Continue…
Step1: Tape reader looks for which instruction to use
as no instruction are found because there is no
instruction given go to step 2
Step2: Immediately, the machine halts, which
changing the tape at all.
Result: Therefore, the output is identical to the input,
and on input n, n is outputted.
Example2: Increment
Operation [ f(n)=n+1 ]
Here, we build a machine which takes input n and
outputs n+1.
Strategy : We’ll instruct the tape-head that as long as it
sees the symbol 1, it will move to the right, leaving
the 1 as it is. This way, the tape-reader will move right
until it reaches the first zero. Once the tape-reader
reaches the first zero on the tape, it will replace that
zero with a 1 and then immediately halt. In this way,
the string of n consecutive 1’s originally on the tape
will be turned into a string of n+1 consecutive 1’s.
Continue…
States: s0 (initial state)=“haven’t found first zero yet” and
s1=‘found first zero, ready to halt”.
Step1: If the tape-head is in state s0, i.e., it hasn’t found the first
zero yet, and the current cell contains 1, then the reader should
move right, leaving the 1 as it is, and staying in the same state.
The instruction is represented in the form of quintuple:
(s0,1,1,”R”,s0).
Step2: If the tape-head is in state s0, i.e., still looking for that
first zero, and the current cell contains 0, the first zero has been
found. In that case, we want to replace the first zero with a 1 and
then prepare to halt. So we’ll instruct the reader to write 1, move
right, and go to state s1. Going to state s1 will be equivalent to
halting, provided that we don’t give the machine any
instructions in state s1 . Represented as: (s0,0,1,”R”,s1).
Continue…
Step3: We add no other instructions. This ensures that
after the machine goes to state s1 after writing that
new “1”, it will immediately halt.
Result: The TM which computes the function
f(n)=n+1 is the set of quintuples: {(s0,1,1,”R”,s0),
(s0,0,1,”R”,s1)}
Comparison with real machines
Anything a real computer can compute, a Turing
machine can also compute.
Like a Turing machine, a real machine can have its
storage space enlarged as needed, by acquiring more
disks or other storage media
Descriptions of real machine programs using simpler
abstract models are often much more complex than
descriptions using Turing machines
Turing machines simplify the statement of algorithms.
Real time example of TM
Example 1
Continue…
Execution and Controls.
The Run button starts execution.
The Pause button suspends execution.
The Run Speed slider changes the execution speed.
The Step button executes the next step and pauses.
The BackStep button reverses the effect of the previous step. A
Turing Machine can be back stepped all the way to its initial state.
The Reset button returns the Turing Machine to its initial state. In
effect, the definition is reloaded.
Continue…
Example 2:
https://www.youtube.com/watch?v=E3keLeMwf
HY
References
Introduction to Automata Theory, Languages, and
Computation by J. E. Hopcroft, (R. Motwani) and J.
D. Ullman, Addison Wesley.
http://www.ieee.org (SIMULATION OF A TURING MACHINE
ON A DIGJT AL COMPUTER)
http://www.xamuel.com/turing-machines
http://www.cs.odu.edu/~sainswor/Projects/QTMS
https://www.youtube.com
Thank You