JPH03263221A - Detection of recursive structure - Google Patents

Detection of recursive structure

Info

Publication number
JPH03263221A
JPH03263221A JP6530590A JP6530590A JPH03263221A JP H03263221 A JPH03263221 A JP H03263221A JP 6530590 A JP6530590 A JP 6530590A JP 6530590 A JP6530590 A JP 6530590A JP H03263221 A JPH03263221 A JP H03263221A
Authority
JP
Japan
Prior art keywords
description
structures
holding unit
directed graph
rule
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
JP6530590A
Other languages
Japanese (ja)
Inventor
Hiroyasu Kondo
浩康 近藤
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.)
NEC Corp
Original Assignee
NEC 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 NEC Corp filed Critical NEC Corp
Priority to JP6530590A priority Critical patent/JPH03263221A/en
Publication of JPH03263221A publication Critical patent/JPH03263221A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

PURPOSE:To synthesize programs with a small calculation volume by applying a rule to description between set structures to generate description of relations between divided structures and deciding the conformity between them. CONSTITUTION:A rule which is not applied to a part of a directed graph at the time when the conditional structure is the part of the directed graph is taken out of a structure dividing rule holding part 103 with respect to the directed graph held in a structure description holding part 101, and divided structure description of the rule is merged in a directed graph in a divided structure description holding part 102 to update the directed graph in the holding part 102, and the processing is repeated. When there are no parts to which the rule is applied, it is discriminated whether a part which is not checked for conformity of the directed graph in the holding part 101 exists or not by a structure conformity discriminating means 104; and when it does not exist, detection of a recursive structure is recognized to terminate the processing. Thus, the calculation volume for structure division and struction conformity is reduced, and programs are synthesized with the small calculation quantity.

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明は再帰構造検出方式、特にプログラムの合成を行
なうシステムにおいて使用される再帰構造検出方式に関
する。
DETAILED DESCRIPTION OF THE INVENTION [Field of Industrial Application] The present invention relates to a recursive structure detection method, particularly to a recursion structure detection method used in a system for synthesizing programs.

[従来の技術] 従来、プログラムの合成を行なうシステムにおいては、
プログラムの宣言的な入出力仕様からプログラムテキス
トを導き出す場合、入出力仕様を論理式で表わし、プロ
グラミングおよびプログラミング言語に関する知識を公
理として定理証明機で当該論理式を証明することにより
、再帰構造を検出していた。
[Conventional technology] Conventionally, in systems that synthesize programs,
When deriving program text from a program's declarative input/output specifications, detect recursive structures by expressing the input/output specifications as logical formulas and proving the logical formulas with a theorem prover using knowledge of programming and programming languages as axioms. Was.

[発明が解決しようとする課題] 上述した従来の再帰構造検出方式は、定理証明機を用い
た証明に多大の計算量が必要とされるため、実用となり
難いという欠点がある。
[Problems to be Solved by the Invention] The conventional recursive structure detection method described above has the disadvantage that it is difficult to put it into practical use because a large amount of calculation is required for proof using a theorem prover.

本発明の目的は、従来方式に比較して計算量が少なく、
少ない計算量でプログラムの合成を可能とする再帰構造
検出方式を提供することにある。
The purpose of the present invention is to reduce the amount of calculation compared to conventional methods.
The purpose of this invention is to provide a recursive structure detection method that enables program synthesis with a small amount of calculation.

【課題を解決するための手段1 本発明の再帰構造検出方式は、 入力された構造および構造間の関係の記述を構造記述保
持部に保持し、 前記構造および構造間の関係の記述にルールを適用して
得られた分割後の構造および構造間の記述を分割構造記
述保持部に保持し、 入力された構造および構造間の関係の記述に対して分割
後の構造および構造間の関係の記述を対応付けている前
記ルールを構造分割ルール保持部に複数個保持して、 与えられた構造および構造間の関係について2つの記述
が一致するか否かを判定する構造一致判断手段と、 前記構造分割ルール保持部に格納されたルールを用いて
、前記構造記述保持部の記述から前記分割構造記述保持
部への記述の生成と、前記構造一致判断手段を用いて前
記構造記述保持部内の記述と前記分割構造記述保持部内
の記述の一致の判定とを制御する制御手段とを有してい
る。
[Means for Solving the Problems 1] The recursive structure detection method of the present invention stores input descriptions of structures and relationships between structures in a structure description holding unit, and applies rules to the descriptions of the structures and relationships between structures. The structure after the division and the description between the structures obtained by applying the application are held in the divided structure description holding unit, and the description of the structure and the relationship between the structures after the division is applied to the input structure and the description of the relationship between the structures. structure matching determination means for storing a plurality of rules that associate each other in a structure division rule holding unit and determining whether or not two descriptions match regarding a given structure and a relationship between the structures; Generating a description from the description in the structure description holding unit to the splitting structure description holding unit using the rules stored in the splitting rule holding unit; and generating a description from the description in the structure description holding unit using the structure matching determination means. and control means for controlling determination of coincidence of descriptions in the divided structure description holding unit.

〔作   用〕[For production]

第1図は本発明の再帰構造検出方式の構成を示すブロッ
ク図である。
FIG. 1 is a block diagram showing the configuration of the recursive structure detection method of the present invention.

本発明における構造および構造間の関係の記述は、構造
をノードとし、関係をリンクとする有向グラフで表わす
ものとする。
In the present invention, structures and relationships between structures are described using a directed graph in which structures are nodes and relationships are links.

初期データとして、構造記述保持部101は構造および
構造間の関係を記述した有向グラフGを保持し、分割構
造記述保持部102は空の有向グラフG0を保持してい
る。また、構造分割ルール保持部103は構造および構
造間の関係を表わす有向グラフの複数個の順序対(G’
−0G ”、)(i=1.  ・・・、N)よりなるル
ールを格納している。但し、ルールの構成要素である有
向グラフGL、を条件構造、有向グラフG”lを分割構
造と呼ぶ。
As initial data, the structure description holding unit 101 holds a digraph G that describes structures and relationships between structures, and the divided structure description holding unit 102 holds an empty digraph G0. Further, the structure division rule holding unit 103 stores a plurality of ordered pairs (G'
-0G'', ) (i=1. . . , N). However, the digraph GL, which is a component of the rule, is called a conditional structure, and the digraph G''l is called a division structure.

条件構造の条件はルールの適用条件という意味で、条件
構造の有向グラフが構造記述保持部内の有向グラフの部
分とマツチする場合に、そのルールを適用しても良いこ
とを意味する。分割構造は、構造記述保持部内の有向グ
ラフの部分にマツチする条件構造に対応する分割構造記
述保持部内の部分有向グラフを表わしている。その意味
でルールは部分有向グラフ同士の対応関係を示している
。分割という言葉を用いているのは、条件構造の有向グ
ラフを(ある意味で)分割したものが分割構造の有向グ
ラフになっているからである。
The condition of the conditional structure means the application condition of the rule, and means that if the directed graph of the conditional structure matches the part of the directed graph in the structure description holding unit, the rule may be applied. The split structure represents a partial digraph in the split structure description holding unit that corresponds to a conditional structure that matches a portion of the directed graph in the structure description holding unit. In this sense, rules indicate the correspondence between partially directed graphs. The word "partition" is used because (in a sense) a digraph with a conditional structure is divided into a digraph with a partitioned structure.

制御手段105は以下の処理を行なう。The control means 105 performs the following processing.

(1)構造記述保持部101に保持されている有向グラ
フGに対して構造分割ルール保持部103の中から、条
件構造GL、が有向グラフGの部分となっていて当該部
分がルール未適用であるようなルール(GL3.G”、
)を取り出す。
(1) For the digraph G held in the structure description holding unit 101, it is determined from the structure division rule holding unit 103 that the conditional structure GL is a part of the digraph G and the rule is not applied to that part. rules (GL3.G”,
).

