JPH02112026A - Method for processing prolog program - Google Patents

Method for processing prolog program

Info

Publication number
JPH02112026A
JPH02112026A JP26533888A JP26533888A JPH02112026A JP H02112026 A JPH02112026 A JP H02112026A JP 26533888 A JP26533888 A JP 26533888A JP 26533888 A JP26533888 A JP 26533888A JP H02112026 A JPH02112026 A JP H02112026A
Authority
JP
Japan
Prior art keywords
goal
program
stack
section
control information
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
Application number
JP26533888A
Other languages
Japanese (ja)
Inventor
Takayuki Ito
孝之 伊藤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric Corp
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP26533888A priority Critical patent/JPH02112026A/en
Publication of JPH02112026A publication Critical patent/JPH02112026A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PURPOSE:To release an unnecessary stack used for a goal to reduce the using quantity of a stack by clearly stating the goal in a PROLOG program, to which only one solution exists or which requires only one solution. CONSTITUTION:An execution controlling section 2 reads out a predicate verb to be executed from an input section 4 and discriminates whether or not a read-out goal means 'SCUT', namely cancellation of the control information stored in a stack after the goal is executed. When the goal does not mean the 'SCUT', the section 2 fetches the program having the read-out goal at the head section from a program storing section 1. At the same time, the section 2 analyzes control information from a program, accumulates the information in a stack 3, and finds a solution by executing the goal by referring to the control information. After executing the goal, the section discriminates whether or not a next goal is designated from the input section 4 and, when no designation is made, the section completes the program process. Therefore, the quantity of stacks used for executing a predicate verb to which only one solution exists or which requires only one solution can be reduced.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 この発明は、PROLOGプログラムの処理方法に関す
るものである。
DETAILED DESCRIPTION OF THE INVENTION [Field of Industrial Application] The present invention relates to a method for processing a PROLOG program.

〔従来の技術〕[Conventional technology]

第3図は従来のPROLOGプログラムの処理方法を説
明する図であり、(1)はPROLOGプログラム(以
下、単にプログラムと略証する)を格納するプログラム
格納部、(2) はプログラム格納部(1)より読み取
ったプログラムを実行する実行制御部、(3)は実行制
御部(2)で読み取りたプログラムより解釈された制御
情報を格納するスタック、(4)は実行制御部(2) 
で実行すべき述語を指定入力する入力部である。
FIG. 3 is a diagram explaining the conventional PROLOG program processing method, in which (1) is a program storage section that stores the PROLOG program (hereinafter simply referred to as a program), and (2) is a program storage section (1). (3) is a stack that stores control information interpreted from the program read by the execution control unit (2); (4) is an execution control unit that executes the program read by the execution control unit (2);
This is an input section for specifying and inputting the predicate to be executed.

次に上記構成に基づき動作について説明する。今、プロ
グラム格納部(1) には“run”。
Next, the operation will be explained based on the above configuration. Now, "run" is written in the program storage section (1).

“ l−、′b”、“、“P という述語が夫々付され
たプログラムが格納されている。これらの述語中、特定
の述語を実行しプログラム処理を行なう場合、実行制御
部(1)は人力部(4)より実行すべき述語(ゴール)
、例えば“run”を取り出し、実行制御部(4)は“
run  というゴールを頭部に持つプログラム(節)
をプログラム格納部(1)より取り出す、この時、実行
制御部(4)は取り出したプログラムより、ゴール実行
のための制御情報を解釈しスタック(3)に格納する。
Programs to which predicates "l-, 'b,"", and "P are attached are stored. When executing a specific predicate among these predicates to perform program processing, the execution control unit (1) selects the predicate (goal) to be executed from the human power unit (4).
, for example, extracts “run”, and the execution control unit (4) extracts “run”.
A program (section) with the goal run as its head
is retrieved from the program storage unit (1). At this time, the execution control unit (4) interprets control information for goal execution from the retrieved program and stores it in the stack (3).

この動作を実行制御部(4)は指定ゴールに従ってプロ
グラムを取り出す毎に行ない、各ゴール対応の制御情報
をスタック(3)に積んでいく。
The execution control unit (4) performs this operation every time it retrieves a program according to the specified goal, and stores control information corresponding to each goal on the stack (3).

