“We see the tax code as a calculator,” said Jacob Rosen, a researcher at the Massachusetts Institute of Technology who focuses on the abstract representation of financial transactions and artificial intelligence techniques. “There are lots of extraordinarily smart people who take individual parts of the tax code and recombine them in complex transactions to construct something not intended by the law.”

A recent paper by Mr. Rosen and four other computer scientists — two others from M.I.T. and two at the Mitre Corporation, a nonprofit technology research and development organization — demonstrated how an algorithm could detect a certain type of known tax shelter used by partnerships.

First, the researchers translated tax regulations governing partnerships, a growing source of tax trickery, into source code. Then they rendered the transactions underpinning a questionable shelter known as “installment-sale bogus optional basis,” or Ibob, as a series of codes. The Ibob shelter artificially inflates the basis value of an asset on a tax return to wipe out taxable gains when that asset is sold. While some of Ibob’s individual transactions are perfectly legal, the collective result is a bogus deduction.

Next, the researchers mapped out in code the tangle of entities that make up typical partnerships. The results flagged specific combinations of transactions and partnership structures that were likely to produce the Ibob dodge.

Large corporations attract most of the attention when it comes to tax avoidance and tax evasion, but partnerships, which have separate tax rules, are a growing source of worry for the authorities. Commonly used by hedge funds, private equity funds, real estate outfits and oil and gas concerns, partnerships are far less likely to be audited than corporations. A Government Accountability Office r eport from 2010 said that the I.R.S. knew of one million “networks” involving partnerships and similar entities, adding that “the I.R.S. also knows that many questionable tax shelters and abusive transactions rely on the links among commonly owned entities in a network.”