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
2.8.0: inconsistent behavior of partial functions and undefined values #760
Comments
First regarding the output annotations, the correct annotation is The reason why the first model does not give a warning, and the second does. Is because the compiler has realised that the divisor is Although the difference between
Finally for the last model, if-then-else has a special relationship with the relational sementics (as noted in the handbook):
This effectively means that if one side becomes undefined, the semantics are that a different branch of the if-then-else expression must have been selected. So for example in this case an additional constraint would be enforced that |
Actually rereading that comment from the handbook, this doesn't actually say what I then explained underneath. However, my explanation is certainly the semantics as I understand it, where the if-then-else expression is really a seperate expression that interacts with relational semantics (picking a defined branch), and should not be seen as a function. We should update the handbook to include an explanation of this behaviour. |
My last model does not contain if-then-else, it contains |
Sorry, I missed that last model yesterday. That one certainly seems like a bug to me. A slightly smaller variant:
Somehow having the variable |
I found the problem in this final model. It seems that aggregation of linear expressions did not yet account for undefined expressions. A fix for this problem should be merged soon to the I think I also forgot to mention that if you want to avoid the generation of the warnings, then you can annotate known partial expressions with |
This behavior is consistent with the relational semantics [Section 2.2.7 of the Handbook]: division by zero gets silently treated as falsehood:
But if you narrow the domain of
D
to0..0
, the falsehood is not silent any more:So in the first case it's silent, in the second case it's verbose. This is a bit inconsistent. The verbosity can get in the way. Please provide a way to turn off warnings.
Another odd thing:
D
andQ
were annotated:: output_var
but onlyD
was output. Why?Another example:
Note the solution with
D = 0
for which the constraintQ = if P then 1 else -1 div D endif
contains a division by zero. Says Section 2.2.7: any undefinedness “bubbles up” to the closest Boolean context and becomesfalse
there.Apparently, the if-then-else-endif integer expression does not behave as a partial function in this respect. I did not expect a solution for
D = 0
.Another example:
I expected the division by zero to bubble up, effectively turning the constraint into
false <-> false
. I expected to get two solutions but got none.The text was updated successfully, but these errors were encountered: