Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 461 – Oct. 26 TM practice Arithmetic on a TM TM variants (handout)

Similar presentations


Presentation on theme: "CS 461 – Oct. 26 TM practice Arithmetic on a TM TM variants (handout)"— Presentation transcript:

1 CS 461 – Oct. 26 TM practice Arithmetic on a TM TM variants (handout)
0*1* Twice as many 0’s as 1’s Palindrome… Adding register(s) to simplify programming Arithmetic on a TM TM variants (handout) Adding more features doesn’t add power. If a TM can’t do it, nothing can.

2 Palindrome If “0”/”1”, change to _ and go to 2/4. If _, accept.
Continue right until _. Then go left and go to 3. If “0”, change to _, go left. Go to 6. If “1” reject (states 4,5 are analogous to 2,3) If “1”, change to _, go left. Go to 6. If “0” reject. Continue left until _. Turn right. Start over at 1.

3 Closer look at δ [s1]101 _[s4]01 _0[s4]1 _01[s4]_ _0[s5]1 _[s6]0_
 transitions have been added. State 1 _ 2, _, R 4, _, R 2 2, 0, R 2, 1, R 3, _, L 3 6, _, L Reject 4 4, 0, R 4, 1, R 5, _, L 5 6 6, 0, L 6, 1, L 1, _, R

4 Registers In palindrome example, we needed 2 extra states because leftmost input symbol could be 0 or 1. What if alphabet were { a, b, c, … z } ? Do we literally want 2*25 more states?  In place of those extra states, store a finite amount of information in TM’s “control unit”, just like registers in CPU. With a register, our state is just an ordered pair like (2, ‘t’). More and more, a TM is looking like a computer!

5 New palindrome If _, accept. Otherwise copy first symbol to register. Change tape to _ and go to 2. Continue right until _. Then go left and go to 3. If input matches register, change to _, go left. Go to 6. If no match, reject. (if _, accept) Continue left until _. Turn right. Start over at 1.

6 Arithmetic Can do binary addition on a TM.
Method #1: Unary programming  Input is of the form for Method #2: With binary notation: Modify our definition of TM so it can have 3 parallel tracks on the tape. The third track can hold the answer. Can do other operations analogously.

7 Unary + Make sure input is of the form 1*01*. If not, reject. If so, put = at end and go back to beginning of word. Copy all the 1s on left side of 0 to the right end of word. Copy all the 1s between the 0 and = to the right end of word. This is just an outline, and I didn’t attempt to count exact number of states needed. If we didn’t care about changing the input, we could just get rid of the 0 and squeeze the 1s together!

8 TM Variants Based on additional features.
Can save a lot of effort. Multi-tape probably most useful. We can show that a new feature can be emulated by the ordinary TM model.  Nothing can beat a TM. The extra bells and whistles just make programming easier.

9 Some variants Allowing a TM to “stay put” instead of having to move left or right.  Multi-tape (not to be confused with multi-track tape) Makes use of stay-put Scanning the “virtual heads”  Non-deterministic Makes use of multi-tape

10 Non-determinism The non-deterministic computations can be arranged in a tree. If we want to deterministically search this tree, DFS or BFS? P. 151: Tape 3 will contain a list of transitions to experiment on. Copy tape 1 to tape 2, and use tape 2 for scratch work. If reject, increment tape 3 to next possible set of transitions. Ex. Accept the union of 2+ languages Ex. For some language L, design a TM that will accept substrings (of length 3) of these words.

11 Computer A TM with multiple tapes can simulate a computer.
One tape contains data and instruction memory. Unfortunately, need to label each with address. One tape can store the address of current instruction. Another tape can store address of data operand. Finally, a tape for scratch work.


Download ppt "CS 461 – Oct. 26 TM practice Arithmetic on a TM TM variants (handout)"

Similar presentations


Ads by Google