Why do we get back taxes when sold asset for less than carrying?

Hi, what is the logic under this?!

If taxes 40 %, asset sold for 50 K, Carrying 100 K

0,4 (50-100)=- 20, hence, we have lower initial outflow (in replacement projects)? How do we get back taxes in real life?

Because the company will book a loss on the sale of the asset for 50k.

If the company’s earnings before tax without the sale would have been 100k, now it’s only 50k.

Taxes go from 40k without the sale to 20k with the sale.

Great. Thx