CSC 11 Theory of Computtion Tutoril on DFAs, NFAs, regulr expressions, regulr grmmr, closure of regulr lnguges, context-free grmmrs, non-deterministic push-down utomt, Turing mchines,etc. Tutoril 2 Second Semester 2017 Assume tht Σ = {,} when it is not otherwise given. 1. Given the regulr expression ( ) *, the corresponding NFA is given on the right. Rewrite this NFA into its corresponding DFA.ShowtheresultingDFAothstrnsition tle nd s trnsition digrm., ε q q 4 q 5 2. Given the NFA N with L(N) = {w Σ w strts with }, s the regulr expression (+) *, first confirm tht its NFA is s shown on the right, then derive its corresponding DFA. Show the resulting DFA oth s trnsition tle nd s trnsition digrm.. L(N) = {w Σ w hs s its 2nd letter} is the lnguge of the NFA N. Write its corresponding regulr expression. First confirmthtitsnfaissshownontherightthenderiveitscorresponding DFA. Show the resulting DFA oth s trnsition tle nd s trnsition digrm. 4. Consider NFA N digrmmed on the right. Descrie L(N) = {w Σ w...}. Derive its corresponding DFA nd write the resulting DFA oth s trnsition tle nd s trnsition digrm.,, q q, ε ε q 5. Give regulr expression for this NFA given s trnsition grph. Show the resulting DFA oth s trnsition tle nd s trnsition digrm. 6. Minimize the DFA given y this trnsition grph. Show the resulting DFA oth s trnsition tle nd s trnsition digrm. q q 4 7. Rewrite the NFA given y the trnsition grph s DFA, nd then minimize the DFA. Show the resulting DFA oth s trnsition tle nd s trnsition digrm. 1 q 5, ε 2, ε 4
8. Minimize the DFA given y the trnsition grph (Grcí et l., 2011). Show the resulting DFA oth s trnsition tle nd s trnsition digrm. 9. Minimize the DFA given y the trnsition grph. Show the resulting DFA oth s trnsition tle nd s trnsition digrm. 10. Minimize the DFA given y the trnsition grph. Show the resulting DFA oth s trnsition tle nd s trnsition digrm (Hopcroft et l., 2001, Pge 155). 11. Minimize the DFA given y the trnsition tle. Show the resulting DFA oth s trnsition tle nd s trnsition digrm (Hopcroft et l., 2001, Pge 164). 12. Minimize the DFA given y the trnsition tle. Show the resulting DFA oth s trnsition tle nd s trnsition digrm (Hopcroft et l., 2001, Pge 165). 1. Minimize the DFA given y the trnsition tle. Show the resulting DFA oth s trnsition tle nd s trnsition digrm (Hopcroft et l., 2001, Pge 165). 14. Minimize the DFA given y the trnsition grph. Show the resulting DFA oth s trnsition tle nd s trnsition digrm (Vlmri, 2010). Note tht ll the missing trnsitions led to ded or sink stte, which is not shown in the stte digrm. 4 2 1 5 7 9 10 6 8, 1 4 2 q q 4 q 5 q 6 q 7 0 1 0 1 0 2 1 * 0 4 5 5 6 4 6 5 6 7 6 1 2 5 2 6 * 4 8 4 5 8 5 6 9 6 7 2 7 8 2 8 9 *9 1 5 0 1 4 1 2 5 2 7 * 4 7 4 5 8 5 6 1 6 7 1 7 8 2 8 0 4 q q 4 q 5
15. Minimize the DFA given y the trnsition grph. Show the resulting DFA oth s trnsition tle nd s trnsition digrm (Hopcroft et l., 2001, Pge 158). q 16. Minimize the DFA given y the trnsition grph. Show the resulting DFA oth s trnsition tle nd s trnsition digrm., 17. Minimize the DFA given y the trnsition grph. Show the resulting DFA oth s trnsition tle nd s trnsition digrm. q q 4 q 5 q 6, 18. Show tht the sentence Jim trins rt students hs derivtion in the following grmmr. Give prse tree for the sentence. S NV P N NN V P VN N students Jim rt trins V trins 19. Let G e the following grmmr S AB BC A BA B CC C AB Use the CYK lgorithm to determine whether w = is in L(G). Give prse tree for w, nd its rightmost derivtion from S
20. Given the grmmr G with strt symol E in CNF use the CYK lgorithm to determine whether w = (x + x) * x is in G. E is the strt vrile. E EF LR x F ME CE G EQ P + T * L ( R ) 21. Given the grmmr G with strt symol S in CNF use the CYK lgorithm to determine whether w = is in L(G). S AT AU ε T UB U AT UT A B 22. Show the CYK lgorithm for the CNF grmmr G with strt symol S y showing tht w = is or is not in L(G). S AB BC A BA B CC C AB 2. Wht is the lnguge L tht is derived from S where S AB A A B AB? 24. Write python code to red in the specifictions for n NFA or DFA nd then turns it into DFA if it is not lredy one. Your specifictions should give the NFA/DFA in the form of stte tle with numericlly numered sttes nd single chrcters s the lphet. Use python s sets, dictionry nd regulr expression pckge re. 25. Write python code which which minimizes your DFA.
26. Write python code to turn context-free grmmr into Chomsky-norml form if it is not yet in tht form. 27. Write python code to implement the CYK lgorithm, given grmmr in Chomsky norml form. It should red grmmr nd run CYK to determine if some strings re ccepted or rejected. 28. Develop code to implement PDA from specifictions, nd use it to show tht the PDA ccepts the plindromes lnguge. 29. Develop code to implement Turing mchine from specifictions, nd use it to show tht the TM ccepts the lnguge n n c n. Fuller specifictions for the coding prolems cn e given on request. References Grcí, P., López, D., nd Vázquez de Prg, M. 2011. DFA minimiztion: from Brzozowski to Hopcroft. Unknown, p. Unknown. Hopcroft, J. E., Motwni, R., nd Ullmn, J. 2001. Introduction to Automt Theory, Lnguges nd Computtion. Addison-Wesley, 2nd edn. Vlmri, A. 2010. O(m log n) time lgoritms for DFA minimiztion nd more. In Lecture Slides.