If patent filers chose to obfuscate their code, ideally their patent would be rejected for being unclear, or at least, they'd have a hard time defending their patent, as the difference between it and an alleged infringer would be quite large.
If patent filers chose to obfuscate their code, ideally their patent would be rejected for being unclear, or at least, they'd have a hard time defending their patent, as the difference between it and an alleged infringer would be quite large.
For example, in spatial indexing you can implement some widely used algorithms as either traversing the obvious space decomposition tree or doing lookups using projections onto higher dimensionality space-filling curves. The former is "obvious" but all good implementations use the latter code design because it is much more scalable in real systems even though the algorithms are equivalent.
Most algorithm patents with code go for "matches the high-level description of the algorithm" rather than "is an optimal representation of the algorithm given current computer science". That said, in my experience people are pretty good at reconstructing an algorithm implementation from patent descriptions that do not include code, assuming they have some domain expertise (i.e. in the above example, it should not be necessary to explain the representational equivalency of literal space decomposition and projections onto space-filling curves).
Most (all?) patentable subject matters work this way; the abstract process is patentable and the reduction to a specific implementation is protected by copyright because they are unrelated bodies of work. It is not uncommon, for example, to license a chemical process (read: algorithm) patent from one company and license a copyrighted implementation design from another company. Computer algorithm patents work the same way.
If you were to require that the patent code and the alleged patent-violating source code were defined functionally and represented the exact same function (prove f(x) = g(x)), that would cut down the space of potential patent violations, but patent holders would scream that such a limitation is unfair. There would still be plenty of silly patents that would be patentable, and the same problems would exist as with the existing system: if you read patents to see whether your code violates one of them, you're on the hook for more damages. In any case where exact behavior is not critical, someone might be able to get around patents simply by changing the mechanism/computation slightly. I'm thinking of things like mpeg patents, where encoding and decoding techniques are constantly being tweaked, improved, and getting new settings. Would allowing an additional input to a function f(a, b, c, ..., m), i.e. f(a, b, c, ..., m, n) render it immune to a patent that hardcodes n as "5" in the function?
This works very well in European Union, although this is an ongoing fight between lobbyists and civil rights defenders (such as FFII and EDRi).
(Note that there are lots of European software patents already filed, but those not legally enforcible right now.)
Why do we need software patents in the first place?
What constitutes theft of creativity? Stealing Mickey Mouse is an extremely concerted act, you have to present a character that is intended to fool people into thinking it's Mickey.
But stealing innovation is much broader. Accompanying a software patent application with illustrative source code will not limit the scope of the patent to copying the code. It covers use of the method, not just the code.
If someone, for instance, applied for a patent by describing an electronic game in which a player controlled character collects tokens inside a maze while computer-controlled characters tried to capture him, and accompanied his application with a full working copy of Pac-Man, then the patent would protect him against clones as well as direct copies. The point is not protecting against copies, that's the job of copyright. The point is the clones.
Patent law is intended to safeguard innovation that one could say would not have happened otherwise.
As to why we need software patents, recent articles have described the legal situation better than I can in a HN comment. Basically there's no legal distinction that has been drawn yet between software patents and other types of patents, one needs to be properly described and that's the job of the Supreme Court. At one point they were banned because they were insufficiently distinguishable from mathematical formulas, which definitely are unpatentable.
Over the years, Congress decided that patents were getting too complex for the court system to properly adjudicate, so they created a separate court to hear patent cases. This court turned out to be friendly to big business and gradually opened the doors to software patents while the Supreme Court chose not to get involved.
At that point of course it will also be much easier to limit all those overly broad claims.
Source code should not be patentable.