(2)分割構造記述保持部102に保持されている有向
グラフG工に有向グラフG ”mを融合した結果の有向
グラフをG ma+とし、分割構造記述保持部102を
有向グラフGk1を保持するように更新する。
(2) The digraph resulting from fusing the digraph G''m with the digraph G held in the split structure description holding unit 102 is set to Gma+, and the split structure description holding unit 102 is updated to hold the digraph Gk1.

(3)構造記述部101に保持されている有向グラフG
の中にルール未適用の部分があれば(1)の処理に戻っ
て同様の処理を繰り返し、なければ次の(4)の処理を
行なう。
(3) Directed graph G held in the structure description section 101
If there is a portion to which the rule has not been applied, the process returns to step (1) and repeats the same process; if not, the next step (4) is performed.

(4)構造一致判断手段104を用いて、構造記述保持
部101に保持されている有向グラフ全体と一致する、
分割構造記述保持部102の中の部分有向グラフを検出
する。
(4) Using the structure matching determination means 104, match the entire directed graph held in the structure description holding unit 101;
A partially directed graph in the partitioned structure description holding unit 102 is detected.

次に、本発明の作用を例を用いて説明する。Next, the operation of the present invention will be explained using an example.

いま、合成対象とするプログラムの入出力仕様が、「入
力リストFに対して、リストFの各要素を2乗した要素
を各要素とする出力リストHを生成するプログラム」で
あるとする。
Assume now that the input/output specifications of the program to be synthesized are "a program that generates, for input list F, an output list H in which each element is the square of each element of list F."

第2図(a)は入出力仕様を示す有向グラフであり、リ
スト構造を持つ入力リストF201、リスト構造を持つ
出力リストH2O2、各要素にその2乗の要素が対応し
ていることを示す関係211よりなる。また、構造分割
ルール保持部103の中には、ルール八「リストをその
第1要素と残りのリストに分割する」、ルールB「一連
の対応関係を第1の関係と残りの関係とに分割する」と
いうルールが存在している。第2図(b)は部分有向グ
ラフ(201)にルールAを、部分有向グラフ(211
)にルールBを、部分有向グラフ(202)にルールA
を、それぞれ適用した結果生成される有向グラフであり
、l要素203、リスト構造204、l要素205、リ
スト構造206.2乗関係212、および各要素にその
2乗の要素が対応していることを示す関係213よりな
る。そこで、構造一致判断手段104により、第2図(
a)の有向グラフ(201,211,202)と第2図
(b)の部分有向グラフ(204,213,206)と
の構造が一致することが検出される。
FIG. 2(a) is a directed graph showing input/output specifications, including an input list F201 with a list structure, an output list H2O2 with a list structure, and a relationship 211 showing that each element corresponds to the element of its square. It becomes more. Also, in the structure division rule holding unit 103, Rule 8 "Divide a list into its first element and the remaining list" and Rule B "Divide a series of correspondence relations into the first relation and the remaining relations." There is a rule that says "do." FIG. 2(b) shows that rule A is applied to the partially directed graph (201), and rule A is applied to the partially directed graph (211).
) and rule A for the partially directed graph (202).
It is a directed graph generated as a result of applying the above, and it is understood that the l element 203, the list structure 204, the l element 205, the list structure 206, the square relation 212, and each element corresponds to its square element. The relationship 213 shown in FIG. Therefore, the structure matching determination means 104 determines the
It is detected that the structures of the directed graph (201, 211, 202) in a) and the partially directed graph (204, 213, 206) in FIG. 2(b) match.

