[HN Gopher] A Modern Compiler for the French Tax Code
___________________________________________________________________
A Modern Compiler for the French Tax Code
Author : sebg
Score : 139 points
Date : 2023-01-30 13:22 UTC (9 hours ago)
(HTM) web link (arxiv.org)
(TXT) w3m dump (arxiv.org)
| [deleted]
| nayuki wrote:
| I wish the state officially makes their income tax calculation
| available as machine-executable open-source software in an
| industry-standard language. For example, a Python function that
| takes a dictionary of inputs (gross income, number of dependents,
| capital gains, etc.) and produces a dictionary of outputs
| (federal tax, state tax, rebates, contribution limits, etc.).
|
| This would solve many problems: The verbosity and ambiguity of
| human language (tax laws, tax calculation forms in English), the
| ability to inspect and independently verify calculations done by
| the state, the rent-seeking tax preparation software companies.
|
| Here is my own feeble demonstration of the idea:
| https://www.nayuki.io/page/a-math-programming-view-of-canada...
|
| Even if the state has its own online portal for you to review and
| adjust your tax return, I still want to see the full tax code be
| open source and runnable by the user.
| andylynch wrote:
| While this could help with the mechanical calculations and
| preparation of returns, the wider point about 'verbosity and
| ambiguity of human language' can't be nearly so easily dealt
| with outside the simplest cases, and would likely make the tax
| code /harder/ for people concerned to interpret and reason
| about, which is probably the opposite of the desired result.
|
| Firstly the actual text of the law must be as legislated.
|
| Secondly, law and most certainly _tax_ law is necessarily
| nuanced in interpretation and the consequences for taxpayers
| and the government are material (to use a relatively simple and
| well-known British case, a machine-executable model would be
| unhelpful in determining whether Jaffa Cakes should be taxed
| for VAT as biscuits, or exempt as cakes. Then ask about
| chocolate chip cookies (zero rated) vs chocolate digestives
| (taxed!)). Stuff like this and more is argued about all the
| time.
| BlueTemplar wrote:
| Well, there's also that law which mandates that any algorithm
| used in an administrative decision must be explained in
| simple language upon request... but I am not certain that
| "administrative decisions" also covers the tax code ? (Though
| frankly, it should.)
| mytailorisrich wrote:
| That's why you should keep things as simple as possible and
| avoid exceptions and special cases, which legislators are
| experts at creating in tax codes.
|
| In your example this is because someone argued that staple
| food should not be taxed. Right, what is staple food?
| Obviously they decided that biscuits were but not cake.
| Pandora box is opened as soon as you allow any special cases.
| MichaelZuo wrote:
| How would you encode trillions of possible permutations of
| special cases?
| klabb3 wrote:
| > a machine-executable model would be unhelpful in
| determining whether Jaffa Cakes should be taxed for VAT as
| biscuits, or exempt as cakes.
|
| You can have these definitions remain vague and still have an
| algorithm that is well defined over pre-labeled data. The
| purely mechanical steps based on arithmetic could (and
| should!) be defined as machine-parseable code or formulas.
| krackers wrote:
| It would also allow people to re-use ML optimizers to get the
| highest tax returns!
| masklinn wrote:
| > This would solve many problems: The verbosity and ambiguity
| of human language (tax laws, tax calculation forms in English)
|
| 1. It would not, the tax law remains the spec.
|
| 2. France does provide an executable encoding of the tax code,
| TFA is literally a compiler for that.
|
| 3. France started to do so circa 2016 (https://joinup.ec.europa
| .eu/collection/egovernment/document/...) after losing a FOIA-
| type case, though feelers had already been sent as a
| governmental agency (CAS) is at the root of OpenFisca
| (https://openfisca.org/), and by then the prime minister's data
| sharing and coordination office (etalab) had started using and
| contributing to it (https://openfisca.org/doc/manifest-
| history.html)
|
| 4. You can use OpenFisca to encode your own country's tax law,
| or lobby for your country to encode its tax law there
| (https://openfisca.org/en/packages/).
| addcommitpush wrote:
| Openfisca started a bit earlier, in 2011.
| masklinn wrote:
| Yep, I fixed the timeline a bit after checking out the
| history page, as my original memories were incorrect. I
| guess because I'd first heard of openfisca around the time
| of the lawsuit.
| addcommitpush wrote:
| It is my understanding that before it became an Etalab
| project, it was quite obscure.
| nextaccountic wrote:
| > 1. It would not, the tax law remains the spec.
|
| Unless you rewrite the law to make the code the spec. Indeed,
| code is probably a better medium for unambiguously
| communicating calculations.
|
| > 2. France does provide an executable encoding of the tax
| code, TFA is literally a compiler for that.
|
| But other countries might not do so.
|
| > 4. You can use OpenFisca to encode your own country's tax
| law, or lobby for your country to encode its tax law there
| (https://openfisca.org/en/packages/).
|
| This would be amazing!
| noughtme wrote:
| > Indeed, code is probably a better medium for
| unambiguously communicating calculations.
|
| Ambiguity and obfuscation are usually intentional.
| Legislators and individual citizens do not necessarily have
| the same interests. This is why omnibus bills exist.
| nicbou wrote:
| Germany kind of does.
|
| They publish all the diagrams for income tax calculation, if
| you can decipher them. It takes a while but you get it right
| eventually.
|
| This is how I built my income tax calculator and keep it
| updated.
| [deleted]
| addcommitpush wrote:
| The French "income tax" (which, confusingly, is only one of the
| several taxes on income in France, and not the largest) is open
| source (https://gitlab.adullact.net/dgfip/ir-calcul).
|
| There's also the OpenFisca project (https://openfisca.org/en/)
| which is a Python framework for coding tax and benefit system -
| France being the most complete - which is used in many things,
| like a web app to see which benefits you might be eligible to
| (https://www.mesdroitssociaux.gouv.fr/accueil/) or the French
| National Assembly tool to compute the effects of changing tax
| law (https://socio-fiscal.leximpact.an.fr/).
| el_nahual wrote:
| I would accept just the test suite! For a given set of inputs
| here is your tax owed.
| ape4 wrote:
| Wow the old version is only 92K lines of M code.
| gandalfgeek wrote:
| The paper is fascinating from a compilers + VM perspective.
|
| Short video summary: https://youtu.be/ES7fkec3Jv8
| ZachWick wrote:
| Two of these authors are also two of the creators of the Catala
| programming language, which is "a domain-specific programming
| language designed for deriving correct-by-construction
| implementations from legislative texts." (https://catala-
| lang.org/en/).
|
| Other publications in this area can be found at https://catala-
| lang.org/en/publications.
| guerby wrote:
| From the article:
|
| Unlike, say, the United States, the French system relies heavily
| on automation. During tax season, French taxpayers log in to the
| online tax portal, which is managed by the state. There,
| taxpayers are presented with online forms, generally pre-filled.
| If applicable, taxpayers can adjust the forms, e.g. by entering
| extra deductions or credits. Once the taxpayer is satisfied with
| the contents of the online form, they send in their return.
| Behind the scenes, the IR algorithm is run, and taking as input
| the contents of the forms, returns the final amount of tax owed.
| The taxpayer is then presented with the result at tax-collection
| time.
| phh wrote:
| Nowadays, some people (like if they just have French salaries
| and no tax breaks) can even not look at it at all and their
| automatic filling will be automatically accepted
| nicbou wrote:
| Same in Germany, although almost everybody is entitled to
| _something_. This must be why you get a default amount
| deducted for certain things. It must prevent labor-intensive
| tax declarations for very small refunds.
|
| I built a tax calculator for English speakers, and
| highlighting that is next on my todo list. Many people pass
| up on significant returns, especially parents.
| tmnvdb wrote:
| Same thing in the Netherlands, if you're a regularly employed
| person you usually just click 'next' a few times.
| ralfn wrote:
| But we didnt develop our own programming language to do this
| though.
| secondcoming wrote:
| The system is the same in the UK, for people who have to do
| Self-Assessment.
| mytailorisrich wrote:
| UK taxes are much simpler than French ones.
|
| In France everything is complicated with a huge number of
| taxes and rules.
|
| In the UK, if you are employed you don't have to do anything.
| Income tax and National Insurance are calculated and taken at
| source automatically. Your other tax is the local Council
| tax, which is also simple and can be paid automatically.
| madeofpalk wrote:
| > Council tax, which is also simple and can be paid
| automatically.
|
| Helpfully my local council resets your enrollment or
| automatic payments each year, leading one to forget about
| them until you get a big nasty letter in the mail.
| peterisza wrote:
| y no solidity
| maelito wrote:
| Another huge French "tax" set is the social contributions, that
| makes our payrolls quite complex.
|
| Computing payrolls is handled by the private sector, contrary to
| the case of the income tax.
|
| But the French administration develops an open source set of
| online simulators :
|
| https://mon-entreprise.fr
|
| This is the source code of the underlying "tax" rules :
|
| https://github.com/betagouv/mon-entreprise/tree/master/model...
|
| Is uses an open source specific language that frames the writing
| of simple calculation rules, auto-generates an online
| documentation for non-developers and helps developers build
| automatic UIs.
|
| It is unfortunately not yet translated for English speakers and
| developers.
|
| https://publi.codes
| gnad_sucks wrote:
| Is the logic for such calculations known for the US? What about
| the UK?
| thechao wrote:
| Given that you know to apply a specific tax rule, the logic is
| formalized for the US. The problem is knowing _when_ a specific
| tax rule applies to a given tax situation. In general, the IRS
| has an opinion -- and not matching their opinion can land you
| in an audit -- but the nuts-and-bolts application is still an
| interpretation. The IRS is, in my experience, pretty flexible
| with their interpretation. While individual auditors can have
| their hands tied with respect to fines /fee-schedules, I've
| always found them easy to work with, and knowledgeable. The
| last time I was audited, I ended up starting with a $220 fine;
| however, the auditor requested I review the previous several
| years of returns (for the same class of error), and I ended up
| getting a substantial check.
| guerby wrote:
| The FOIA request ("demande CADA") that led to publication of the
| French IRS ("DGFIP") software that computes taxes is here:
|
| https://cada.data.gouv.fr/20144578/
|
| Court ruling:
|
| https://www.april.org/files/20160216-jugement-tribunal-admin...
|
| Some history:
|
| https://www.april.org/le-tribunal-administratif-valide-lavis...
| layer8 wrote:
| (2021)
___________________________________________________________________
(page generated 2023-01-30 23:00 UTC)