Skip to content
Back to the collection

A Modern Compiler for the French Tax Code

Denis Merigoux, Raphaël Monat, Jonathan Protzenko

2020 · arXiv

Read the paper
HN score
0
Mentions
8
Readers
6
Months
7
What’s in a score?

From the abstract

In France, income tax is computed from taxpayers' individual returns, using an algorithm that is authored, designed and maintained by the French Public Finances Directorate (DGFiP). This algorithm relies on a legacy custom language and compiler originally designed in 1990, which unlike French wine, did not age well with time. Owing to the shortcomings of the input language and the technical limitations of the compiler, the algorithm is proving harder and harder to maintain, relying on ad-hoc behaviors and workarounds to implement the most recent changes in tax law. Competence loss and aging code also mean that the system does not benefit from any modern compiler techniques that would increase confidence in the implementation. We overhaul this infrastructure and present Mlang, an open-source compiler toolchain whose goal is to replace the existing infrastructure. Mlang is based on a reverse-engineered formalization of the DGFiP's system, and has been thoroughly validated against the private DGFiP test suite. As such, Mlang has a formal semantics; eliminates previous handwritten workarounds in C; compiles to modern languages (Python); and enables a variety of instrumentations, providing deep insights about the essence of French income tax computation. The DGFiP is now officially transitioning to Mlang for their production system.

Metadata: arXiv. Abstracts retain their original authors’ rights.

In the conversation

Original HN comments, with labels from simple text rules. A label describes the whole comment and may miss context or irony. Read the discussion to make up your own mind. About the labels

8 selected excerpts · 8 total mentions

