Constructing Complex Turing Machines Idea Use a modular











- Slides: 11
Constructing Complex Turing Machines Idea: Use a modular approach similar to the one use to construct complex programs Example (programming): Given two n n matrixes A and B to compute ABT we: 1. Construct a procedure to compute BT, transverse(B, C) 2. Construct a procedure to multiply two matrices, multiply(B, C, D) 3. Call transverse(B, C) and then multiply(A, C, D). D contains the answer
Graphical Conventions We will use a convention similar to a flow chart to indicate how to put together Turing machines (TMs). Convention. Let A and B be 2 TMs, and a be a character in then: A; a A B if a then B Means that: 1. If A halts in a configuration of the form (h, w 1 aw 2), where w 1 or w 2 are any words 2. Then B starts with the configuration (s, w 1 aw 2), where s is the initial state in B
Graphical Conventions (2) M a A a B M; If a then A else B Means that: • • If M halts in a configuration of the form (h, w 1 aw 2), then A starts with the configuration (s, w 1 aw 2), where s is the initial state of A If M halts in a configuration of the form (h, w 1 w 2) with a, then B starts with the configuration (s’, w 1 w 2), where s’ is the initial state in B
Graphical Conventions (3) a A a while (not a) do A Means that: • If the initial configuration has the form (s, w 1 w 2), then A starts with this configuration if a, where s is the initial state in A • If A halts in a configuration of the form (h, w 1 w 2) with a, then A starts with the configuration (s, w 1 w 2)
Basic Turing Machines a Denotes “write a on the current cell” (a is a character in ) Denotes “move to the right of the current cell” (the book uses “R” instead of “ ”) Denotes “move to the left of the current cell” (the book uses “L” instead of “ ”)
Other Simple Turing Machines Machine a � b a What it does “if current cell has an a, then replace it with a b” “if current cell has a character a different than �, then move once to the right and write that a”
The � Turing Machine – � • What it does? Move to the right until if finds �
The � Turing Machine Draw diagram for � – �
–� and –� – Move to the left until the first non-blank space cell � is found – � Move to the right until the first non-blank space cell is found
The Conventions • 2 simple rules: • Rule # 1: R “move to the right until you find “ R “move to the right until you find a symbol other than “ Note: first check. Then move (think of a “while”) • Rule # 2: “Never forget Rule # 1” (Mr Miogi, The Karate Kid)
Example: The (ab)* Turing Machine a b 1 �? ? a b a a 0 �? ?