What happens when you take the tax laws of 38 countries and translate them into a formally verifiable programming language? Lexifina conducted an ambitious experiment, formalizing personal income tax legislation using Lean, a programming language and interactive theorem prover designed for mathematical reasoning and formal verification. The result: 179 reported discrepancies and errors across 37 of the 38 countries, including outdated tax tables, benefit cliffs, incorrect reference data, withholding errors, and problems in government systems. This video presents an overview of the research, its methodology, findings, and implications for the future of legislation, public policy, taxation, and government software. Turning Tax Laws into Verifiable Code Lexifina translated income tax legislation into formal mathematical models containing: - 38 national tax systems - 9,568 definitions and theorems - 2,114 theorems - 12 reusable components forming a common taxation framework Individual rules are linked to specific legislative provisions, making it possible to trace discrepancies back to the relevant legal text. The researchers discovered that 33 of the 38 national tax systems could be constructed using a common set of taxation components, including progressive rates, rounding rules, deductions, tax credits, and contributions. To validate this approach, a UK tax model constructed from these reusable components was compared with the complete model across 10,279 household scenarios, producing identical results. 179 Errors and Discrepancies The research identified: - 49 benefit cliffs - 42 outdated tax tables - 39 errors in OECD data and other reference sources - 18 withholding discrepancies - 18 frozen monetary thresholds - 13 issues in government systems Some of the most striking findings include: South Korea: Withholding tables based on outdated rules dating back to 2014 can result in monthly overpayments of up to 28,040 Korean won. Cyprus: Crossing an annual income threshold of €49,000 by just one cent can result in the loss of €4,708 in annual benefits. Estonia: Interactions between taxation rules can produce an effective marginal tax rate of 37.99%, despite a headline income tax rate of 22%. Beyond Conventional Software Testing Traditional software testing evaluates selected scenarios. Formal verification can establish mathematical properties across entire ranges of possible inputs within a defined model. This makes it possible to investigate how tax rules behave across different income levels and household circumstances, including edge cases that conventional testing might miss. The researchers also compared their models with nine open-source tax calculators across 31 countries, including Tax-Calculator, EUROMOD, PolicyEngine, and Grattan. They identified five errors in their own models and 20 in external implementations, examining the discrepancies against the underlying legislation. Can We Make Laws Machine-Verifiable? Another important aspect of this research is the treatment of legislation as versioned data. Instead of treating laws as static documents, legal rules can be associated with effective dates, allowing historical versions of tax legislation to be queried and evaluated. Potential applications extend far beyond taxation: - Machine-readable legislation - Automated regulatory compliance - Verifiable government software - Public policy simulation - Transparent welfare and benefit systems - Legal engineering - Computational law - Rules as Code - FinTech and GovTech applications Formal verification does not eliminate the need for legal interpretation. A mathematical model represents a particular interpretation of legislation, and proving its internal properties does not automatically establish that this interpretation is legally correct. Nevertheless, this research demonstrates how mathematical reasoning, software engineering, and formal methods could help make public institutions more transparent and accountable. Perhaps the future of software belongs to Rust, while the future of legislation belongs to Lean. Original research by Lexifina: https://lexifina.com/blog/formalizing-taxation-across-38-nations Learn more about the Lean programming language and theorem prover: https://lean-lang.org/ Should governments publish machine-verifiable versions of their laws alongside traditional legal documents? Share your thoughts in the comments. Subscribe for more technology research, programming languages, formal verification, artificial intelligence, software engineering, computational law, and emerging technologies. #LeanLang #FormalVerification #Taxation #Programming #ComputerScience #GovTech #LegalTech #RulesAsCode