Hello Ernest,

Thanks for answer.

(defrule frog-color
 (need-color ?name ?)
 (kind ?name frog)

And since "color" is the first pattern in the rule, there's no
indication what the value of "?name" should be. So the goal need-color
contains "nil" in that position. "nil" doesn't match "Fritz" (or
whatever the user types in) so the "kind" and "need-color" facts don't
match, and so the rule doesn't fire.

Right... Got that (finally).

I have to say that daisy-chained backward-chaining rules are  decidedly
non-trivial (and therefore harder to write and debug), while
forward-chaining rules are very easy to understand (at least for me).

I'm writing about Jess in my thesis on AI techniques, and so I wanted to
ask you a few questions - is backward-chaining is really valuable in
practice, outside of subjects like calling queries to databases (like in
the example you give in "Jess in Action")?

If so, where do you think it is most useful? Are there any problems that
are awkward to code using forward-chaining while they are more natural
to code using backward-chaining rules?

How do you think backward-chaining adds to the expressive power of Jess
understood as language? Is it worth the effort, both for rule engine
developer and for the rule engine user?

I have sort of stumbled on one limitation of backward-chaining in Jess:
constraints on slots, I found I couldn't call a function on slot:

Jess> Jess reported an error in routine ReteCompiler.addRule.
  Message: Can't use funcalls in backchained patterns __data.

Is there a way around that? Or am I misunderstanding the problem,
because one perhaps doesn't want to constrain slots in backward-chained
rules as finding their values is the goal of this part of rule engine
operation (as constraints would simply prevent firing one of b-c rules
in the chain of reasoning in some cases, like it happened in my
uncorrected example)?

Thanks in advance,

==
I finished coding the Wikipedia example, I send it here bc it might be
of interest to another Jess beginner:

(clear)
(do-backward-chaining color)
(do-backward-chaining kind)
(do-backward-chaining activity)

(defrule print-pet-color
 (color ?name ?val) =>
 (printout t "Color of " ?name " is " ?val crlf)
)

(defrule frog-color
 (need-color ? ?)
 (kind ?name frog)
 =>
 (assert (color ?name green))
)

(defrule canary-color
 (need-color ? ?)
 (kind ?name canary)
 =>
 (assert (color ?name yellow))
)

(defrule pet-frog
 (need-kind ? ?)
 (activity ?name croaks)
 =>
 (assert (kind ?name frog))
)

(defrule pet-canary
 (need-kind ? ?)
 (activity ?name sings)
 =>
 (assert (kind ?name canary))
)

(defrule get-pet-activity
 (need-activity ? ?)
 =>
 (printout t "Pet name? ")
 (bind ?name (read))
 (printout t "Pet croaks or sings? ")
 (bind ?type (read))
 (assert (activity ?name ?type))
)

(reset)
(run)

TRUE

Jess> Pet name? Fritz
Pet croaks or sings? sings
Color of Fritz is yellow
4
Jess> (facts)
f-0   (MAIN::initial-fact)
f-1   (MAIN::need-color nil nil)
f-2   (MAIN::need-kind nil frog)
f-3   (MAIN::need-kind nil canary)
f-4   (MAIN::need-activity nil croaks)
f-5   (MAIN::need-activity nil sings)
f-6   (MAIN::activity Fritz sings)
f-7   (MAIN::kind Fritz canary)
f-8   (MAIN::color Fritz yellow)
For a total of 9 facts in module MAIN.



--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to