DCP 3122 Introduction to Formal Languages

DCP 3122 Introduction to Formal Languages

A Hierarchy of Formal Languages and Automata Wen-Guey Tzeng Computer Science Department National Chiao Tung University Recursively enumerable language • A language L is recursively enumerable if there exists a Turing machine M such that L(M)=L. – For a string w in L, M(w) halts and enters a final state. – For a string w, not in L, M(w) • Either, halt and enter a non-final state • Or, run forever (non-halt) 2016 Spring 2 • Why is it called ”recursively enumerable” ? – “recursive” = “computational” = “algorithmical” • We can list (enumerate) all strings in a r.e. language. – Later ! 2016 Spring 3 Recursive language • A language L is recursive if there exists a Turing machine M such that – L(M)=L – For every string w in *, M(w) always halts. All languages 2016 Spring 4 Theorem: If L is recursive, we can enumerate all strings in L. • Assume that M accepts L and halts on every input. • Let * be w1=, w2=0, w3=1, w4=00, w5=01, … in the alphabetical order. • Algorithm for enumerating strings in L: 1. i=0; 2. i=i+1; 3. Run M(wi) and wait till halt. 4. If M(wi) enters a final state 5. then list wi 6. Goto 2. 2016 Spring 5 M(w) w1 = w2 = 0 w3 = 1 w1 = 00 . wk . 1st move 2nd Halt & move non-final 3rd Halt & X move final 4th Halt & X X move non-final . X X X . rth Halt & X X X move final . Halt & Halt & . X X X X . final non-final 2016 Spring 6 Theorem: If L is recursive, so is 퐿ത • Assume that M=(Q, , , , , q0, F) accepts L and halts on all inputs. – If wL, M halts and enters pF – If wL, M halts and enter qF • Let M’=(Q, , , , , q0, F’), where F’=Q-F. – If w퐿ത, M halts and enters p F’ – If wL, M halts and enter q F’ – Thus, L(M’)=퐿ത. • Since M’ halts on all inputs, 퐿ത is recursive. 2016 Spring 7 Theorem: If L is r.e., all strings in L can be enumerated. • Assume that M accepts L. • Let * be w1=, w2=0, w3=1, w4=00, w5=01, … in the alphabetical order. • Wrong statement 3. Run M(wi) and wait till halt. 2016 Spring 8 • Algorithm for enumerating L 1. i=0; 2. i=i+1; 3. For j=1 to i; 4. Run M(wj) for the (i-j+1)-th step. 5. If M(wj) halts and enters a final state 6. then list wj 7. Goto 2. 2016 Spring 9 M(w) w1 = w2 = 0 w3 = 1 w1 = 00 . wk . 1st move 2nd Halt & Halt & move final non-final 3rd move X X 4th Halt & X X move non-final . X X X . rth Halt & X X X move final . X forever X X forever X . 2016 Spring 10 • Why does the algorithm work? – If wk is in L and accepted by M in r steps, it will be listed when j=k and i=r+j-1, within finite steps. • Thus, every w L will be listed within finite steps and every w L won’t be listed. 2016 Spring 11 Questions ? All languages L2 L1 • Does language L1 exist? – R.E., but not recursive • Does language L2 exist? – Not recursively enumerable 2016 Spring 12 A non-r.e. language • Let ={a}. • Let M1, M2, … be a list of all TM over . i i • Let L = {a : a L(Mi)}. a aa aaa . ak . M1 o x 0 . o . M2 o o x . o . M3 x x x . x . Mk o x o . x . L o o x . x . 2016 Spring 13 i i Theorem: L = {a : a L(Mi)} is r.e. • Algorithm A: Input: ak; ; 1. List the k-th TM Mk k 2. Run Mk(a ) and wait for the result If Mk(ak) halts on a final state then A enters an accepting configuration If Mk(ak) halts on a non-final state then A enters a non-accepting configuration 2016 Spring 14 – What is A’s running result on input ak? • when akL • when akL 2016 Spring 15 i i • Let 퐿 = {a : a L(Mi)} a aa aaa . ak . M1 o x 0 . o . M2 o o x . o . M3 x x x . x . Mk o x o . x . 퐿 o o x . x . 퐿 x x o . o . 2016 Spring 16 • Theorem: 퐿 = S is not r.e. – Assume that S is r.e. and accepted by TM Mk such that L(Mk)=S for some k. – Contradiction: k k • If a S, then, by definition of S, a L(Mk)=S. k k • If a S, then, by definition of S, a L(Mk)=S. – Thus, Mk does not exist and S is not r.e. 2016 Spring 17 • Theorem: L is r.e., but not recursive. – L is r.e. (why?) – If L is recursive, so is 퐿. – But, 퐿 is not recursive. Thus, L is not recursive. All languages L2 L1 2016 Spring 18 2016 Spring 19.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    19 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us