turing machines and modern computers abhijit das
play

TURING MACHINES AND MODERN COMPUTERS Abhijit Das Department of - PowerPoint PPT Presentation

TURING MACHINES AND MODERN COMPUTERS Abhijit Das Department of Computer Science and Engineering Indian Institute of Technology Kharagpur April 9, 2020 FLAT, Spring 2020 Abhijit Das What is a Modern Computer? No standard well-accepted


  1. TURING MACHINES AND MODERN COMPUTERS Abhijit Das Department of Computer Science and Engineering Indian Institute of Technology Kharagpur April 9, 2020 FLAT, Spring 2020 Abhijit Das

  2. What is a Modern Computer? • No standard well-accepted definition. • Laptop and desktop computers. • Servers, clusters, GPUs. • Supercomputers. • Computers in a network. • Quantum computers. • FPGAs and ASICs. • Embedded processors. • Modern computer architectures are rather complex. • How to make a mathematical model of such a machine? • Let us take a laptop or desktop computer as a representative. • We informally show that such a modern computer is equivalent to a Turing machine. FLAT, Spring 2020 Abhijit Das

  3. Simulation of a Turing Machine by a Modern Computer • Input: A Turing machine M and an input w for M . • Output: A C program to simulate the work of M on w . • Seems like no big deal. • Issues to worry about: • A modern computer has limited memory. • How to simulate the infinite tape of M ? • What if the description of M does not fit in the computer’s memory (including hard disks)? • What if w is so large that it does not fit in the computer’s memory? • What if Σ or Γ for M is too large? • Solution: Use an unlimited source of external memory (like pen drives). • Need to update the OS to support this simulation. FLAT, Spring 2020 Abhijit Das

  4. Handling Infinite Memory 5 4 3 2 1 7 0 8 6 FLAT, Spring 2020 Abhijit Das

  5. Handling Infinite Memory • Number the pen drives used as 0 , 1 , 2 , 3 ,... . • Let c be the current pen drive in use. • The pen drives storing the part of the tape to the left of the c -th drive are organized as a stack. • The pen drives storing the used part of the tape to the right of the c -th drive are organized as another stack. • In each of these stacks, the most recently used drive is at the top. • If the head wants to move to the left of the first cell of the current drive, push the current drive to the right stack, pop and insert the drive at the top of the left stack. • If the head wants to move to the right of the last cell of the current drive, push the current drive to the left stack, pop and insert the drive at the top of the right stack. • If the right stack is empty, a new pen drive is opened. FLAT, Spring 2020 Abhijit Das

  6. Handling Enormous Inputs or Alphabets • The input w for M may span across multiple pen drives. • If Γ is very large, the entire memory of a pen drive may be insufficient to store a single symbol. • For a 16 GB pen drive, this means | Γ | > 2 137438953472 . • To solve this problem, encode the symbols in binary. • Breaks inside a tape symbol is allowed. • There is now a reading mode to collect all the bits of an individual tape symbol and to interpret the bit collection. • This may increase the number of states of M significantly. FLAT, Spring 2020 Abhijit Das

  7. Handling an Enormous M • The input w may span across multiple pen drives. • M should reside in the internal memory of the computer. • The internal memory is finite, and may fail to accommodate M . • Solution: Send M to the tape (a sequence of pen drives). • Do not simulate M on w . • Simulate the Universal Turing Machine U . • U simulates M on w upon the input of M # w on the tape. • U is a fixed machine of moderate size. • U fits in an amount of memory independent of M and w . FLAT, Spring 2020 Abhijit Das

  8. Stored-Program Computers • Memory hierarchy: Registers, Cache memory, main memory, hard drives, removable storage. • Assume that a modern computer has infinite memory. • We flatten the hierarchy. • The memory is organized as an array of words (32-bit or 64-bit). • The words are addressed as 0 , 1 , 2 , 3 ,... . • Compiled programs reside somewhere in the memory. • Computer programs consist of instructions: Copy w i to w j . Add w i and w j , and store the result in w k . Compare w i with w j . Jump to the address l . • The input may be stored in the memory or come from a special device. FLAT, Spring 2020 Abhijit Das

  9. The Fetch-Decode-Execute Cycle • Each instruction consists of • An opcode (the operation) • Zero or more operands • The destination • A counter stores the address of the instruction to execute next. • The opcode is first fetched. • The opcode is decoded and the requisite operands are fetched from memory. • The operation is performed. • The result is written back to the destination address. • If the instruction is a jump instruction, the instruction-address counter is rewritten by the jump address. • Otherwise the counter is incremented to the address of the next instruction. • Initially, the counter is loaded with the address of the first instruction. FLAT, Spring 2020 Abhijit Das

  10. Simulation of a Modern Computer by a Turing Machine M • M contains six tapes. • The first tape stores the memory of the computer as ⊲ 0 ∗ w 0 # 1 ∗ w 1 # 10 ∗ w 2 # 11 ∗ w 3 # 100 ∗ w 4 # 101 ∗ w 5 # ··· , where w i is the content of the i -th word encoded in binary. • The second tape stores the instruction address. • The third tape stores the operand addresses. • The fourth tape is used for scratch work. • The fifth tape stores the input of the user. • The sixth tape is used to write the outputs to the user. • The finite control stores the information of the instruction set of the computer. FLAT, Spring 2020 Abhijit Das

  11. The Organization of M Finite Control . . . w 2 # 11 Memory 0 w 0 # 1 # 10 # * * w 1 * * w 3 Instruction Address 10011101001110 Operand Address 0111001100010 * 101011100 Rough Work Input Output FLAT, Spring 2020 Abhijit Das

  12. Simulation of an Instruction Cycle • Locate the word whose address is on the second tape. • Read and remember the opcode in the finite control. • Copy the operand addresses (if any) from the rest of the instruction to the third tape. • Locate the operand addresses on the first tape, and copy the operands to the fourth tape. • Apply the operation on the operands on the fourth tape. • The result is produced in the fourth tape. • Locate the destination address on the first tape. • Copy the result to this location (relocation of the rest of the tape content may be needed). • If it is a jump instruction, replace the second tape by the content of the third tape. • Otherwise, increment the second tape by an appropriate amount. FLAT, Spring 2020 Abhijit Das

  13. Handling Input/Output • Input and output are not part of the computation. • There are specific read/write instructions. • A read instruction scans the input from specified addresses on the fifth tape (or sequentially). • A write instruction prints the output to specified addresses on the sixth tape (or sequentially). • Peripheral devices handle these tapes. • A keyboard controller can write to the fifth tape. • A screen controller can read the sixth tape to change the graphic display. • M may have an accept state t and a reject state r . • Upon successful or unsuccessful termination, M goes to t or r , and halts. FLAT, Spring 2020 Abhijit Das

  14. Running Time of the Simulation • Suppose that the computer takes n steps for some computation. • Assume that the words of the computer are of fixed size (like 64 bits). • Overflows during arithmetic operations are ignored. • It can be calculated that the simulation by the TM requires O ( n 3 ) steps. • If we use a single-tape Turing machine, the number of steps is O ( n 6 ) . • If n is a polynomial in the input size, the running time remains polynomial (but of a higher degree). • The notion of polynomial-time computability is quite robust. • Turing machines can perfectly capture this notion. FLAT, Spring 2020 Abhijit Das

  15. No Tutorial Exercises You may informally argue how a Turing machine can simulate a C program (instead of its compiled version). FLAT, Spring 2020 Abhijit Das

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend