When (deffacts) is evaluated to build the facts, (fact-id) won't return a fact since only the (reset) inserts the defined facts. You'll have to use dynamic insertion with (assert) to insert a fact referring to another fact.
-W On 20 July 2010 19:23, Henrique Lopes Cardoso <[email protected]> wrote: > Hi, > > I have just reproduced the example of section 6.10 of the Jess manual: > > (defrule forall-example > (not (and (a ?x) > (not (b ?x)) ) ) > => > (printout t "whassup?" crlf) ) > > (deffacts qwe > (a 1) > ; (a 2) > (b 1) ) > > (reset) (facts) (run) > > So in this case, if I comment out fact (a 2), the rule stops firing. > But then I tried to implement the following rule: > > (defrule r > (not (and ?x <- (a ?) ; variable binding > (not (b ?x)) ) ) ; check if there is a b referring > to the a fact > => > (printout t "sure thing!" crlf) ) > > (deffacts qwe > (a 1) > ; (a 2) > (b (fact-id 1)) ) ; fact b referring to fact (a 1) > > (reset) (facts) (run) > > It's quite similar to the previous one, but now I am inspecting if fact > b contains a reference to fact a. > In this case the rule does not cease to fire when I comment out (a 2). > > Am I missing something? > > Thanks, > > Henrique > > > > -------------------------------------------------------------------- > 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]. > -------------------------------------------------------------------- > > -------------------------------------------------------------------- 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]. --------------------------------------------------------------------
