Expert systems in Clojure (clara rule,rete4frames)

Web Technology   Digital Transformation Technology Artificial Intelligence Technology   Natural Language Processing Technology   Semantic Web Technology   Deep Learning Technology   Online Learning & Reinforcement Learning Technology  Chatbot and Q&A Technology   User Interface Technology   Knowledge Information Processing Technology   Reasoning Technology  Clojure Programming

There are several Clojure libraries inspired by CLIPS, such as clara rule and rete4fmanes, as described in “Expert Systems and CLIPS“. The sample code of clara rule is as follows.

(ns clara.example
  (:require [clara.rules :refer :all]))

(defrecord SupportRequest [client level])

(defrecord ClientRepresentative [name client])

(defrule is-important
  "Find important support requests."
  [SupportRequest (= :high level)]
  =>
  (println "High support requested!"))

(defrule notify-client-rep
  "Find the client representative and request support."
  [SupportRequest (= ?client client)]
  [ClientRepresentative (= ?client client) (= ?name name)]
  =>
  (println "Notify" ?name "that"  
          ?client "has a new support request!"))

In clara rule, the rete4frame described below is similar to the CLIPS function expression, while some of the functions have their own settings. For example, (defrecord) is equivalent to (deftenplate) in CLIPS, and (defrule) has the same function name, but the conditional statement becomes an argument and it lists them.

Next, Rete4frames is as follows.

<Application description>
((templates t1 t2 ... tn )
 (rules r1 r2 ... rm )
 (functions d1 d2 ... dl )
 (facts f1 f2 ... fk ))

<template>
(monkey
  location
  on-top-of
  holding)

<rules>
(walk-holding-object 0 ?goal (goal-is-to action walk-to argument1 ?place) ?monkey (monkey location ?loc on-top-of floor holding ?obj ((not= ?loc ?place) (not= ?obj blank))) => (println (str "Monkey walks to " ?place " holding the " ?obj "." )) (modify ?monkey location ?place) (retract ?goal))

<functions>
(asser goal-is-to action hold argument1 ?chest)
(modify ?monkey holding blank)

<fact>
(monkey location t5-7 on-top-of green-couch holding blank)
(monkey location ?place on-top-of ?on2 holding blank)

The basic syntax is based on that of CLIPS, and there is also a library that works with protege, the ontology editor in rete4frames.

When considering the introduction of the expart system in Clojure, it is important to first understand the basic prospective inference behavior, then understand the behavior of CLIPS as an implementation of CLIPS, and then understand the behavior of rete4frames, a Clojure library that basically reproduces CLIPS. After understanding the behavior of rete4frames, which is a Clojure library that basically reproduces CLIPS, I think it is appropriate to proceed to the Clara rule, which has more flexibility.

A simple implementation of the details of Clara Rules and an applied implementation will be discussed later.

コメント

タイトルとURLをコピーしました