5. Consider the following simple programming language. It has a single infinite ar-
ray A of elements in {0,1, B} (initialized to B) and a single integer variable i. A
program in this language contains a sequence of lines of the following form:
label: If A[i] equals $\sigma$ then cmds.
Where $\sigma \in$ {0,1, B} and cmds is a list of one or more of the following commands:
(1) Set A[i] to $\tau$ where $\tau \in$ {0,1,B}, (2) Goto label, (3) Increment i by one,
(4) Decrement i by one, and (5) Output b and halt, where b$\in$ {0,1}. A pro-
gram is executed on an input $x \in$ {0,1}$^n$ by placing the i'th bit of x in A[i]
and then running the program following the obvious semantics. Prove that for
every functions $f: {0,1}^* \rightarrow$ {0,1} and (time constructible) $T : N \rightarrow N$, if f is
computable in time T(n) by a program in this language, then $f \in DTIME(T(n))$.
6. Recall that normally we assume that numbers are represented as string using the
binary basis. That is, a number n is represented by the sequence $x_0, x_1,..., x_{log n}$
such that $n = \sum_{i=0}^{log n} x_i 2^i$, where for each $i \in [0..log n]$ $x_i \in$ {0,1}. However, we
could have used other encoding schemes. If $n \in N$ and $b \geq 2$, then the represen-
tation of n in base b, denoted by $[x]_b$ is obtained as follows: first represent n as
a sequence of digits in {0,..., b-1}, and then replace each digit $d \in [0..b-1]$ by
its binary representation. The unary representation of n, denoted by $[n]_1$ is the
string $1^n$ (i.e., a sequence of n ones).
(a) Show that choosing a different base of representation will make no difference
to the class P. That is, show that for every subset $S$ of the natural numbers,
if we define $L_s^b = \{ [n]_b : n \in S \}$ then for every $b \geq 2$, $L_s^b \in P \Leftrightarrow L_s^2 \in P$.
(b) Show that choosing the unary representation may make a difference by show-
ing that the following language is in P:
UNARYFACTORING = { < $[n]_1, [l]_1, [k]_1 >$: there is a prime $j \in (l, k)$ dividing n}.
It is not known to be in P if we choose the binary representation.