Asserting a fact when triggering a rule
Baltasar García Perez-Schofield <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Organization | UVigo |
| Message-ID | <[email protected]> |
Hi, there, I'm new to SWI Prolog. I'm using it through pySWIP, a bridge between SWI Prolog and Python. I need to assert an extra fact when a given rule is triggered. I know how to do this in Pyke, but, I can't figure it out in SWI Prolog. So, an example would be: person( X ) :- human( X ). So, every human is also a person. But say I want to assert that it is also a mammal. I can do it repeating the rule: person( X ) :- human( X ). mammal( X ) :- human( X ). However, I've been trying to accomplish this in swipl, and it seems that the second rule is not triggered unless a query asks for it. I wonder whether it would be possible to assert both facts at the same time, something like: person(X) :- human(X), if_triggered(assert(mammal(X))). Thanks in advance, -- Baltasar García Perez-Schofield ([email protected]) Dpt. Informática, Universidad de Vigo, España http://webs.uvigo.es/jbgarcia/