By the work-energy theorem, we can justify that the work on a particle due to the net force equals the change in kinetic energy of the particle. In compact notation, \begin{align}\tag{1} W_{\text{net}} = \Delta KE. \end{align} This seems very useful. However, there are other contexts where work is used.
For example, we might want to find the potential energy of a certain configuration of charges in electrostatics. In that case, we imagine bringing charges from infinity together quasi-statically. By calculating the work needed to assemble the charge configuration, we say we have found the potential energy of the setup: $W = \Delta U$. But this time, we assume there is no kinetic energy is involved, because the process was quasi-static.
A more simple example is the case of trying to find gravitational potential energy, where we consider what it takes to lift something up quasi-statically (which can be done by applying a constant force $\vec{F} = mg\vec{e}_{z}$ to counteract $\vec{F}_{g}=-mg\vec{e}_{z}$), compute $W = \int_{0}^{h} mg\, dz = mgh$, and find $\Delta U = mgh$.
So now we might want to write \begin{align}\tag{2} W = \Delta KE + \Delta U. \end{align} I am aware we are no longer considering net work (which was crucial to the initial formulation of the work-energy theorem).
To make this more general, we might also consider internal energy (which will take into account thermal energy). So for example, maybe we have a system in which friction occurs internally, so there is work done by friction which "siphons" off energy into heat. In that case, if we define our system carefully, the work produced by a force external to the system will result in \begin{align}\tag{3} W_{\text{ext}} = \Delta KE + \Delta U + \Delta E_{\text{int}}. \end{align}
My question is, are there theorems or (semi-)rigorous arguments that demonstrate the validity of equations $(2)$ and $(3)$? I suppose $(2)$ might be trivial if we qualify that the forces involved are conservative (so by definition we have $\vec{F} = -\nabla U$), but it's not clear exactly what rigorous argument can be made. And what about equation $(3)$? How is that rigorously justified?
Some related questions: