turing machine as transducer
play

Turing Machine as Transducer Transducer -- any device that converts - PDF document

Turing Machine as Transducer Transducer -- any device that converts Turing Machines a signal from one form to another Turning machine Computation and programming Converts input to output Start with string on the tape After


  1. Turing Machine as Transducer  Transducer -- any device that converts Turing Machines a signal from one form to another  Turning machine Computation and programming  Converts input to output  Start with string on the tape  After acceptance string left on the tape Computation with Turing Computation with Turing Machines Machines  Computing functions with TMs  Turing’s original use of his machine was to calculate integer valued functions.  The result of the function applied to an  Integers were represented in unary as blocks of a input string x, will be left on the tape when single symbol. the machine accepts.  Example  Functions with multiple arguments can be  111111 would represent 6 placed on the input tape with arguments  1111 would represent 4 separated by some character.  In our text  1s are used as the unary symbol  0s are used to separate arguments Computation with Turing Computation with Turing Machines Machines  Computing functions with TMs  Computing functions with TMs  Formally,  Formally (with multiple arguments)  Let M = (Q, Σ , Γ , δ , q 0 ,  , F) be a TM and let f be a  Let M = (Q, Σ , Γ , δ , q 0 ,  , F) be a TM and let partial function on ( Σ *) k . We say T computes f (or f is f be a partial function on Σ * . We say T Turing-computable) if for every (x 1 , x 2 . …, x k ) where f is computes f (or f is Turing-computable) if for defined: every x ∈ Σ * where f is defined:  q 0 x 1 0x 2 … 0x k a * pf(x 1 , x 2 . …, x k )  q 0 x a * pf(x)  Where p ∈ F  Where p ∈ F  And for every other k-tuple, T rejects on input x.  And for every other x, T rejects on input x. 1

  2. Example Example  Addition x + y  Addition x + y  q 0 1 x 01 y a * p1 x 1 y  Create a machine that will perform the computation  q 0 1 x 01 y a * p1 x 1 y  Basic idea: Simply remove the 0 between the two sets of ones.  Where p ∈ F  Read all 1s up to 1st 0  Replace 0 with 1  Remove last 1 Example Another example  Addition (JFLAP)  “Copy routine”  Copies its input and concatenates a copy of itself on the tape  q 0 1 x a * p1 x 1 x Another example Another example  “copy routine”  “copy routine”  Basic idea:  “count” number of 1’s by replacing with X  Go back and re-read all Xs and as you re-read each X, add a 1 to the end of the tape.  Repeat until all Xs are converted back to 1s 2

  3. One more example One more example  A simple “if” statement  Simple “if” statement  Create a TM that will accept in one state if a  Basic idea: similar to 0 i 1 i example condition is true (e.g. x ≤ y) and another if the condition is false.  Match 1’s before 0 with 1’s after.  Will either exhaust all initial 1s or trailing 1’s.  q 0 1 x 01 y a * p1 x 01 y if x > y  Go to target state based on cases above  q 0 1 x 01 y a * r1 x 01 y if x ≤ y  MUST return tape to initial input when done.  Note that contents of tape is the same after computation. If statement Reality check  Turing Machine as transducer  Converts input to output  Turing-Computable functions Combining Turing Machines Combining Turing Machines  Suppose an algorithm has a number of  Composite TMs tasks to perform  T 1 T 2  Each task has its own TM  Start at start state of T 1  For any move that causes T 1 to enter the halt  Much like subroutines or functions state, have T 1 move to the start state of T 2 .  They can be combined into a single TM  So T 2 will get executed immediately after T 1 as  T 1 T 2 is the composite TM long as T 1 will halt on a given input.  T 1 → T 2  Allows one to define subroutines. 3

  4. TMs and subroutines TMs and subroutines  Each TM “subroutine” must define  Example  Start state  The final state (with conditions) f ( x , y ) = x + y if x > y �  Contents of tape after acceptance � 0 otherwise �  Position of tape head after acceptance TMs and subroutines TM and Subroutines  Now we have TMs for doing the  The “Eraser” following  Logical compare of x with y  Addition of x with y  We could easily write one:  Erasing all 1s TM building blocks TM and subroutines  Modified “if” � f ( x , y ) = x + y if x > y � 0 otherwise � 4

  5. Let’s try a non-context free Building TM from blocks language  Example  L = { xx | x ∈ { a, b } * }  Basic idea  Find and mark the middle of the string  Compare characters starting from the start of the string with characters starting from the middle of the string. Let’s try a non-context free Let’s try a non-context free language language  Example  Example  L = { xx | x ∈ { a, b } * }  L = { xx | x ∈ { a, b } * }  Three “subroutines”  Finding the middle of the string  Find and mark the middle of the string  Convert first character to it’s upper case equiv.  Convert the 1 st half of the string back to lower  Move all the way to the right to the last lower case. case character and change it to upper case.  Match and compare  Move all the way back left to the first lower case character and change it to upper case  And so on. Let’s try a non-context free Let’s try a non-context free language language  Example  Middle  L = { xx | x ∈ { a, b } * }  Finding the middle of the string  Start with tape head at first symbol on tape  End with tape head at the last character of the 1st half of string  Will reject if string is not even. 5

  6. Let’s try a non-context free Let’s try a non-context free language language  Once you’ve found the middle,  Tolower  Convert the 1 st half of the string back to lower case.  Start from current tape position and change read backwards to end converting characters along the way.  Leaves tape at start of input when done. Let’s try a non-context free Let’s try a non-context free language language  Once you’ve found the middle and converted to lower  Match case  Start from the left of the tape  Match lower case chars in 1 st half with upper case chars in the 2 nd .  Replace a matched upper case char with blanks  Repeat until only 1st half remains  Assumes string of form llUU  The routine will leave the repeated string on the tape Let’s try a non-context free Questions? language  Putting it together 6

  7. Summary To come  Turing Machines  Next time:  Computation on TMs  TM Variants  Languages associated with TMs.  Subroutines  Questions 7

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