consider a mole of an ideal gas enclosed in a container with a mass-less piston undergoing isothermal reversible expansion. now we know that in an reversible process the system and the environment must be in equilibrium at all times.

• if that is the case then how does the pressure of the ideal gas change since at all times it must be equal to the pressure of the environment which is a constant?
• The pressure of the gas and the environment are equal only if the frictionless piston is allowed to move freely. In order for the ideal gas to undergo an isothermal process, the piston must therefore not be allowed to move freely. In fact, it must be set up to move very slowly in order for the system to always be in thermal equilibrium with the surroundings. – march Jan 12 '16 at 5:55

The pressure of the environment is not held constant. The gas is allowed to expand very gradually by, say, removing tiny weights from the top of the piston. Along the entire path of the expansion process, the pressure of the surroundings is held slightly below the pressure of the gas so that the gas is always only slightly removed from being at thermodynamic equilibrium. A reversible process is thus ideally regarded as a continuous sequence of thermodynamic equilibrium states for the system.

The state equation says:

P V = R T

For an isothermal process, T is constant by definition

R is a physical constant

For an expansion process V is increasing

So, P must necessarily be decreasing for the gas within the system

Assuming a constant piston area of A, the force on the piston is:

F (on piston from internal gas) = P (internal gas) A (piston)

And since P is decreasing with the expansion in V, the internal force on the piston must also be decreasing.

Since the external force on the piston is equal to the pressure of the surrounding atmosphere acting on the area of the piston, this force is again according to the F = P A formula giving

F (atmosphere on piston) = P (atmosphere) A (piston)

With a constant atmospheric pressure and piston area this force is also a constant.

Since the net force on the piston must be zero for equilibrium and since this net force is the sum of all the forces it is given by:

F (net) = P (internal gas) A - P (atmosphere) A - F (external load)

For the net force to sum to zero with a decreasing internal pressure and constant surrounding atmospheric pressure and constant piston area, we must have a decreasing load force on the piston.

Alternatively, we can have the absence of an external load force on the piston accompanied by a reducing surrounding atmospheric pressure acting on the piston.

Either way, the key here is to do it slowly - which is termed quasi-static or quasi-equilibrium - so there is no discernible pressure difference across the piston (modeled with a massless and frictionless piston) and no discernible temperature difference across the heat transfer boundary (again modeled as ideal).