big picture
play

Big picture All languages Decidable Turing machines NP P - PowerPoint PPT Presentation

Big picture All languages Decidable Turing machines NP P Context-free Context-free grammars, push-down automata Regular Automata, non-deterministic automata, regular expressions Turing Machines Like DFA but Access


  1. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x x x x – – …

  2. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x x x x – – …

  3. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x x x x – – …

  4. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x x x x – – …

  5. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x x x x – – …

  6. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x x x x – – …

  7. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x x x x – – …

  8. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x x x x – – …

  9. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x x x x – – …

  10. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x x x x – – …

  11. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x x x x – – …

  12. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V DONE! REJECT # x x x x x – – …

  13. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R Now a REJECT example V REJECT a a b b b c – – …

  14. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V BEGIN REJECT a a b b b c – – …

  15. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # a b b b c – – …

  16. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # a b b b c – – …

  17. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # a x b b c – – …

  18. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # a x b b c – – …

  19. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # a x b b c – – …

  20. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # a x b b x – – …

  21. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # a x b b x – – …

  22. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # a x b b x – – …

  23. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # a x b b x – – …

  24. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # a x b b x – – …

  25. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # a x b b x – – …

  26. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # a x b b x – – …

  27. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # a x b b x – – …

  28. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x b b x – – …

  29. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x b b x – – …

  30. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x x b x – – …

  31. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x x b x – – …

  32. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V REJECT # x x x b x – – …

  33. L = {a n b n c n : n ≥ 0} {a,b,c,x} → L x → R _ → R go # → R find left next a _ → L ACCEPT {b,x} → R {c,x} → R {a,x} → R a→x,R c→x,R b→x,R _→R scan a's scan b's scan c's a→#,R {c,_}→R {a,_}→R {a,b} → R {b,c} → R V DONE! REJECT # x x x b x – – …

  34. 2 n Example: TM for L = {a : n  0} = {a, aa, aaaa, aaaaaaaa, … } M := “On input w, 1) if only one a, ACCEPT 2) cross off every other a on the tape 3) if the number of a's is odd, REJECT 4) Go back to 1)” For instance: 8 a's → 4 a's → 2 a's → 1 a → ACCEPT 12 a's → 6 a's → 3 a's → REJECT

  35. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V a a a a – –

  36. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # a a a – –

  37. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # a a a – –

  38. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # a x a – –

  39. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # a x a – –

  40. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # a x a – –

  41. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # a x a – –

  42. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # a x a – –

  43. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # a x a – –

  44. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # a x a – –

  45. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # x x a – –

  46. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # x x a – –

  47. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # x x a – –

  48. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # x x a – –

  49. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # x x a – –

  50. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # x x a – –

  51. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # x x a – –

  52. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # x x a – –

  53. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # x x a – –

  54. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # x x a – –

  55. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V # x x x – –

  56. Another example: L = {a : n  0} 2 n x→R _ → R skip the REJECT next a _ → R a → R a → x, R x→R a → #,R x→R a → R mark the next a _ → R _ → L a → x, R # → R go ACCEPT left {a,x} → L x→R V ACCEPT! # x x x – –

  57. Unlike DFA and PDA, TM computation may never halt. That is, it may continue forever without entering accept/reject states This is when your computer “freezes” Example {a,_} → R V a a – – – –

  58. Unlike DFA and PDA, TM computation may never halt. That is, it may continue forever without entering accept/reject states This is when your computer “freezes” Example {a,_} → R V a a – – – –

  59. Unlike DFA and PDA, TM computation may never halt. That is, it may continue forever without entering accept/reject states This is when your computer “freezes” Example {a,_} → R V a a – – – –

  60. Unlike DFA and PDA, TM computation may never halt. That is, it may continue forever without entering accept/reject states This is when your computer “freezes” Example {a,_} → R And so on! V a a – – – –

  61. ● Definition: A Turing Machine TM is a 7-tuple (Q, ∑ , Γ , δ , q 0 , q accept , q reject ) where: ● Q is a finite, non-empty set of states ● ∑ is the input alphabet. Blank symbol _ ∑ ∉ ● Γ is the tape alphabet, ∑ Γ and _ Γ ⊆ ∈ ● δ : Q X Γ → Q x Γ x {L, R} is the transition function ∈ ● q 0 Q is the start state ∈ ● q accept Q is the accept state ∈ ● q reject Q is the reject state; q accept ≠ q reject

  62. ● Definition: A configuration of a TM specifies contents of tape, state, head location ∈ ∈ It is written as u q v where q Q, u, v Γ* Meaning: 1) TM in state q 2) head is on first symbol of v. 3) Tape contains uv, blanks not shown  q 7 . . . ? . . . V 0 0 1 1 – – –

  63. ● Definition: A configuration of a TM specifies contents of tape, state, head location ∈ ∈ It is written as u q v where q Q, u, v Γ* Meaning: 1) TM in state q 2) head is on first symbol of v. 3) Tape contains uv, blanks not shown  q 7 . . . 00q 7 11 . . . V 0 0 1 1 – – –

  64. ● Definition: A configuration C yields a configuration C' if TM goes from C to C' in one step: ● u a q b v yields u q' a c v if δ (q,b) = (q',c,L) ● u a q b v yields u a c q' v if δ (q,b) = (q',c,R) ● u a q is treated like u a q _ ● q b v yields q' c v if δ (q,b) = (q', c, L) ● q b v yields c q' v if δ (q,b) = (q', c, R)

  65. ● Definition: Start configuration of TM on input w is q 0 w Accept configuration: any configuration with q accept Reject configuration: any configuration with q reject Halt (stop) configur.: Accept U Reject configur. ● Definition: TM M accepts (rejects, halts on) input w if ∃ configurations C 1 , C 2 , ..., C k : C 1 is start configuration ∀ C i yields C i+1 i < k C k is accept (reject, halt) configuration

  66. 2 n Example: L = {a : n  0} q 0 aaaa

  67. 2 n Example: L = {a : n  0} q 0 aaaa # q 1 aaa

  68. 2 n Example: L = {a : n  0} q 0 aaaa # q 1 aaa #a q 2 aa

  69. 2 n Example: L = {a : n  0} q 0 aaaa # q 1 aaa #a q 2 aa #ax q 3 a

Recommend


More recommend