Fall 2006Costas Busch - RPI1 Turing Machines
Fall 2006Costas Busch - RPI2 The Language Hierarchy Regular Languages Context-Free Languages ? ?
Fall 2006Costas Busch - RPI3 Regular Languages Context-Free Languages Languages accepted by Turing Machines
Fall 2006Costas Busch - RPI4 A Turing Machine Tape Read-Write head Control Unit
Fall 2006Costas Busch - RPI5 The Tape Read-Write head No boundaries -- infinite length The head moves Left or Right
Fall 2006Costas Busch - RPI Read-Write head The head at each transition (time step): 1. Reads a symbol 2. Writes a symbol 3. Moves Left or Right
Fall 2006Costas Busch - RPI Example: Time Time 1 1. Reads 2. Writes 3. Moves Left
Fall 2006Costas Busch - RPI Time Time 2 1. Reads 2. Writes 3. Moves Right
Fall 2006Costas Busch - RPI9 The Input String Blank symbol head Head starts at the leftmost position of the input string Input string
Fall 2006Costas Busch - RPI10 States & Transitions Read Write Move Left Move Right
Fall 2006Costas Busch - RPI11 Example: Time 1 current state
Fall 2006Costas Busch - RPI Time Time 2
Fall 2006Costas Busch - RPI Time Time 2 Example:
Fall 2006Costas Busch - RPI Time Time 2 Example:
Fall 2006Costas Busch - RPI15 Determinism Allowed Not Allowed No lambda transitions allowed Turing Machines are deterministic
Fall 2006Costas Busch - RPI16 Partial Transition Function Example: No transition for input symbol Allowed:
Fall 2006Costas Busch - RPI17 Halting The machine halts in a state if there is no transition to follow
Fall 2006Costas Busch - RPI18 Halting Example 1: No transition from HALT!!!
Fall 2006Costas Busch - RPI19 Halting Example 2: No possible transition from and symbol HALT!!!
Fall 2006Costas Busch - RPI20 Accepting States Allowed Not Allowed Accepting states have no outgoing transitions The machine halts and accepts
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
Fall 2006Costas Busch - RPI22 Observation: In order to accept an input string, it is not necessary to scan all the symbols in the string
Fall 2006Costas Busch - RPI23 Turing Machine Example Accepts the language: Input alphabet
Fall 2006Costas Busch - RPI24 Time 0
Fall 2006Costas Busch - RPI25 Time 1
Fall 2006Costas Busch - RPI26 Time 2
Fall 2006Costas Busch - RPI27 Time 3
Fall 2006Costas Busch - RPI28 Time 4 Halt & Accept
Fall 2006Costas Busch - RPI29 Rejection Example Time 0
Fall 2006Costas Busch - RPI30 Time 1 No possible Transition Halt & Reject
Fall 2006Costas Busch - RPI31 Accepts the language: but for input alphabet A simpler machine for same language
Fall 2006Costas Busch - RPI32 Time 0 Halt & Accept Not necessary to scan input
Fall 2006Costas Busch - RPI33 Infinite Loop Example A Turing machine for language
Fall 2006Costas Busch - RPI34 Time 0
Fall 2006Costas Busch - RPI35 Time 1
Fall 2006Costas Busch - RPI36 Time 2
Fall 2006Costas Busch - RPI37 Time 2 Time 3 Time 4 Time 5 Infinite loop
Fall 2006Costas Busch - RPI38 Because of the infinite loop: The accepting state cannot be reached The machine never halts The input string is rejected
Fall 2006Costas Busch - RPI39 Another Turing Machine Example Turing machine for the language
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:
Fall 2006Costas Busch - RPI41 Time 0
Fall 2006Costas Busch - RPI42 Time 1
Fall 2006Costas Busch - RPI43 Time 2
Fall 2006Costas Busch - RPI44 Time 3
Fall 2006Costas Busch - RPI45 Time 4
Fall 2006Costas Busch - RPI46 Time 5
Fall 2006Costas Busch - RPI47 Time 6
Fall 2006Costas Busch - RPI48 Time 7
Fall 2006Costas Busch - RPI49 Time 8
Fall 2006Costas Busch - RPI50 Time 9
Fall 2006Costas Busch - RPI51 Time 10
Fall 2006Costas Busch - RPI52 Time 11
Fall 2006Costas Busch - RPI53 Time 12
Fall 2006Costas Busch - RPI54 Halt & Accept Time 13
Fall 2006Costas Busch - RPI55 If we modify the machine for the language we can easily construct a machine for the language Observation:
Fall 2006Costas Busch - RPI56 Formal Definitions for Turing Machines
Fall 2006Costas Busch - RPI57 Transition Function
Fall 2006Costas Busch - RPI58 Transition Function
Fall 2006Costas Busch - RPI59 Turing Machine: States Input alphabet Tape alphabet Transition function Initial state blank Accept states
Fall 2006Costas Busch - RPI60 Configuration Instantaneous description:
Fall 2006Costas Busch - RPI61 Time 4Time 5 A Move: (yields in one mode)
Fall 2006Costas Busch - RPI62 Time 4Time 5 Time 6Time 7 A computation
Fall 2006Costas Busch - RPI63 Equivalent notation:
Fall 2006Costas Busch - RPI64 Initial configuration: Input string
Fall 2006Costas Busch - RPI65 The Accepted Language For any Turing Machine Initial stateAccept state
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:
Fall 2006Costas Busch - RPI67 Computing Functions with Turing Machines
Fall 2006Costas Busch - RPI68 A function Domain: Result Region: has:
Fall 2006Costas Busch - RPI69 A function may have many parameters: Example: Addition function
Fall 2006Costas Busch - RPI70 Integer Domain Unary: Binary: Decimal: We prefer unary representation: easier to manipulate with Turing machines
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
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
Fall 2006Costas Busch - RPI73 Example The function is computable Turing Machine: Input string: unary Output string: unary are integers
Fall 2006Costas Busch - RPI74 Start initial state The 0 is the delimiter that separates the two numbers
Fall 2006Costas Busch - RPI75 Start Finish final state initial state
Fall 2006Costas Busch - RPI76 Finish final state The 0 here helps when we use the result for other operations
Fall 2006Costas Busch - RPI77 Turing machine for function
Fall 2006Costas Busch - RPI78 Execution Example: Time 0 Final Result (=2)
Fall 2006Costas Busch - RPI79 Time 0
Fall 2006Costas Busch - RPI80 Time 1
Fall 2006Costas Busch - RPI81 Time 2
Fall 2006Costas Busch - RPI82 Time 3
Fall 2006Costas Busch - RPI83 Time 4
Fall 2006Costas Busch - RPI84 Time 5
Fall 2006Costas Busch - RPI85 Time 6
Fall 2006Costas Busch - RPI86 Time 7
Fall 2006Costas Busch - RPI87 Time 8
Fall 2006Costas Busch - RPI88 Time 9
Fall 2006Costas Busch - RPI89 Time 10
Fall 2006Costas Busch - RPI90 Time 11
Fall 2006Costas Busch - RPI91 HALT & accept Time 12
Fall 2006Costas Busch - RPI92 Another Example The function is computable Turing Machine: Input string: unary Output string:unary is integer
Fall 2006Costas Busch - RPI93 Start Finish accept state initial state
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
Fall 2006Costas Busch - RPI95 Turing Machine for
Fall 2006Costas Busch - RPI96 Example Start Finish
Fall 2006Costas Busch - RPI97 Another Example The function is computable if Input: Output: or
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
Fall 2006Costas Busch - RPI99 Combining Turing Machines
Fall 2006Costas Busch - RPI100 Block Diagram Turing Machine inputoutput
Fall 2006Costas Busch - RPI101 Example: if Comparator Adder Eraser