以上のように制御情報を格納したスタック(3)は、制
御情報に対応するゴールの実行により解が得られない(
失敗した)時は、スタックは制御情報から解放される。
The stack (3) that stores control information as described above cannot be solved by executing the goal corresponding to the control information (
(failure), the stack is freed from control information.

しかし、同じゴールの実行により別の解を求める場合は
、スタックの内容(制御情報)を参照する必要があるた
め、スタックを制御情報から解放することができない。
However, when obtaining a different solution by executing the same goal, it is necessary to refer to the contents of the stack (control information), so the stack cannot be released from the control information.

(発明が解決しようとする課題) 従来のPROLOGプログラムは以上の方法で処理され
るので、プログラムを実行した際、解が得られないゴー
ル以外、例えば別の解が存在しないゴール、又は別の解
が必要ないゴールを実行した後であフても、スタックは
これらゴールの制御情報から解放されないため、スタッ
クの必要記憶領域はゴール実行毎に既に不要となた制御
情報に記憶領域を占められ有効にスタックを活用できな
いと云った問題点があった。
(Problems to be Solved by the Invention) Conventional PROLOG programs are processed in the manner described above, so when the program is executed, goals other than goals for which no solution can be obtained, for example, goals for which no other solution exists, or goals that have another solution Even after executing unnecessary goals, the stack is not freed from the control information of these goals, so the required storage area of the stack is occupied by unnecessary control information each time the goal is executed, and becomes effective. There was a problem that the stack could not be used.

この発明は上記のような問題点を解消するためになされ
たもので、不必要な制御情報にスタックを占められるこ
とがなく有効にスタックを活用できるPROLOGプロ
グラムの処理方法を提供する。
The present invention has been made to solve the above-mentioned problems, and provides a PROLOG program processing method that can effectively utilize the stack without unnecessary control information occupying the stack.

〔課題を解決するための手段〕[Means to solve the problem]

この発明に係るPROLOGプログラムの処理方法は、
PROLOGプログラム格納部中の各プログラムをプロ
グラム実行制御手段で実行する際にプログラムを構成す
る述語の制御情報をスタックへ読み出し、制御情報に基
づいて述語の実行を行なう時、上記プログラム格納部の
プログラムの述語に単一の解しか存在しないもの、或は
牟−の解しか必要のないものに関してはそれを明示する
述語を付し、これら述語をプログラム実行制御手段にて
実行後、スタックを上記実行後の述語の制御情報から解
放するものである。
The PROLOG program processing method according to the present invention includes:
When each program in the PROLOG program storage section is executed by the program execution control means, the control information of the predicates constituting the program is read out to the stack and the predicates are executed based on the control information. For predicates for which there is only a single solution or for which only a single solution is required, a predicate is attached to clearly indicate this, and after these predicates are executed by the program execution control means, the stack is created after the above execution. The control information of the predicate is released.

〔作 用〕[For production]

この発明によれば、PROLOGプログラム中のゴール
で単一の解しか存在しない又は単一の解しか必要のない
ものに対してそれを明示することにより、P ROLO
Gプログラムの処理の中で、そのゴールに使用した不要
なスタックを解放し、スタックの使用量を減らす様にし
たものである。
According to this invention, by specifying a goal in the PROLOG program for which there is only a single solution or for which only a single solution is required, the P ROLO
During the processing of a G program, unnecessary stacks used for the goal are released to reduce the stack usage.

〔実施例〕〔Example〕

以下、この発明の一実施例を図について説明する。第1
図において、(1)はPROLOGプログラムを格納す
る部分で、ここでは−例としてrun、a、b、c、p
という述語が格納されている。(2)は実行制御部で、
入力部(4)より実行する述語を読み出し、プログラム
格納部(1)内の述語を参照し、スタック(3)に情報
の書込み、参照を行ないながら述語の実行を打なう。(
3)はスタックで、述語の実行に必要な情報が読み書き
され、−例として、runという述語の中のpという述
語の実行が開始された直後の状態を示している。(4)
は入力部で、実行すべき述語の読込みを行なう。
An embodiment of the present invention will be described below with reference to the drawings. 1st
In the figure, (1) is the part that stores the PROLOG program, and here - for example, run, a, b, c, p
The predicate is stored. (2) is the execution control section,
A predicate to be executed is read from the input section (4), the predicate in the program storage section (1) is referred to, and information is written and referenced in the stack (3) while executing the predicate. (
3) is a stack in which information necessary for the execution of a predicate is read and written; - For example, it shows the state immediately after execution of a predicate p in a predicate run has started. (4)
is the input section and reads the predicate to be executed.

次に上記構成に基づき本実施例の動作を第2図のフロー
チャートを参照して説明する。
Next, the operation of this embodiment based on the above configuration will be explained with reference to the flowchart of FIG.

先ず、実行制御部(2) は入力部(4)より実行すべ
き述語(ゴール)を読み出す(S−1)。次に読み出し
たゴールが“5CUT”すなわちゴール実行後、スタッ
クに記憶した制御情報を解除することを意味するゴール
か否かを判定する(S−2)   ここでゴールが”5
CUT”でなければ、従来のプログラム処理方法同様、
読み出したゴールを頭部に有するプログラムをプログラ
ム格納部(1)より取り出す(S−3)。この時、プロ
グラムより制御情報を解釈してスタック(3)に積む(
S−4)   この制御情報を参照してゴールを実行し
解を求める(S−5)。
First, the execution control unit (2) reads out a predicate (goal) to be executed from the input unit (4) (S-1). Next, it is determined whether the read goal is "5CUT", which means to release the control information stored in the stack after the goal is executed (S-2).
CUT", the same as the conventional program processing method,
The program having the read goal in its head is taken out from the program storage section (1) (S-3). At this time, the program interprets the control information and places it on the stack (3) (
S-4) Refer to this control information to execute the goal and find a solution (S-5).

ゴール実行後入力部(4)より次のゴールが指定されて
いるか否かを判定し、指定されていれば(S−2)へ戻
り次のゴールを読込み、指定されていなければプログラ
ム処理を終了する(S−6)或は、(S−2)でゴール
が5CUT”であると判定されたならば、“5CUT”
の述語の引数をゴールとして実行する(S−7) 、次
に、この引数をゴールとするプログラムをプログラム格
納部(1)より取り出しく5−a) 、スタック(3)
 にゴールの制御情報を積む(S−9) 、この時スタ