以上により、第2図(a)で示される入出力仕様のプロ
グラムは再帰構造を持ったものとして合成できることが
わかり、第2図(b)の部分有向グラフ(203,21
2,205)で示される入出力仕様のプログラムの合成
を行なえば全てのプログラムの合成が可能となる。
From the above, it can be seen that the program with the input/output specifications shown in Figure 2(a) can be synthesized as having a recursive structure, and the partially directed graph (203, 21
2, 205), it becomes possible to synthesize all programs.

〔実 施 例] 次に、本発明の実施例について図面を参照して説明する
[Example] Next, an example of the present invention will be described with reference to the drawings.

第3図(a)、(b)は、それぞれ本発明の再帰構造検
出方式の一実施例の構造記述保持部101および分割構
造記述保持部102の保持する有向グラフのノードとリ
ンクの表現を示す図、第4図は本実施例の構造分割ルー
ル保持部103に格納されているルールの表現を示す図
、第5図は本実施例の処理を示すフローチャートである
FIGS. 3(a) and 3(b) are diagrams showing representations of nodes and links of a directed graph held by the structure description holding unit 101 and the divided structure description holding unit 102, respectively, in an embodiment of the recursive structure detection method of the present invention. , FIG. 4 is a diagram showing the expression of the rules stored in the structure division rule holding unit 103 of this embodiment, and FIG. 5 is a flowchart showing the processing of this embodiment.

有向グラフはノードとリンクの集合で表現されており、
第3図(a)がノードのフレーム表現であり、ノードを
識別するための識別子スロットと、構造の種類を示す構
造タイプスロットからなっている。また、第3図(b)
がリンクのフレーム表現であり、識別子スロットと、関
係の種類を示す関係タイプスロットと、関係の源のノー
ドの識別子を保持する関係源ノードスロットと、関係の
先のノードの識別子を保持する関係先ノードスロットか
らなっている。有向グラフの順序対である構造分割ルー
ルは、それぞれがノードとリンクの集合である条件構造
記述と分割構造記述とを用いて第4図に示すように表現
される。構造一致判断手段104は、構造記述保持部1
01内の有向グラフが分割構造記述保持部102内の部
分有向グラフに一致するか否かを検出する。
A directed graph is represented by a set of nodes and links.
FIG. 3(a) is a frame representation of a node, which consists of an identifier slot for identifying the node and a structure type slot for indicating the type of structure. Also, Fig. 3(b)
is a frame representation of a link, with an identifier slot, a relationship type slot indicating the type of relationship, a relationship source node slot that holds the identifier of the source node of the relationship, and a relationship destination that holds the identifier of the destination node of the relationship. Consists of node slots. A structural partitioning rule, which is an ordered pair of directed graphs, is expressed as shown in FIG. 4 using a conditional structure description and a partitioning structure description, each of which is a set of nodes and links. The structure matching determination means 104 includes the structure description holding unit 1
It is detected whether the directed graph in 01 matches the partial directed graph in the partitioned structure description holding unit 102.

次に、第5図を用いて本実施例の制御手段1()5によ
る処理を説明する。
Next, the processing by the control means 1( ) 5 of this embodiment will be explained using FIG.

プログラムを開始して、構造分割ルール保持部103中
に、その条件構造記述が構造記述保持部101に格納さ
れている有向グラフのルール未適用の部分と一致するル
ールの有無を調べて(ステップ501)、そのルールが
存在するときはそれを取り出す(ステップ502)、ル
ールが存在しないときはステップ504へ進む。
The program is started, and it is checked whether there is a rule in the structure division rule holding unit 103 whose conditional structure description matches a rule-unapplied part of the directed graph stored in the structure description holding unit 101 (step 501). , if the rule exists, it is extracted (step 502); if the rule does not exist, the process advances to step 504.

