How to justify Dirac delta in integral kernels? I wonder if it is justified, in any manner, to treat the identity operator $I$ on $L^2(\mathbb{R})$ as an integral transform with the kernel $K(y,x) = \delta(x-y)$ such that
$$f(y) = (I f)(y) = \int_\mathbb{R} K(y,x) f(x) dx = \int_\mathbb{R} \delta(x-y) f(x) dx.$$
This is quite ubiquitous in quantum mechanics literature where "generalized position eigenstates" are used in the place of an orthonormal basis in identities like
$$\langle\phi|\psi\rangle = \langle\phi|I|\psi\rangle = \int_{\mathbb{R}^2} \langle\phi|y\rangle\langle y|I|x\rangle\langle x|\psi\rangle\,dx\,dy = \int_{\mathbb{R}^2} \phi(y)^\ast \delta(x-y) \psi(x)\,dx\,dy = \int_\mathbb{R} \phi(x)^\ast \psi(x) dx.$$
On the one hand, Dirac $\delta$ is an object from an entirely different part of mathematics than $L^2$ functions, and the integral sign has a different meaning in generalized functions and in Lebesgue spaces. So I'm inclined to say that the above calculation is wrong on many levels. On the other hand, the $\delta$ is not used as a functional here and only some of its properties are needed for the integral kernel, and the resulting integral is perfectly alright, so the reasoning might have a potential to work, perhaps in some theory I just don't know.
Disregarding the rest I'm interested whether I can make the very last “=” work in the above display. Is there such a theory in which $\delta(x)$ (and its derivatives) could be used in (formal) integral transforms applied on Lebesgue spaces, or $L^2$ at least?
 A: If you study physics and not pure math, my advice would be "your intuition (and all formulas you wrote) is fine, don't worry about the rigorous details". But here go some ramblings on math, maybe it helps.
$\delta$ is a distribution, not a function. It is an element of the dual space of a space of "testfunctions". Typically, you take as testfunction-space either Schwarz-functions $S$ or smooth functions with compact support.


*

*$\int \delta(x) f(x) dx$ is an abuse of notation, its not an integral, but should be written as $\delta[f]$ strictly speaking.

*The expression $\int \delta(x-y)f(x)dx$ is only defined for testfunctions $f$. So this defines you an operator $S\to S\subset L^2$. But this operator is bounded, and $S$ is dense in $L^2$, so there is a unique extension of this operator on the whole $L^2$ ("BLT lemma").

*in the expression $\int\int \phi(y)^*\delta(x-y)\psi(x)dxdy$ you have to specify which of the two integrals actually is an integral, and which one is an application of a distribution. Depending on that choice, you have either a function $S\times L^2\to\mathbb{C}$ or $L^2\times S\to\mathbb{C}$. In both cases you show boundedness which implies a unique extension.

*For a general distribution (even the derivative distribution $\delta'$), the situation is trickier. You start by defining your operator (or quadratic form) on test-functions, but that operator will generally not be bounded, so there is plenty of choice which extension to take (and typically you wouldn't want to extend it to the whole $L^2$ anyway). Often you are interested in self-adjoint extensions, which might be unique if you imposed good boundary conditions or such things.

*The expression $ \int_{\mathbb{R}^2} \langle\phi|y\rangle\langle y|I|x\rangle\langle x|\psi\rangle\,dx\,dy$ is not very mathematical at all, because $|x\rangle$ does not really exist. The way such things are written in functional analysis is
$$X = \int_\mathbb{R}x\ dE(x)$$
$$1 = \int_\mathbb{R}\ dE(x)$$
where $X$ is the position-operator and $E$ is the spectral measure of $X$. The sloppy physics version of the second version is writing $1=\int_\mathbb{R} |x\rangle\langle x|$ which is misleading, because $|x\rangle$ does not exist, but $|x\rangle\langle x|$ does (as a projection-valued distribution).

