Spring 2020, Final Exam

General comments:

- you are allowed up to 10 pages of handwritten notes;
- the main goal of most questions is to show that you know the corresponding algorithms; so, if you are running of time, just follow the few first steps of the corresponding algorithm;
- each question will be graded on its own merit; so, for example, if on one stage, you got a wrong context-free grammar, but on the second stage, you correctly apply the Chomsky normal form algorithm to the resulting grammar, you will get full credit for the second stage.

1. *Finite automata and regular languages:*

1a. Design a finite automaton for recognizing binary sequences that end with 1. Assume that the input strings contain only symbols 0 and 1. The easiest is to have two states:

- the state z indicating that the last read symbol was 1, and
- the state n indicating that either no symbol was read yet or the last symbol read was 0.

1b. Explain why in most computers binary numbers are represented starting with the lowest possible digit.

1c. On the example of the above automaton, show how the word 011 can be represented as xyz in accordance with the pumping lemma.

1d. Use a general algorithm to describe a regular expression corresponding to the finite automaton from the Problem 1a. (If you are running out of time, it is Ok not to finish, just eliminate the first state.)

1e-f. The resulting language can be described by a regular
expression (0 U 1)^{*}1. Use a general algorithm to
transform this regular expression into a finite automaton: first a
non-deterministic one, then a deterministic one.

2. *Beyond finite automata: pushdown automata and context-free
grammars:*

2a. In a fictitious state of Saxet, four universities A, B, C, and
D -- located in four different cities -- compete for state funding.
They want to make sure that each got an equal number of funds. So,
e.g., if we the sequence of allocated grants is ABABCCDD, this is
good. Prove that the set of all "good" sequences is not
*regular* and therefore, cannot be recognized by a finite
automaton.

2b. Use a general algorithm to transform the finite automaton from the Problem 1a into a context-free grammar (CFG). Show, step-by-step, how this CFG will generate the word 011.

2c. For the context-free grammar from the Problem 2b, show how the word 011 can be represented as uvxyz in accordance with the pumping lemma.

2d. Use a general algorithm to translate the CFG from 2b into Chomsky normal form.

2e. Use a general algorithm to translate the CFG from 2b into an appropriate push-down automaton. Explain, step-by-step, how this automaton will accept the word 011.

2f. Use the general stack-based algorithms to show:

- how the compiler will transform a Java expression 1 − 7 − 3 into inverse Polish (postfix) notation, and
- how it will compute the value of this expression.

3. *Beyond pushdown automata: Turing machines*

3a. In a fictitious state of Saxet, four universities A, B, C, and
D -- located in four different cities -- compete for state funding.
They want to make sure that each got an equal number of funds. So,
e.g., if we the sequence of allocated grants is ABABCCDD, this is
good. Prove that the set of all "good" sequences is not
*context-free* and therefore, cannot be recognized by a
pushdown automaton.

3b-c. Use a general algorithm to design a Turing machine that accepts exactly all sequences accepted by a finite automaton from Problem 1a. Show, step-by-step, how this Turing machine will accept the word 011. Describe, for each step, how the state of the tape can be represented in terms of states of two stacks.

3d-e. Design Turing machines for computing a − 2 in unary and in binary codes. Trace both for a = 3, i.e., for a = 111 in unary code and a = 11 in binary code.

4. *Beyond Turing machines: computability*

4a. Formulate Church-Turing thesis. Is it a mathematical theorem? Is it a statement about the physical world?

4b. Prove that the halting problem is not algorithmically solvable.

4c. Not all algorithms are feasible, but, unfortunately, we do not have a perfect definition is feasibility. Give a current formal definition of feasibility and give two examples:

- an example of an algorithm's running time which is feasible according to the current definition but not practically feasible, and
- an example of an algorithm's running time which is practically feasible but not feasible according to the current definition.

4d. Briefly describe what is P, what is NP, what is NP-hard, and what is NP-complete. Is P equal to NP?

4e. Give an example of an NP-complete problem: what is given, and what we want to find.

4f. Give definitions of a recursive (decidable) language and of a recursively enumerable (Turing-recognizable) language.