I read through the pdf you linked, and I'm trying to wrap my head around the example given at the end. Here's how I'm currently understanding the description:
(defrule cousins-may-inherit-trait
(has ?x ?trait)
(cousin ?x ?y)
(has ?y ?trait)
=>
(assert (inherited (status possible) (trait ?trait))))
(defrule cousin
(goal (cousin ?x ?y))
(parent ?x ?parent-1)
(sibling ?parent-1 ?parent-2)
(parent ?y ?parent-2)
=>
(assert (cousin ?x ?y)))
(defrule sibling
(goal (sibling ?x ?y))
(parent ?x ?parent)
(parent ?y ?parent)
=>
(assert (sibling ?x ?y)))
(assert (has John freckles))
==> f-1 (has John freckles)
==> g-1 (cousin John ?1)
;(defrule cousins-may-inherit-trait
; (has John freckles)
; (cousin John ?y)
; (has ?y freckles)
; =>
; (assert (inherited (status possible) (trait freckles))))
(assert (parent John George))
==> f-2 (parent John George)
==> cousins g-1,f-2
==> g-2 (sibling George ?1)
;(defrule cousin
; (goal (cousin John ?y))
; (parent John George)
; (sibling George ?parent-2)
; (parent ?y ?parent-2)
; =>
; (assert (cousin John ?y)))
;(defrule sibling
; (goal (sibling George ?y))
; (parent George ?parent)
; (parent ?y ?parent)
; =>
; (assert (sibling George ?y)))
(assert (parent George Adam))
==> f-3 (parent George Adam)
==> sibling g-2,f-3
;(defrule sibling
; (goal (sibling George ?y))
; (parent George Adam)
; (parent ?y Adam)
; =>
; (assert (sibling George ?y)))
(assert (parent Sally Adam))
==> f-4 (parent Sally Adam)
==> sibling g-2,f-3,f-4
;(defrule sibling
; (goal (sibling George Sally))
; (parent George Adam)
; (parent Sally Adam)
; =>
; (assert (sibling George Sally)))
==> activation sibling g-2,f-3,f-4
(run)
FIRE sibling g-2,f-3,f-4
==> f-5 (sibling George Sally)
==> cousin g-1,f-2,f-5
;(defrule cousin
; (goal (cousin John ?y))
; (parent John George)
; (sibling George Sally)
; (parent ?y Sally)
; =>
; (assert (cousin John ?y)))
(assert (parent Mary Sally))
==> f-6 (parent Mary Sally)
==> cousin g-1,f-2,f-5,f-6
;(defrule cousin
; (goal (cousin John Mary))
; (parent John George)
; (sibling George Sally)
; (parent Mary Sally)
; =>
; (assert (cousin John Mary)))
==> activation cousin g-1,f-2,f-5,f-6
(run)
FIRE cousin g-1,f-2,f-5,f-6
==> f-7 (cousin John Mary)
==> cousins-may-inherit-trait f-1,f-7
;(defrule cousins-may-inherit-trait
; (has John freckles)
; (cousin John Mary)
; (has ?y freckles)
; =>
; (assert (inherited (status possible) (trait freckles))))
> From which point, asserting that Mary has freckles
> activates the rule, thereby leading to the assertion the freckles
> may be inherited.
(assert (has Mary freckles))
What is the value of goals in the above scenario? Since we have these "intermediary" facts to represent siblings and cousins, I'm not sure I understand the role of goals.