Lean proof checker finds 138 drafting errors in the US tax code

Formalizing US Tax Code (Using Lean)

Lean proof checker finds 138 drafting errors in the US tax code

Lexifina turned Title 26 into structured data and pointed Lean at every cross-reference, flagging 138 real faults — dead citations, typos, duplicated paragraph numbers, unclosed parentheses — each backed by a machine-checked certificate. They then modeled the 2025 income tax in Lean, validated it against PolicyEngine-US, Tax-Calculator and UsTaxes, and ran a loophole search that rediscovered known strategies and surfaced a few results they could not find documented anywhere.

One dollar can cost $8,046. The EITC's investment-income limit at $11,950 is a cliff, and the saver's credit tiers are cliffs: a couple at $47,500 gets $2,000, at $47,501 they get $800.
  1. patrickmay

    I worked for a company pre-LLMs that analyzed laws and regulations in order to answer questions about financial transaction legality and reporting requirements. One problem that came up frequently is that the rules governments make don't have to be consistent. There are conflicts, some quite significant. The best we could do was make them visible and escalate to a human.

    It would be interesting to require laws to be compilable. Charles Stross wrote a couple of books that include that idea.

  2. rancar2

    Wow, if I'm reading this correctly, the Big Beautiful Bill introduced a pretty large gap that punishes married couples filing jointly: a couple making about $300K each can lose up to $15K in write-offs compared with filing separately, pretty much everywhere except the nine states with no broad income tax (Alaska, Florida, Nevada, New Hampshire, South Dakota, Tennessee, Texas, Washington, and Wyoming), where few couples pay the $25K in state and local taxes needed to trigger it. I think most tax software will assume the $5K cap each, but the regulation here is inconsistent. Here’s the take-away quote from the article:

    “A married couple can deduct more state and local tax by filing separately. The deduction for state and local taxes (SALT) is capped, and the cap shrinks as income rises: by 30 cents for each dollar over $500,000 on a joint return. On a separate return, the law halves the cap after shrinking it, so it shrinks by only 15 cents a dollar. A couple earning $300,000 each can deduct up to $25,000 on two separate returns, but only $10,000 on one joint return.”

    This is non-trivial impact to joint returns if this is true, and I won’t be surprised if there are multiple appeals for refunds and more people filling separately going towards.

  3. delichon

    > Today, we set out to formalize the entire Internal Revenue Code to hunt for unknown loopholes (bugs).

    Saying that loopholes are bugs is a political statement that a particular allocation of resources is inherently fraudulent. There is no data that Lean code could use to decide whether a result is intentional or not.

    It's like deciding that any tax provision that increases income inequality is illegitimate, and writing code to identify them. That could be a useful exercise, but it isn't a way to justify a human value with math. It may be a formalization of an ethic as applied to a tax code, but not of the tax code.

  4. qrobit

    There's whole language for law formalization called Catala.

    See https://catala-lang.org/

    and https://github.com/CatalaLang/catala-examples

    French government seems to actually use it in one of their web services, see https://docs.aides.beta.gouv.fr/03_mutualiser/02_outils.html (page in French)

  5. jedberg

    It's important to remember that the loopholes are often intentional. They are left there so that rich people who can afford CPAs can take advantage of them, while middle income and poor people cannot afford to.

    They are also left there so there is wiggle room for interpretation if it comes in front of an auditor or a judge.

    And also, it's important to remember that in tax matters, the final arbiter of interpretation is a judge. Judges are humans, not machines. You can't "Trick" them by saying "well technically this is allowed!". Because they rule on the sprit of the law, not as it was written. Judges aren't amused when you try to be cute with how you interpret a law. And some Judges have biases, where you get a different ruling depending on if you play at their golf club or not.

    Laws aren't computer code. They are vague on purpose.

  6. matthewbauer

    It’s a neat idea but I don’t understand what value Lean adds here. Is there really anything to “prove” in the tax code? Or are they just using Lean as a scripting language?

  7. tsoukase

    Law is written by people to be interpreted by people. So there is a limit in codifying it in a logic language.

  8. michaelrbock

    Have you tried testing against the open source cases here? https://github.com/column-tax/tax-calc-bench

More from this day

2026-11-14