ウェブ技術 デジタルトランスフォーメーション技術 人工知能技術 自然言語処理技術 セマンティックウェブ技術 深層学習技術 オンライン学習&強化学習技術 チャットボットと質疑応答技術 ユーザーインターフェース技術 知識情報処理技術 推論技術 Clojure プログラミング
“エキスパートシステムとCLIPS“に述べのCLIPSにインスパイアーされて作られたClojureのライブラリとしてclara ruleやrete4fmanesやがある。まずclara ruleについて、サンプルコードは以下となる。
(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!"))
clara ruleでは後述のrete4framesがCLIPSの関数表現に近いのに対して一部独自の関数設定になっている。例えば(defrecord)がCLIPSの(deftenplate)に相当し、(defrule)は関数名はそのままだが、条件文が引数となりそれらを列記するような形となる。
次にRete4framesについては以下のようになる。
<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)
基本的な構文はCLIPSのそれを踏襲するものとなり、更にrete4framesではontology editorであるprotegeと連携したライブラリも存在する。
expart systemのClojureでの導入を考えた場合、まず基本の前向き推論の動作を理解し、次にそれらの実装形態としてのCLIPSの動作を理解し、更にそれらを基本的に再現したClojureライブラリであるrete4framesの動作を理解した上で、よりフレキシビリティのあるClara ruleに進むのが妥当となる。
Clara Rulesの詳細のシンプルな実装にと応用的な実装に関しては後日述べる。
Chinoba
Intelligence as Relationship
Research Platform
founded by
Masao Watanabe
AI Systems Architecture
Decision Trace
Human–AI Coordination
Algorithmic Governance
Related Research
この記事は Chinoba Knowledge Base の一部です。

コメント
[…] 前回に引き続き、Clojureでのexpert systemであるClara Ruleを用いた実装について述べる。2017年にiku00088さんが書いた「clara-rulesの世界」のコードを参考に一部動かない所を修正したコードを掲載する。まず一番シンプルな動作コードは以下となる。 […]
[…] ClojurScriptを構成したり、Java等のOOPプラットフォームとの連携を考えたり、また前述のCralaでもClojureでのクラスの操作の理解が必要となる。 […]
[…] エキスパートシステムの実装例としてはJavaによるCLIPSがある。またそれらをベースとしたClojureでの実装と活用に関しても別途述べる。 […]
[…] これらをClojureで実装して活用した例を別途述べる […]
[…] Clojureでのエキスパートシステム Clara RuleとRete4Frame […]
[…] Clojureでのエキスパートシステム Clara Rule, Rete4grame […]