Question about definite/estimate consequences
rkaminsk opened this issue · comments
Hi, clasp's model object has two member functions to inspect whether a literal is definite or estimated. I also want to offer this functionality via the clingo API.
As far as I can see, I only have to expose the following two functions:
struct Model {
//! True if p is part of a definite answer.
bool isDef(Literal p) const;
//! True if p is part of the current estimate of consequences.
bool isEst(Literal p) const;
};
Now, I was thinking to add a few more lines to the documentation. To see if I understood correctly, can you tell me whether the statements below are true.
- not in cautious/brave enumeration mode
isDef
is the same asisTrue
isEst
is always false
- in cautious/brave enumeration mode
isDef
andisEst
partition the true literals into estimated and definite consequences
I am asking, because I want to write a bit more in the API docs.
I implemented a first version in potassco/clingo#423.
To see if I understood correctly, can you tell me whether the statements below are true.
1. not in cautious/brave enumeration mode 1. `isDef` is the same as `isTrue`
Yes.
2. `isEst` is always false
I think in the current implementation this is true but strictly speaking, isEst
is undefined in this case.
2. in cautious/brave enumeration mode 1. `isDef` and `isEst` partition the true literals into estimated and definite consequences
Yes.
I decided to go with a "tribool" in the API. I also documented what happens in the normal enumeration mode.
In hindsight, it would have been better to call Model Solution and maybe use contains
instead of is_true
/is_consequence
because one can nicely combine the two.
def is_consequence(self, literal: int) -> Optional[bool]:
"""
Check if the given program literal is a consequence.
The function returns `True`, `False`, or `None` if the literal is a
consequence, not a consequence, or it is not yet known whether it is a
consequence, respectively.
While enumerating cautious or brave consequences, there is partial
information about which literals are consequences. The current state of
a literal can be requested using this function. If this function is
used during normal model enumeration, the function just returns whether
a literal is true of false in the current model.
Parameters
----------
literal
The given program literal.
Returns
-------
Whether the given program literal is a consequence.
"""
@rkaminsk Can we close this issue or is there something more to do?
@rkaminsk Can we close this issue or is there something more to do?
We can close it.