arXiv:2610.02792cs.AIOct 2026

Manuscript Offprint

arXiv:2610.02792

Law And Order: Tax Law Autoformalization

Sophia Simeng Han, Yoshiki Takashima, Anjiang Wei, Zhaoyu Li, Michael Genesereth

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Legal systems are increasingly implemented through software, yet scalable methods for translating legal texts into accurate symbolic representations remain underdeveloped. We study this problem through tax law, where forms and filing instructions define large computational structures involving arithmetic, branching, recursion, and tabular reasoning. We propose LAW&ORDER, a neuro-symbolic framework for automatically formalizing tax forms and instructions into executable symbolic programs. Our approach establishes two forms of correspondence between law and logic: structural correspondence, which aligns legal and symbolic components such as cells and schedules, and denotational correspondence, which requires symbolic components to implement the computations specified by their legal counterparts. We combine large language model synthesis with cell-level verification and iterative localized error repair using human-written OpenTaxSolver tax returns. We then evaluate the resulting formalizations on independently authored, held-out TaxCalcBench returns, that are never exposed during generation or repair. Although the most advanced LLM achieves only 66% accuracy, LAW&ORDER achieves 100% cell-level and form-level accuracy on 51 held-out returns, demonstrating the effectiveness of combining LLM-based synthesis with symbolic verification for scalable and verifiable large-scale legal autoformalization compared with using an LLM alone.

1 INTRODUCTION

Modern societies increasingly rely on software to operationalize law (de la Garza, 2020; Lessig, 2009). Tax systems, regulatory frameworks, and other rule-based systems translate legal requirements written in natural language into executable procedures. Yet automating this translation remains an open problem. Existing auto-formalization methods are concentrated primarily in mathematics (Jiang et al., 2022; Zhou et al., 2024; Yang et al., 2026), while formalization in expert legal domains remains largely manual, expensive, and difficult to scale (Lawsky, 2026b; Holzenberger et al., 2020). For example, the IRS Direct File system required $16 million and more than two years to build (Treasury Inspector General for Tax Administration, 2026). Beyond applications to relatively small legal fragments (Judson et al., 2024; Lawsky, 2022), scalable automated legal formalization has yet to be realized.

Tax law provides a challenging setting for studying this problem. Existing implementations illustrate its scale: OpenTaxSolver (Roberts, 2026) contains more than 16,000 lines of C code, while implementations of individual forms such as Form 1040 can exceed 1,000 lines. Moreover, legal rules exist at different levels of abstraction. Statutes and other high-level legal sources are progressively refined through regulations, guidance, forms, and instructions before ultimately being implemented in software. We focus on IRS tax forms and their accompanying instructions. These documents occupy a useful intermediate position between legal text and software. Unlike statutes and regulations, they are written for ordinary taxpayers and express many legal requirements in comparatively concrete and operational terms.

Tax forms also provide a natural structure for formalization and verification. A form consists of cells containing numeric, Boolean, or finite-sort values. Some cells are taxpayer inputs, while others are computed from preceding cells according to natural-language instructions. Formalization therefore

∗^{*}Please direct correspondence to sophiahsm6@gmail.com.

†^{\dagger}Part of this project was done when Yoshiki Takashima was a Postdoctoral Scholar at Yale Law School.

Figure

Final F is evaluated once on a separate test set for the reported accuracy.

Figure 1: The LAW&ORDER generation–verification–repair loop. Starting from an initial set of cell functions F and a repair-set of test cases T, the system repeatedly executes F on T and compares each cell's model output o against its gold annotation G. Any cell function f whose output disagrees with G is regenerated by an LLM using that cell's natural-language instruction, and the cycle repeats until every cell matches across all repair-set test cases. The resulting corrected F is then evaluated once on a held-out test set — never seen during synthesis or repair — to produce the final reported accuracy.

requires translating these instructions into executable arithmetic, branching, tabular operations, and dependencies among cells. Although individual computations are often simple, errors can propagate through the dependency structure of a large form, making final-output verification insufficient for identifying where a formalization diverges from the intended rules.

