Let us focus on the case of a simple homogeneous substance that does not dissociate or undergo other chemical reactions. Then a thermodynamic state is any state where the substance has a definite pressure, equal in all its parts, a definite temperature, without any temperature variations in its different parts, and a fixed volume (it is not busy expanding or contracting). As usual we also assume the mass is fixed and so the density is also definitely related to the volume: so nothing more will be said about mass or density.
A bit of, e.g., gas cannot be in equilibrium if different parts have different temperatures, this is an observational fact: the temperatures tend to equalise. But we just make it part of the definition of a 'state' that the system has a definite temperature. It is only in more advanced, not so classical, thermodynamics that one relaxes to some extent this assumption.
This is not the definition of equilibrium, it is the definition of 'state'.
Now further, the definition of equilibrium is that if there is any thermal contact with the environment, then the environment must also be at a definite temperature, the same as that of the system. If the system can interact with the environment through doing work by expanding its volume, then the pressure of the system must be equal to the pressure of the environment. This is the definition of equilibrium.
Note carefully: if there is no interaction with the environment, then every thermodynamic state is a state of equilibrium, because there is no condition that it has to satisfy.
All of these remarks are logically prior to either the First or the Second Law of Thermodynamics, prior, too, to notions of reversibility or irreversibility, even to the notion of 'path'.
For that reason, they are sometimes called 'The Zero'th Law of Thermodynamics'.
All of this makes sense even if one does not know that temperature or pressure is the result of the motion of molecules: it was formulated before the modern theory of heat was understood, it was sometimes thought that heat was a fluid.
Comparative Statics does not have a true dynamics, but it is meant as a shortcut for use when the true dynamical evolution of the system is either unknown or too complicated to analyse.
One defines `equilibrium' by the balance of forces, by having the net sum of the forces acting at any point be zero. In thermodynamics, the two main principles are equalisation of temperature, thought of as the result of transferring heat from the hotter body to the colder, and equalisation of pressure, which occurs by expansion or contraction of the volume.
It is assumed that if one studies the properties of a system at one equilibrium point (i.e., the equilibrium state which would subsist under one set of values of the parameters such as the temperature of the environment and the pressure of the environment), and then studies the properties of that same system at a different equilibrium point which would subsist under different values of the parameters, then one has a good deal of information even about the process of transformation from the first point to the second point. In thermodynamics this is true provided the transformation proceeds slowly enough.
Equilibrium is meant to embody the notion that the system is in a stable state and will not evolve. Even so, the notion in thermodynamics of a reversible path is that a system passes through several different equilibrium states under outside influence (namely, a change in the external parameters which means that what was formerly an equilibrium state is no longer in equilibrium with the environment). Although it may violate strict logic, this is a very useful idealisation of reality. (In reality, only irreversible processes can take place.)
All of Classical Thermodynamics is Equilibrium Thermodynamics (to a first approximation), but it studies heat engines and refrigerators, in which the system does pass through different states, changing its pressure and volume. The theory uses comparative statics to be able to make statements about the end results of these processes, without being able to say anything about how the process happens exactly, at what rate, or anything truly dynamical.
If the system is in the state given by an equilibrium point, it will not change its state unless the external conditions are changed. If the external conditions, such as the temperature of the environment, go through a finite non-zero change, the shock will lead to an irreversible transformation through disequilibrium states, e.g., the part of the system closer to the boundary will heat up before the rest of the system, and this means the system is not in a thermodynamic state at all. Eventually the system will reach a new equilibrium state, but the amount of work done or heat absorbed during this transition period is not exactly calculable using Classical Equilibrium Thermodynamics. (At least, not in the elementary part.)
If the non-zero change is very small, it will be a reasonable approximation to treat it as the result of an infinite number of infinitesimal changes. An infinitesimal change does not shock the system out of equilibrium, but coaxes it gently to a neighbouring state of equilibrium. Hence the system traverses a reversible path of equilibrium states. Infinitely slowly. In reality this is not possible. Logically, if a path is reversible, then there is no reason for the system to pick which direction in which to traverse it, so the system will stay put. But this is an idealisation which is a useful approximation to the real world of irreversible transformations through disequilibrium states. More importantly, it gives us a theoretical bound on the efficiency of an irreversible process, an efficiency which can never be improved on.
The Second Law of Thermodynamics will be taken in the formulation due to Lord Kelvin and preferred by Nobel laureate Max Planck. It is impossible to find a cycle (of paths) whose only effects on the environment are to produce work and take heat from the environment.
Note by contrast that the Carnot cycle both takes in heat and puts out heat. In fact, it has to have two heat reservoirs, at two different temperatures. It takes in heat from the hot one, and puts out heat to the cold one. The point of the Second Law is that it is impossible to turn into work all the heat taken from the hot reservoir. Some of the heat has to be 'passed on' to a colder reservoir.
Our strategy will be to first consider reversible cycles. A reversible path is one where we infinitesimally nudge one equilibrium state to a nearby one and there are only two ways to do this: we can put it into thermal contact with an inifitesimally hotter (or colder) heat reservoir. It will absorb (or lose) a tiny amount of heat so slowly that the equilibrium is not disturbed, and any other adjustments allowed by the setup will also happen infinitely slowly and delicately. We can adjust its volume infinitesimally: we can alter, very delicately and infinitesimally, the pressure of the environment which, if we allow the system to be in the kind of setup where it feels the pressure and can alter its volume, it then contracts (or expands) until pressure is equalised.
There are only two ways to reversibly move the equilibrium state around, any reversible path is really a combination of adiabatic transformations and isothermal transformations. If we allow thermal contact with the environment, that is of course an isothermal transformation. If we do not allow thermal interaction with the environment, then of course no heat can be exchanged, and that by definition is an adiabatic transformation, and that is the only way the temperature can be altered.
The first point is to deduce from Lord Kelvin's formulation of the Second Law of Thermodynamics that no cycle (heat engine) can be more efficient than a reversible cycle (heat engine).
The basic idea of this deduction is that if C were a cycle (and, for simplicity, assume it operates between two heat reservoirs only, 1 is 'hot' and 2 is 'cold') that was more efficient than a reversible cycle R operating between the same two reservoirs, then the Second Law would be violated. For we could run the engine C and use its external work to drive R in reverse, as a refrigerator, since R is reversible. By scaling R up or down, if necessary, we can assume that R requires the same amount of heat input from the cold reservoir as is output there by C. Since C is more efficient than R, C produces more work than R really needs to operate. Hence, the combination of running C then R is that the cold heat reservoir is unchanged, heat has been absorbed from the hot reservoir only, and net work has been produced (since not all the work produced by C was needed by R). But this violates the Second Law of Thermodynamics.
The second point is to note that therefore, every reversible cycle operating between the same two temperatures has the same efficiency.
For we can apply the above argument to two reversible cycles, and then
neither of them can be more efficient than the other.
We are about to use a little algebra, so we have to formalise the notation for
the intuitive argument we already presented in words.
Let $W$ be the total work done in one cycle by a given engine. Since it is a cycle, there is no change in the internal energy $U$, so the work done is $ W = \Delta Q_1 - \Delta Q_2 $, where $\Delta Q_1$ is the heat absorbed at the hot reservoir and $\Delta Q_2$ is the wasted heat, expelled to the cold reservoir. The efficiency, by definition, is $W \over \Delta Q_1$ and this is equal to $1-{\Delta Q_2 \over \Delta Q_1} $.
Hence, all reversible cycles operating between the same two reservoirs have
the same ratio $ \Delta Q_2 \over \Delta Q_1 $.
This fact is used to define the temperature of the reservoirs by
$$ {\Delta Q^R_2 \over \Delta Q^R_1 } = {T_2 \over T_1} .$$
(I wrote $R$ this time to emphasise that this is only for reversible cycles.)
This defines the temperature up to a scaling factor. It also immediately gives us
$$ {\Delta Q^R_2 \over T_2 } = {\Delta Q^R_1 \over T_1} .$$
Now, redefine $\Delta Q_2$ to mean, just as with the other reservoir, the heat absorbed by the system from the cold reservoir. This is more rational, less prejudiced against refrigerators. We now get for all reversible cycles,
$$ {\Delta Q^R_2 \over T_2 } + {\Delta Q^R_1 \over T_1} = 0 $$
and for an arbitrary cycle,
$$ {\Delta Q_2 \over T_2 } + {\Delta Q_1 \over T_1} \leq 0 .$$
By approximating an arbitrary path by segments like these and using lots of reservoirs, two for each segment, we get the curved versions:
$$ \int_{\mbox{closed path}} {dQ \over T} \leq 0,$$
with equality whenever the path is completely reversible. This is Clausius's inequality, and it follows from the Second Law by the line of reasoning we followed involving comparing an arbitrary cycle to a reversible cycle being run in reverse. Arranging it to cancel out the effect of the given cycle on one heat reservoir, and getting a contradiction to the Second Law.
If we now confine ourselves to reversible transformations between equilibrium thermodynamic states only, then the fact that this path integral is zero means we can define a potential function $S$ (well-defined up to an additive constant) such that $$S(\mbox{state two}) - S(\mbox{state one}) = \int_1^2 {dQ \over T}.$$
This is pure mathematics. It's like an antiderivative (except in two dimensions). This is the basic definition of entropy in Classical Thermodynamics (as distinguished from the informational definition of entropy in Stats or in Stat Mech, due to Boltzmann, Sir Ronald Fisher, and Shannon).
But from the Clausius inequality, it follows that for an irreversible path, $$\int_1^2 {dQ \over t} < S_2 - S_1 .$$ Now, for an isolated system, $dQ$ is always zero since no heat can be exchanged with the environment. So $$S_2 - S_1 > 0.$$ I.e., along an irreversible path, the entropy of an isolated system increases, and along a reversible path, the entropy cannot change.
There is something illogical about this. Entropy has only been defined for equilibrium states, and if a system is isolated, there is no way to disturb the system, and so, no processes will take place.
But as an idealisation, to give us simplified approximations to real processes
provided they take place very slowly, it is logical in its own way.
Clausius's inequality does not tell us how fast the dynamics will go along a
path, but it will tell us which direction is possible and which direction is
impossible. Because $$\int_1^2 {dQ \over t} = - \int_2^1 {dQ \over t} ,$$
so if one direction yields a negative value of the integral, the other
direction will yield a positive value, which is forbidden by Clausius's
inequality so that other direction is impossible.