Closed niklasdewally closed 1 week ago
@ozgurakgun what are the undefinedness semantics of (a/y !=z)?
The existing div_to_bubble
rule seems to be trying to do
Not(Neq(UnsafeDiv(x,y),z))
~> Not(And[Neq(SafeDiv(x,y),z), Neq(y,0)])
~> And[Eq(SafeDiv(x,y),z),Eq(y,0)]
which might be wrong?
This is causing div_undefzero-05-nested-noteq
to fail.
I have made to_aux_var
fail when it has an undefined thing inside it so that we don't bring something to the top that should've been bubbled; but this doesn't make a difference...
div-05
, which does (a!= b/c), works as expected, so it might be more to do with double negations?
I know that its probably not my flattening rules doing it, so I'm a bit stuck...
Rule applicable: negated_neq_to_eq ([("Base", 8800)]), to expression: Not((SafeDiv(y, z) != 0)), resulting in: (SafeDiv(y, z) = 0) new_top=And([])
This is weird....
(for context, this safediv is the b/c in a/(b/c))
bubbling up the auxvar instead of posting it to the top level is also very wrong...
for
!(x/(y/z) = 10)
it just makes z=0
and gets solutions that way, which conjure does not seem to do.
Heres the rule trace: https://gist.github.com/niklasdewally/39a3a938e477f4b109202850e33e3b66
(a/y !=z)
~~> parsed as:
Neq(Div(a,y), z)
~~> make safe
Eq(Bubble(SafeDiv(a,y), Neq(y,0)), z)
~~> bubble-up
Bubble(Eq(SafeDiv(a,y), z), Neq(y, 0))
~~> bubble-to-and since first arg is bool
And(Eq(SafeDiv(a,y), z), Neq(y, 0))
the nested case is interesting
!(x/(y/z) = 10)
~~> parsed as
Not(Eq(Div(x, Div(y,z)), 10))
~~> make-safe the inside div
Not(Eq(Div(x, Bubble(SafeDiv(y,z), Neq(z,0)), 10))
~~> (*)
Not(Eq(SafeDiv(x, Bubble(SafeDiv(y,z), Neq(z,0)), Neq(Bubble(SafeDiv(y,z), Neq(z,0), 0), 10))
(*) if we allow make-safe the outside div without bubbling up first, we would get. not wrong, but if we bubbled-up first and then converted the outside Div to SafeDiv we probably won't repeat work?
So rule_Div_to_SafeDiv should refuse to apply i fthe second arg is a Bubble.
Happy for you to try both options (both should be correct) and see the rule application trace before we commit to one.
here
x/(y/z) != 10
!(x/(y/z) = 10)
both !=0 bubbles should stay in the !() for the second one, end up at the top level for the first one.
Did you test x/y != 10
and !(x/y=10)
as well? Do they work as expected?
here
x/(y/z) != 10 !(x/(y/z) = 10)
both !=0 bubbles should stay in the !() for the second one, end up at the top level for the first one.
Did you test
x/y != 10
and!(x/y=10)
as well? Do they work as expected?
We already had a test case for the first; just tried the second and that passes too.
(*) if we allow make-safe the outside div without bubbling up first, we would get. not wrong, but if we bubbled-up first and then converted the outside Div to SafeDiv we probably won't repeat work?
So rule_Div_to_SafeDiv should refuse to apply i fthe second arg is a Bubble.
Do you mean that we should not create a bubble if we have a bubble as a child?
I tried bottom up vs top-down bubbling previously, and that didn't have an affect on the result, although not with the above condition.
as rule traces if you could produce something of the style I used above that would be the easiest for me to follow/debug
something like
expr1
~~> rulename
expr2
~~> rulename
expr3
I think both (created nested bubbles and waiting untill they bubble up) should work correctly actually, but one will be fewer steps - I suspect the latter will be fewer steps.
I'm not sure if this is what you meant, but it still doesn't work.
Makes smaller models though :)
This made the rule ordering a lot shorter... By process of elimination, could we be missing something in distribute_not_over_and? This runs after each bubble while there are still some UnsafeDivs left in the tree. not(eq) to neq , flattening etc wait until we only have SafeDivs
I remember having an issue with != ~> !(=)
. Are the semantics we use in that case correct? This is for the final step after bubbling etc.
This made the rule ordering a lot shorter... By process of elimination, could we be missing something in distribute_not_over_and? This runs after each bubble while there are still some UnsafeDivs left in the tree. not(eq) to neq , flattening etc wait until we only have SafeDivs
I made distribute_not_over_and not applicable if its universe contains a bubble or unsafe div, forcing it to not apply until all bubbling is done (similarly to !=). This did not change anything :(
I remember having an issue with
!= ~> !(=)
. Are the semantics we use in that case correct? This is for the final step after bubbling etc.
We do this when everything is fully defined. This seems to work, as the non-nested !(=) and != tests work.
An updated gist with better spacing for @lixitrixi
https://gist.github.com/niklasdewally/968d67b7b569c9f74df2aa33c01128a0
@lixitrixi and I wrote this on paper and theres nothing in the rewritten model that says that z cannot equal zero...
Yet, those are the solutions that we are missing?
Infact, it says z=0 as one of the or cases!
conjure gives us the following minion, which seems the same as what we get as output:
Its a domain evaluation issue!!!!
In our model,__1
has domain {1..20}, but Conjure gives it domain {0..20}!
Yep, it needs to have 0 in its domain. Good debug!
@ozgurakgun if this is all good, I will write a commit message and clean this up to merge tomorrow.
This PR: Detailed Report
lines......: 72.8% (3522 of 4840 lines)
functions..: 59.2% (367 of 620 functions)
branches...: no data found
Main: Detailed Report
lines......: 72.5% (3455 of 4764 lines)
functions..: 58.8% (359 of 611 functions)
branches...: no data found
Lines coverage changed by 0.30% and covered lines changed by 67
Functions coverage changed by 0.40% and covered lines changed by 8
Branches... coverage: No comparison data available
oh also there are a few extra files (2, a*txt) but I assume you know about these.
Completed by #454
The purpose of this PR is to get feedback on my ongoing work on flattening nested divs and to debug a failing testcase.
The test case in question is
div_undefzero-05-nested-noteq
, which is defined as:This PR is completed in #454