They are relatively self-contained: annual revisions are consolidated within form and instruction documents rather than dispersed across amendments and cross-references. Although forms and instructions carry less legal authority than statutes or regulations, they serve as the primary interface through which taxpayers operationalize tax law and determine their tax obligations.

Our central approach is to preserve this structure in the symbolic representation. We represent computed cells as individual symbolic functions and organize them according to the sections and schedules of the source form. This correspondence allows natural-language instructions, symbolic functions, and execution outputs to be compared at the same granularity. When an output disagrees with an expected return, the system can localize the discrepancy to individual cells and revise the corresponding functions. Building on this structure, we present a neuro-symbolic system for tax-law auto-formalization. The system combines (1) a synthesis module that translates tax forms and instructions into executable symbolic representations, (2) a verification module that compares generated programs against expected cell-level outputs, and (3) an iterative repair procedure that localizes discrepancies and revises the corresponding symbolic functions. The system therefore performs test-driven legal formalization, repeatedly generating, executing, verifying, and repairing the formalization. Figure 1 illustrates this process.

Crucially, we use different test cases for development and final evaluation. During synthesis and repair, the system receives human-written test returns from OpenTaxSolver (Roberts, 2026). These returns provide execution feedback and are explicitly available for correcting the generated formalization. Once this process is complete, the formalization is frozen and evaluated on a separate set of independently authored returns from TaxCalcBench (Bock et al., 2025). These evaluation returns were written by Certified Public Accountants (CPAs) and are never exposed during generation or correction. The final evaluation therefore measures whether formalizations developed using one set of human-written cases generalize to independently written, previously unseen returns.

Our contributions are threefold. First, we formulate large-scale legal formalization around structurally corresponding representations that align natural-language rules with executable units. Second, we introduce a neuro-symbolic synthesis, verification, and repair framework that exploits this structure for fine-grained error localization. Third, we demonstrate that resulting formalizations generalize from human-written development cases to independently authored, CPA-written held-out returns across 26 tax forms. Although the most advanced LLM can only achieve 66% accuracy, LAW&ORDER achieves 100%, showing the effectiveness of our neuro-symbolic system.

Lean program: > 10,000 lines

/-- 2025 SALT cap (post-OBBBA): base cap 40,000(40,000 (20,000 MFS), reduced by 30% of MAGI (^AGI) over 500,000(500,000 (250,000 MFS), but not below the 10,000(10,000 (5,000 MFS) floor. -/

def cell_072_a5e_limited_state_local_taxes (i : Inputs) : Float := let baseCap := if i.isMarriedSeparate then 20000.0 else 40000.0 let threshold := if i.isMarriedSeparate then 250000.0 else 500000.0 let floorCap := if i.isMarriedSeparate then 5000.0 else 10000.0 let reduced := baseCap - 0.30 * notLessThanZero (i.agi - threshold) let cap := if reduced < floorCap then floorCap else reduced smallerOf (cell_071_a5d_state_local_taxes i) cap

def cell_075_a10_total_interest (i : Inputs) : Float := cell_074_a8e_home_mortgage_interest i + inputNum "A9" i

def cell_076_a14_total_gifts_to_charity (i : Inputs) : Float := inputNum "A11" i + inputNum "A12" i + inputNum "A13" i

def cell_077_a17_total_itemized_deductions (i : Inputs) : Float := cell_070_a4_medical_deduction i + cell_073_a7_total_taxes i + cell_075_a10_total_interest i + cell_076_a14_total_gifts_to_charity i + inputNum "A15" i + inputNum "A16" i

end F1040sa

More than 10,000 lines of reusable executable formalization

Figure 2: Excerpt from an automatically generated tax program. Shown is a small contiguous excerpt of the executable symbolic program generated from tax forms and filing instructions. The complete formalization comprises more than 10,000 lines of Lean code, with dependencies spanning individual cells, worksheets, schedules, and forms. The output of legal auto-formalization is therefore not merely an isolated formula or short program, but a large, interconnected executable artifact. This scale illustrates a central challenge of legal auto-formalization: correctness must be maintained not only for individual rules, but across the computational structure as a whole. It also motivates our focus on compositional synthesis and verification: even when individual rules are relatively compact, their composition produces a program whose correctness cannot be reliably established through generation alone.

References (28)