Quote by Confusus
Now for the irreversible compression, with same initial and final system states. Since entropy is a state function, ΔS for the system is exactly the same value as above. However when you calculate the heat transfer q, that has a higher value now (more work was required for the irreversible compression, so more heat was expelled). To get entropy change of the surroundings, textbooks use ΔS_{surr}=q_{surr}/T=q_{sys}/T, which is higher than ΔS_{sys}. But isn't it illegal to use that formula for this irreversible process? I'm totally confused. All of the textbooks brush right over this point, but it seems like an obvious objection.

I suspect that your textbook is assuming the irreversibilities are generated inside the gas volume, but that the external heat transfer can be modeled as reversible. This makes it simple to calculate the entropy change in the surroundings.