[syllabus] | [lecture notes] | [HW1-6,Q1] | [HW7-10,Q2,F] | [project]

[simulators/parsers] | [language definitions] | [automata definitions] | [computable definitions]

CS451 Details of homework assignments, Part 2 and Quiz 2

The most important item on all homework is YOUR submit

Homework must be submitted when due. You loose 10%, one grade, the first day homework is late. Then 10% more per week, each week homework is late. Max of 50% off. A ZERO really hurts your final points. Do and turn in all homework, even if it is late. See HW1 for submit details. (no late penalty for online courses)

Do your own homework!

You can discuss homework with other class members but DO NOT COPY!

Contents

  • Quiz 2
  • HW7 L(NPDA)=CFL=L(CFG)
  • HW8 CYK Example
  • HW9 CFL Pumping Lemma
  • HW10 Turing machines
  • Final Exam
  • Other Links
  • Quiz 2 Information

      Open book, open note. Multiple choice questions based on lectures,
      and homework. No cheating = no discussions with other students.
    
      Exam covers lectures: 12 -18
      Exam covers homework: HW4, HW5 and HW6
      Get exam, edit answers, save, submit.
    
      cp /afs/umbc.edu/users/s/q/squire/pub/download/cs451q2.doc . # your directory
      libreoffice cs451q2.doc
      or scp, winscp, to windows and use Microsoft word
      
      submit cs451 q2 cs451q2.doc
      
    

    HW7 L(NPDA)=CFL=L(CFG) 25 points

      1) Construct a NPDA equivalent to the following grammar:
         G = ( {S, A}, {a, b}, P, S )
           Productions
             S -> a A A
             A -> a S | b S | a
     
      Define all the components M = ( Q, Sigma, Gamma, delta, q0, Z0, F) 
      Show your work, partial credit given
    
    
      2) Construct a grammar equivalent to the following PDA
         M = ({q0, q1}, {0,1}, {Z0, X}, delta, q0, Z0, phi)
        
       delta          Sigma input, Gamma Top of stack
             |    0,Z0   |    0,X   |   1,Z0     |  1,X       |  eps,Z0    | eps,X
         ----+-----------+----------+------------+------------+------------+--
          q0 | phi       | {(q1,X)} | {(q0,XZ0)} | {(q0,XX)}  | {(q0,eps)} | phi
          q1 | {(q0,Z0)} | phi      | phi        | {(q1,eps)} | phi        | phi
    
      eps is short for epsilon the null string.
      Define all components G = ( V, T, P, S)
      Show your work, partial credit given
    
      submit cs451 hw7 your.file
      
    

    HW8 CYK example 25 points

     You are allowed to use the executable 'cykp' and copy the V table.
     You are allowed to look at C++ code in cykp.cpp, cykp.java, cykp.py
     you may use hw8.g  or if problem with my code, g_83.g
     
    
     1) Given the CFG G = ( {S, A, B, C}, {a, b}, P, S
        with Productions
           S -> AB | BC
           A -> BA | a
           B -> CC | b
           C -> AB | a
     
        Determine if these strings are in the language:
        a) aaaaa
        b) aaaaaa
        c) baabab
    
        You must show the V table.
    
        Hint: use hw8.g and any cykp.
                  cyk_hw8.out
     
          or  use g_83.g and any cykp.
                  cyk_g_83.out
    	      
     2) Let G be a CFG in Chomsky Normal Form
        Give an algorithm to determine the number of distinct
        derivations of a string x from ( a) or b) or c) above).
        You can give the list of productions used or the tree
        of variables for the algorithm.
     
        You may show neat pseudo code with comments 
        
        You have complete freedom on how to proceed.
        One method is to assume the two-tuples from lecture 24
        are in the sets in the V matrix. Systematically walk
        the indexes and keep a count of successful walks.
    
      submit cs451 hw8 your.file
      
    

    HW9 CFL pumping lemma 25 points

     1) write out the steps using the pumping lemma for CFL's to prove that
    
            i  i  i
     L = { a  b  c  | i >= 1 } is not a CFL.
    
     2) Using the steps in 1) [go back and add more if you missed some],
        prove, using the pumping lemma for CFL's that
    
    
            i  j  k
     L = { a  b  c  | i < j < k } is not a CFL.
    
      submit cs451 hw9 your.file
      
    

    HW10 Turing Machines 25 points

      1) Write the machine description for a Turing machine, including
         delta transition table for the specific machine that
         starts with a number n on the tape and finishes with
         n squared on the tape. n on the input is just n zeros followed
         by blank tape.  tape 000#b
         P.S. 3 squared is nine  000000000#b
         Hint: copy the input string as many times as there are 0's
               on the tape at the start. 000#b000000000#b 
               (ok to leave initial tape with #b followed by copies)
    
         Code your program and test it using the Turing Machine simulator,
         "tm"  The name of your program is to be  'square.tm'
         More details are found in Simulators.
    
         tm < square.tm > square_tm.out  # best my code should be working
         python3 tm.py square.tm > square_tm_py.out  # my code may have bugs
         java tm square.tm > square_tm_java.out  # my code may have bugs
    
     
         Submit your homework on gl using   submit cs451 hw10 square.tm 
    
      submit cs451 hw10 your.file
    
      I suggest 4 input tapes:
      You get 10 points if  1#b    has final tape  1
      you get 15 points if  11#b   has final tape  1111
      you get 20 points if  111#b  has final tape  111111111
      you get 25 points if  1111#b has final tape  1111111111111111
    
      Sample .tm  files and results cpp tm  java tm  trace all for debugging
      tm < add.tm > add_tm.out               # tm.cpp  download just tm
       add.tm   with  trace all   
       add_tm.out  with  trace all   
      tm < add_nt.tm > add_nt_tm.out
       add_nt.tm   no  trace all   
       add_nt_tm.out  no  trace all   
      tm < l0n1na.tm > l0n1na_tm.out
       l0n1na.tm    with  trace all   
       l0n1na_tm.aout  with  trace all   
      tm < l0n1n.tm > l0n1n_tm.out
       l0n1n.tm   no  trace all   
       l0n1n_tm.out  no  trace all   
      
      java tm add.tm > add_tm_java.out         # tm.java  download and compile tm.java
       add.tm           with  trace all 
       add_tm_java.out  with  trace all 
      java tm add_nt.tm > add_nt_tm_java.out
       add_nt.tm        no trace all 
       add_nt_tm_java.out  no trace all 
      java tm l0n1na.tm > l0n1na_tm_java.out
       l0n1na.tm           with  trace all   
       l0n1na_tm_java.out  with  trace all   
      java tm l0n1n.tm > l0n1n_tm_java.out
       l0n1n.tm           no  trace all 
       l0n1n_tm_java.out  no  trace all 
    
      For more example of programming a Turing Machine see Turing Machine simulator  
      Really big  .tm  for general binary number addition  b_add.tm
    
    

    Final Exam

      Open book, Open note. Covers all lectures, all homework
      and project. Multiple choice and short answer questions.
      No cheating = no discussion with other students.
    
      1) go over the Quiz 1 and Quiz 2
         the final exam will include some of these questions
      2) You may find it helpful to go over the
         Lecture Notes  but not the details of constructions
      3) Understand what classes of languages go with what machines,
         automata and Turing machines,
         and grammars and regular expressions
      4) Understand the statement of the Pumping Lemma for Context Free Languages
      5) Understand the Halting Problem and why it is not computable
      6) Understand the Church Turing Hypothesis
    
      Get .doc, edit, save, exit, submit:
      cp /afs/umbc.edu/users/s/q/squire/pub/download/cs451fin.doc . # your directory
      libreoffice cs451fin.doc
    
      submit cs451 final cs451fin.doc
      
    
      last updated  5/6/2021