I would like to prove that $ac[0,1]$ which is defined as the set of all absolutely continuous functions on $[0, 1]$ is dense in $L^1([0,1])$.
I was thinking about defining, for $f \in L^1,$
$$f_n(x):=n \int_{(x,x+1/n)} |f|\ d\lambda$$ and prove that:
$1)\ f_n$ is absolutely continuous.
$2)\ f_n$ converge to $f$ in $L^1$ norm ($\|f_n-f\|_1<\epsilon$)
I know how to prove $1$, but I need help in $2.$ Thanks.
For the sake of convenience, extend $f$ to $\mathbb{R}$ by letting $f(x) = 0$ if $x \notin [0,1]$. Given $n \in \mathbb{N}$, define $f_{n}(x) = n \int_{x}^{x + n^{-1}} f(y) \, \lambda(dy)$, where $\lambda$ is the Lebesgue measure. Note that we don't want the absolute value bars in the integrand: if $f = -1$, for example, then $n \int_{x}^{x + n^{-1}} |f(y)| \, \lambda(dy) = 1$, from which we would obtain $\|f - f_{n}\|_{L^{1}([0,1])} \simeq 2$.
I'll trust that you can prove $(f_{n})_{n \in \mathbb{N}}$ is a sequence of absolutely continuous functions.
Now I'll prove $f_{n} \overset{L^{1}}\to f$. The key fact is the following: if $f \in L^{1}(\mathbb{R})$ and $\tau_{y}f$ denotes the $L^{1}$-function $(\tau_{y}f)(x) = f(x + y)$, then $$\tau_{y}f \overset{L^{1}}\to f \quad \text{as} \, \, y \to 0.$$ If $f \in C_{c}(\mathbb{R})$, then this follows from uniform continuity of $f$. The general case then follows by density of $C_{c}(\mathbb{R})$ and uniform boundedness of the operators $\{\tau_{y}\}_{y \in \mathbb{R}}$ acting on $L^{1}(\mathbb{R})$. Indeed, $$\|\tau_{y}f\|_{L^{1}(\mathbb{R})} = \int_{-\infty}^{\infty} |f(x + y)| \, \lambda(dx) = \int_{-\infty}^{\infty} |f(x)| \, \lambda(dx) = \|f\|_{L^{1}(\mathbb{R})}$$ so $\|\tau_{y}\| = 1$. If $f \in L^{1}(\mathbb{R})$ and $(h_{n})_{n \in \mathbb{N}} \subseteq C_{c}(\mathbb{R})$ satisfies $h_{n} \overset{L^{1}}\to f$, then \begin{align*} \limsup_{y \to 0} \|\tau_{y}f - f\|_{L^{1}(\mathbb{R})} &\leq \limsup_{y \to 0} \left[\|\tau_{y} h_{n} - h_{n} \|_{L^{1}(\mathbb{R})} + \|h_{n} - f\|_{L^{1}(\mathbb{R})} + \|\tau_{y}h_{n} - \tau_{y} f\|_{L^{1}(\mathbb{R})}\right] \\ &\leq 2 \|h_{n} - f\|_{L^{1}(\mathbb{R})}. \end{align*} Taking $n \to \infty$, we find $\limsup_{y \to 0} \|\tau_{y}f - f\|_{L^{1}(\mathbb{R})} = 0$, proving the claim.
Now to see that $f_{n} \overset{L^{1}}\to f$, integrate and change variables: \begin{align*} \|f - f_{n}\|_{L^{1}([0,1])} &= \int_{0}^{1} |f(x) - f_{n}(x)| \, \lambda(dx) \\ &= \int_{0}^{1} \left| f(x) - n \int_{0}^{n^{-1}} f(x + y) \, \lambda(dy) \right| \, \lambda(dx) \\ &= \int_{0}^{1} n \int_{0}^{n^{-1}} \left|f(x) - f(x + y) \right| \, \lambda(dy) \, \lambda(dx) \\ &= n \int_{0}^{n^{-1}} \left[ \int_{0}^{1} \left|f(x) - f(x + y) \right| \, \lambda(dx) \right] \, \lambda(dy) \\ &= n \int_{0}^{n^{-1}} \|\tau_{y} f - f \|_{L^{1}(\mathbb{R})} \, \lambda(dy) \\ &\leq \sup\{ \|\tau_{y} f - f\|_{L^{1}(\mathbb{R})} \, \mid \, y \in [0,n^{-1}]\} \end{align*} Since $\lim_{y \to 0} \|\tau_{y}f - f\|_{L^{1}(\mathbb{R})} =0$, we conclude $$\lim_{n \to \infty} \|f_{n} - f\|_{L^{1}(\mathbb{R})} = 0.$$