wahern
Neutral mention · rule
> [US] tax law drafting style follows default logic, a non-monotonic logic that is hard to encode in languages with first-order logic (FOL). https://arxiv.org/pdf/2011.07966.pdf Most law generally is non-monotonic. (See https://en.wikipedia.org/wiki/Non-monotonic_logic) The French tax code is one of the few exceptions.
mdaniel
Neutral mention · rule
I briefly actually tried to read up on the laws that governed me, since I once heard "ignorance of the law is no excuse" and also was curious what, exactly, it would take to really, no kidding, translate the tax code into python or Mlang (https://arxiv.org/abs/2011.07966 https://news.ycombinator.com/item?id=34579236 https://news.ycombinator.com/item?id=25208853 ) However, once I realized that -- as you said -- it's not just the law it's the court (and presumably IRS) rulings that supplement the law, that was too much for me and I noped out. My 2nd idea was to become an Enrolled Agent and then write up that experience, but I couldn't readily identify how much time and money that would cost
BiteCode_dev
Neutral mention · rule
The french initiative started in 2013 is still alive (last commit a few days ago), and passes the gov test suite (they keep in touch with our version of the IRS): https://github.com/openfisca/openfisca-france The way we got this is interestingly twisted. French citizens requested the software used by the administration, and they managed to get it! But, it was written in Mlang, a proprietary language created by the french administration in the 90: https://github.com/MLanguage/mlang. Someone then decided to create an OCaml compiler that takes mlang and emits python: https://arxiv.org/abs/2011.07966 As a result, we got Open Fisca. I now think there are other techs in the…
Read the full comment
mix... A slide of the story: https://www.slideshare.net/Etalab/opening-up-the-french-tax-... But I believe it should be mandatory for the state to provide the source of every softwares they use internally to manage our lives. Also a test suite to allow any citizen to validate their own effort to comply with the law. Just like laws should be published as diff of the previous laws, in a VCS repo.
paulvorobyev
Neutral mention · rule
Adding to this list: * https://catala-lang.org/ -- DSL for translating/annotating legal texts * https://arxiv.org/pdf/2011.07966.pdf -- A Modern Compiler for the French Tax Code * https://www.youtube.com/watch?v=EshxZVMURt4 -- Formal Methods and the Law
wahern
Neutral mention · rule
AFAIU, the French Tax Code is effectively defined in terms of an algorithm. There was a recent HN thread (https://news.ycombinator.com/item?id=25208853) on a new open-source compiler for the tax code (https://arxiv.org/abs/2011.07966). The paper for the compiler references some interesting literature on the computability of legal codes. For example, > [U.S.] tax law drafting style follows default logic, a non-monotonic logic that is hard to encode in languages with first-order logic (FOL).
wahern
Neutral mention · rule
In general the law is absolutely not so rigorous. It's more like general philosophical literature in terms of logical rigor--diverse, disjoint, etc. But certain subdomains of the law can be closer to a formal system. The French tax code is peculiar (though I'm not sure its unique) in literally being defined by the rules encoded in an official program. A recent paper on a new language for compiling those rules, "A Modern Compiler for the French Tax Code" (https://arxiv.org/pdf/2011.07966.pdf, via HN a couple of weeks ago), contains a blurb at the very end, > Closer to the topic of this paper, the logical structure of the US tax law has been extensively studied by Lawsky…
Read the full comment
[18, 19], pointing out the legal ambiguities in the text of the law that need to be resolved using legal reasoning. She also claims that the tax law drafting style follows default logic [24], a non-monotonic logic that is hard to encode in languages with first-order logic (FOL). This could explain, as M is also based on FOL, the complexity of the DGFiP codebase. See https://en.wikipedia.org/wiki/Default_logic and https://en.wikipedia.org/wiki/Non-monotonic_logic But note that it's written in that "style", not that it's done consistently or correctly. Unfortunately I couldn't easily find a copy of the cited papers, but I made a note for later reference. EDIT: I once took a class in law school taught by a Professor of Systems Engineering from the parent university. I forget why, but long ago he took an interest in the rules of evidence in the common law. While the rules evolved organically over more than a thousand years, they actually strongly reflect a formal system of abductive reasoning: https://en.wikipedia.org/wiki/Abductive_reasoning. And there's significant, hidden rigor. In one project he had everyone in class create a tree consisting of evidence (e.g. size 7 shoe) at the leaves, with the branches as inferences all the way up to the top, which was the core legal claim--1) Jim did 2) break and 3) enter into 4) said building.... Anyhow, being a programmer I decided to create my tree using the DOT language and render it using Graphviz. While I was doing that it occurred to me that some of the more esoteric, technical rules of evidence, such as that any piece of evidence can only be used to prove a single element, actually ensures that the tree is an acyclic graph. I'm not sure precisely why (perhaps the professor had more insight), but I believe it's because the rules are in part crafted to ensure that the finder of fact is presented with a tractable problem to solve. The process would get too confusing (and possibly logically inconsistent?) if you didn't keep the tree of evidence and inference simple. No judge or lawmaker likely ever had in mind the literal shape of the evidence tree. In fact, AFAIU nobody thought to represent it as a tree until the late 19th century, when the famous scholar of common law evidence, John Wigmore (https://en.wikipedia.org/wiki/John_Henry_Wigmore), developed a system for analyzing and preparing trial evidence in that manner. Anyhow, a proper and infinitely more rigorous treatment of this is presented in the book, "Analysis of Evidence, 2nd Ed." by Terence Anderson, David Schum, and William Twining. (Schum taught the class.) A large part of the book explores and explains the law of evidence as a system of Bayesian reasoning. (Oh, that's why! I think Prof. Schum first stumbled into the legal realm after he got the idea of using Bayesian statistics to resolve historically famous and contentious legal trials.)

Keep following the thread.

More in Programming languages

More from the same topics.

2018arXiv

Talent vs Luck: the role of randomness in success and failure

A. Pluchino. A. E. Biondo, A. Rapisarda

The largely dominant meritocratic paradigm of highly competitive Western cultures is rooted on the belief that success is due mainly, if not exclusively, to personal qualities such as talent, intelligence, skills, efforts or risk taking.

16 mentions14 months
2.5HN score