Re: Assert with concepts
Thomas Russ <[email protected]> Fri, 6 Apr 2007 10:03:42 -0700
| Newsgroups | gmane.comp.ai.powerloom |
|---|---|
| Message-ID | <[email protected]> |
On Apr 6, 2007, at 6:29 AM, Laecio Lima wrote: > Hy. See the comands below: > > defconcept(Person ?x) > defrelation(likes ((Person ?x)(Person ?x)) > > assert(Person James) > assert(not(Person Frank)) > > assert(likes James Frank) > > that create the relation without problems. How can I do to make > that this assert returns a error for Frank don't be a Person? Background: The constraint is not something that PowerLoom checks after every assertion. This is a performance optimization, since we like to safe up the checks and then do them in larger groups. Solution: There are three ways you can get PowerLoom to check for such constraint violations: (1) If you ask any query, either with ASK or RETRIEVE, PowerLoom will process the type checks before running the query. This has the advantage of simplicity, since the constraints are checked right before PowerLoom thinks it needs them. It has the drawback that the constraint violation that is found is usually not even related to the query at all. That can be confusing. (2) You can tell PowerLoom to run the forward rules, either with the command (RUN-FORWARD-RULES <module>) or with the similarly named PLI interface function. This will cause constraints to be checked and other forward rules to run. If you are relying on forward rules running, then supplying the force parameter may be necessary. (3) You can call (PROCESS-DEFINITIONS) and this will also cause the type checking constraints to run. This applies even if all you have done is add assertions. Of these choices, I favor using (2), since in the other cases, the checking is more of a side-effect. So, try (run-forward-rules pl-user) ;; or whatever the name of the module you are reasoning in. and you should see a clash: ? (defconcept person) |c|PERSON ? (defrelation likes ((?x person) (?y person))) |r|LIKES ? (assert (person james)) |P|(PERSON JAMES) ? (assert (not (person frank))) |P|(NOT (PERSON FRANK)) ? (assert (likes james frank)) |P|(LIKES JAMES FRANK) ? (run-forward-rules pl-user) Derived both TRUE and FALSE for the proposition `|P#|(PERSON FRANK)'. Clash occurred in module `|MDL|/PL-KERNEL-KB/PL-USER'. |L|TRUE ? One further note: Once such a violation has been found, it will not be noted in subsequent calls, so you will have to arrange to remember any such constraint violations.“