Re: forward-chaining issue
Xingzhi Pan <[email protected]>
| Newsgroups | gmane.comp.ai.powerloom |
|---|---|
| Message-ID | <[email protected]> |
Thanks very much. It's clear now. 2005/12/1, Hans Chalupsky <[email protected]>: > Dear Pan Xingzhi, > > yes, the PowerLoom forward chainer only considers rules with simple > antecedents and rules with complex antecedents that are marked as > `:forward-only? TRUE'. You can of course get the answer you are > looking for by using backward inference via `ask': > > STELLA(163): (all-facts-of com1) > (|P|(COMPANY COM1) |P|(NUMBER-OF-MANAGERS COM1 10) |P|(NUMBER-OF-EMPLOYEES COM1 50)) > STELLA(164): (ask (small-company com1)) > TRUE > STELLA(165): > > The division of labor between forward and backward chaining is > primarily a performance issue, since depending on fanout, some rules > are much more efficiently run forward than backward and vice versa. > You can help PowerLoom by annotating which rules you want to run > forward and which ones backwards only. > > For example, if you want this to be added with the forward-chainer, > you can mark the rule as "forward-only" with the `=>>' notation: > > STELLA(165): (assert > (forall ?c > (=>> (and (number-of-employees ?c 50) > (number-of-managers ?c 10)) > (small-company ?c)))) > |P|(FORALL (?c) > (=>> (AND (NUMBER-OF-EMPLOYEES ?c 50) (NUMBER-OF-MANAGERS ?c 10)) > (SMALL-COMPANY ?c))) > > STELLA(166): (all-facts-of com1) > (|P|(COMPANY COM1) |P|(NUMBER-OF-MANAGERS COM1 10) |P|(NUMBER-OF-EMPLOYEES COM1 50) > |P?|(SMALL-COMPANY COM1)) > STELLA(167): > > The proposition is only true in an inference-cache world associated > with the current module, which is why it is printed with a question > mark here. These inference caches are blown away if there are any > retractions or non-monotonic changes, since then they might not be > valid anymore. > > Finally, you can use the PowerLoom classifier to eagerly infer all > types of instances and add them to the KB: > > STELLA(177): (setq *classify-from-non-inferable-parents-only?* false) > () > STELLA(178): (classify-instances pl-user true) > u > () > STELLA(179): (all-facts-of com1) > (|P|(COMPANY COM1) |P|(NUMBER-OF-MANAGERS COM1 10) |P|(NUMBER-OF-EMPLOYEES COM1 50) > |P|(SMALL-COMPANY COM1)) > STELLA(180): > > Caveat: by default, the variable > `*classify-from-non-inferable-parents-only?*' is set to TRUE which > prevents COM1 to be classified (this is an optimization for > classification of large hierarchies). Currently, you can't change its > setting with a PowerLoom command which is why I changed it with a Lisp > statement above (or you would have to change the corresponding C++ or > Java variable and then recompile). In future versions we should make > this available as a user feature that you can change. > > Hans > > >>>>> Xingzhi Pan <[email protected]> writes: > > > Hello, friends. > > I've been trying forward-chaining in PowerLoom. It seemed that, > > sometimes PowerLoom will add inferred facts into KB, and sometimes > > not. Try to compare these: > > > (defconcept company) > > (defrelation number-of-employees ((?c company)(?n INTEGER)) ) > > (defrelation number-of-managers ((?c company)(?n INTEGER)) ) > > (defconcept small-company ((?c company))) > > (assert (forall ?c (=> (small-company ?c) (and(number-of-employees ?c > > 50)(number-of-managers ?c 10))) )) > > (assert (small-company com1)) > > (all-facts-of com1) > > > and > > > (defconcept company) > > (defrelation number-of-employees ((?c company)(?n INTEGER)) ) > > (defrelation number-of-managers ((?c company)(?n INTEGER)) ) > > (defconcept small-company ((?c company))) > > (assert (forall ?c (=> (and(number-of-employees ?c > > 50)(number-of-managers ?c 10))(small-company ?c)) )) > > (assert (company com1)) > > (assert (and (number-of-managers com1 10)(number-of-employees com1 50)) ) > > (all-facts-of com1) > > > I found that PowerLoom will do the inference only when the antecedent > > is an 'atom' proposition. When it's something like (and P Q), nothing > > seems happened. Have I done something wrong? Or it's designed so? Any > > help would be appreciated. > > -- > > Pan Xingzhi > > _______________________________________________ > > powerloom-forum mailing list > > [email protected] > > http://mailman.isi.edu/mailman/listinfo/powerloom-forum > -- Pan Xingzhi