Open rohanpadhye opened 1 year ago
Hi @rohanpadhye! Thanks for reporting all of this. I'm very excited to know more about the experimental tooling you're working about :)
Concerning the bug you found I'm tagging @AltGr and @slawsk who are currently working on this formalization (https://github.com/CatalaLang/catala/blob/us121/examples/us_tax_code/section_121.catala_en). I agree with you that we should do a bit more of defensive programming and handle well user inputs where periods extend beyond the date of sale or exchange. However currently handling time intervals is a bit clunky in Catala because the language is restricted : for instance we cannot merge two lists of periods of time and aggregate them because that would involve sorting the lists of intervals and you can't implement sort in Catala. So the solution we're heading towards is having an externally-implemented (and trusted) library for periods of time with handy operations in them. But to do that we need https://github.com/CatalaLang/catala/issues/89, and https://github.com/CatalaLang/catala/issues/88, which are scheduled to happen in the next months.
Agreed that this is a bug--the periods of interest absolutely should end on the date of sale or exchange, the Code is clear. @AltGr and I are working on 121(c), which uses these definitions.
Thanks, @slawsk, for confirming the bug.
@denismerigoux. Thanks, I'm also excited about the results---the corner case above was discovered automatically using an instrumented version of Catala's Python backend + the Z3 theorem prover. So far it's been a fun side project of mine so I get very little time to work on it, but I aim to share some code and docs of a preliminary version with the community later this week.
The module system seems very interesting and quite complex. Thanks for the pointer, I'll keep an eye out on those issues.
That's neat! Did you know that we already have a Z3 integration in Catala? We generate proof obligations for specific properties and show the results with the Proof
CLI command of the Catala compiler. It's the beginning of what we described here: https://hal.inria.fr/hal-03447072/.
Very nice! I think came across at one point, and I intend to look into the implementation further. I'm trying to do something less ambitious: instead of proving properties directly, just generating test inputs systematically—with the hope that the "properties" can be encoded as assertions. The proof backend is probably the stronger approach in the long run, though the testing approach might be able to get past some cases that haven't yet been (or cannot feasibly be) modeled formally. Let me open a separate PR for this soon and we can discuss there.
Hi folks,
I'm working on some experimental tooling for testing of Catala programs (more on that later), and I encountered what I think is a bug in the formalization of Section 121 of the US Tax Code. Here's a test that demonstrates the bug:
(a) Exclusion
Gross income shall not include gain from the sale or exchange of property if, during the 5-year period ending on the date of the sale or exchange, such property has been owned and used by the taxpayer as the taxpayer’s principal residence for periods aggregating 2 years or more.
$ catala Interpret -s FiveYearBug bug121.catala_en --disable_warnings [ERROR] Assertion failed
┌─⯈ bug121.catala_en:19.12-42: └──┐ 19 │ assertion not scope121a.requirements_met │ ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ └┬ Section 121 └┬ (b) Limitations └┬ (5) Exclusion of gain allocated to nonqualified use └─ (D) Coordination with recognition of gain attributable to depreciation