7 ms·
Compiler for the M language of the French DGFiP
- deleted 6y ago[deleted]
- glutamate 6y agoReally 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. [1] https://www.thisismoney.co.uk/money/pensions/article-7100019/State-pension-data-blunder-means-3-given-WRONG-online-forecasts.html https://www.thisismoney.co.uk/money/pensions/article-7100019...
- Nextgrid 6y agoDoes HMRC provide those free of charge? I'd be curious to have a look at them.
- glutamate 6y agoe.g. https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/788319/SA110_notes_2019.pdf https://assets.publishing.service.gov.uk/government/uploads/...
- justinclift 6y agoSomething seems off with the current repo being pointed to. The repo Readme says: This work is based on a retro-engineering of the syntax and the semantics of M, from the codebase released by the DGFiP. Sounds like an external re-implementation, of the "original" release here: https://framagit.org/dgfip/ir-calcul 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 6y agoThe author explains in the twitter thread (french): https://twitter.com/DMerigoux/status/1314531302079688709 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.html 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. .
- deleted 6y ago[deleted]
- noname120 6y agoThe 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.
- justinclift 6y agoThanks, that's good info. :)
- cproctor 6y agoI 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.
- chromatin 6y agoI understand your worry, but could you feel better offering it under a free software license that expressly disclaims warranties of usefulness for any purpose?
- jeffrallen 6y agoOr leak it via Tor plus a pastebin, so that you are protected from liability via anonymity?
- boleary-gl 6y agoGitLab team member here 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-relations/opensource-program/ https://about.gitlab.com/handbook/marketing/community-relati....
- senstax 6y agoRelated: 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.
- remexre 6y agoI think you'd want a differentiable language to make that easy.
- dakdak 6y agoThere's a much broader project that can compute most taxes and benefits for France (and a few other countries) : https://github.com/openfisca/openfisca-france https://github.com/openfisca/openfisca-france 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.
- kensai 6y agoWhat is the German equivalent?
- jeffrallen 6y agoC'est toujours rigolo de trouver des noms français pour les variables dans un program.
- lgvld 6y agoC’est toujours rigolo de trouver un commentaire écrit en français sur HN. ;-)
- maelito 6y agoBonne lecture ;) https://github.com/betagouv/mon-entreprise/blob/master/mon-entreprise/source/rules/dirigeant.yaml https://github.com/betagouv/mon-entreprise/blob/master/mon-e...
- jmnicolas 6y agoprogramme :o
- Rexxar 6y agoEt même les mots clefs : https://www.spip.net/fr_article1498.html https://www.spip.net/fr_article1498.html
- deleted 6y ago[deleted]
- whitten 6y agoCalling your language the "M programming Language", unfortunately, is ambiguous. One of the oldest langauges to claim the name, is the MUMPS programming language used in healthcare computing and in financial computing is also called M ( https://opensource.com/health/12/2/join-m-revolution https://opensource.com/health/12/2/join-m-revolution ). The the Power Query Formula Programming Language is informally called the M programming language. Kiran S J of Bangalore has a language named the M Programming language (https://github.com/kiransj/m-programming-language https://github.com/kiransj/m-programming-language) The Cache programming language is a super set of the M programming language ( https://cedocs.intersystems.com/latest/csp/docbook/Doc.View.cls?KEY=GORIENT_ch_intro https://cedocs.intersystems.com/latest/csp/docbook/Doc.View.... ). Microsoft has a modeling language called the M Programming language ( http://community.bartdesmet.net/blogs/bart/archive/2009/02/13/getting-started-with-oslo-introducing-m.aspx http://community.bartdesmet.net/blogs/bart/archive/2009/02/1... ) There is the M# programming language ( https://en.wikipedia.org/wiki/M_Sharp https://en.wikipedia.org/wiki/M_Sharp ) and the M programming language for language for HardWare description from MentorGraphics and The language for Mathematica, was called M, and now I think, is called the Wolfram Programming Language. ( http://wiki.c2.com/?ProgrammingLanguageNamingPatterns http://wiki.c2.com/?ProgrammingLanguageNamingPatterns )
- AshamedCaptain 6y agoDoesn'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.
- bouzouk 6y agoThere 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 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. We are using it in a challenger bank I started.
- maelito 6y agoRelated : 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 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 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 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 https://code.etalab.gouv.fr
- littlestymaar 6y ago> the french adminstration's code must by law be made public 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/20161019.RUE4070/admission-post-bac-le-code-est-quasiment-inexploitable.html https://www.nouvelobs.com/rue89/rue89-nos-vies-connectees/20... (in French) on how “making code public” was just a few years ago.
- throwawaybutwhy 6y agoConfused about inclusion of floating-point arithmetic in tax calculations [0]. Am I missing anything? [0] https://gitlab.inria.fr/verifisc/mlang/-/blob/master/formal_semantics/Semantique.fst#L8 https://gitlab.inria.fr/verifisc/mlang/-/blob/master/formal_...
- ftomassetti 6y agoYou may be interested in what the Dutch Tax & Custom Agency is doing: they built a DSL to express tax calculations. Here you can find the case study: https://resources.jetbrains.com/storage/products/mps/docs/MPS_DTO_Case_Study.pdf https://resources.jetbrains.com/storage/products/mps/docs/MP... 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
- julienfr112 6y agoThe 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 !
- fsflover 6y agoVery good news. Consider signing the petition to make all publicly funded code free: https://publiccode.eu https://publiccode.eu.
- jmole 6y agois there an initiative like this in the US?
- aloukissas 6y agoDoubt it. The Intuit and HR Block lobbying dollars make sure our tax system is complicated enough to keep their businesses booming.
- j4nt4b 6y agoPetitions are free, right? Unless it actually does exist, it makes sense to start one.
- fsflover 6y agoThis petition is made by Free Software Foundation Europe. I guess you should ask Free Software Foundation to start one in the US.
- j4nt4b 6y agoJust sent an email. I'll update when I learn more.
- aloukissas 6y agoThis is cute, but this isn't how things work in the US. Money talks :)
- j4nt4b 6y agoAnd though a tooth may bend the purest coin, remember too how gold will knead reason and virtue themselves like dough.
- aunetx 6y agoThat's funny because the INRIA is 5 minutes away from the place I am studying sciences right now, I did not think I would ever see them top in HN :)
- hansjorg 6y agoThey've been on the frontpage many times just the last year (click inria.fr after the post title to see all submissions linking there).
- ccktlmazeltov 6y agoreally? They're often on the frontpage.
- agumonkey 6y agounlike parent
- coliveira 6y agoINRIA is very popular in the CS community, I wonder how you've never heard of their work.
- aaronblohowiak 6y agoOCaml gets a lot of love here from time to time..
- testcross 6y agoThe author explains what were the challenging bits in this thread (in french): https://twitter.com/DMerigoux/status/1314531302079688709 https://twitter.com/DMerigoux/status/1314531302079688709
- agumonkey 6y agoand his blog https://blog.merigoux.ovh/en/2019/12/20/taxes-formal-proofs.html https://blog.merigoux.ovh/en/2019/12/20/taxes-formal-proofs....
- sushshshsh 6y agoIt'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."
- emilecantin 6y agoNative French speaker here (Québécois). Minor nitpick: Your translation of "jeux de tests" to "test games" is incorrect. The word "jeu" can indeed mean "game", but it can also mean a group of things. A better translation would be "test suites", "test sets" or similar.
- 6y ago