ステップ502で取り出されたルールの分割構造記述を
分割構造記述保持部102内の有向グラフと融合して分
割構造記述保持部102内の有向グラフを更新しくステ
ップ503)、ステップ501へ戻って同様の処理を繰
り返す、ステップ504に進むと、構造一致判断手段1
04により構造記述保持部101内の有向グラフでまだ
一致のチエツクがされていない部分の有無を調べ、それ
がなければ再帰構造が検出されたとして処理を終る(プ
ログラムの合成可能)、有れば当該部分有向グラフを取
り出しくステップ505) 、取り出した部分に対して
、分割構造記述保持部102から一致する部分が有るか
どうかを調べる(ステップ506)、見つかればステッ
プ504へ戻って同様の処理を繰り返し、見つからなけ
れば再帰構造が検出されなかったとして処理を終了する
(プログラムの合成不可)。
The division structure description of the rule retrieved in step 502 is merged with the digraph in the division structure description holding unit 102 to update the digraph in the division structure description holding unit 102 (step 503), and the process returns to step 501 to perform the same process. Repeatedly, proceeding to step 504, the structure matching determination means 1
04, the directed graph in the structure description holding unit 101 is checked to see if there is a part that has not been checked for a match. If there is no part, it is assumed that a recursive structure has been detected and the process ends (program synthesis is possible). Step 505 for extracting a partially directed graph; Check whether there is a matching portion from the partitioned structure description holding unit 102 for the extracted portion (Step 506); if found, return to Step 504 and repeat the same process; If no recursive structure is found, processing is terminated (program synthesis is not possible).

【発明の効果1 以上説明したように本発明は、有向グラフを用いて構造
と構造間の関係の記述を表現し、設定された構造と構造
間の関係の記述にルールを適用して分割後の構造と構造
間の関係の記述な生成し、両者の一致を判定することに
より、構造分割および構造一致の計算量は定理証明機な
どを用いる方法を比べて相対的に少なく、少ない計算量
でプログラム合成を可能とする効果がある。
Effects of the Invention 1 As explained above, the present invention uses a directed graph to express the description of structures and the relationships between the structures, and applies rules to the description of the set structures and the relationships between the structures. By generating a description of the structure and the relationship between the structures and determining whether they match, the amount of calculation for structure partitioning and structure matching is relatively small compared to methods that use a theorem prover, etc., making it possible to program with less calculation. It has the effect of enabling synthesis.

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

第1図は本発明の再帰構造検出方式の構成を示すブロッ
ク図、第2図(a)、(b)はそれぞれ、入出力仕様を
示す有向グラフとこれにルールを用いて生成した有向グ
ラフを示す図、第3図(a)、(b)はそれぞれ、本実
施例における構造記述保持部101および分割構造記述
保持部102の保持する有向グラフのノードとリンクの
表現を示す図、第4図は本実施例の構造分割ルール保持
部103に格納されているルールの表現を示す図、第5
図は本実施例の処理を示すフローチャートである。 101・・・構造記述保持部、 102・・・分割構造記述保持部、 103・・・構造分割ルール保持部、 104・・・構造一致判断手段、 105・・・制御手段、 201・・・入力リストF、 202・・・出力リストH1 203,205・・・−要素、 204 206・・・リスト構造、 501〜506・・・ステップ。
Figure 1 is a block diagram showing the configuration of the recursive structure detection method of the present invention, and Figures 2 (a) and (b) are diagrams showing a directed graph showing input/output specifications and a directed graph generated using rules for this, respectively. , FIGS. 3(a) and 3(b) are diagrams showing representations of nodes and links of a directed graph held by the structure description holding unit 101 and the divided structure description holding unit 102, respectively, in this embodiment, and FIG. A fifth diagram showing the expression of rules stored in the example structure division rule holding unit 103.
The figure is a flowchart showing the processing of this embodiment. DESCRIPTION OF SYMBOLS 101... Structure description holding part, 102... Division structure description holding part, 103... Structure division rule holding part, 104... Structure matching judgment means, 105... Control means, 201... Input List F, 202...Output list H1 203, 205...-Elements, 204 206...List structure, 501-506...Steps.

Claims (1)

