An irreversible process is slightly problematic because, in an irreversible process, the pressure and/or the temperature are non-uniform, and vary with spatial position within the system. But that doesn't mean that we cannot apply the first law to a system that has undergone a reversible process. However, unlike a reversible process where we can calculate the pressure and temperature variation throughout the entire process, in the case of an irreversible process, the system is at thermodynamic equilibrium only at the start of the process and at the end, and it is at these points that the pressure and temperature again become uniform (and can be determined).
It is helpful for the present purposes to restate the first law: The change in internal energy between equilibrium states of a closed system is equal to the heat absorbed from the surroundings (path dependent) minus the work done on the surroundings (path dependent). But, if the pressure varies with spatial position within the system during an irreversible process, what pressure should one use to calculate the work done on the surroundings during the process? For both reversible and irreversible processes, the answer to this question is the pressure at the interface between the system and the surroundings. Since, even in an irreversible process, the pressure is continuous at the interface, the pressure to use in calculating the work is always the pressure of the surroundings Psurr. In a reversible process, the pressure within the system becomes uniform, and thus, becomes equal to the pressure of the surroundings. So, for both reversible and irreversible processes, the mathematical statement of the first law becomes:
ΔU = Qsurr - Wsurr = Qsurr - ∫PsurrdV
In this equation, the change in internal energy ΔU depends only on the initial and final equilibrium states of the system, but is independent of the path between the initial and final states. But both the heat absorbed from the surroundings Qsurr and the word done on the surroundings Wsurr is dependent on the path.
As an aside, we talked about how the work done on the surroundings is calculated. But how is the heat absorbed from the surroundings calculated? What you do is take the heat flux vector at the boundary and evaluate its component normal to the boundary (by dotting the heat flux vector with a unit normal). This then gives the local rate of heat absorbed from the surroundings per unit area of interface. You then integrate over the entire area of the interface to get the total rate of heat absorbed from the surroundings. You then integrate this with respect to time to get the total amount of heat absorbed from the surroundings during the entire process.
I'd like to illustrate how this all works with a specific example. Suppose you have an ideal gas contained within a cylinder, and, in the initial equilibrium state, the pressure, temperature, and volume per mole are Pi, Ti, and Vi, respectively. We will be looking at an isothermal and then an adiabatic expansion of the gas in an irreversible process for which the imposed pressure of the surroundings is suddenly changed at time zero from Pi to Psurr, and subsequently held constant. Of course, the final state for the isothermal process will be different from the final state for the adiabatic process.
First the Isothermal Process:
Wsurr = Psurr(Vf - Vi)
where Vf is the final volume per mole. Now, in the final equilibrium state, the pressure will be Psurr, so that, from the ideal gas law
Vf = RTi/Psurr
where, for the isothermal process, the final temperature is equal to the initial temperature. Also, applying the ideal gas law to the initial state, we get:
Vi = RTi/Pi
If we substitute these results from the ideal gas law into the equation for the work Wsurr, we get
Wsurr = RTi (1 - Psurr/Pi)
I've frequently heard it said that, for an irreversible expansion, in the limit of very low pressures for the surroundings, the amount of work done on the surroundings approaches zero. But that is not what this equation is telling us. It is saying that, for an irreversible isothermal expansion, as the pressure of the surroundings gets very low, the amount of work done on the surroundings approaches RTi. The reason for this result is that even though the surroundings pressure is very low, the final volume of the system becomes very large, and so a finite amount of work gets done.
In this isothermal case, the change in internal energy for an ideal gas is zero, so the amount of heat absorbed from the surroundings is equal to the work done on the surroundings.
Adiabatic Irreversible Process:
In this case, the equation for the work done on the surroundings is again given by:
Wsurr = Psurr(Vf - Vi)
If we again apply the ideal gas law tot this equation for an adiabatic expansion, we obtain:
Wsurr = RTf - RTiPsurr/Pi
For an adiabatic process, the heat absorbed from the surroundings Qsurr is zero, but the change in internal energy is equal to minus the work done on the surroundings:
ΔU = Cv(Tf- Ti) = RTiPsurr/Pi - RTf
This equation can be used to solve for the final equilibrium state temperature Tf in terms of the initial temperature:
Tf=Ti(Cv+RPsurr/Pi)/(Cv+R)
Substitution of this into the equation for the work done by the surroundings then gives:
Wsurr = RTi (1 - Psurr/Pi)Cv/(Cv+R)
Note that this is the same result as for the isothermal case, except for the additional factor of Cv/(Cv+R). As expected, in the adibatic case, less work is done on the surroundings.
Finally, in the limit as the pressure of the surroundings Psurr becomes small, the adiabatic work for this irreversible process is not zero, but becomes:
Wsurr = RTiCv/(Cv+R)