example 3 7 i
play

Example 3.7 I Consider the following language { 0 2 n | n 0 } - PowerPoint PPT Presentation

Example 3.7 I Consider the following language { 0 2 n | n 0 } Strings in this language are 0 , 00 , 0000 , 00000000 , . . . Idea: crossing off every other 0 and the remaining string should still have even length October 23, 2020 1 / 8


  1. Example 3.7 I Consider the following language { 0 2 n | n ≥ 0 } Strings in this language are 0 , 00 , 0000 , 00000000 , . . . Idea: crossing off every other 0 and the remaining string should still have even length October 23, 2020 1 / 8

  2. Example 3.7 II Example: 0000 00 0 Procedure left → right, mark every other 0 1 if in step 1, only one 0 left, then accept 2 if in step 1, odd # 0 left, then reject 3 move head to the beginning 4 October 23, 2020 2 / 8

  3. Example 3.7 III go back to stage 1 5 Formal definition Q = { q 1 , q 2 , q 3 , q 4 , q 5 , q accept , q reject } Σ = { 0 } Γ = { 0 , x , ⊔} The diagram October 23, 2020 3 / 8

  4. Example 3.7 IV 0 → L q 5 x → L x → R ⊔ → R ⊔ → L q 1 q 2 q 3 x → R 0 → ⊔ , R 0 → x, R ⊔ → R ⊔ → R 0 → x, R 0 → R x → R q a q r q 4 x → R ⊔ → R October 23, 2020 4 / 8

  5. Example 3.7 V 0 → R ≡ 0 → 0 , R Consider the input 0000 q 1 0000 ⊔ q 2 000 ⊔ xq 3 00 ⊔ x 0 q 4 0 ⊔ x 0 xq 3 ⊔ x 0 q 5 x ⊔ xq 5 0 x ⊔ q 5 x 0 x q 5 ⊔ x 0 x ⊔ q 2 x 0 x ⊔ xq 2 0 x ⊔ xxq 3 x ⊔ xxxq 3 ⊔ ⊔ xxq 5 x ⊔ xq 5 xx ⊔ q 5 xxx q 5 ⊔ xxx ⊔ q 2 xxx ⊔ xq 2 xx ⊔ xxq 2 x ⊔ xxxq 2 ⊔ xxx ⊔ q a The δ function: October 23, 2020 5 / 8

  6. Example 3.7 VI 0 x ⊔ q 1 q 2 , ⊔ , R q reject , x , R q reject , ⊔ , R q 2 q 3 , x , R q 2 , x , R q accept , ⊔ , R . . . No need to have rows for q accept , q reject ⇒ accepting/rejecting takes immediate effect Now a deterministic TM We can have nondeterministic TM later They are equivalent Main idea of δ : October 23, 2020 6 / 8

  7. Example 3.7 VII q 1 : mark the start by ⊔ first element must be 0, otherwise, reject Using ⊔ , so the start is known q 2 → q 3 : handle initial 00 q 3 → q 4 → q 3 : sequentially 00 → 0 x If not pairs (e.g., 0x0x0x), fails This is the place of checking if # of remained zeros is even q 3 → q 5 → q 2 back to beginning October 23, 2020 7 / 8

  8. Example 3.7 VIII First 0 (or ⊔ ) is considered the single final 0 q 2 → · · · → q 2 → · · · → q accept check if a single 0 is left in the string October 23, 2020 8 / 8

Recommend


More recommend