Skip to content
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

A catch-all for retrieving all facts from a model #34

Open
daveraja opened this issue Oct 7, 2020 · 3 comments
Open

A catch-all for retrieving all facts from a model #34

daveraja opened this issue Oct 7, 2020 · 3 comments
Labels
api Request change to the API enhancement New feature or request

Comments

@daveraja
Copy link
Collaborator

daveraja commented Oct 7, 2020

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.

@daveraja 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
@daveraja
Copy link
Collaborator Author

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.

@daveraja
Copy link
Collaborator Author

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).

@daveraja daveraja added api Request change to the API enhancement New feature or request labels Nov 21, 2021
@Nsharma213
Copy link

Hi Sir, I am sorry for not catching up on Issue#61. I have a question posted there. Could you please take a look. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Request change to the API enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants