General comment: Unless explicitly specified, each homework should be turned in on a sheet of paper:
1. (Due August 29) In class, we studied an automaton for recognizing signed or unsigned binary integers. This automaton has 4 states: start (st), sign (si), integer (i), and error (e). Start is the starting state, integer is the only final state. The transitions are as follows:
2. (Due August 29) In class, we had yet another finite automaton for recognizing signed or unsigned binary integers. This new automaton has 5 states: the starting state start (st), the state sign_read (sr), the state signed_integer (si), the state unsigned_integer (u), and the sink (error) state e. This automaton has two final states: si and u. The transitions are as follows:
3. (Due August 29) Similarly to the automaton from Problem 1 (that we analyzed in class), draw an automaton for recognizing all possible signed and unsigned integers (not necessary binary), so that this automaton will also recognize numbers like 32, +32, and −32.
4. (Due September 5) Let A be an automaton described in Problem 1. Let B be the following automaton that accepts all the strings that contain only +s, 0s, and 1s but not any other symbols. This automaton has two states: the start state which is also a final state, and the sink state. The transitions are as follows:
5. (Due September 12) Use the general algorithm that we learned in class to design a non-deterministic finite automaton that recognizes the language (0 U 1)(1 U 2).
6. (Due September 19) Use the general algorithm that we learned in class to design a non-deterministic finite automaton that recognizes the language (0 U 1)(1 U 2)*: a composition of the union 0 U 1 and a Kleene star (1 U 2)*. Use a general algorithm to transform this non-deterministic automaton into a deterministic one.
7. (Due September 26) Apply the general algorithm for transforming the finite automaton into a regular language (i.e., a language described by a regular expression) to Automaton B from Problem 4. Assume that we are allowing four possible symbols: in addition to +, 0, and 1, we also have a symbol X.
8. (Due September 26) Automaton from Problem 1 accepts the word +10.
9. (Due October 3) Write a method that emulates a general finite automaton. The input to this method should include:
Your program should emulate the work of the finite automaton step-by-step. Return the printout of the method, the printout of the program that you used to test this method, and the printout of the result of this testing. Feel free to use Java, C, C++, Fortran, or any programming language in which the code is understandable.
10. (Due October 3) Prove that the following language is not regular {0^{n}1^{n}2^{n}} = {Λ, 012, 001122, 000111222, ...}.
11. (Due October 10) In class, we had a pushdown automaton for recognizing words of the type ww^{R}, where w is any word, and w^{R} means the same word reversed. For example, if w = cat, then w^{R} = tac, and ww^{R} = cattac.
The automaton that we came up with has 4 states:
12. (Due October 10) The following context-free grammar (CFG) generates palindromes. This CFG has the following rules:
13. (Due October 10) On the example of the Automaton B from Problem 4, show how the general algorithm will produce a context-free grammar that generates all the words accepted by this automaton -- and only words generated by this automaton. On the example of a word +1+ accepted by this automaton, show how the tracing of acceptance of this word by the finite automaton can be translated into a generation of this same word by your context-free grammar.
14. (Due October 17) Use a general algorithm to construct a (non-deterministic) pushdown automaton that corresponds to the context-free grammar from Problem 12 (limit yourselves to only three letters a, c, and t). Show, step by step, how the derivation of the word cattac in the original grammar translates into the acceptance of this word by the resulting pushdown automaton.
15. (Due October 17) Prove that the following language is not context-free: {0^{n}1^{2n}2^{3n}} = {Λ, 011222, 001111222222, 000111111222222222, ...}.
16. (Due October 17) On the example of the word cattac generated by a grammar from Problem 12, show how this word will be represented as uvxyz according to the Pumping Lemma. Show how the words uxz and uvvxyyz will be generated by this grammar.
17. (Due October 24) Apply the general algorithm to transform the grammar from Problem 12 into the Chomsky normal form; for simplicity, only consider letters a and b; full credit if you do preliminary step and Step 0. Extra credit if you perform all the steps of the algorithm.
18. (Due October 31) Finish applying the general algorithm to transform the grammar from Problem 12 into the Chomsky normal form -- if you have not yet done that for extra credit. For simplicity, only consider letters a and b.
19. (Due October 31) Apply, step-by-step, the general algorithm of converting a pushdown automaton to a context-free grammar to the pushdown automaton from Problem 11. Explain how the acceptance of the word cattac by this automaton will be translated into a derivation of this word in the resulting grammar.
20. (Due November 7) Show, step by step, how the stack-based algorithm will transform the expression (3 − 1) * (2 − 5) into a postfix expression, and then how a second stack-based algorithm will compute the value of this postfix expression.
21. (Due November 14) Write a program that, given an arithmetic expression,
22. (Due November 14) Design a Turing machine that, given a positive unary number n, subtracts 1 from this number. Test it, step-by-step, on the example of n = 5.
23. (Due November 14) Design a Turing machine that, given a positive binary number n, subtracts 1 from this number. Test it, step-by-step, on the example of n = 5.
24. (Due November 14) Transform a finite automaton B from Problem 4 into a Turing machine. Show step-by-step, on an example of a word 101, how this word will be recognized by your Turing machine.
25. (Due November 21) Write a method that emulates a general Turing machine. The input to this method should include:
Your program should emulate the work of the Turing machine step-by-step. Return the printout of the method, the printout of the program that you used to test this method, and the printout of the result of this testing. Feel free to use Java, C, C+++, Fortran, or any programming language in which the code is understandable.
26. (Due November 28) As we discuss in class, a Turing machine can be described as a finite automata with two stacks:
27. (Due December 5) Give two examples:
28. (Due December 5) What is NP? What is P? What is NP-complete? What is NP-hard? Give brief definitions. Give an example of an NP-complete problem. Is P equal to NP?