You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently you have to specify each predicate that you want to match to; either explicitly through a class definition or using the simple_predicate() helper function. However, it may also be useful to capture all output, for example during a debugging phase or because it would too cumbersome to explicitly define all the predicates that you want to match to,
A solution to this would be to introduce a catch all flag into the SymbolPredicateUnifier class; the unifier list ultimately gets turned into a SymbolPredicateUnifier object. With the flag enable this object would then dynamically define a new Predicate sub-class whenever it finds a symbol that it cannot unify.
I think this would be possible to implement without breaking anything. The unifier could have a member function that returns the list of new predicates that it defined.
The text was updated successfully, but these errors were encountered:
daveraja
changed the title
A catch-all for getting the facts from a stable model
A catch-all for retrieving all facts from a model
Oct 7, 2020
Rather than adding a catch all flag to the SymbolPredicateUnifier, I think a better option would be to create a new catch all class object where the object can be added to the end of the unifier list. So it will behave a bit like a Predicate class object but will unify with anything by dynamically creating matching predicate sub-classes. This should make it easier to use for those that want it and won't break anything for people that don't want it.
One more alternative option might be to query the Control.symbolic_atoms property to build a list of all the predicate name-arity pairs that make up the atoms in the ASP program. You can then use simple_predicate() to generate matching predicates. Something like the following should work:
unifier = [ .... ] # An existing unifier list
catchall = []
caught = set()
for name,arity,sign in ctrl.symbolic_atoms.signatures:
if (name,arity) in caught: continue
caught.add((name,arity))
catchall.append(simple_predicate(name,arity))
unifier = unifier + catchall
On the positive side, this is something a user could do now without any special hacks into the internals of clingo or clorm. I could also provide a simple convenience function (that does the above) just to make it a little simpler. On the negative side, it requires a bit of effort on the part of the user to specify these newly created predicate definitions to the end of the unifier list (and to update this list if the grounding changes).
Currently you have to specify each predicate that you want to match to; either explicitly through a class definition or using the simple_predicate() helper function. However, it may also be useful to capture all output, for example during a debugging phase or because it would too cumbersome to explicitly define all the predicates that you want to match to,
A solution to this would be to introduce a catch all flag into the SymbolPredicateUnifier class; the unifier list ultimately gets turned into a SymbolPredicateUnifier object. With the flag enable this object would then dynamically define a new Predicate sub-class whenever it finds a symbol that it cannot unify.
I think this would be possible to implement without breaking anything. The unifier could have a member function that returns the list of new predicates that it defined.
The text was updated successfully, but these errors were encountered: