Proving that $f = 0$ if $\int fg = 0$ for all $g \in S$ Let $f \in L^1$. I want to prove that if $\int f g = 0$ for all $g\in S$, then $f = 0$ a.e. $S$ denotes Schwartz space.
My Approach: My idea is to let $h = sgn(f)$ and then smooth it somehow to get a function in $S$. But I don't know how to proceed. Any hint?
 A: Write $f = \sum_Q f 1_Q$ where the sum is taken over a countable collection of disjoint cubes that cover $\mathbb{R}^n$.
Firstly, we can approximate $1_Q$ from the inside by Schwartz functions $a_n$ to get that $\int_Q fg = \lim_n \int f g a_n  = 0$ for all Schwartz  functions $g$.
Thus, by replacing $f$ with $f1_Q$ we may assume $f$ is compactly supported but still satisfies $\int fg = 0$ for all Schwartz $g$.
Now $h = \mathrm{sign}(f)$. Take $h_\epsilon = \eta_\epsilon * h$ where $\eta_\epsilon(x) = \frac{1}{\epsilon^n} \eta\left(\frac{x}{\epsilon}\right)$ and $\eta(x) = C \exp\left(\frac{1}{|x|^2-1}\right)$ if $|x|<1$ and $\eta(x) = 0$ elsewhere, where $C$ is chosen so $\int \eta = 1$. I.e. $\eta$ is a standard mollifier. Then $h_\epsilon$ is $C^\infty$ with compact support, in particular $h_\epsilon$ is Schwartz, and $h_\epsilon \to h$ almost everywhere. Moreover, $h_\epsilon$ is uniformly bounded by $1$ by Young's convolution inequality. Then by dominated convergence $\int|f| = \int f h =\lim_\epsilon \int f h_\epsilon = 0$.
A: Thanks to NullUser, I have come up with a simple proof with contradiction.
Let $E_n= \{|f| \geq \frac{1}{n}\}$and assume by contradiction that $f \neq 0$ a.e. Note that $\{|f| \neq 0\} = \cup_{n\geq1}E_n$. So there exist $E_N$ with $0 <\mu(E_N)< \infty$. Note that $E_N = E_N^+ \cup E_N^-$ where $E_N^+ = \{f \geq \frac{1}{n}\}$ and $E_N^- = \{f \leq \frac{-1}{n}\}$. WLOG assume that $\mu (E_N^+)>0$.
Note that $1_{E_N^+} \in L^1$. So there exist $g_n \in S$ s.t. $|g_n| \leq 1$ for all $n$ and $g_n \to 1_{E_N^+}$ in $L^1$. Moreover, $|fg_n| \leq |f|$. So by DCT, $fg_n \to f1_{E_N^+}$ in $L^1$ which implies $\int fg_n \to \int f1_{E_N^+}$, but LHS is zero, while RHS $\geq\frac{1}{n}\mu(E_N^+)>0$
