Note: Show a complete proof for each item and statement.
SLIDES
(f) Use the CYK (dynamic programming) algorithm to determine if the G we used in class (see slides) generates the string babba (draw a similar table).
ACFG E P & Bottom-up DP = = n • Fix CFG G in Chomsky normal form. Input to DP algorithm is string w=w,w2w, with [w] =n = •W, In our case of DP, subproblems are to determine which variables in G can generate each substring of w. Create an n x n table 1 2 3 Complete string O FZ 3 Substrings of length 3 Substrings of length 2 Substrings of length 1 12 w
ACFG E P & Bottom-up DP 1 2 3 FZ Complete string 1 2 3 Substrings of length 3 Substrings of length 2 Substrings of length 1 21 TO O For i =j, (i, j)-th entry contains those variables that can generate substring w=w;W+1 • • •W ; For i>j, (i, j)-th entry is unused DP starts by filling in all entries for substrings of length 1, then all entries for length 2, then all entries for length 3, etc. Idea: Use shorter lengths to determine how to construct longer lengths O
ACFG E P & Bottom-up DP Suppose s = uv, B=*u, C=*v, and (3) rule A → BC. Then A=*s because A = BC=*uv = s. Suppose that algorithm has determined which variables generate each substring of length <k To determine if variable A can generate substring of length k +1: split substring into 2 non-empty pieces in all possible (k) ways For each split, algorithm examines rules A™ BC Each piece is shorter than current substring, so table tells how to generate each piece • Check if B generates first piece • Check if C generates second piece If both possible, then add A to table
ACEG E P & Bottom-up DP = = - = D = "On input string w=wW2...Wn: 1. For w=ɛ, if S → E is a rule, accept; else reject. (w = ε case) 2. For i= 1 to n [examine each substring of length 1] 3. For each variable A, 4. Test whether A →b is a rule, where b=wi 5. If so, put A in tableli, i) 6. For 1 = 2 to n, [l is length of substring] 7. For i=1 to n - 1+1, 8. Let j = i+1-1, [j is end position of substring] 9. For k=i to j-1, [k is split position] 10. For each rule ABC, 11. If table(i, k) contains B and table(k +1, j) contains C, put A in table(i, j) 12. If S is in table(1, n), accept; else, reject." = - - n
Note: Show a complete proof for each item and statement. SLIDES
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Note: Show a complete proof for each item and statement. SLIDES
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!