Here is a paper I wrote and put in my last book The Great Noetic Filter. It is all about how to derive the adiabatic gradient from first thermodynamic principles, and it addresses the claim that the troposphere should be isothermal – it should NOT be.