patternMinor
Proving language in Space Complexity
Viewed 0 times
provingspacecomplexitylanguage
Problem
I'd like to know if I have the right intuition and my answer is headed the correct way.
I am given a function
$ f = \{0, 1\}^ \rightarrow \{0, 1\}^ $ that is computable in space $O(\log n)$ assume that for every $x \in \{0, 1\}^*$, $f$ is length preserving, $|f(x)| = |x|$.
Define
$$L = \left\{ x\#y \mid \ x, y \in \{0, 1\}^*, |x| = |y|, \ \text{and} \ f(x) = f(y)\right\}$$
I am suppose to prove that $ L \in {\sf DSPACE}(\log n) $.
Please correct me if my intuition is incorrect.
My solution would be to build a decider $M$ which is a Turing machine.
$M$ takes inputs $x$ and $y$, run the function $f$ on input $x$ and $y$ and if the lengths of the two strings are equal then accept, otherwise reject.
Now the Turing machine runs in $ O(\log n) $ because the function $f$ is computable in $ O(\log n) + O(\log n) = O(\log n) $ and comparing the length returned by the function is $ O(1) $
Thus the language is decidable by a Turing machine that is run in $ O(\log n) $ and only takes Space $ O(\log n) $.
I am given a function
$ f = \{0, 1\}^ \rightarrow \{0, 1\}^ $ that is computable in space $O(\log n)$ assume that for every $x \in \{0, 1\}^*$, $f$ is length preserving, $|f(x)| = |x|$.
Define
$$L = \left\{ x\#y \mid \ x, y \in \{0, 1\}^*, |x| = |y|, \ \text{and} \ f(x) = f(y)\right\}$$
I am suppose to prove that $ L \in {\sf DSPACE}(\log n) $.
Please correct me if my intuition is incorrect.
My solution would be to build a decider $M$ which is a Turing machine.
$M$ takes inputs $x$ and $y$, run the function $f$ on input $x$ and $y$ and if the lengths of the two strings are equal then accept, otherwise reject.
Now the Turing machine runs in $ O(\log n) $ because the function $f$ is computable in $ O(\log n) + O(\log n) = O(\log n) $ and comparing the length returned by the function is $ O(1) $
Thus the language is decidable by a Turing machine that is run in $ O(\log n) $ and only takes Space $ O(\log n) $.
Solution
Here is a rough idea how to solve this. You compare $f(x)$ and $f(y)$ character by character. Your tape is devided into 4 pieces. The first one is for simulating $f(x)$ the second one for $f(y)$, then you have two parts, one that counts which character of $x$ you are currently computig, and another $O(\log n)$ area that helps you to navigate. Now the programm looks like this
- Determine $|x|$ and $|y|$ (store it in binary!) and check if there are the same.
- Compute the first character of $f(x)$ by simulating it on your machine. Store the output in a TM-state. Pause the Computation of $f(x)$.
- Walk $|x|+1$ step to the right.
- Simulate $f(y)$ until you get the first character, check if it coincides with the start of $f(x)$, if no reject, otherwise continue.
- Walk $|x|$ steps left.
- Repeat the steps 2.-5. until you check $f(x)=f(y)$ completely.
Context
StackExchange Computer Science Q#11588, answer score: 3
Revisions (0)
No revisions yet.