ックの状態を記憶しておく (S−10)、ゴールを実
行したならば、このゴールに関する制御情報を解除して
制御情報記憶前のスタック状態に戻し、ゴールの実行結
果を格納し直す(S−11)、 (S−12)。その次
のゴールが入力部(4) によって指定されているか否
か判定する(S−6)  これによりゴール実行不要と
なった制御情報はスタック(3)から解除される。
After executing the goal, it is determined from the input section (4) whether or not the next goal has been specified, and if it has been specified, the process returns to (S-2) and the next goal is read, and if it has not been specified, the program processing ends. (S-6) Or, if it is determined that the goal is "5CUT" in (S-2), "5CUT"
Execute the predicate argument with the goal as the goal (S-7). Next, extract the program with this argument as the goal from the program storage section (1). 5-a) , Stack (3)
The control information for the goal is stacked in (S-9), the state of the stack is memorized at this time (S-10), and once the goal is executed, the control information related to this goal is released and the state before the control information is stored is stored. It returns to the stack state and stores the goal execution results again (S-11), (S-12). It is determined whether the next goal has been designated by the input section (4) (S-6). As a result, the control information that is no longer required to execute the goal is released from the stack (3).

なお、上記実施例では、スタックの節約を行なう述語の
名前として、5CUTという名前を用いたが、他の名前
でも良い。また、スタックについても、格納する情報に
よって複数のスタックを使用しても良い。
In the above embodiment, the name 5CUT is used as the name of the predicate that saves the stack, but other names may be used. Further, regarding the stack, a plurality of stacks may be used depending on the information to be stored.

〔発明の効果〕〔Effect of the invention〕

以上のように、この発明では、スタックの節約を行なう
述語を導入することにより、複数の解が存在しない、あ
るいは一つの解のみ必要とされる述語を実行する場合に
使用するスタックの量を節約できる効た果がある。
As described above, in this invention, by introducing a predicate that saves stack space, the amount of stack used is saved when executing a predicate where multiple solutions do not exist or only one solution is required. There is an effect that can be achieved.

【図面の簡単な説明】[Brief explanation of the drawing]

第1図はこの発明の一実施例によるPROLOGプログ
ラムにおけるスタックの使用量を減らす処理方法を説明
する構成図、第2図は、この発明の制御動作を示すフロ
ーチャート、第3図は従来のP ROLOGプログラム
における処理方法を説明する構成図である。 (1) ハブログラム格納部、(2)はPROLOGプ
ログラムの実行制御部、(3)はPROLOGプログラ
ム実行時の制御情報を格納するスタック、(4) は実
行すべき述語を読み込む入力部。 なお、図中同一符号は同一、又は相当部分を示す。
FIG. 1 is a block diagram illustrating a processing method for reducing the amount of stack used in a PROLOG program according to an embodiment of the present invention, FIG. 2 is a flowchart showing the control operation of the present invention, and FIG. It is a block diagram explaining the processing method in a program. (1) Hub program storage section, (2) an execution control section for the PROLOG program, (3) a stack that stores control information during execution of the PROLOG program, and (4) an input section that reads predicates to be executed. Note that the same reference numerals in the figures indicate the same or equivalent parts.

Claims (1)

【特許請求の範囲】[Claims] PROLOGプログラム格納部中の各プログラムをプロ
グラム実行制御手段で実行する際、プログラムを構成す
る述語の制御情報をスタックへ読み出し、制御情報に基
づいて述語の実行を行ないPROLOGプログラムを処
理するものにおいて、上記プログラム格納部のプログラ
ムの述語に単一の解しか存在しないもの、或は単一の解
しか必要のないものに関してはそれを明示する述語を付
し、これら述語をプログラム実行制御手段にて実行後、
スタックを上記実行後の述語の制御情報から解放するこ
とを特徴とするPROLOGプログラムの処理方法。
When each program in the PROLOG program storage unit is executed by the program execution control means, the control information of the predicates constituting the program is read to the stack, and the predicates are executed based on the control information to process the PROLOG program. If there is only a single solution to the predicates of the program in the program storage section, or if only a single solution is required, a predicate that clearly indicates this is attached, and after these predicates are executed by the program execution control means. ,
A method for processing a PROLOG program, characterized in that a stack is released from control information of the predicate after execution.
JP26533888A 1988-10-21 1988-10-21 Method for processing prolog program Pending JPH02112026A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP26533888A JPH02112026A (en) 1988-10-21 1988-10-21 Method for processing prolog program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP26533888A JPH02112026A (en) 1988-10-21 1988-10-21 Method for processing prolog program

Publications (1)

Publication Number Publication Date
JPH02112026A true JPH02112026A (en) 1990-04-24

Family

ID=17415799

Family Applications (1)

Application Number Title Priority Date Filing Date
JP26533888A Pending JPH02112026A (en) 1988-10-21 1988-10-21 Method for processing prolog program

Country Status (1)

Country Link
JP (1) JPH02112026A (en)

Similar Documents

Publication Publication Date Title
JPS63501454A (en) data processor controller
JPH02112026A (en) Method for processing prolog program
JPS5851327A (en) Input and output control system
JP2551075B2 (en) Overlay structure program execution method
US20020129229A1 (en) Microinstruction sequencer stack
JPS60181837A (en) Processing system for execution instruction
JPH05250150A (en) Sequence controller
JPH083792B2 (en) Function call processing method
JPS595370A (en) Processing time controlling system
JPS63296140A (en) Interruption control system
JPS6116334A (en) Data processor
JPS6314260A (en) System for generating communication control program
JPH02113363A (en) Time slice controlling system for multiprocessor system
JPH02151956A (en) Command procedure starting system
JPH01201728A (en) Program correcting system
JPH05181671A (en) Emulation system for software instruction
JPH09325892A (en) Job parallel execution control method
JPH04316133A (en) System for processing program interpreter
JPH1124939A (en) Program conversion method
JPS6266357A (en) File controller
JPH04128936A (en) Program execution environment changeover system
GB2173614A (en) Calculating processing method
JPH01288931A (en) Pl/i program debugging system
JPH0776926B2 (en) Loop control processing method
JPH0477840A (en) Collection system for fault analysis system