Are bikes with sloping top tubes lighter than bikes with horizontal top tubes?
So are bikes with sloping top tubes lighter than bikes with horizontal top tubes?

No.
The frame may be lighter but the total bicycle ain't. The larger bending moment at the location where the seatpost enters the frame must be supported, and it means the seatpost requires more material besides needing to be longer. Even if the seatpost is not made more sturdy (which would mean you're not comparing apples to apples anymore, as you can't just increase the seatpost length and have an equally durable seatpost), a given length of the seatpost would weigh more than the same length of the seat tube.
The reason for sloping top tubes is something entirely different. Just look at the relative saddle and handlebar heights of the two bikes. The horizontal top tube frame has low handlebars, whereas the sloping top tube frame has high handlebars.
Now, you can have high handlebars on a horizontal top tube frame you can stand over, but it would require lots of spacers around the fork steerer tube, or alternatively a high-rise stem. Many people consider the look of either of these solutions ugly.
I have a Surly Long Haul Trucker I built myself. It has a 17 degree stem flipped down, so the stem is horizontal in addition to the top tube. It indeed requires a very very large number of spacers around the fork steerer tube. This is despite the fact that the height of the top tube above the ground is such that I can barely stand over the frame.
If you want to have handlebars at the same height as the saddle, either you require a sloping top tube, a lot of spacers or a high-rise stem.
This of course doesn't affect those of us who prefer a low racing style handlebar height.
So, the reason for sloping top tubes is most likely the fact that we have nowadays threadless headsets (aheadsets) and the stems that clamp around the fork steerer tube. When horizontal top tube bikes were the norm, we had quill stems that don't require spacers.