How do we know that P != LINSPACE without knowing if one is a subset of the other?

Suppose by contradiction that P=SPACE(n). Then there exists an algorithm to simulate an n-space Turing machine in (say) nc time, for some constant c. But this means that there exists an algorithm to simulate an n2-space Turing machine in n2c time. Therefore SPACE(n2) is also contained in P. So

P = SPACE(n) = SPACE(n2).

But SPACE(n) = SPACE(n2) contradicts the Space Hierarchy Theorem. QED

(Notice that in this proof, we showed neither that P is not contained in SPACE(n), nor that SPACE(n) is not contained in P! We only showed that one or the other must be true, by using the different closure properties of polynomial time and linear space. It's conjectured that P and SPACE(n) are incomparable.)


I think I spotted a problem with the above proof by Scott. If P=SPACE($n$) implied that there's an algorithm to simulate an n-space Turing machine in (say) $n^c$ time, for some constant $c$, it would also imply that there's an algorithm in $n^c$ time to simulate all polynomial time Turing machines, and that P=TIME($n^c$), which contradicts the Time Hierarchy Theorem. But this problem can be fixed, of course:

Suppose that P=SPACE($n$). For contradiction with the Space Hierarchy Theorem, we'd like to show that every language in SPACE($n^2$) can be reduced in polynomial time to SPACE($n$). We will do this using the padding argument.

Let $L$ ∈ SPACE($n^2$), $M$ a Turing machine with space complexity $n^2$ for the language $L$. Let $L'$ be the “padded” version of $L$ defined as the set of words of the form $x01^{|x|^2}$ for each $x ∈ L$. Now $L'$ is in SPACE($n$) because for an input of size $n$, no more than $\sqrt{n}$ characters are the original input and we can run the simulation of the original machine $M$ using space $n$.

A reduction from $L$ to $L'$ can be easily done in polynomial time, hence P=SPACE($n$)=SPACE($n^2$), and we get the desired contradiction with the Space Hierarchy Theorem.


In comparison to the existing answers, the following answer tries to better distinguish between complexity classes, languages in a complexity class, and words over the alphabet of a language.


Assume $\mathsf{P}=\mathsf{SPACE}(n)$. Then we can show that $L\in\mathsf{SPACE}(n^2)$ implies $L\in \mathsf{P}$. This is equivalent to $\mathsf{SPACE}(n^2)\subset \mathsf{P}=\mathsf{SPACE}(n)$, which contradicts the Space Hierarchy Theorem.

Let's show that $L\in\mathsf{SPACE}(n^2)$ would imply $L\in \mathsf{P}$, if $\mathsf{P}=\mathsf{SPACE}(n)$. Let $L \in \mathsf{SPACE}(n^2)$ be a language over the alphabet $\Sigma_L$, i.e. $L\subset \Sigma_L^*$. WLOG assume $\Sigma_L=\{0,1\}$. We define the "padding" function $f_L:\Sigma_L^*\to \Sigma_L^*$ via $f_L(w)=w01^{|w|^2-|w|}$, where $|w|$ is the length of the word $w$. Let $L':=f_L(L)$. We have $w\in L \Leftrightarrow f_L(w)\in L'$, because $f_L$ is injective. We have $L' \in \mathsf{SPACE}(n)$, because $|f_L(w)|=|w|^2+1$. (This point is already elaborated in the other answers.) We can now conclude $L\in \mathsf{P}$ based on our assumption $\mathsf{P}=\mathsf{SPACE}(n)$ and the fact that $f_L(w)$ can be computed in time $O(|w|^2)$.