Related : the french administration has built a custom language for another big set of tax rules, those that dictate our social security system (which collects 500 billons of € / year)
It's presented on https://publi.codes but unfortunately we've not translated it yet. The language keywords themselves are in french, by design, to bridge the law and its official implementation. It's not yet used to compute taxes, just to simulate them on the official mon-entreprise.fr website.
The "code" expressed in YAML is parsed to build the computation model (in TypeScript), to document this model on the Web (each variable has a Web page) and to generate typeform-like forms.
Edit : in case you didn't know, the french adminstration's code must by law be made public. This is just the beginning, expect lots of similar projects ! You can browse some repos here https://code.etalab.gouv.fr
Really interesting to see this. I'm a co-founder of AdviceBridge, where we have implemented part of the UK tax code related to income tax and pensions in order to provide digital financial advice.
In the UK, the HMRC (again, equivalent of IRS) makes worksheets available for computational tax but these are not machine-readable and are not guaranteed to be correct! (Indeed on some points, government websites give incorrect information related to the state pension. [1])
We did something similar to this approach but much simpler - we wrote a little arithmetic language specifying the tax rules, embedded in a spreadsheet for quick verification, and then translated this language into C++ using a Haskell compiler.
It's rare that I (an American) get to help out others by translating something, so I will post my translation here.
"Four years after the first publication by DGFIP, I have the pleasure of announcing that the source code permitting the calculation of taxes on revenue is finally reusable (recompilable by others)!
To use this algorithm in your application, follow this link...
It took us 1.5 years (with my coauthor Raphael Monat) to identify that which was missing in the published code in order for it to be reusable, and to fix this situation.
More or less, thanks to our project Mlang, a person can simulate IR's calculations without needing to interface with DGFIP.
The difficulty came from a constraint from DGFIP, who did not want us to publish (for security reasons) a part of the code that corresponds to a mechanism that handles "multiple liquidations". Raphael and I recreated this unpublished part in a new DSL.
DGFIP equally didnt want to publish their internal test games (cases). We had proceeded therefore with the creation of a suite of random test cases, separate from the non published ones, to finally be able to reproduce the validation of Mlang outside of DGFIP."
There is also a similar and very good project funded by the URSAAF and the DGFiP (the two main entities in the french tax system) : https://publi.codes
IMO (I am not part of this project) it is more interesting as it is language agnostic, easy to use for everyone (based on yaml) and more importantly, it is starting to be implemented in the government actual tax computing system.
I have implemented parts of the tax code, following 1040 and the network of forms it references line-by-line, for my own financial planning. I've been selective about what I implement based on what applies to me.
I don't share the code because I'm not sufficiently confident that it's correct, don't want liability, and don't want an obligation to keep it up to date.
That said, it feels like the scope of the project would be manageable for a small nonprofit, and would be of great social value. One reflection from my work is that it would be particularly valuable to represent annual changes in the tax code as transformations of the code AST.
I understand your worry, but could you feel better offering it under a free software license that expressly disclaims warranties of usefulness for any purpose?
It would be quite interesting to check that both the French IRS implementation of the tax & benefit laws and the free software community (though most devs of the project were employed by the French admnistration) implementation of the tax and benefit laws actually output the same results.
The french administration ( once the best in the world, circa 1850-1900 ) is failing almost everywhere : education, police, justice, and so on. The only thing that works very well in the french administration is taxes recovery. They help you fill your taxes, the internet site is working well (you don't have to be scammed by turbotax), you can send a mail with a question and have the answer on the next open day. Really good Job guys !
Personally I work in the Language Engineering area and it seems obvious that you want tax lawyers and accountants to interpret the tax code and translate it into “code”. Is just that you also want “code” to be obvious for them and support by proper tooling, which catch all inconsistencies.
I would also love to interview the author of this and the work for mon-entreprise. While I understand French, I also have these interviews in English to reach more people
Related: does anyone know if, by using these languages (Coq and OCaml), they've kept the door open to computer-assisted tax sensitivity analysis? E.g., I'm interested in outputting some kind of 2-dimensional or 3-dimensional solution space on 2, 3, or 4 input variables to identify discontinuities and slopes. Any thoughts?
ETA: Diving into my thoughts on this a little: really what I'm describing would require (1) a dumb numerical analysis algorithm or (2) some CAS computer algebra system features, my preference. I don't know all the keywords and concepts, but I think term rewriting and equation solving would get me towards the output I seek: a multivariate, piecewise equation with user-selected input variables and user-selected output variables: e.g., current year tax, n+1 year tax, etc. Seems too involved, but ai have hope.
> The difficulty arose from a constraint on the part of the
DGFiP which did not wish to publish, for security reasons,
part of the logic of the calculation corresponding to the
"multiple liquidations" mechanism. Raphael and I recreated
this unpublished part in a new DSL.
> The DGFiP also did not wish to publish its internal test
sets. We therefore proceed to the creation of a completely
random test set, from the unpublished content, in order to
be able to reproduce the validation of Mlang outside the
DGFiP.
> A little less than a year after the publication of
https://blog.merigoux.ovh/en/2019/12/20/taxes-formal-proofs....,
we therefore found a compromise allowing to respect both
the 'source code publication obligation, and the security
constraints of the DGFiP.
> By allowing us to go to its operating site and
confidentially access the source code that it did not wish
to publish, the DGFiP has enabled us to find alternative
solutions that make the publication of the source code
concrete and operational. .
The repo that you're linking to isn't an implementation of the M compiler. Rather it's the rules/definitions that are used to compute the income tax (« Impôt sur le Revenu »).
The M compiler reimplementation linked in this submission allows you to actually execute those rules and perform simulations.
Doesn't matter. From a quick glance, no one would be able to distinguish MUMPS monstrosities from the monstrosities that are the tax .m files. Maybe this M and MUMPS are even related.
[+] [-] maelito|5 years ago|reply
It's presented on https://publi.codes but unfortunately we've not translated it yet. The language keywords themselves are in french, by design, to bridge the law and its official implementation. It's not yet used to compute taxes, just to simulate them on the official mon-entreprise.fr website.
The "code" expressed in YAML is parsed to build the computation model (in TypeScript), to document this model on the Web (each variable has a Web page) and to generate typeform-like forms.
It's in the https://github.com/betagouv/mon-entreprise monorepo, but it's also used to implement a model of our personnal climate impact, here : https://github.com/betagouv/ecolab-data/tree/master/data
Et bravo Denis :)
Edit : in case you didn't know, the french adminstration's code must by law be made public. This is just the beginning, expect lots of similar projects ! You can browse some repos here https://code.etalab.gouv.fr
[+] [-] littlestymaar|5 years ago|reply
And this time, the code isn't printed on paper and send by post mails, which is a neat progress ;).
See, https://www.nouvelobs.com/rue89/rue89-nos-vies-connectees/20... (in French) on how “making code public” was just a few years ago.
[+] [-] fsflover|5 years ago|reply
[+] [-] jmole|5 years ago|reply
[+] [-] glutamate|5 years ago|reply
In the UK, the HMRC (again, equivalent of IRS) makes worksheets available for computational tax but these are not machine-readable and are not guaranteed to be correct! (Indeed on some points, government websites give incorrect information related to the state pension. [1])
We did something similar to this approach but much simpler - we wrote a little arithmetic language specifying the tax rules, embedded in a spreadsheet for quick verification, and then translated this language into C++ using a Haskell compiler.
[1] https://www.thisismoney.co.uk/money/pensions/article-7100019...
[+] [-] Nextgrid|5 years ago|reply
[+] [-] testcross|5 years ago|reply
[+] [-] sushshshsh|5 years ago|reply
"Four years after the first publication by DGFIP, I have the pleasure of announcing that the source code permitting the calculation of taxes on revenue is finally reusable (recompilable by others)!
To use this algorithm in your application, follow this link...
It took us 1.5 years (with my coauthor Raphael Monat) to identify that which was missing in the published code in order for it to be reusable, and to fix this situation.
More or less, thanks to our project Mlang, a person can simulate IR's calculations without needing to interface with DGFIP.
The difficulty came from a constraint from DGFIP, who did not want us to publish (for security reasons) a part of the code that corresponds to a mechanism that handles "multiple liquidations". Raphael and I recreated this unpublished part in a new DSL.
DGFIP equally didnt want to publish their internal test games (cases). We had proceeded therefore with the creation of a suite of random test cases, separate from the non published ones, to finally be able to reproduce the validation of Mlang outside of DGFIP."
[+] [-] agumonkey|5 years ago|reply
[+] [-] bouzouk|5 years ago|reply
IMO (I am not part of this project) it is more interesting as it is language agnostic, easy to use for everyone (based on yaml) and more importantly, it is starting to be implemented in the government actual tax computing system.
We are using it in a challenger bank I started.
[+] [-] cproctor|5 years ago|reply
I don't share the code because I'm not sufficiently confident that it's correct, don't want liability, and don't want an obligation to keep it up to date.
That said, it feels like the scope of the project would be manageable for a small nonprofit, and would be of great social value. One reflection from my work is that it would be particularly valuable to represent annual changes in the tax code as transformations of the code AST.
[+] [-] chromatin|5 years ago|reply
[+] [-] jeffrallen|5 years ago|reply
[+] [-] lgvld|5 years ago|reply
[+] [-] maelito|5 years ago|reply
https://github.com/betagouv/mon-entreprise/blob/master/mon-e...
[+] [-] Rexxar|5 years ago|reply
[+] [-] jmnicolas|5 years ago|reply
[+] [-] dakdak|5 years ago|reply
It would be quite interesting to check that both the French IRS implementation of the tax & benefit laws and the free software community (though most devs of the project were employed by the French admnistration) implementation of the tax and benefit laws actually output the same results.
[+] [-] julienfr112|5 years ago|reply
[+] [-] ftomassetti|5 years ago|reply
Personally I work in the Language Engineering area and it seems obvious that you want tax lawyers and accountants to interpret the tax code and translate it into “code”. Is just that you also want “code” to be obvious for them and support by proper tooling, which catch all inconsistencies.
I would also love to interview the author of this and the work for mon-entreprise. While I understand French, I also have these interviews in English to reach more people
[+] [-] senstax|5 years ago|reply
ETA: Diving into my thoughts on this a little: really what I'm describing would require (1) a dumb numerical analysis algorithm or (2) some CAS computer algebra system features, my preference. I don't know all the keywords and concepts, but I think term rewriting and equation solving would get me towards the output I seek: a multivariate, piecewise equation with user-selected input variables and user-selected output variables: e.g., current year tax, n+1 year tax, etc. Seems too involved, but ai have hope.
[+] [-] remexre|5 years ago|reply
[+] [-] aunetx|5 years ago|reply
[+] [-] coliveira|5 years ago|reply
[+] [-] aaronblohowiak|5 years ago|reply
[+] [-] hansjorg|5 years ago|reply
[+] [-] ccktlmazeltov|5 years ago|reply
[+] [-] justinclift|5 years ago|reply
https://framagit.org/dgfip/ir-calcul
That original release says it's under a free license too.
Wonder why there's a re-implementation?
[+] [-] joelellis|5 years ago|reply
https://twitter.com/DMerigoux/status/1314531302079688709
> The difficulty arose from a constraint on the part of the DGFiP which did not wish to publish, for security reasons, part of the logic of the calculation corresponding to the "multiple liquidations" mechanism. Raphael and I recreated this unpublished part in a new DSL.
> The DGFiP also did not wish to publish its internal test sets. We therefore proceed to the creation of a completely random test set, from the unpublished content, in order to be able to reproduce the validation of Mlang outside the DGFiP.
> A little less than a year after the publication of https://blog.merigoux.ovh/en/2019/12/20/taxes-formal-proofs...., we therefore found a compromise allowing to respect both the 'source code publication obligation, and the security constraints of the DGFiP.
> By allowing us to go to its operating site and confidentially access the source code that it did not wish to publish, the DGFiP has enabled us to find alternative solutions that make the publication of the source code concrete and operational. .
[+] [-] noname120|5 years ago|reply
The M compiler reimplementation linked in this submission allows you to actually execute those rules and perform simulations.
[+] [-] unknown|5 years ago|reply
[deleted]
[+] [-] whitten|5 years ago|reply
[+] [-] AshamedCaptain|5 years ago|reply
[+] [-] unknown|5 years ago|reply
[deleted]
[+] [-] unknown|5 years ago|reply
[deleted]
[+] [-] kensai|5 years ago|reply
[+] [-] throwawaybutwhy|5 years ago|reply
[deleted]
[+] [-] boleary-gl|5 years ago|reply
This is fantastic! If interested, you may want to check out our program for Open Source users of GitLab: https://about.gitlab.com/handbook/marketing/community-relati....