If you go back to mathematics and consider (Newton's method)[http://en.wikipedia.org/wiki/Newtons_method], that seems like it might have been invented, but it's derived from a series of discoveries, and hence is considered a discovery rather than an invention. If you used the Newton-Rhapson method to calculate the zero of a function in code somewhere, you should feel safe that it's not protected by a patent (not to mention it was discovered ages ago).
Since computer science is applied mathematics, and mathematics are discovered rather than invented, it makes sense that it should be protected as well. I'm not the best at explaining things, but hopefully you can understand the difference.
It's all discovery.
This is just semantic wordplay. I bet the legal literature is the same way. Even if we somehow fit these clunky classifications to reality, we would be no closer to designing a sensible patent system.
Don't worry, I understand the semantic distinction when the case is clear cut. Lead is a discovery, lead pipes are an invention. Addition is a discovery, arabic numerals are an invention. (by today's standards)