-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement negation of conditional expressions during simplification. #9
Conversation
BTW, the test suite doesn't pass. It fails on |
What's the failure? Everything passes for me. |
Tested on Ubuntu 16.04 LTS with bash v4.3.48. The test suite doesn't ever run on macOS due to bash script incompatibilities. |
Well, time to setup TravisCI... Should be fixed in master. |
6ceb71d
to
aed52fc
Compare
Yep. I've just fixed the test case affected by my changes. |
Back to the patch. Thanks for taking a stab at it! But it's cheating ;-). I don't know if you noticed or not, but xform_expr_infer.py implements poorman's Prolog inference engine, i.e. tries to do stuff declaratively. That's how it's different from xform_expr.py, which implements imperative passes. So, your patch wouldn't belong to xform_expr_infer.py, but to xform_expr.py. But when I said it would go to xform_expr_infer.py, I meant that it should be tried to be done "declaratively". The "consequent" part in your code is good, no need to re-do work which COND.neg() does (but I'd add a TODO comment that creating COND from EXPR just to call .neg() on it sucks). But at least pattern matching should be done declaratively. I've pushed b926b98 as an example of dealing with relational operations. Please also follow commit message format of the existing codebase. (But commits for test updates should be separate from code commits, yeah). Also, there should be unit-level tests. I have a lot of experimental code lying around, and I penalize myself (and make world better) by not pushing it to master unless there're tests. I give up regularly on that rule (tests are boring!), and even by looking at the stuff for these 1-2 weeks, you can see that with the fact that there's some testsuite, it's maybe 20% of what should be there. You can add tests to expr-simplify1.lst, unless it warrants to create a new file. |
Now should go in expr-simplify-cmp.lst: 2a3c755 |
Thank you for your review. I'll do the proposed changes tonight... |
6ceb71d
to
129ecee
Compare
Here we go: 129ecee Everything is now done "declaratively". I reuse the COND.NEG dictionary from
|
Looks good, thanks. I hope a test is also coming ;-).
Let's do it later I guess. |
I've tried to extend expr-simplify-cmp.lst with the following line:
The test suite now fails with the following error:
I have to clue why it happens. Any idea? |
129ecee
to
66115c8
Compare
Tests have been updated as requested. |
Cool, merged, thanks! Happy New Year! |
Thanks, many happy returns! |
Hey, it's my first attempt to implement condition negation during expression simplification as you suggested.
Morevover, I added a shortcut that immediately returns
None
in the case a non-expression argument is passed. That prevents unneeded looping and pattern matching.Let me know if the patch is okay or need any improvement..