Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.

Similar presentations


Presentation on theme: "CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons."— Presentation transcript:

1 CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Based on a work at http://peerinstruction4cs.org. Permissions beyond the scope of this license may be available at http://peerinstruction4cs.org.

2 TURING MACHINES At last we reach: 2

3 Turing Machine Model 3 Draw a picture here

4 PDA’s vs. Turing Machines PDA Processes input string left to right Only memory access is the top of the stack Non-deterministic Halts when all input is read No “blank” symbol Both models: infinite memory Turing Machine Processes input string in any order; it starts out on the tape Can move tape head to any point on the tape Deterministic Halts whenever q_accept or q_reject is reached “Blank” symbol included

5 Important Turing Machine detail There is ONE way for a Turing Machine to accept a string. – Visit state q accept ; the machine halts and accepts. There are TWO ways for a Turing Machine to not accept a string. – Visit state q reject ; the machine halts and rejects. – Infinite loop. The LANGUAGE of a Turing machine is: the set of strings that are accepted by a Turing machine. All strings that are NOT accepted are NOT in the language.

6 Turing Machine Formal Description In the TM transition function δ: Q x Γ -> Q x Γ x {L,R}, a given input of the transition function is: a)A current state, a character read, and whether we came from the left or right b)A current state, a character read c)A current state, a character to write d)A destination state, a character read e)None of the above or more than one of the above 6

7 Turing Machine Formal Description In the TM transition function δ: Q x Γ -> Q x Γ x {L,R}, a given output of the transition function is: a)A current state, a character read, and whether we came from the left or right b)A current state, a character to write, and whether we should next go left or right c)A destination state, a character read, and whether we should write ‘L’ or ‘R’ d)A destination state, a character to write, and whether we should next go left or right e)None of the above or more than one of the above 7

8 Turing Machine configurations Suppose we have at TM s.t. Γ={a,b,c,d,_}, Q = {q x | 1≤x≤10} U {q acc,q rej }. Suppose the current configuration is xbq 1 ay. What does this mean? a)The TM is in state q 1, the tape contains “xbay”, and the tape head is on the “b”. b)The TM is in state q 1, the tape contains “xbay”, and the tape head is on the “a”. c)The TM is in state q 1, the tape contains “xbq 1 ay”, and we don’t know where the tape head is. 8

9 Executing a Transition, “yields” Suppose we have at TM s.t. Γ={a,b,c,d,_}, Q = {q x | 1≤x≤10} U {q acc,q rej }, and the transition function includes rules δ(q 1,a) = (q 3,b,R) and δ(q 1,b) = (q 3,a,L). We also have strings x,y in Γ*. Which configuration does the current configuration, xbq 1 ay, yield? a)xq 3 bay b)xbbq 3 y c)xbaq 3 by d)xq 3 aay e)None of the above or more than one of the above 9

10 Executing a Transition, “yields” Suppose we have at TM s.t. Γ={a,b,c,d,_}, Q = {q 1, q 2, q 3, q 4,q acc,q rej }, and the transition function includes rules δ(q 2,c) = (q 3,d,R) and δ(q 2,d) = (q 3,c,L). We also have strings u,v,x,y in Γ*. Which configuration does the current configuration, xcq 2 dy, yield? a)xq 3 ddy b)xcdq 3 y c)xq 3 ccy d)xq 3 ccdy e)None of the above or more than one of the above 10

11 More Transition Function (a) TRUE (b) FALSE x0q rej 11y yields x01q 1 1y can never happen in any Turing Machine 11

12 DECIDABLE AND TURING- RECOGNIZABLE LANGUAGES Turing machines give you these: 12

13 So a language is not context-free. What is it? L = {1^{2 n } | n ≥ 0}. Not context-free. – Exercise: prove it! – So there is no PDA or CFG with L as its language. – What about Turing Machines? Regular Context-Free What about this stuff???

14 L = {1^{2 n } | n ≥ 0} WHOA, that looks complicated. Let’s break this down.

15 L = {1^{2 n } | n ≥ 0} How could you check to see if a number is a power of 2? a)Check to see if it’s even b)Keep on dividing by 2; if you get an odd number, it’s not a power of 2 c)Keep on dividing by 2; if you get an odd number > 2, it’s not a power of 2 d)Keep on dividing by 2; if you get down to 0, it’s a power of 2

16 L = {1^{2 n } | n ≥ 0} STEP 1: Scan the tape left to right, cross off every other 1, keep track if the number of 1’s is even, odd, or equal to 1. No 1’s One 1 Even 1’s Odd 1’s

17 L = {1^{2 n } | n ≥ 0} STEP 2: If you’re left with just one 1, halt and accept! No 1’s One 1 Even 1’s Odd 1’s

18 L = {1^{2 n } | n ≥ 0} STEP 3: If you’re left with an odd number of 1’s, but more than one, halt and reject! No 1’s One 1 Even 1’s Odd 1’s

19 L = {1^{2 n } | n ≥ 0} STEP 4: Send the tape head back to the left end of the tape. No 1’s One 1 Even 1’s Odd 1’s

20 L = {1^{2 n } | n ≥ 0} STEP 5: Go back to STEP 1. No 1’s One 1 Even 1’s Odd 1’s

21 L = {1^{2 n } | n ≥ 0} This is a “high-level” description of a Turing Machine: – STEP 1: Scan the tape left to right, cross off every other 1, keep track if the number of 1’s is even, odd, or equal to 1. – STEP 2: If you’re left with just one 1, halt and accept! – STEP 3: If you’re left with an odd number of 1’s, but more than one, halt and reject! – STEP 4: Send the tape head back to the left end of the tape. – STEP 5: Go back to STEP 1. On Homework and Exams: give high-level descriptions. – This should be easier than drawing the diagram, specifying the transition details, etc.

22 L = {1^{2 n } | n ≥ 0} This language L is: a)Decidable b)Turing-recognizable c)Decidable AND Turing-recognizable d)Neither decidable nor Turing-recognizable

23 So a language is not context-free. What is it? Decidable: there is a TM that always halts on all inputs. Turing-recognizable: there is a TM that always halts for accepted strings, but MAY NOT HALT on rejected strings. Regular Context-Free What’s out here…? After Exam 2. Decidable Turing-recognizable


Download ppt "CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons."

Similar presentations


Ads by Google