Law to Code: An End-to-End Pipeline for Catala Code Generation and Evaluation from German Statutory Text
Abstract
Automatically generating and maintaining executable legal code requires more than just isolated text-to-code translation. In this paper, we present an end-to-end system for representing, linking, executing, and interacting with German statutory law. First, we construct a graph-native representation of 6,867 statutes that preserves hierarchy, supports efficient retrieval, and change detection. Second, on top of this, we develop an LLM-based multi-agent pipeline that detects and resolves internal and external references, creating a globally connected citation graph. Third, we introduce an LLM-based multi-agent pipeline that translates reference-aware legal provisions into Catala, a domain-specific language for legislative programming, generating paragraph-scoped executable code. This supports executable forms, decision trees, and scenario-based simulations, enabling legal experts to use and validate the generated formalization. Finally, we integrate these artifacts into a legal reasoning assistant that uses reference-aware statutory text and code to infer relevant inputs, outcomes, and provide verdicts from legal scenarios. We evaluate our reference detection and code generation methods on the first part of the German Corporate Income Tax Act (KStG), comprising 8 sections and 25 paragraphs. We use 86 synthetic legal scenarios with corresponding unit tests, complemented by a legal expert evaluation.