-
Notifications
You must be signed in to change notification settings - Fork 5
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
Clean up Predicate comparison relations #97
Comments
I'm not sure If I do understand this completely. But maybe I'm not seeing something here ? |
@MaxOstrowski @pobermei @sthiele Thanks for the discussion earlier. Also adding @rkaminsk @teiesti @florianfischer91 here in case they have some thoughts on the issue. I think the (weak) consensus so far is that the comparison operators should be overload to compare the underlying clingo
Here But,
This feels a bit strange to me that you can have both The less than can also be a bit strange:
Note: the above
Anyway, in the above we've had examples of where using the
If we implement a normal python tuple-like semantics then executing both |
I can't really judge what a good design decision would be but as has been said, using the same comparison behavior for Predicate and Symol would be the most consistent solution. What feels a bit strange is that when you compare arguments individually it depends on the argument which comparison 'mechanism' is used right? F. i. if you have simple types like int, str etc. the builtin-comparison is used, but if the argument is a Predicate-Instance then the symbol-comparsion is used... |
As far as I understand, predicates only capture ground atoms. I think that implementing the comparison operators delegating to the underlying symbol is a good idea. |
That sounds like a +1 for using BTW. I think it's probably best to implement the operators individually, as the docs for
Yes. if you compare the individual argument then that argument's builtin comparison is used. So if you wanted to you could create some odd behaviour like: |
Yes. Predicate instances only capture ground atoms. Ok. Looks like using the underlying symbol is the popular choice. I'll do that. I guess the odd behaviour that I highlighted earlier is really for boundary cases. If users define their predicates sensibly then it will behave sensibly. |
Hmm. I'm feeling more nervous about this change. Changing the behaviour of With the new semantics we will currently have the following (using the new syntax for defining predicates):
The problem is that Leaving this issue open until I make all the changes and add to the docs. |
What would be the reason for a user to define two different classes (predicates) which lead to the exact same symbol-representation? |
You could still group by predicate name; "p" in your example. The instance |
Sort of. I will need to group by the python class name, not the asp predicate "p". For consistency with |
Yes, I can't think of good scenarios where this is not a modelling mistake. The only scenario I can come up with is something like modelling a dynamic system where you have fluents. Say you have a
Now maybe you are interested in specifying the initial robot position to pass to the solver but then once your run the solver you want to know what fluents were set but you don't care about accessing the internal details of each fluent. So you could define the following Predicate subclasses.
So here the symbol produced by any This isn't the greatest example but not completely implausible. |
Based on discussions #97 the decision is to overload the Predicate instance comparison to simply call the underlying Symbol object.
The behaviour of the
Predicate
sub-class comparison relations (==
,!=
,<
,<=
, etc) is currently a bit of a mess as it tries to combine two competing intuitions:Symbol
object, behave like aSymbol
object.The big reason to not simply treat it like a tuple-like object is that the comparison relations are not always defined. For example,
("a",1) < (1,"a")
will fail because of the failed comparison between astr
and anint
. In contrast, the comparison of twoSymbol
objects is always well-defined. Being able to compare arbitrary facts is useful. For example, you can sort a list of facts. Even when you don't care what the order is, it is still useful that it exists.Note, for python tuples, equality and inequality are always well defined. So,
("a",1) == (1,"a")
.So, my current thought is:
<
,<=
,>
,>=
relations to only use the underlyingSymbol
object.==
and!=
relations.Predicate
subclass). This means you can also compare a normal python tuple to a clorm tuple.@florianfischer91 @MaxOstrowski or anyone else have thoughts?
The text was updated successfully, but these errors were encountered: