I'm trying to solve an exercise in Brezis' Functional Analysis, i.e.,
Let $1 \le q \le p \le \infty$. Prove that the canonical injection from $L^p(0, 1)$ to $L^q(0, 1)$ is continuous but not compact.
There are possibly subtle mistakes that I could not recognize in below attempt. Could you please have a check on it? Is there a simpler approach that does not rely on below Lemma?
Consider $J:L^p(0, 1) \to L^q(0, 1), f \mapsto f$. For $f \in L^p(0, 1)$, we have $\|f\|_q \le \|f\|_p$ and thus $\|J\| \le 1$. Then $J$ is linear continuous. Let's prove that $J$ is not compact. We need the following result, i.e.,
Lemma Let $p \in [1, \infty]$ and $T>0$. Let $f:\mathbb R \to \mathbb R$ be a $T$-periodic function with $$ f(x) := \begin{cases} 0 &\text{if} \quad x \in [0, \frac{T}{2}), \\ 2 &\text{if} \quad x \in [\frac{T}{2}, T). \\ \end{cases} $$ We define $f_n:(0, 1) \to \mathbb R$ by $f_n (x) := f(nx)$ for all $x \in (0, 1)$. Let $\bar f := \frac{1}{T} \int_0^T f (t) \, dt$. We have
Let $f_n$ be given by above Lemma. Then $$ \|f_n\|_q \le \|f_n\|_p \le\|f_n\|_\infty=2 \quad \forall n \ge 1. $$
We claim that $(f_n)$ does not have any convergent sequence in $L^q(0, 1)$. Assume the contrary that $(f_{n_k})_k$ is a subsequence of $(f_n)$ and $g \in L^q(0, 1)$ such that $\|f_{n_k} - g\|_q \xrightarrow{k \to \infty} 0$. Then $f_{n_k} \xrightarrow{k \to \infty} g$ in $\sigma(L^q, L^{q'})$. Then $g= \bar f$ a.e. by (1). On the other hand, $\|f_{n_k} - g\|_q \not \to 0$ as $k \to \infty$ by (2). This is a contradiction. This completes the proof.