Search code examples
artificial-intelligencerule-enginefirst-order-logicrete

Are function symbols allowed in rule engines / Rete algorithm?


AI: A Modern Approach brings up the Rete algorithm when discussing inference in first-order logic.

However, all descriptions of the Rete algorithm I found seem to use rules free of function symbols. In other words, rules look like

a(X) ∧ b(X, Y) → c(Y)

but not

a(f(X)) ∧ b(X, Y) → c(f(Y))

(The difference can be fundamental, as it is the difference between Prolog and Datalog, only one of which is Turing-complete)

Is the Rete algorithm limited to rules free of function symbols? Do modern rule engines like Drools and CLIPS handle function symbols?


Solution

  • In CLIPS, this is how you'd implement the rule "For every person, there exists one and only one father of said person, and if a person's father is rich, then so is he/she":

    (defrule inherited-wealth
       (forall (person ?p)
               (father ?p ?f)
               (not (father ?p ~?f)))
       (person ?p)
       (father ?p ?f)
       (rich ?f)
       =>
       (assert (rich ?p)))