Theory of Computation CS 3102 Spring 2014 A

  • Slides: 15
Download presentation
Theory of Computation CS 3102 – Spring 2014 A tale of computers, math, problem

Theory of Computation CS 3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer Science University of Virginia www. cs. virginia. edu/~njb 2 b/theory

Vio late s. P Lem umpi ng For ma CFL s Hierarchy: So Far

Vio late s. P Lem umpi ng For ma CFL s Hierarchy: So Far an b n bn ing p Pum RLs s e or lat Vio ma F Lem abba Described by DFA, NFA, Reg. Exp, Des finite Languages Des Regular Languages crib DP ed by DA Deterministic Context-Free s e g a u g n a L e e Context-Fr ww. R crib e ND d by C PD A FG ,

Hierarchy: Next step y n a y ed b iz n g o ec

Hierarchy: Next step y n a y ed b iz n g o ec R s e ag ine u h g c a n m La g n i t u comp finite Languages Regular Languages ? s n Deterministic Context-Free a hum y b le es b a v l oanguag s L s e e r F m t x Con. Ptreoble

PDA Enhancements Theorem: 2 -stack PDAs are more powerful than 1 -stack PDAs. Hint:

PDA Enhancements Theorem: 2 -stack PDAs are more powerful than 1 -stack PDAs. Hint: Find an example non-CFL accepted by a 2 -stack PDA. a, ↓b, ↓c start ε, ↓$ a‘s b, ↑b, - Input b‘s c, -, ↑c a a b b c c c‘s ε, ↑$ end b c $ $ Stack 1 Stack 2

PDA Enhancements Theorem: 2 -stack PDAs are more powerful than 1 -stack PDAs. Hint:

PDA Enhancements Theorem: 2 -stack PDAs are more powerful than 1 -stack PDAs. Hint: Find an example non-CFL accepted by a 2 -stack PDA. a, ↓a, b, ↓b, - start ε, ↓$, - w 1 ε, ↑a, ↓a ε, ↑b, ↓b ε, -, ↓$ Input flip a, -, ↑a b, -, ↑b ε, ↑$, - a b b w 2 ε, -, ↑$ end b a b $ $ Stack 1 Stack 2

PDA Enhancements Is there anything we can’t simulate with a 2 -PDA? How about

PDA Enhancements Is there anything we can’t simulate with a 2 -PDA? How about a 3 -PDA? b a a b b b a b b $ $ $ Stack 1 Stack 2 Stack 3 a b b $ b b a $ Stack 1 To pop from stack 1: ε, ↑b, -, - x $ b b a Stack 2 y Do: σϵ{a, b}, ωϵ{a, b, $} ε, ↑σ, ↓σ x ε, ↑σ, ↓σ ε, ↑$, ↓$ Move stack 3 Move stack 2 ε, ↓ω, ↑ω ε, ↑b, - Pop ε reset y

PDA Enhancements Is there anything we can’t simulate with a 2 -PDA? 2 -PDA=Turing

PDA Enhancements Is there anything we can’t simulate with a 2 -PDA? 2 -PDA=Turing Machine b a b $ $ Stack 1 Stack 2 Current Symbol

Turing Machine FSM … Infinite tape: Γ* Tape head: read current square on tape,

Turing Machine FSM … Infinite tape: Γ* Tape head: read current square on tape, write into current square, move one square left or right FSM: like PDA, except: transitions also include direction (left/right) final accepting and rejecting states

Turing Machine FSM … 7 -tuple: (Q, , Γ, δ, q 0, qaccept, qreject)

Turing Machine FSM … 7 -tuple: (Q, , Γ, δ, q 0, qaccept, qreject) Q: finite set of states : input alphabet (cannot include blank symbol, _) Γ: tape alphabet, includes and _ (blank) δ: transition function: Q Γ {L, R} (in FSM) q 0: start state, q 0 Q qaccept: accepting state, qaccept Q qreject: rejecting state, qreject Q

Turing Machine Configuration q FSM … u v (u, q, v)ϵΓ* × Q ×

Turing Machine Configuration q FSM … u v (u, q, v)ϵΓ* × Q × Γ* tape contents current left of head FSM state tape contents head and right

Initial Configuration FSM a b b input a _ _ _ blanks Configuration: (a,

Initial Configuration FSM a b b input a _ _ _ blanks Configuration: (a, start, bba) …

Operation δ*: Γ* Q Γ* Transition from configuration to configuration FSM q The qaccept

Operation δ*: Γ* Q Γ* Transition from configuration to configuration FSM q The qaccept and qreject states are final (you never leave): δ*(u, qaccept, v) δ*(u, qreject, v) … u v

Operation FSM a u q … b c v δ*(ua, q, bv) = (uac,

Operation FSM a u q … b c v δ*(ua, q, bv) = (uac, qr, v) if δ(q, b) = (qr, c, R) δ*(ua, q, bv) = (u, qr, acv) if δ(q, b) = (qr, c, L) b, c, R qr

Operation FSM a u q … b c v δ*(ua, q, bv) = (uac,

Operation FSM a u q … b c v δ*(ua, q, bv) = (uac, qr, v) if δ(q, b) = (qr, c, R) δ*(ua, q, bv) = (u, qr, acv) if δ(q, b) = (qr, c, L) b, c, L qr

Church Turing Thesis ≡ 1. Read notes 2. Ponder 3. Scribble notes 4. Repeat

Church Turing Thesis ≡ 1. Read notes 2. Ponder 3. Scribble notes 4. Repeat 1. Read from tape 2. Change state 3. Write to tape 4. Repeat