【特許請求の範囲】 1、プログラム合成を行うシステムにおいて、入力され
た構造および構造間の関係の記述を構造記述保持部に保
持し、 前記構造および構造間の関係の記述にルールを適用して
得られた分割後の構造および構造間の記述を分割構造記
述保持部に保持し、 入力された構造および構造間の関係の記述に対して分割
後の構造および構造間の関係の記述を対応付けている前
記ルールを構造分割ルール保持部に複数個保持して、 与えられた構造および構造間の関係について2つの記述
が一致するか否かを判定する構造一致判断手段と、 前記構造分割ルール保持部に格納されたルールを用いて
、前記構造記述保持部の記述から前記分割構造記述保持
部への記述の生成と、前記構造一致判断手段を用いて前
記構造記述保持部内の記述と前記分割構造記述保持部内
の記述の一致の判定とを制御する制御手段とよりなる再
帰構造検出方式。
[Claims] 1. In a system that performs program synthesis, a description of input structures and relationships between structures is held in a structure description holding unit, and rules are applied to the descriptions of the structures and relationships between structures. The obtained structure after division and descriptions between structures are retained in the division structure description holding unit, and the descriptions of the structures and relationships between structures after division are associated with the input descriptions of structures and relationships between structures. a structure matching determination means that stores a plurality of rules in a structure division rule holding unit and determines whether two descriptions of a given structure and the relationship between the structures match; generation of a description from the description in the structure description holding unit to the divided structure description holding unit using rules stored in the structure description holding unit; and generating a description between the description in the structure description holding unit and the split structure using the structure matching determination means A recursive structure detection method comprising a control means for determining whether a description in a description storage unit matches.
JP6530590A 1990-03-14 1990-03-14 Detection of recursive structure Pending JPH03263221A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP6530590A JPH03263221A (en) 1990-03-14 1990-03-14 Detection of recursive structure

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP6530590A JPH03263221A (en) 1990-03-14 1990-03-14 Detection of recursive structure

Publications (1)

Publication Number Publication Date
JPH03263221A true JPH03263221A (en) 1991-11-22

Family

ID=13283066

Family Applications (1)

Application Number Title Priority Date Filing Date
JP6530590A Pending JPH03263221A (en) 1990-03-14 1990-03-14 Detection of recursive structure

Country Status (1)

Country Link
JP (1) JPH03263221A (en)

Similar Documents

Publication Publication Date Title
US5490266A (en) Process oriented logic simulation having stability checking
CN107092491B (en) Configuration loading method and system
JP2534190B2 (en) How to automatically generate an implicit representation of a prime implicant of a function
US8712775B1 (en) Method and system to generate finite state grammars using sample phrases
CN113641591A (en) Test case generation method and device and test method and device
CN112860264B (en) Method and device for reconstructing abstract syntax tree
KR102161545B1 (en) Task processing method and distributed computing framework
JPH0565892B2 (en)
US5905977A (en) Method for automatic demonstration
JPH03263221A (en) Detection of recursive structure
CN113313419B (en) Method and device for acquiring window change risk of information system
CN113761746B (en) Algebraic ring identification method and device
Rönkkö Introduction to matrixpls
CN113434599A (en) Block chain account book synchronization method and device based on half nodes
CN112925564B (en) Method and device for cleaning redundant import class of source code
CN115936095B (en) Parameter gradient synchronization method, device, equipment and storage medium
JP2001051690A (en) Pattern recognition device
CN117850757A (en) Quick dynamic generation method for middle-background visual complex form
JPH01232434A (en) Virtual structure introduction system
CN114595464A (en) Intelligent contract reentry vulnerability detection method and device, storage medium and related equipment
CN115659186A (en) Virtual object matching method, virtual object matching device, and storage medium
JP2922207B2 (en) Program conversion system
CN117149770A (en) Method and device for executing storage process of database and computer equipment
JP2024058594A (en) Control method, device and storage medium based on automobile simulation model
CN115357430A (en) Node mirror image optimization method and device, electronic equipment and storage medium