Allow exceptions to a group of rules #170
Labels
🔧 compiler
Issue concerns the compiler
✨ enhancement
New feature or request
💡 language
Language design
The problem
Suppose you have a piece of legislation that defines a quantity piecewise:
Then, another article defines an exceptional case for the benefit:
## Article 3 If the person is disabled, the benefit is equal to $2000.
To formalize that in Catala, you would want the definition in article 3 to be an exception to the group of piecewise definitions in articles 1 and 2. However, you cannot do that currently since you can only declare an exception to a single rule. This situation happens in a real-world example :
catala/examples/allocations_familiales/securite_sociale_L.catala_fr
Lines 47 to 54 in 62e1e01
Solution
Syntax
I propose to piggyback on the
label
syntax and allow to have the same label being applied to several definitions. Using the same label effectively "groups" them together :Semantics
The semantics effect of this proposal will be limited to how the default tree is built from the various definitions and the exceptions relationships between them. The critical function that will be modified is
catala/compiler/desugared/desugared_to_scope.ml
Lines 25 to 42 in cacf605
In the current version, the vertices of the exceptions graph are single rules or definitions. With this proposal, the vertices should be sets of rules. Several rules
r_1,...,r_n
grouped together shall be encoded with the default< r_1 ... r_n | false :- EmptyError >
so that they are at the same level exception-wise.The text was updated successfully, but these errors were encountered: