Abstract
Testing tax preparation software is a critical yet challenging task due to the "Oracle Problem"—the lack of a universal ground truth for every possible taxpayer profile. This paper investigates the feasibility of using Large Language Models (LLMs) to automate the extraction of metamorphic relations from IRS regulations and translate them into First-Order Logic (FOL). By comparing various prompting strategies and model scales, the research identifies that while decomposition-based few-shot learning significantly improves performance, LLMs still face substantial hurdles in maintaining the logical precision required for legal-critical software.
Introduction
In the United States, tax laws are notoriously complex, leading nearly half of all taxpayers to rely on software for filing. Ensuring the correctness of this software is vital, yet developers face a fundamental hurdle: there is no reference oracle to verify calculations across the infinite variety of edge cases.
To address this, researchers employ metamorphic testing. Rather than verifying a single output against a known truth, metamorphic testing checks the relationship between two or more related inputs. For instance, a metamorphic relation (MR) might state that if a "senior" taxpayer qualifies for a specific deduction, a "non-senior" taxpayer with an identical financial profile should receive a lower or equal benefit. If the software violates this relationship, a bug is identified. However, manually extracting these MRs from thousands of pages of IRS publications and translating them into formal logic is a labor-intensive process requiring both legal expertise and technical proficiency in formal methods.
Methodology
The study explores whether LLMs can bridge the gap between natural language tax code and formal logic specifications. The researchers framed this as a few-shot translation task, comparing GPT-3.5 and Alpaca 7B across three distinct prompting strategies:
- End-to-End (E2E): The model is prompted to generate both logical predicates and the final FOL specification in a single pass.
- Decomposed - Implicit: The task is split into two phases within the same context. The model first generates predicates and then uses that output to construct the FOL specification.
- Decomposed - Explicit: The tasks are entirely decoupled into separate modules. One module focuses exclusively on predicate generation, while a second, independent module generates the FOL. This ensures the model's full attention is focused on one sub-task at a time.
These strategies were tested in 0-shot, 1-shot, and 2-shot scenarios to evaluate the impact of domain-specific examples on model performance.
Data and Evaluation
Due to the lack of public benchmarks for tax software testing, the authors curated a new dataset consisting of 33 high-quality natural language properties derived from IRS documents, including Form 1040 and Publication 596 (Earned Income Tax Credit). Each property was manually paired with a ground-truth formal logic representation by experts.
Evaluation was conducted using a human-annotated 1–5 scale, where a score of 5 represents a perfect logical match to the ground truth. This approach was chosen because standard NLP metrics like BLEU or ROUGE are insufficient for logic; a single character error (e.g., flipping a > to a <) can render a logical statement entirely incorrect despite high text overlap.
Key Results and Insights
The Power of Decomposition
The research found that decomposition is essential for complex logic generation. The Explicit strategy consistently outperformed others because it prevented the model from being overwhelmed by the transition from messy natural language to rigid formal code. GPT-3.5 using the 2-shot Explicit strategy emerged as the top performer, achieving an average score of 4.27/5 for predicate generation and 3.16/5 for full FOL generation.
The Impact of Few-Shot Learning
Few-shot examples provided a dramatic performance boost. In the E2E strategy, the FOL generation score jumped from 1.19 (0-shot) to 2.85 (2-shot). This suggests that LLMs require specific structural guidance to understand the nuances of the tax domain and the desired formal output format.
Model Scale and Logic
There was a significant performance gap between models. The Alpaca 7B model struggled to improve even with few-shot examples, suggesting that the reasoning capabilities required for formal logic translation may only emerge at higher parameter counts, such as those found in GPT-3.5.
Challenges and Limitations
Despite the promise shown by GPT-3.5, the study identified several critical limitations:
- Stochastic Dependencies: LLMs often suffer from internal inconsistency, such as declaring a variable in the first half of a formula but renaming or omitting it in the second half.
- Complexity Scaling: A "performance cliff" was observed as the number of predicates increased. When a tax rule involved more than six conditions, the model's ability to maintain logical consistency dropped sharply.
- Precision Errors: The models frequently made "silly" mistakes, such as flipping operators or missing variables, which would be catastrophic in a real-world tax filing scenario.
Conclusion
While LLMs show significant potential for automating the generation of metamorphic specifications, they are not yet reliable enough for fully autonomous use in legal-critical domains like tax software. Future work should focus on "closing the loop" by integrating LLM outputs with symbolic execution tools to verify the generated logic against real code. Additionally, leveraging larger datasets and task-oriented prompting may help mitigate the current limitations in logical precision and complexity scaling.
Summary updated