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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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 – – …
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
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – –
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 – – – –
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 – – – –
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 – – – –
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 – – – –
● 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
● 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 – – –
● 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 – – –
● 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)
● 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
2 n Example: L = {a : n 0} q 0 aaaa
2 n Example: L = {a : n 0} q 0 aaaa # q 1 aaa
2 n Example: L = {a : n 0} q 0 aaaa # q 1 aaa #a q 2 aa
2 n Example: L = {a : n 0} q 0 aaaa # q 1 aaa #a q 2 aa #ax q 3 a
Recommend
More recommend