Total derivative in action of the field theory Consider a classical field theory. 
When applying the least action I see that a term is considered total derivative.
We say that 
$$\int \partial_\mu \left(\frac {\partial L}{\partial\left(\partial_\mu \phi\right)}\delta \phi\right) d^4x= \int d\left(\frac {\partial L}{\partial\left(\partial_\mu \phi\right)}\delta \phi\right)= \left(\frac {\partial L}{\partial\left(\partial_\mu \phi\right)}\delta \phi\right)$$
And then because the variation at the spatial infinity vanishes this terms is equal to zero.
I do not get the calculation from $$\partial_\mu \left(\frac {\partial L}{\partial\left(\partial_\mu \phi\right)}\delta \phi\right) d^4x=\frac {\partial \left(\frac {\partial L}{\partial\left(\partial_\mu \phi\right)}\delta \phi\right)}{\partial x^\mu} dtdxdydz$$ to
$$d\left(\frac {\partial L}{\partial\left(\partial_\mu \phi\right)}\delta \phi\right)=\frac {\partial \left(\frac {\partial L}{\partial\left(\partial_\mu \phi\right)}\delta \phi\right)}{\partial t}dt+\frac {\partial \left(\frac {\partial L}{\partial\left(\partial_\mu \phi\right)}\delta \phi\right)}{\partial x}dx+\frac {\partial \left(\frac {\partial L}{\partial\left(\partial_\mu \phi\right)}\delta \phi\right)}{\partial y}dy+\frac {\partial \left(\frac {\partial L}{\partial\left(\partial_\mu \phi\right)}\delta \phi\right)}{\partial z}dz$$
$$\neq \frac {\partial \left(\frac {\partial L}{\partial\left(\partial_\mu \phi\right)}\delta \phi\right)}{\partial x^\mu} dtdxdydz$$
Can you expand this to fill the gap for me.
Also, why we require "spatial infinity" here, isn't it also true that $$\delta \phi$$ in the $$\frac {\partial L}{\partial\left(\partial_\mu \phi\right)}\delta \phi$$ vanishes at any two endpoints of the events path, but why we require infinity here?
 A: Look more closely at what you write. I'm not going to write it with all the partial derivative and Lagrangians, because the confusions are not dependent on that:


*

*The requirement for spatial infinity arises because $\int_\mathcal{M} \mathrm{d}\omega \neq \omega$, but $\int_\mathcal{M} \mathrm{d}\omega = \int_{\partial\mathcal{M}}\omega $ (Stokes' theorem). For the latter term to vanish, it suffices that $\omega$ vanishes on $\partial\mathcal{M}$. Since the integrals are over $\mathbb{R}^4$, the boundary of our space is "infinity". (Since one would compute such integrals e.g. by taking them over a 4-ball of radius $r$ and sending that to $\infty$.)

*Observe that, if $\mathcal{L}$ is the Lagrangian density, i.e. a $0$-form, then its derivative with respect to $\partial_\mu\phi$ is a vector field, since it has upper Lorentz indices. And for any vector field $v$, the expression $\partial_\mu v^\mu = \partial^\mu v_\mu$ is exactly the component of the derivative of the Poincaré dual $3$-form $v^\mu \epsilon_{\mu\nu\sigma\rho}\mathrm{d}x^\nu\wedge\mathrm{d}x^\sigma\wedge\mathrm{d}x^\rho$, i.e. the derivative of the Poincare dual is just $\partial_\mu v^\mu \mathrm{d}^4 x$ (up to constants I'm too lazy to chase). Therefore, integrating that is integration of an exact form over a volume, which, by Stokes' theorem, reduces to the boundary values of the $3$-form is it a derivative of. Since the duality is a bijection, if $v^\mu$ vanishes, so must its dual, justifying looking just at the value of $\partial_\phi \mathcal{L} \delta \phi$ on the boundary. Equivalently, one could just lower the index of $v^\mu$ to get a $1$-form $v_\mu\mathrm{d}x^\mu$, apply Hodge duality to it to get a $3$-form, take the derivative of that, and get the same $4$-form with coefficient $\partial_\mu v^\mu$.
