JPH03185522A - Inference engine - Google Patents
Inference engineInfo
- Publication number
- JPH03185522A JPH03185522A JP1324263A JP32426389A JPH03185522A JP H03185522 A JPH03185522 A JP H03185522A JP 1324263 A JP1324263 A JP 1324263A JP 32426389 A JP32426389 A JP 32426389A JP H03185522 A JPH03185522 A JP H03185522A
- Authority
- JP
- Japan
- Prior art keywords
- inference
- language
- facts
- inference engine
- section
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 230000006870 function Effects 0.000 claims abstract description 16
- 238000000034 method Methods 0.000 claims abstract description 13
- 238000010586 diagram Methods 0.000 description 3
- 230000000694 effects Effects 0.000 description 3
- 238000004519 manufacturing process Methods 0.000 description 3
- 238000007796 conventional method Methods 0.000 description 1
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
Description
【発明の詳細な説明】
〔産業上の利用分野〕
この発明は、エキスパートシステム等に用いられるプロ
ダクションシステムにおける推論エンジンに関し、特に
動作の高速化をはかった推論エンジンに関するものであ
る。DETAILED DESCRIPTION OF THE INVENTION [Industrial Application Field] The present invention relates to an inference engine in a production system used for an expert system or the like, and particularly to an inference engine that operates at high speed.
第3図は従来のp rolog処理系によるプロダクシ
ョンシステムを示すブロック図であり、図において、l
はルールが集合したルールベース、2は事実が集合した
事実ベース、3は推論を実行する推論エンジン、4は操
作者が事実や目標を入力する入出力部、3aはP ro
logで記述された推論部、3bはP rologプロ
グラムを解釈、実行するPrologインタプリータで
ある。FIG. 3 is a block diagram showing a production system using a conventional prolog processing system.
2 is a rule base that is a collection of rules, 2 is a fact base that is a collection of facts, 3 is an inference engine that executes inference, 4 is an input/output unit where the operator inputs facts and goals, 3a is a Pro
The inference section 3b written in log is a Prolog interpreter that interprets and executes a Prolog program.
次に動作について説明する。プロダクションシステムで
は一般に、ルールベース1に格納されたルールは、IF
(前提部)THEN (結論部)の形式となっている。Next, the operation will be explained. In production systems, the rules stored in rule base 1 are generally
(Premise part) THEN (Conclusion part) format.
また、入出力部4に入力された事実および推論実行中に
得られた事実は事実ベース2に格納される。前向き推論
を行う場合には、例えば、推論エンジン3はルールベー
ス1中のルールを先頭から探索して、前提部が事実ベー
ス2中の事実と適合するものを探す、適合したルールが
あればその結論部を新たな事実として事実ベース2に付
加するとともに、再度ルールベース1の探索を行う、そ
して、事実に適合するルールが見つからなくなった時に
、得られた事実のうちの適正なものを結論とする。Further, the facts input to the input/output unit 4 and the facts obtained during the execution of the inference are stored in the fact base 2. When performing forward inference, for example, the inference engine 3 searches the rules in rule base 1 from the beginning, searches for those whose premises match the facts in fact base 2, and if there is a matching rule, it Add the conclusion part to fact base 2 as a new fact, search rule base 1 again, and when no rule matching the facts is found, use the appropriate one of the obtained facts as the conclusion. do.
以上のような推論を実行するにあたって、ルールの条件
部または結論部と事実とのパターンマツチングが繰り返
し行われるので、推論エンジン3はパターンマツチング
機能が備わった処理系とする必要がある。従って、従来
から推論エンジン3はパターンマツチング機能やリスト
処理機能等が強力であるP rologやLi5p等の
処理系が使用されている。When performing the above-described inference, pattern matching between the condition part or the conclusion part of the rule and the facts is repeatedly performed, so the inference engine 3 needs to be a processing system equipped with a pattern matching function. Therefore, processing systems such as Prolog and Li5p, which have powerful pattern matching functions and list processing functions, have been used as the inference engine 3.
例えば、P rolog処理系を採用した場合には、推
論部3a、事実およびルールはP rologでプログ
ラミングされる。そして、第3図に示すように。For example, if a Prolog processing system is adopted, the inference section 3a, facts, and rules are programmed using Prolog. And as shown in Figure 3.
P rologインタプリータ3bは推論部3aを解釈
して、ルールベース1中のルールおよび事実のパターン
マツチングを行いながらルールベース1の探索を順次実
行する。The Prolog interpreter 3b interprets the inference section 3a and sequentially searches the rule base 1 while performing pattern matching of rules and facts in the rule base 1.
従来の推論エンジン3は以上のように構成されているの
で、P rologインタプリータ3b等のインタプリ
ータにより推論が進められ、そのために推論速度はある
程度以上には向上させることができないという課題があ
った。特に、ルール数が多数となったり推論機能を豊富
にする程推論速度の低下は顕著である。Since the conventional inference engine 3 is configured as described above, the inference is proceeded by an interpreter such as the Prolog interpreter 3b, and therefore there is a problem that the inference speed cannot be improved beyond a certain level. In particular, as the number of rules increases and the number of inference functions increases, the reduction in inference speed becomes more pronounced.
この発明は上記のような課題を解消するためになされた
もので、推論速度を従来のものに比べて大幅に向上させ
ることができるとともに、ユーザに対しては従来のP
rolog等の処理系で推論を行っているように振舞う
ことができる推論エンジンを得ることを目的とする。This invention was made to solve the above-mentioned problems, and it is possible to significantly improve the inference speed compared to the conventional method, and it also provides users with the ability to
The purpose of this invention is to obtain an inference engine that can behave as if it were performing inference using a processing system such as rolog.
C111題を解決するための手段〕
この発明に係る推論エンジンは、パターンマツチング等
の推論を実行する際の推論過程における各処理を、C3
語、アセンブリ言語等のいわゆるハードウェア寄りの言
語で記述した関数で記述した上、これらの関数を集合さ
せた実行部を設け、かつ、ハードウェア寄りの言語で記
述されていて。Means for Solving the C111 Problem] The inference engine according to the present invention performs each process in the inference process when performing inference such as pattern matching using the C3
It is written using functions written in a so-called hardware-oriented language, such as Japanese language or assembly language, and has an execution section that is a collection of these functions, and is written in a hardware-oriented language.
入出力部に与えられた事実や推論実行中に得られた事実
等に応じて実行部の関数を呼び出す、ブまり実行させる
推論部を設けたものである。It is provided with an inference section that calls a function of the execution section in accordance with the facts given to the input/output section or the facts obtained during the execution of the inference, and causes the function to be executed in a block manner.
この発明における実行部は、コンパイルまたはアセンブ
ルされた後に推論エンジンに組込まれることになるので
、推論を実行する際のそれぞれの推論過程を高速で処理
し、結局、推論を高速で実行することになる。Since the execution unit in this invention is incorporated into the inference engine after being compiled or assembled, it processes each inference process at high speed when executing inference, and ultimately executes inference at high speed. .
以下、この発明の一実施例を図について説明する。第1
図において、5はパターンマツチング等の推論過程にお
ける処理を1つの関数としたものを集合させた実行部で
あり、C言語(以下、Cという、)やアセンブリ言語(
以下、アセンブラという、)で記述したプログラムをコ
ンパイルまたはアセンブルしたものである。また、6は
入出力部4に与えられた事実と中間処理結果とに応じて
必要な関数を呼び出して推論を進める推論部であり、や
はり、Cやアセンブラで記述されたものである。その他
のものは同一符号を付して第3図に示したものと同一の
ものである。An embodiment of the present invention will be described below with reference to the drawings. 1st
In the figure, reference numeral 5 denotes an execution unit that collects processes in the inference process such as pattern matching into a single function, and includes C language (hereinafter referred to as C) and assembly language (
It is a compilation or assembly of a program written in (hereinafter referred to as an assembler). Further, 6 is an inference section that advances inference by calling necessary functions according to the facts given to the input/output section 4 and intermediate processing results, and is also written in C or assembler. Other parts are the same as those shown in FIG. 3 with the same reference numerals.
次に動作について説明する。初めに、基本となるプログ
ラム言語にP rologを採用した場合の実行部5お
よび推論部6の作成の仕方について説明する。まず、P
rologの機能、規約および組込み述語をCやアセ
ンブラでサブルーチン形式で記述する。さらに、これら
をコンパイルまたはアセンブルして(必要ならリンクを
行って)実行部5とする。一方、ルールベース1や事実
ベース2へのアクセス動作を適当な単位ごとにCやアセ
ンブラでサブルーチン形式で記述する。そして、サブル
ーチン化した部分以外をCやアセンブラで記述する6次
に、これらをコンパイルまたはアセンブルして推論部6
とする。そして、実行部5と推論部6とをリンクして、
コンピュータ等の記憶部に格納する。Next, the operation will be explained. First, a description will be given of how to create the execution section 5 and the inference section 6 when Prolog is adopted as the basic programming language. First, P
The functions, rules, and built-in predicates of rolog are written in subroutine format in C or assembler. Furthermore, these are compiled or assembled (linked if necessary) to form the execution unit 5. On the other hand, access operations to the rule base 1 and fact base 2 are described in subroutine format in C or assembler for each appropriate unit. Then, parts other than the subroutine parts are written in C or assembler.Next, these are compiled or assembled and the inference section 6
shall be. Then, by linking the execution unit 5 and the inference unit 6,
Stored in a storage unit of a computer, etc.
次に、推論の実行動作について第2図に示したフローチ
ャートを参照して説明する。まず、入出力部4に事実が
入力された場合には(ステップ5T1)、推論部6は事
実ベースへ格納するルーチンを呼び出すことによりこの
ルーチンを実行させ、入力された事実を事実ベース2に
格納する(ステップ5T2)。そして、実行部5のパタ
ーンマツチングルーチンを呼び出して、ルールベース1
の各ルールの前提部と事実ベース2の事実とのパターン
マツチングを行う(ステップ5T3)、ここで、マツチ
したものがあって(ステップ5T4)、結論部に記述さ
れた手続きを実行する必要が生じた時には(ステップS
T 5 ) 、 Prologインタプリータ3bを
呼び出してこれを処理させる(ステップ5T6)。また
、そのルールの結論部を新たな事実として事実ベース2
に付加する場合には(ステップ5T7)、事実ベースへ
格納するルーチンを呼び出す(ステップ5T8)。以上
のような処理を繰り返した後に、事実にマツチする前提
部を有するルールがなくなったら推論は終了する。Next, the inference execution operation will be explained with reference to the flowchart shown in FIG. First, when a fact is input to the input/output unit 4 (step 5T1), the inference unit 6 executes this routine by calling a routine for storing it in the fact base 2, and stores the input fact in the fact base 2. (Step 5T2). Then, the pattern matching routine of the execution unit 5 is called to match the rule base 1.
Pattern matching is performed between the premise of each rule and the facts of fact base 2 (Step 5T3). Here, there is a match (Step 5T4), and it is necessary to execute the procedure described in the conclusion. When it occurs (step S
T5), the Prolog interpreter 3b is called and processed (step 5T6). In addition, the conclusion part of the rule can be treated as a new fact in Fact Base 2.
(Step 5T7), a routine for storing in the fact base is called (Step 5T8). After repeating the above process, the inference ends when there are no more rules with a premise that matches the facts.
このように、推論エンジン3を、P rolog処理系
を基本としてハードウェア寄りの言語でインプリメント
したので、外部からはP rolog処理系によって推
論が進められているように見えると同時に、その処理速
度を大幅に向上させることができる。処理速度の向上の
度合は、ルールや事実の個数によって差はあるが、10
0ルール程度の推論システムでは数10倍の速度となる
。In this way, the inference engine 3 is implemented in a hardware-oriented language based on the Prolog processing system, so that it appears from the outside that inference is proceeding with the Prolog processing system, and at the same time, the processing speed is can be significantly improved. The degree of improvement in processing speed varies depending on the number of rules and facts, but
An inference system with about 0 rules will be several tens of times faster.
なお、基本となる処理系はP rologに限らず、パ
ターンマツチングやリスト処理に適したものであれば他
のものでもよい。Note that the basic processing system is not limited to Prolog, but may be any other system as long as it is suitable for pattern matching and list processing.
以上のように、この発明によれば推論エンジンを、推論
過程で用いられる処理単位をハードウェア寄りの言語で
関数表現するとともに、推論を進行させる部分もハード
ウェア寄りの言語で記述したもので構成したので、従来
の推論エンジンの機能を落とすことなく、より高速に推
論を行えるものが得られる効果がある。As described above, according to the present invention, the inference engine is configured such that the processing unit used in the inference process is expressed as a function in a language that is closer to hardware, and the part that advances the inference is also written in a language that is closer to hardware. Therefore, it has the effect of being able to perform inference faster without reducing the functionality of conventional inference engines.
第1図はこの発明の一実施例による推論エンジンを含む
システムの構成を示すフローチャート、第2図は推論部
の動作を示すフローチャート、第3図は従来の推論エン
ジンを含むシステムの構成を示すブロック図である。
1はルールベース、2は事実ベース、3は推論エンジン
、4は入出力部、5は実行部、6は推論部。
なお、図中、同一符号は同一、または相当部分を示す6FIG. 1 is a flowchart showing the configuration of a system including an inference engine according to an embodiment of the present invention, FIG. 2 is a flowchart showing the operation of the inference section, and FIG. 3 is a block diagram showing the configuration of a system including a conventional inference engine. It is a diagram. 1 is a rule base, 2 is a fact base, 3 is an inference engine, 4 is an input/output section, 5 is an execution section, and 6 is an inference section. In addition, in the figures, the same reference numerals indicate the same or corresponding parts.
Claims (1)
ルールベースを順次探索して結論を導く推論エンジンに
おいて、前記ルールベースを探索する際の推論過程で用
いられる処理単位のそれぞれをハードウェア寄りの言語
で記述した関数を集合させた実行部と、前記ハードウェ
ア寄りの言語で記述され、前記入出力部に与えられた事
実および前記ルールベースを探索する際の中間処理結果
に応じて前記関数を呼び出す推論部とを備えたことを特
徴とする推論エンジン。In an inference engine that sequentially searches a rule base containing a set of rules and draws a conclusion according to facts given to the input/output section, each processing unit used in the inference process when searching the rule base is an execution unit that is a collection of functions written in a language that is similar to the hardware; An inference engine characterized by comprising an inference section that calls a function.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP1324263A JPH03185522A (en) | 1989-12-14 | 1989-12-14 | Inference engine |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP1324263A JPH03185522A (en) | 1989-12-14 | 1989-12-14 | Inference engine |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| JPH03185522A true JPH03185522A (en) | 1991-08-13 |
Family
ID=18163856
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP1324263A Pending JPH03185522A (en) | 1989-12-14 | 1989-12-14 | Inference engine |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JPH03185522A (en) |
-
1989
- 1989-12-14 JP JP1324263A patent/JPH03185522A/en active Pending
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US4890240A (en) | Coalescing changes in pattern-directed, rule-based artificial intelligence production systems | |
| US20040049768A1 (en) | Method and program for compiling processing, and computer-readable medium recoding the program thereof | |
| Allan et al. | A flow analysis procedure for the translation of high-level languages to a data flow language | |
| JPH03185522A (en) | Inference engine | |
| JPH0764766A (en) | Maximum / minimum value calculation method for parallel computers | |
| JP2585780B2 (en) | DO loop optimization processing method for input / output library | |
| JP3278584B2 (en) | Computer program generation apparatus and method | |
| JPH0447337B2 (en) | ||
| JP2633918B2 (en) | Method search method and method search procedure generation method | |
| JPH0573335A (en) | Automatic in-line development system for program | |
| JP2601541B2 (en) | FORTRAN input / output list processing method | |
| JPH03144830A (en) | Parallel processing system | |
| JPH0573312A (en) | List processing system | |
| JPH08263298A (en) | Compiler device | |
| JPH0659905A (en) | Parallel processing system for compiler | |
| JPH04165537A (en) | Program automatic inline expansion method | |
| JPH08263300A (en) | Inline expansion method | |
| JPH06274351A (en) | Optimizing system for compiler | |
| JPH02181830A (en) | Loop optimizing processing method | |
| JPH0619721A (en) | Machine language translation optimizing system | |
| JPH01158532A (en) | Program execution method | |
| Gary et al. | An optimizing precompiler for finite-difference computations on a vector computer | |
| JPH04107605A (en) | Language processing device for control programs | |
| JPH05298117A (en) | Optimizing system for procedure with constant as argument | |
| uri Kiho et al. | Control Structure Transformations in the Program Multiviewer |