TOPIC
Turing Machine
Programming Techniques
Group Member
Basit Hussain 2017 – CS- 126
Hamza 2017 – CS- 105
Irtiza 2017 – CS- 126
Minhaj Wajid 2017 – CS- 051
Muhammad Umer Khan 2017 – CS- 027
Tu r i n g M a c h i n e P r o g r a m m i n g Te c h n i q u e s
Problem: How can we recognize the left end of the tape of a Turing machine?
Solution: Put a Special Symbol $ on the left end of the Tape and shift the
input over one cell to the right
a a a b b a ….
a a a b b a ….$
Tu r i n g M a c h i n e P r o g r a m m i n g Te c h n i q u e s
over one cell to the right.
a a a b b a ….
a a a b b a ….$
D
B
C
A
a $, R
a a, R
a, L
$ $, R
b $, R
a b, R b a, R
a a, L
b b, L
b, L
b b, R
Tu r i n g M a c h i n e P r o g r a m m i n g Te c h n i q u e s
Example: Building a Turing Machine to recognize the language 0N 1N 0N
We already hava a Turing Machine to turn 0N 1N to XN YN and to decide
that language.
USE THIS TURING MACHINE AS A SUBROUTINE
IDEA
Tu r i n g M a c h i n e P r o g r a m m i n g Te c h n i q u e s
Example: Building a Turing Machine to recognize the language 0N 1N 0N
Step 1: 0 0 0 0 1 1 1 1 0 0 0 0
x x x x y y y y 0 0 0 0
Step 2: Build a similar Turing Machine to recognize yN 0N
Step 3: Build a final Turing Machine combining these two smaller
Turinng Machine together into one larger Turing Machine
Tu r i n g M a c h i n e P r o g r a m m i n g Te c h n i q u e s
Comparing Two Strings
A Turing Machine to decide { w # w | w E {a, b, c}*}
Solution:
• Use a new Symbol such as ‘x’.
• Replace each Symbol into an x after it has been examined.
Tu r i n g M a c h i n e P r o g r a m m i n g Te c h n i q u e s
Solution:
• Use a new Symbol such as ‘x’.
• Replace each Symbol into an x after it has been examined.
a b b a c # a b b a c
x b b a c # a b b a c
x x b a c # a b b a c
x x x c # a b b a c
a b x a c # a b b a c
a b b a c # a b b a c
We lost the original
String
Tu r i n g M a c h i n e P r o g r a m m i n g Te c h n i q u e s
Problem:
Can we do its non-destructively? i.e without losing the original strings?
Solution:
Replace each unique symbol with another unique symbol instead of replacing
all with the same symbol.
a b b a c # a b b a c
p q q p r # p q q p r
Restore the original string if required

Automata presentation turing machine programming techniques

  • 1.
  • 2.
    Group Member Basit Hussain2017 – CS- 126 Hamza 2017 – CS- 105 Irtiza 2017 – CS- 126 Minhaj Wajid 2017 – CS- 051 Muhammad Umer Khan 2017 – CS- 027
  • 3.
    Tu r in g M a c h i n e P r o g r a m m i n g Te c h n i q u e s Problem: How can we recognize the left end of the tape of a Turing machine? Solution: Put a Special Symbol $ on the left end of the Tape and shift the input over one cell to the right a a a b b a …. a a a b b a ….$
  • 4.
    Tu r in g M a c h i n e P r o g r a m m i n g Te c h n i q u e s over one cell to the right. a a a b b a …. a a a b b a ….$ D B C A a $, R a a, R a, L $ $, R b $, R a b, R b a, R a a, L b b, L b, L b b, R
  • 5.
    Tu r in g M a c h i n e P r o g r a m m i n g Te c h n i q u e s Example: Building a Turing Machine to recognize the language 0N 1N 0N We already hava a Turing Machine to turn 0N 1N to XN YN and to decide that language. USE THIS TURING MACHINE AS A SUBROUTINE IDEA
  • 6.
    Tu r in g M a c h i n e P r o g r a m m i n g Te c h n i q u e s Example: Building a Turing Machine to recognize the language 0N 1N 0N Step 1: 0 0 0 0 1 1 1 1 0 0 0 0 x x x x y y y y 0 0 0 0 Step 2: Build a similar Turing Machine to recognize yN 0N Step 3: Build a final Turing Machine combining these two smaller Turinng Machine together into one larger Turing Machine
  • 7.
    Tu r in g M a c h i n e P r o g r a m m i n g Te c h n i q u e s Comparing Two Strings A Turing Machine to decide { w # w | w E {a, b, c}*} Solution: • Use a new Symbol such as ‘x’. • Replace each Symbol into an x after it has been examined.
  • 8.
    Tu r in g M a c h i n e P r o g r a m m i n g Te c h n i q u e s Solution: • Use a new Symbol such as ‘x’. • Replace each Symbol into an x after it has been examined. a b b a c # a b b a c x b b a c # a b b a c x x b a c # a b b a c x x x c # a b b a c a b x a c # a b b a c a b b a c # a b b a c We lost the original String
  • 9.
    Tu r in g M a c h i n e P r o g r a m m i n g Te c h n i q u e s Problem: Can we do its non-destructively? i.e without losing the original strings? Solution: Replace each unique symbol with another unique symbol instead of replacing all with the same symbol. a b b a c # a b b a c p q q p r # p q q p r Restore the original string if required