clipsexpert-system

Which rule will be fire first, more specific or the last one?


I am new to CLIPS, but I have dealt before with Prolog, and as I remember that Prolog will execute the more specific rules, what is the case for CLIPS?

For example, I have the following facts:

(male Rayan)
(male Mark)
(female Jamila)
(female Maria)
(male Osama)
(male Brad)
(parent Rayan Mark) ; Rayan is father of Mark
(parent Brad Rayan)
(parent Maria Rayan)
(parent Rayan Osama)

and then I defined two rules

(defrule grand-parent 
(parent ?x ?y) (parent ?y ?z) 
=> (assert (grand-parent ?x ?z)))

and

(defrule grand-mother
(parent ?x ?y) (parent ?y ?z) (female ?x) 
=> (assert (grand-motehr ?x ?z)))

I thought that regardless of the order of the defined rules, the grand-mother rule will be activated first since it is more specific, but it seems this is not the case. So, what is the strategy of the activation in term of specification?

update:

is this related to resolution conflicts or to certain strategies


Solution

  • The conflict resolution strategy determines where rules are placed on the agenda relative to each other. The details are discussed in section 5.3 of the CLIPS Basic Programming Guide. The default depth strategy chooses the rule activated by the most recent assertion of a fact. The lex strategy uses a combination of recency and specificity to determine the order in which rules fire.