If you want to use fact references as slot values you'll have to assert the
"family" facts
algorithmically, i.e., not from within a deffacts.
Matching via fact references requires you to match a fact to obtain the
binding to a
fact references, and then you can use the bound variable in a subsequent
pattern's slot.
Here's a rule which you can easily convert to a query:
(defrule findFather
?f <- (person (name ?name))
?c <- (person (name AB))
(family (father ?f)(children $? ?c $?))
=>
(printout t "father of AB is " ?name crlf)
)
-W
On Fri, Jul 24, 2009 at 5:04 AM, Nopphadol Chalortham
<[email protected]>wrote:
> Hello,
> this is an example of my problem.
>
> (deftemplate person (slot name)(slot age))
>
> (deftemplate family (slot father)(slot mother)(multislot children))
>
> (deffacts test-facts
> (person (name A)(age 35)) ;fact-1
> (person (name B)(age 28)) ;fact-2
> (person (name C)(age 38)) ;fact-3
> (person (name D)(age 31)) ;fact-4
> (person (name E)(age 30)) ;fact-5
> (person (name F)(age 23)) ;fact-6
> (person (name AB)(age 8)) ;fact-7
> (person (name BA)(age 6)) ;fact-8
> (person (name CD)(age 10)) ;fact-9
> (person (name DC)(age 8)) ;fact-10
> (person (name CDC)(age 4)) ;fact-11
> (person (name FE)(age 1)) ;fact-12
> (family (father <fact-1>)(mother <fact-2>)(children <fact-7> <fact-8>))
> (family (father <fact-3>)(mother <fact-4>)(children <fact-9> <fact-10>
> <fact-11>))
> (family (father <fact-5>)(mother <fact-6>)(children <fact-12>))
>
> I would like to involk the query to find the father's name of the
> family which have
> the children's name is "AB".
> How can I define this query?
>
> regard
>