I understand that duplication is inefficient, but how is the patent system doing anything productive whatsoever to address it in the software industry? If something with market value can be kept as a trade secret then the incentive will be to do so notwithstanding the patent system, and then to patent various other things for legal defensive purposes which are less valuable
in the market but more valuable
in the courtroom. And things which can't effectively be held as trade secrets won't be wastefully duplicated anyway because the first to produce such a product is by stipulation unable to keep the secret.
More than that, if we were at all concerned about the use of trade secrets causing wasteful duplication then we cannot consistently allow the law to protect them as something of value. If we are so keen on disclosure and reducing duplication then industrial espionage should be fully legal as an efficient means of distributing knowledge to other market participants, and holders of trade secrets should be directed to the Patent Office as their sole means of protection. But I think we are not so keen because the problem of duplication is not so large, and the incentive provided by the patent system would not compare well with the incentive provided by the alternative.