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

turing machine as transducer
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

1 Turing Machines

Computation and programming

Turing Machine as Transducer

 Transducer -- any device that converts

a signal from one form to another

 Turning machine

 Converts input to output  Start with string on the tape  After acceptance string left on the tape

Computation with Turing Machines

 Computing functions with TMs

 The result of the function applied to an

input string x, will be left on the tape when the machine accepts.

 Functions with multiple arguments can be

placed on the input tape with arguments separated by some character.

Computation with Turing Machines

 Turing’s original use of his machine was to

calculate integer valued functions.

 Integers were represented in unary as blocks of a

single symbol.

 Example

 111111 would represent 6  1111 would represent 4

 In our text

 1s are used as the unary symbol  0s are used to separate arguments

Computation with Turing Machines

 Computing functions with TMs

 Formally,

 Let M = (Q, Σ, Γ , δ, q0, , F) be a TM and let

f be a partial function on Σ*. We say T computes f (or f is Turing-computable) if for every x ∈ Σ* where f is defined:

 q0x a

* pf(x)  Where p ∈ F  And for every other x, T rejects on input x.

Computation with Turing Machines

 Computing functions with TMs

 Formally (with multiple arguments)

 Let M = (Q, Σ, Γ , δ, q0, , F) be a TM and let f be a

partial function on (Σ*) k. We say T computes f (or f is Turing-computable) if for every (x1, x2. …, xk) where f is defined:

 q0x1 0x2… 0xk a * pf(x1, x2. …, xk)  Where p ∈ F  And for every other k-tuple, T rejects on input x.

slide-2
SLIDE 2

2 Example

 Addition x + y

 Create a machine that will perform the

computation

 q01x01y a

* p1x1y

 Where p ∈ F

Example

 Addition x + y

 q01x01y a

* p1x1y

 Basic idea: Simply remove the 0 between

the two sets of ones.

 Read all 1s up to 1st 0  Replace 0 with 1  Remove last 1

Example

 Addition (JFLAP)

Another example

 “Copy routine”

 Copies its input and concatenates a copy of

itself on the tape

 q01x a

* p1x1x

Another example

 “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

Another example

 “copy routine”

slide-3
SLIDE 3

3 One more example

 A simple “if” statement

 Create a TM that will accept in one state if a

condition is true (e.g. x ≤ y) and another if the condition is false.

 q01x01y a

* p1x01y if x > y

 q01x01y a

* r1x01y if x ≤ y

 Note that contents of tape is the same after

computation.

One more example

 Simple “if” statement

 Basic idea: similar to 0i1i example

 Match 1’s before 0 with 1’s after.  Will either exhaust all initial 1s or trailing 1’s.  Go to target state based on cases above  MUST return tape to initial input when done.

If statement Reality check

 Turing Machine as transducer

 Converts input to output

 Turing-Computable functions

Combining Turing Machines

 Suppose an algorithm has a number of

tasks to perform

 Each task has its own TM

 Much like subroutines or functions

 They can be combined into a single TM

 T1T2 is the composite TM  T1 → T2

Combining Turing Machines

 Composite TMs

 T1T2

 Start at start state of T1  For any move that causes T1 to enter the halt

state, have T1 move to the start state of T2.

 So T2 will get executed immediately after T1 as

long as T1 will halt on a given input.

 Allows one to define subroutines.

slide-4
SLIDE 4

4 TMs and subroutines

 Each TM “subroutine” must define

 Start state  The final state (with conditions)  Contents of tape after acceptance  Position of tape head after acceptance

TMs and subroutines

 Example

f (x,y) = x + y if x > y 0 otherwise

  • TMs and subroutines

 Now we have TMs for doing the

following

 Logical compare of x with y  Addition of x with y

 We could easily write one:

 Erasing all 1s

TM and Subroutines

 The “Eraser”

TM building blocks

f (x,y) = x + y if x > y 0 otherwise

  • TM and subroutines

 Modified “if”

slide-5
SLIDE 5

5 Building TM from blocks

Let’s try a non-context free 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 language

 Example

 L = { xx | x ∈ { a, b }* }  Three “subroutines”

 Find and mark the middle of the string  Convert the 1st half of the string back to lower

case.

 Match and compare

Let’s try a non-context free language

 Example

 L = { xx | x ∈ { a, b }* }  Finding the middle of the string

 Convert first character to it’s upper case equiv.  Move all the way to the right to the last lower

case character and change it to upper case.

 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 language

 Example

 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.

Let’s try a non-context free language

 Middle

slide-6
SLIDE 6

6

Let’s try a non-context free language

 Once you’ve found the middle,

 Convert the 1st 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 language

 Tolower

Let’s try a non-context free language

 Once you’ve found the middle and converted to lower

case

 Start from the left of the tape  Match lower case chars in 1st half with upper case chars in the

2nd.

 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 language

 Match

Let’s try a non-context free language

 Putting it together

Questions?

slide-7
SLIDE 7

7 Summary

 Turing Machines  Computation on TMs  Subroutines  Questions

To come

 Next time:

 TM Variants  Languages associated with TMs.