In coding terms, writing regulations is like writing code for something that is going to be attacked by determined adversaries with an abundance of resources to use in the attack.

For example, consider a simple rule that says a dividend from stock is ordinary income, and money from a sale of stock is capital gains income.

It could be simpler--just count everything as ordinary income instead of shoving some off into a separate "capital gains" category that is taxed lower--but that was Congress' call, not the regulator's call. Congress has chosen to make the distinction, and so the regulator has to live with it.

A long time ago, that simple rule or something like it was what was in the regulations. Then some well funded party got clever. They wanted to give their shareholders a dividend. Let's say that dividend came out per share to 1% of the value of the share.

Instead of just doing that, they had the bright idea of doing a fractional stock split that takes each 1 share to 1.0102051 shares, with the price per share dropping to .989898 times the old price. That would be immediately followed by a mandatory stock buyback of 1.01021% of the shares, which would (if I did the math right when picking the split and buyback numbers) raise the share price back to the original price, and leave each shareholder with the same number of shares they had before plus cash from the buyback equal to 1% of the original share price.

But now that money came from a sale of stock, not a dividend! It was now capital gains according the party's lawyers and accountants.

OK, this is easy for the regulators to fix. Just add to the rule that stock buybacks are ordinary income. But then you'll run into cases where a stock buyback is actually motivated by some legitimate (from a public policy point of view) reason instead of simply trying to get capital gains status.

By the time you close off all the tricks, while still giving capital gains status to buybacks that are not trying to game the system, what started out as a simple rule of one seemingly clear sentence will be a few pages delving into considerations of how wide the buyback is and whether it causes substantial changes in the way ownership is distributed among the shareholders in order to classify buybacks as legitimate or attempts at gaming the system.

Now repeat this for all the other simple regulation, and pretty soon your nice simple, clear tax regulations are thousands and thousands of pages.

BTW, this is why most flat tax proposals are silly. They tend to promise great tax simplification by going to a flat rate (which they do not actually propose--they almost always actually keep a progressive rate with two brackets), but the non-flat rate structure in the current US tax code has almost nothing to do with why it is not simple. The non-flat rate structure takes up something like a paragraph on the first or second page of the IRS regulations. Just going flat shortens that paragraph. Once you get past all that, it is just one or more trivial table look ups.

The complexity in the tax code comes from answering the questions "how much of my income is taxable?", "how much of the taxable income is capital gains?", "what tax credits can I claim?", and so on. None of that cares whether the rate structure is flat, highly progressive, or anything else.