fall 2006costas busch - rpi1 turing machines. fall 2006costas busch - rpi2 the language hierarchy...

Download Fall 2006Costas Busch - RPI1 Turing Machines. Fall 2006Costas Busch - RPI2 The Language Hierarchy Regular Languages Context-Free Languages ? ?

Post on 29-Mar-2015

223 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

  • Slide 1

Fall 2006Costas Busch - RPI1 Turing Machines Slide 2 Fall 2006Costas Busch - RPI2 The Language Hierarchy Regular Languages Context-Free Languages ? ? Slide 3 Fall 2006Costas Busch - RPI3 Regular Languages Context-Free Languages Languages accepted by Turing Machines Slide 4 Fall 2006Costas Busch - RPI4 A Turing Machine...... Tape Read-Write head Control Unit Slide 5 Fall 2006Costas Busch - RPI5 The Tape...... Read-Write head No boundaries -- infinite length The head moves Left or Right Slide 6 Fall 2006Costas Busch - RPI6...... Read-Write head The head at each transition (time step): 1. Reads a symbol 2. Writes a symbol 3. Moves Left or Right Slide 7 Fall 2006Costas Busch - RPI7...... Example: Time 0...... Time 1 1. Reads 2. Writes 3. Moves Left Slide 8 Fall 2006Costas Busch - RPI8...... Time 1...... Time 2 1. Reads 2. Writes 3. Moves Right Slide 9 Fall 2006Costas Busch - RPI9 The Input String...... Blank symbol head Head starts at the leftmost position of the input string Input string Slide 10 Fall 2006Costas Busch - RPI10 States & Transitions Read Write Move Left Move Right Slide 11 Fall 2006Costas Busch - RPI11 Example:...... Time 1 current state Slide 12 Fall 2006Costas Busch - RPI12...... Time 1...... Time 2 Slide 13 Fall 2006Costas Busch - RPI13...... Time 1...... Time 2 Example: Slide 14 Fall 2006Costas Busch - RPI14...... Time 1...... Time 2 Example: Slide 15 Fall 2006Costas Busch - RPI15 Determinism Allowed Not Allowed No lambda transitions allowed Turing Machines are deterministic Slide 16 Fall 2006Costas Busch - RPI16 Partial Transition Function...... Example: No transition for input symbol Allowed: Slide 17 Fall 2006Costas Busch - RPI17 Halting The machine halts in a state if there is no transition to follow Slide 18 Fall 2006Costas Busch - RPI18 Halting Example 1:...... No transition from HALT!!! Slide 19 Fall 2006Costas Busch - RPI19 Halting Example 2:...... No possible transition from and symbol HALT!!! Slide 20 Fall 2006Costas Busch - RPI20 Accepting States Allowed Not Allowed Accepting states have no outgoing transitions The machine halts and accepts Slide 21 Fall 2006Costas Busch - RPI21 Acceptance Accept Input If machine halts in an accept state Reject Input If machine halts in a non-accept state or If machine enters an infinite loop string Slide 22 Fall 2006Costas Busch - RPI22 Observation: In order to accept an input string, it is not necessary to scan all the symbols in the string Slide 23 Fall 2006Costas Busch - RPI23 Turing Machine Example Accepts the language: Input alphabet Slide 24 Fall 2006Costas Busch - RPI24 Time 0 Slide 25 Fall 2006Costas Busch - RPI25 Time 1 Slide 26 Fall 2006Costas Busch - RPI26 Time 2 Slide 27 Fall 2006Costas Busch - RPI27 Time 3 Slide 28 Fall 2006Costas Busch - RPI28 Time 4 Halt & Accept Slide 29 Fall 2006Costas Busch - RPI29 Rejection Example Time 0 Slide 30 Fall 2006Costas Busch - RPI30 Time 1 No possible Transition Halt & Reject Slide 31 Fall 2006Costas Busch - RPI31 Accepts the language: but for input alphabet A simpler machine for same language Slide 32 Fall 2006Costas Busch - RPI32 Time 0 Halt & Accept Not necessary to scan input Slide 33 Fall 2006Costas Busch - RPI33 Infinite Loop Example A Turing machine for language Slide 34 Fall 2006Costas Busch - RPI34 Time 0 Slide 35 Fall 2006Costas Busch - RPI35 Time 1 Slide 36 Fall 2006Costas Busch - RPI36 Time 2 Slide 37 Fall 2006Costas Busch - RPI37 Time 2 Time 3 Time 4 Time 5 Infinite loop Slide 38 Fall 2006Costas Busch - RPI38 Because of the infinite loop: The accepting state cannot be reached The machine never halts The input string is rejected Slide 39 Fall 2006Costas Busch - RPI39 Another Turing Machine Example Turing machine for the language Slide 40 Fall 2006Costas Busch - RPI40 Match as with bs: Repeat: replace leftmost a with x find leftmost b and replace it with y Until there are no more as or bs If there is a remaining a or b reject Basic Idea: Slide 41 Fall 2006Costas Busch - RPI41 Time 0 Slide 42 Fall 2006Costas Busch - RPI42 Time 1 Slide 43 Fall 2006Costas Busch - RPI43 Time 2 Slide 44 Fall 2006Costas Busch - RPI44 Time 3 Slide 45 Fall 2006Costas Busch - RPI45 Time 4 Slide 46 Fall 2006Costas Busch - RPI46 Time 5 Slide 47 Fall 2006Costas Busch - RPI47 Time 6 Slide 48 Fall 2006Costas Busch - RPI48 Time 7 Slide 49 Fall 2006Costas Busch - RPI49 Time 8 Slide 50 Fall 2006Costas Busch - RPI50 Time 9 Slide 51 Fall 2006Costas Busch - RPI51 Time 10 Slide 52 Fall 2006Costas Busch - RPI52 Time 11 Slide 53 Fall 2006Costas Busch - RPI53 Time 12 Slide 54 Fall 2006Costas Busch - RPI54 Halt & Accept Time 13 Slide 55 Fall 2006Costas Busch - RPI55 If we modify the machine for the language we can easily construct a machine for the language Observation: Slide 56 Fall 2006Costas Busch - RPI56 Formal Definitions for Turing Machines Slide 57 Fall 2006Costas Busch - RPI57 Transition Function Slide 58 Fall 2006Costas Busch - RPI58 Transition Function Slide 59 Fall 2006Costas Busch - RPI59 Turing Machine: States Input alphabet Tape alphabet Transition function Initial state blank Accept states Slide 60 Fall 2006Costas Busch - RPI60 Configuration Instantaneous description: Slide 61 Fall 2006Costas Busch - RPI61 Time 4Time 5 A Move: (yields in one mode) Slide 62 Fall 2006Costas Busch - RPI62 Time 4Time 5 Time 6Time 7 A computation Slide 63 Fall 2006Costas Busch - RPI63 Equivalent notation: Slide 64 Fall 2006Costas Busch - RPI64 Initial configuration: Input string Slide 65 Fall 2006Costas Busch - RPI65 The Accepted Language For any Turing Machine Initial stateAccept state Slide 66 Fall 2006Costas Busch - RPI66 If a language is accepted by a Turing machine then we say that is: Turing Acceptable Recursively Enumerable Turing Recognizable Other names used: Slide 67 Fall 2006Costas Busch - RPI67 Computing Functions with Turing Machines Slide 68 Fall 2006Costas Busch - RPI68 A function Domain: Result Region: has: Slide 69 Fall 2006Costas Busch - RPI69 A function may have many parameters: Example: Addition function Slide 70 Fall 2006Costas Busch - RPI70 Integer Domain Unary: Binary: Decimal: 11111 101 5 We prefer unary representation: easier to manipulate with Turing machines Slide 71 Fall 2006Costas Busch - RPI71 Definition: A function is computable if there is a Turing Machine such that: Initial configurationFinal configuration Domain accept stateinitial state For all Slide 72 Fall 2006Costas Busch - RPI72 Initial Configuration Final Configuration A function is computable if there is a Turing Machine such that: In other words: Domain For all Slide 73 Fall 2006Costas Busch - RPI73 Example The function is computable Turing Machine: Input string: unary Output string: unary are integers Slide 74 Fall 2006Costas Busch - RPI74 Start initial state The 0 is the delimiter that separates the two numbers Slide 75 Fall 2006Costas Busch - RPI75 Start Finish final state initial state Slide 76 Fall 2006Costas Busch - RPI76 Finish final state The 0 here helps when we use the result for other operations Slide 77 Fall 2006Costas Busch - RPI77 Turing machine for function Slide 78 Fall 2006Costas Busch - RPI78 Execution Example: Time 0 Final Result (=2) Slide 79 Fall 2006Costas Busch - RPI79 Time 0 Slide 80 Fall 2006Costas Busch - RPI80 Time 1 Slide 81 Fall 2006Costas Busch - RPI81 Time 2 Slide 82 Fall 2006Costas Busch - RPI82 Time 3 Slide 83 Fall 2006Costas Busch - RPI83 Time 4 Slide 84 Fall 2006Costas Busch - RPI84 Time 5 Slide 85 Fall 2006Costas Busch - RPI85 Time 6 Slide 86 Fall 2006Costas Busch - RPI86 Time 7 Slide 87 Fall 2006Costas Busch - RPI87 Time 8 Slide 88 Fall 2006Costas Busch - RPI88 Time 9 Slide 89 Fall 2006Costas Busch - RPI89 Time 10 Slide 90 Fall 2006Costas Busch - RPI90 Time 11 Slide 91 Fall 2006Costas Busch - RPI91 HALT & accept Time 12 Slide 92 Fall 2006Costas Busch - RPI92 Another Example The function is computable Turing Machine: Input string: unary Output string:unary is integer Slide 93 Fall 2006Costas Busch - RPI93 Start Finish accept state initial state Slide 94 Fall 2006Costas Busch - RPI94 Turing Machine Pseudocode for Replace every 1 with $ Repeat: Find rightmost $, replace it with 1 Go to right end, insert 1 Until no more $ remain Slide 95 Fall 2006Costas Busch - RPI95 Turing Machine for Slide 96 Fall 2006Costas Busch - RPI96 Example Start Finish Slide 97 Fall 2006Costas Busch - RPI97 Another Example The function is computable if Input: Output: or Slide 98 Fall 2006Costas Busch - RPI98 Turing Machine Pseudocode: Match a 1 from with a 1 from Repeat Until all of or is matched If a 1 from is not matched erase tape, write 1 else erase tape, write 0 Slide 99 Fall 2006Costas Busch - RPI99 Combining Turing Machines Slide 100 Fall 2006Costas Busch - RPI100 Block Diagram Turing Machine inputoutput Slide 101 Fall 2006Costas Busch - RPI101 Example: if Comparator Adder Eraser

Recommended

View more >