WO2021161428A1 - プログラム生成装置、プログラム生成方法及びプログラム - Google Patents

プログラム生成装置、プログラム生成方法及びプログラム Download PDF

Info

Publication number
WO2021161428A1
WO2021161428A1 PCT/JP2020/005388 JP2020005388W WO2021161428A1 WO 2021161428 A1 WO2021161428 A1 WO 2021161428A1 JP 2020005388 W JP2020005388 W JP 2020005388W WO 2021161428 A1 WO2021161428 A1 WO 2021161428A1
Authority
WO
WIPO (PCT)
Prior art keywords
program
input
specifications
natural language
generated
Prior art date
Application number
PCT/JP2020/005388
Other languages
English (en)
French (fr)
Inventor
利行 倉林
弘之 切貫
優 吉村
Original Assignee
日本電信電話株式会社
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 日本電信電話株式会社 filed Critical 日本電信電話株式会社
Priority to US17/798,550 priority Critical patent/US20230342117A1/en
Priority to PCT/JP2020/005388 priority patent/WO2021161428A1/ja
Priority to JP2021577770A priority patent/JP7375835B2/ja
Publication of WO2021161428A1 publication Critical patent/WO2021161428A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/907Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/12Computing arrangements based on biological models using genetic models

Definitions

  • the present invention relates to a program generator, a program generation method, and a program.
  • Non-Patent Document 1 discloses a technique that enables an automatic generation of a program from a natural language by learning the relationship between the natural language and the corresponding program using a machine translation model.
  • Non-Patent Document 2 discloses a technique for automatically synthesizing an Excel (registered trademark) function that satisfies a given input / output example.
  • the input / output example is only an example of the specifications that the program satisfies, and has the drawback that the amount of information is small. Therefore, a program that is overfitted to the input / output example may be generated.
  • the present invention has been made in view of the above points, and an object of the present invention is to increase the possibility that a desired program is automatically generated.
  • the program generator describes the specifications of the program to be generated from the set of associations between the natural language in which the program specifications are described and the program satisfying the syntax of the programming language.
  • a search unit that searches for a first program that corresponds to a specification written in a natural language similar to natural language, and a second that modifies the first program to satisfy one or more sets of input values and output values. It has a modification part that generates the program of.
  • FIG. 1 is a diagram showing a hardware configuration example of the program generation device 10 according to the embodiment of the present invention.
  • the program generation device 10 of FIG. 1 includes a drive device 100, an auxiliary storage device 102, a memory device 103, a CPU 104, an interface device 105, a display device 106, an input device 107, and the like, which are connected to each other by a bus B, respectively.
  • the program that realizes the processing in the program generation device 10 is provided by a recording medium 101 such as a CD-ROM.
  • a recording medium 101 such as a CD-ROM.
  • the program is installed in the auxiliary storage device 102 from the recording medium 101 via the drive device 100.
  • the program does not necessarily have to be installed from the recording medium 101, and may be downloaded from another computer via the network.
  • the auxiliary storage device 102 stores the installed program and also stores necessary files, data, and the like.
  • the memory device 103 reads and stores the program from the auxiliary storage device 102 when the program is instructed to start.
  • the CPU 104 realizes the function related to the program generation device 10 according to the program stored in the memory device 103.
  • the interface device 105 is used as an interface for connecting to a network.
  • the display device 106 displays a programmatic GUI (Graphical User Interface) or the like.
  • the input device 107 is composed of a keyboard, a mouse, and the like, and is used for inputting various operation instructions.
  • FIG. 2 is a diagram showing a functional configuration example of the program generation device 10 according to the embodiment of the present invention.
  • the program generation device 10 includes a similar code search unit 11, a program synthesis unit 12, a synthesis program execution unit 13, and an input / output result determination unit 14. Each of these parts is realized by a process of causing the CPU 104 to execute one or more programs installed in the program generation device 10.
  • the program generation device 10 has a search data set 15.
  • the search data set 15 is a table consisting of a program (source code) that is syntactically correct (that is, that satisfies the syntax of the programming language) and the specifications of the program written in natural language. It is a set of search data to be performed.
  • the search data set 15 is stored in, for example, the auxiliary storage device 102.
  • FIG. 3 is a flowchart for explaining an example of a processing procedure executed by the program generation device 10.
  • the similar code search unit 11 executes the similar code search process (S10).
  • S10 similar code search process
  • specifications described in natural language are input for the program to be generated (hereinafter referred to as "target program"), and the source code of the program having specifications similar to this specification (hereinafter referred to as “similar code”). ") Is searched from the search data set 15.
  • This similar code is the source code that is the base (original) when the target program is automatically generated.
  • the program synthesis unit 12, the synthesis program execution unit 13, and the input / output result determination unit 14 execute the program synthesis process (S20).
  • the program synthesis process one of the similar codes is generated based on the similar code searched in the similar code search process until a program satisfying the input / output example (one or more input value and output value sets) generated in advance is generated.
  • the target program that satisfies the specification is automatically generated.
  • the possibility that a program conforming to the specifications is generated is increased by using two pieces of information, the specifications of the target program written in natural language and the input / output example.
  • FIG. 4 is a flowchart for explaining an example of the processing procedure of the similar code search process.
  • the similar code search unit 11 includes specifications described in natural language for the target program (hereinafter referred to as “target specifications”) and specifications included in each search data constituting the search data set 15. Calculate the similarity of each.
  • FIG. 5 is a diagram showing an example of the search data set 15.
  • one table in the search data set 15 corresponds to one search data.
  • the data structure of the search data set 15 is described below in a format based on the BNF (Backus-Naur form) notation.
  • ⁇ Data set for search> :: [Specification source code] + That is, the search data set 15 is a set of search data including specifications described in natural language (hereinafter, referred to as “search specifications”) and program source code. However, as described above, the source code of the program shall satisfy the syntax of the programming language.
  • search specifications described in natural language
  • program source code the source code of the program shall satisfy the syntax of the programming language.
  • Such a search data set 15 is prepared in advance.
  • Any method may be used as a method for calculating the degree of similarity between the target specifications and each search specification. For example, after vectorizing the target specification and the search specification with TF-IDF, the cosine similarity between the vector corresponding to the target specification and the vector corresponding to the search specification is determined by the target specification and the search specification. It may be calculated as the degree of similarity of.
  • the similar code search unit 11 acquires the source code corresponding to the search specification having the highest degree of similarity as the similar code from the search data set 15 (S102). That is, the similar code search unit 11 identifies the search data including the search specifications having the highest degree of similarity, and then acquires the source code included in the search data as the similar code from the search data set 15. .. As a result, among the source codes included in the search data set 15, the source code having the specifications most similar to the specifications of the target program can be obtained as the similar code.
  • FIG. 6 is a flowchart for explaining an example of the processing procedure of the program synthesis process.
  • Step S201 the program synthesis unit 12 uses a similar code as a synthesis code.
  • Step S201 is merely a name change.
  • the loop process L1 including steps S202 and S203 is executed for each composite code.
  • the synthetic code to be processed in the loop processing L1 is referred to as a “target code”.
  • the composite code when the loop process L1 is first executed is one similar code.
  • step S202 the synthesis program execution unit 13 generates an execution-type program (hereinafter referred to as "synthesis program") by compiling and linking the target code.
  • synthesis program an execution-type program
  • the synthesis program execution unit 13 inputs the input value of each input / output example included in the input / output example set prepared in advance to the synthesis program (hereinafter, referred to as “target synthesis program”).
  • the target synthesis program is executed, and an output value is obtained for each input / output example (S203).
  • the input / output example set is information indicating conditions that the target program should satisfy regarding input / output, and is, for example, preset and stored in the auxiliary storage device 102.
  • FIG. 7 is a diagram showing an example of an input / output example set.
  • the data structure of the input / output example set shown in FIG. 7 is described below in a format based on the BNF notation.
  • One input / output example is a set of an input example and an output example.
  • An input example means an input value of 1 or more
  • an output example means an output value of 1 or more.
  • the synthesis program execution unit 13 executes the target synthesis program with the input values as inputs for each of the M input values in step S203. Obtain M output values.
  • the input / output result determination unit 14 determines whether or not there is a synthesis program in which all the output values match the output example of the input / output example to which the input value corresponding to the output value belongs (S204). .. That is, among the synthesis programs targeted for processing in the loop processing L1, it is determined whether or not there is a synthesis program in which all the output values obtained in step S203 were as expected (correct).
  • step S204 is executed first, in the loop processing L1, only one synthesis program generated based on the similar code is processed. Therefore, in this case, in step S204, a determination is made regarding the input / output result of the synthesis program.
  • the program synthesis unit 12 executes the synthesis code change process (S205).
  • the synthetic code change process a part of the original synthetic code is changed to generate a plurality (N) synthetic codes.
  • N is the number of individuals (source code) in one generation of the genetic algorithm.
  • each synthetic code to which the genetic algorithm is applied is represented by, for example, a tree structure in which the operator is the parent node and the variable, constant, or operator that is the operation target by the operator is the child node. And the subtrees of the tree structure are subject to genetic manipulation.
  • the pass rate of the output value (the rate at which the output value was correct) may be used for the evaluation for selection of the target individual in N times of genetic manipulation.
  • a program component included in the program component list stored in the auxiliary storage device 102 in advance is used as a candidate to replace a part of the synthetic code of the previous generation in the mutation.
  • FIG. 8 is a diagram showing an example of a program component list.
  • the data structure of the program parts list shown in FIG. 8 is described below in a format based on the BNF notation.
  • ⁇ Program parts list> :: Program parts + That is, the program parts list includes (source code) one or more program parts.
  • program components are classified into constants and methods.
  • one constant corresponds to one program component
  • one method corresponds to one program component. That is, the unit surrounded by the broken line in FIG. 8 corresponds to the unit of one program component.
  • step S205 the previous generation individual (synthetic code) is one of the similar codes. Therefore, in this case, by copying the similar code, the same N synthetic codes may be generated, and the N synthetic codes may be genetically manipulated N times. As a result, N new synthesis programs are generated.
  • FIG. 9 is a diagram showing an example of the synthetic code generated by the change process of the synthetic code. As shown in FIG. 9, N synthetic codes are generated by one synthetic process.
  • An existing library such as DEAP (https://deap.readthedocs.io/en/master/) may be used for the synthesis processing of the program using the genetic algorithm.
  • loop processing L1 and subsequent steps are executed for N synthetic codes. Therefore, in this case, steps S202 and S203 are executed N times.
  • the input / output result determination unit 14 outputs the source code (synthesis code) of the synthesis program (S206). That is, it is determined that the synthesis program is the target program. If there are a plurality of synthesis programs for the condition of step S204, the source code of each synthesis program may be output.
  • the second synthetic code from the left in FIG. 9 is output as the target program (source code). NS.
  • a program expected to satisfy the specifications is automatically executed by using two pieces of information, a program specification (character string) written in natural language and an input / output example. Will be generated. That is, from the search data set 15 that includes the syntactically correct source code and its specifications, the source of the specifications written in a natural language similar to the natural language that describes the program specifications (creator's intention). After searching the code, the modification (change) of the program is repeated until a program satisfying all the input / output examples is generated based on the searched source code.
  • a desired program that is, a program that is syntactically correct and satisfies a desired input / output example
  • the similar code is an example of the first program.
  • the similar code search unit 11 is an example of a search unit.
  • the program synthesis unit 12 is an example of a change unit.
  • the target program is an example of the second program.
  • Program generation device 11 Similar code search unit 12
  • Program synthesis unit 13 Synthesis program execution unit 14
  • Input / output result determination unit 15 Search data set 100 Drive device 101 Recording medium 102 Auxiliary storage device 103 Memory device 104
  • CPU 105 Interface device 106 Display device 107 Input device B Bus

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Biophysics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Databases & Information Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Genetics & Genomics (AREA)
  • Biomedical Technology (AREA)
  • Library & Information Science (AREA)
  • Artificial Intelligence (AREA)
  • Stored Programmes (AREA)

Abstract

プログラム生成装置は、プログラムの仕様を記述した自然言語と、プログラミング言語の構文を満たす前記プログラムとの対応付けの集合の中から、生成対象のプログラムの仕様を記述した自然言語と類似する自然言語で記述された仕様に対応する第1のプログラムを検索する検索部と、前記第1のプログラムを変更して、1以上の入力値及び出力値の組を満たす第2のプログラムを生成する変更部と、を有することで、所望のプログラムが自動生成される可能性を高める。

Description

プログラム生成装置、プログラム生成方法及びプログラム
 本発明は、プログラム生成装置、プログラム生成方法及びプログラムに関する。
 近年、社会全体のIT化が進む一方で、IT人材の不足が大きな問題となっている。経済産業省の試算によると、2025年には約36万人のIT人材が不足すると予測されている。特に専門的な知識を必要とする実装工程におけるIT人材の不足は喫緊の課題であり、自動でプログラミングを行う自動プログラミング技術の研究開発が求められている。
 従来、自動プログラミング技術として、自然言語を用いた自動プログラミングや入出力例を用いた自動プログラミング等が知られている。
 自然言語を用いた自動プログラミングでは、ユーザが自然言語によって記述した仕様からプログラムを自動生成する。例えば、非特許文献1には、自然言語と対応するプログラムの関係を機械翻訳モデルを使用して学習することで、自然言語からプログラムを自動生成することを可能とする技術が開示されている。
 入出力例を用いた自動プログラミングでは、ユーザがプログラムの具体的な入出力例を1つ以上与え、その入出力例を満たすようにプログラムの部品を合成する。例えば、非特許文献2には、与えられた入出力例を満たすExcel(登録商標)関数を自動合成する技術が開示されている。
札場 寛之, 小田 悠介, Graham Neubig, 吉野 幸一郎, 中村 哲, "統計的機械翻訳を用いた自然言語からのソースコード生成" 言語処理学会 第22回年次大会 発表論文集 (2016年3月)、[online]、インターネット<URL:https://ahcweb01.naist.jp/papers/conference/2015/201603_NLP_Fudaba_1/201603_NLP_Fudaba_1.paper.pdf> Sumit Gulwani、"Automating String Processing in Spreadsheets Using Input-Output Examples" POPL '11 Proceedings of the 38th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages Pages 317-330、[online]、インターネット<URL:https://dl.acm.org/citation.cfm?id=1926423>
 しかしながら、自然言語というあいまいな情報から正しいプログラムを生成することは難しく、プログラミング言語の構文を満たさないようなプログラムが生成されてしまうことがある。
 また、入出力例はそのプログラムが満たす仕様の一例にすぎず、情報量が少ないといった欠点がある。そのため、入出力例にオーバーフィッティングしたプログラムが生成されてしまうことがある。
 本発明は、上記の点に鑑みてなされたものであって、所望のプログラムが自動生成される可能性を高めることを目的とする。
 そこで上記課題を解決するため、プログラム生成装置は、プログラムの仕様を記述した自然言語と、プログラミング言語の構文を満たす前記プログラムとの対応付けの集合の中から、生成対象のプログラムの仕様を記述した自然言語と類似する自然言語で記述された仕様に対応する第1のプログラムを検索する検索部と、前記第1のプログラムを変更して、1以上の入力値及び出力値の組を満たす第2のプログラムを生成する変更部と、を有する。
 所望のプログラムが自動生成される可能性を高めることができる。
本発明の実施の形態におけるプログラム生成装置10のハードウェア構成例を示す図である。 本発明の実施の形態におけるプログラム生成装置10の機能構成例を示す図である。 プログラム生成装置10が実行する処理手順の一例を説明するためのフローチャートである。 類似コード検索処理の処理手順の一例を説明するためのフローチャートである。 検索用データセット15の一例を示す図である。 プログラム合成処理の処理手順の一例を説明するためのフローチャートである。 入出力例セットの一例を示す図である。 プログラム部品リストの一例を示す図である。 合成コードの変更処理によって生成される合成コードの一例を示す図である。
 以下、図面に基づいて本発明の実施の形態を説明する。図1は、本発明の実施の形態におけるプログラム生成装置10のハードウェア構成例を示す図である。図1のプログラム生成装置10は、それぞれバスBで相互に接続されているドライブ装置100、補助記憶装置102、メモリ装置103、CPU104、インタフェース装置105、表示装置106、及び入力装置107等を有する。
 プログラム生成装置10での処理を実現するプログラムは、CD-ROM等の記録媒体101によって提供される。プログラムを記憶した記録媒体101がドライブ装置100にセットされると、プログラムが記録媒体101からドライブ装置100を介して補助記憶装置102にインストールされる。但し、プログラムのインストールは必ずしも記録媒体101より行う必要はなく、ネットワークを介して他のコンピュータよりダウンロードするようにしてもよい。補助記憶装置102は、インストールされたプログラムを格納すると共に、必要なファイルやデータ等を格納する。
 メモリ装置103は、プログラムの起動指示があった場合に、補助記憶装置102からプログラムを読み出して格納する。CPU104は、メモリ装置103に格納されたプログラムに従ってプログラム生成装置10に係る機能を実現する。インタフェース装置105は、ネットワークに接続するためのインタフェースとして用いられる。表示装置106はプログラムによるGUI(Graphical User Interface)等を表示する。入力装置107はキーボード及びマウス等で構成され、様々な操作指示を入力させるために用いられる。
 図2は、本発明の実施の形態におけるプログラム生成装置10の機能構成例を示す図である。図2において、プログラム生成装置10は、類似コード検索部11、プログラム合成部12、合成プログラム実行部13及び入出力結果判定部14を有する。これら各部は、プログラム生成装置10にインストールされた1以上のプログラムが、CPU104に実行させる処理により実現される。
 また、プログラム生成装置10は、検索用データセット15を有する。検索用データセット15とは、後述するように、構文的に正しい(つまり、プログラミング言語の構文を満たす)プログラム(のソースコード)と、自然言語で記述されたそのプログラムの仕様との組で表される検索用データの集合である。検索用データセット15は、例えば、補助記憶装置102に記憶されている。
 以下、プログラム生成装置10が実行する処理手順について説明する。図3は、プログラム生成装置10が実行する処理手順の一例を説明するためのフローチャートである。
 まず、類似コード検索部11は、類似コード検索処理を実行する(S10)。類似コード検索処理では、生成対象のプログラム(以下、「対象プログラム」という。)について自然言語によって記述された仕様が入力されて、この仕様に類似する仕様のプログラムのソースコード(以下、「類似コード」という。)が検索用データセット15から検索される。この類似コードは、対象プログラムを自動生成する際にベースとなる(元となる)ソースコードである。
 続いて、プログラム合成部12、合成プログラム実行部13及び入出力結果判定部14は、プログラム合成処理を実行する(S20)。プログラム合成処理では、類似コード検索処理において検索された類似コードをベースとして、予め生成された入出力例(1以上の入力値及び出力値の組)を満たすプログラムが生成されるまで類似コードの一部の変更が繰り返される(類似コードが一部ずつ累積的に変更される)ことで、仕様(作成者の意図)を満たすような対象プログラムが自動生成される。
 すなわち、本実施の形態では、自然言語で記述された対象プログラムの仕様と入出力例という2つの情報を用いることで、仕様に沿ったプログラムが生成される可能性が高められる。
 続いて、図3のステップS10の詳細について説明する。図4は、類似コード検索処理の処理手順の一例を説明するためのフローチャートである。
 ステップS101において、類似コード検索部11は、対象プログラムについて自然言語によって記述された仕様(以下、「対象仕様」という。)と、検索用データセット15を構成する各検索用データに含まれる仕様との類似度をそれぞれ算出する。
 図5は、検索用データセット15の一例を示す図である。図5において、検索用データセット15内の1つの表が1つの検索用データに対応する。検索用データセット15のデータ構造をBNF(Backus-Naur form)記法に基づく形式によって記すと以下の通りである。
<検索用データセット>::=[仕様 ソースコード]+
 すなわち、検索用データセット15は、自然言語で記述された仕様(以下、「検索用仕様」という。)とプログラムのソースコードとが含まれる検索用データの集合である。但し、上述したように、プログラムのソースコードは、プログラミング言語の構文を満たすものとする。このような検索用データセット15は予め用意される。
 なお、対象仕様と各検索用仕様との類似度を算出する方法としては任意の手法を用いればよい。例えば、対象仕様と検索用仕様とをTF-IDFでそれぞれベクトル化した上で、対象仕様に対応するベクトルと検索用仕様に対応するベクトルとのコサイン類似度を、対象仕様と当該検索用仕様との類似度として算出すればよい。
 続いて、類似コード検索部11は、最も類似度の高い検索用仕様に対応するソースコードを類似コードとして検索用データセット15から取得する(S102)。すなわち、類似コード検索部11は、最も類似度の高い検索用仕様が含まれる検索用データを特定した上で、この検索用データに含まれるソースコードを類似コードとして検索用データセット15から取得する。これにより、検索用データセット15に含まれるソースコードのうち、対象プログラムの仕様と最も類似する仕様のソースコードが類似コードとして得られる。
 続いて、図3のステップS20の詳細について説明する。図6は、プログラム合成処理の処理手順の一例を説明するためのフローチャートである。
 S201において、プログラム合成部12は、類似コードを合成コードとする。ステップS201は、単に、呼称の変更に過ぎない。
 続いて、合成コードごとにステップS202及びS203を含むループ処理L1が実行される。以下、ループ処理L1において処理対象とされている合成コードを「対象コード」という。但し、最初にループ処理L1が実行される際の合成コードは1つの類似コードである。
 ステップS202において、合成プログラム実行部13は、対象コードをコンパイル及びリンク等することで、実行形式のプログラム(以下、「合成プログラム」という。)を生成する。
 続いて、合成プログラム実行部13は、当該合成プログラム(以下、「対象合成プログラム」という。)に対し、予め用意されている入出力例セットに含まれる各入出力例の入力値を入力して対象合成プログラムを実行し、入出力例ごとに出力値を得る(S203)。入出力例セットは、入出力に関して対象プログラムが満たすべき条件を示す情報であり、例えば、予め設定されて補助記憶装置102に記憶されている。
 図7は、入出力例セットの一例を示す図である。図7に示される入出力例セットのデータ構造をBNF記法に基づく形式によって記すと以下の通りである。
<入出力例セット>::=<入出力例>+
<入出力例>::=<入力例><出力例>
<入力例>::=入力値+
<出力例>::=出力値+
 すなわち、入出力例セットは1以上の入出力例を含む。1つの入出力例は入力例及び出力例の組である。入力例とは1以上の入力値をいい、出力例とは1以上の出力値をいう。
 例えば、入出力例セットに含まれる入出力例がM個である場合、合成プログラム実行部13は、ステップS203において、M個の入力値ごとに当該入力値を入力として対象合成プログラムを実行し、M個の出力値を得る。
 ループ処理L1が終了すると、入出力結果判定部14は、全ての出力値が、当該出力値に対応する入力値が属する入出力例の出力例に一致する合成プログラムの有無を判定する(S204)。すなわち、ループ処理L1において処理対象とされた合成プログラムの中で、ステップS203において得られた全ての出力値が期待通りであった(正しかった)合成プログラムの有無が判定される。なお、最初にステップS204が実行される場合、ループ処理L1では類似コードに基づいて生成された1つの合成プログラムのみが処理対象とされる。したがって、この場合、ステップS204では、当該合成プログラムの入出力の結果について判定が行われる。
 該当する合成プログラムが無い場合(S204でNo)、プログラム合成部12は、合成コードの変更処理を実行する(S205)。合成コードの変更処理では、元の合成コードの一部を変更して、複数(N個)の合成コードが生成される。合成コードの一部の変更には、例えば、遺伝的アルゴリズムが用いられてもよい。すなわち、前世代の合成コードに対してN回の遺伝的操作が行われて、N個の次世代の合成コードが生成されてもよい。ここで、Nは、遺伝的アルゴリズムの一世代における個体(ソースコード)の個数である。この際、遺伝的アルゴリズムの適用対象とされる各合成コードは、例えば、演算子を親ノードとし、当該演算子による演算対象である変数、定数、又は演算子を子ノードとする木構造によって表現され、木構造の部分木が遺伝的操作の対象とされる。N回の遺伝的操作において対象とされる個体の選択のための評価には、出力値の合格率(出力値が正解だった割合)が用いられてもよい。
 また、突然変異において前世代の合成コードの一部に置き換わる候補として、例えば、予め補助記憶装置102に記憶されているプログラム部品リストに含まれるプログラム部品が用いられる。
 図8は、プログラム部品リストの一例を示す図である。図8に示されるプログラム部品リストのデータ構造をBNF記法に基づく形式によって記すと以下の通りである。
<プログラム部品リスト>::=プログラム部品+
 すなわち、プログラム部品リストは、1以上のプログラム部品(のソースコード)を含む。図8では、定数とメソッドとにプログラム部品が分類されている。ここで、1つの定数が1つのプログラム部品に相当し、1つのメソッドが1つのプログラム部品に相当する。すなわち、図8において破線で囲まれた単位が、1つのプログラム部品の単位に相当する。
 なお、最初にステップS205が実行される場合、前世代の個体(合成コード)は類似コードの1つである。したがって、この場合、当該類似コードをコピーすることで、同一のN個の合成コードが生成され、当該N個の合成コードに対して、N回の遺伝的操作が行われればよい。その結果、N個の新たな合成プログラムが生成される。
 図9は、合成コードの変更処理によって生成される合成コードの一例を示す図である。図9に示されるように、1回の合成処理によってN個の合成コードが生成される。
 なお、遺伝的アルゴリズムを用いたプログラムの合成処理には、DEAP(https://deap.readthedocs.io/en/master/)等、既存のライブラリを用いられてもよい。
 続いて、N個の合成コードについてループ処理L1以降が実行される。したがって、この場合、ステップS202及びS203はN回実行される。
 一方、ステップS204の条件を満たす合成プログラムが有る場合(S204でYes)、入出力結果判定部14は、当該合成プログラムのソースコード(合成コード)を出力する(S206)。すなわち、当該合成プログラムが、対象プログラムであると判定される。なお、ステップS204の条件を合成プログラムが複数有る場合、それぞれの合成プログラムのソースコードが出力されればよい。
 例えば、図7に示される3つの入出力例が入出力例セットを構成する全ての入出力例である場合、図9において左から2番目の合成コードが対象プログラム(のソースコード)として出力される。
 上述したように、本実施の形態によれば、自然言語で記述されたプログラムの仕様(文字列)と入出力例という2つの情報を用いて、当該仕様を満たすことが期待されるプログラムが自動生成される。すなわち、構文的に正しいソースコードとその仕様とが含まれる検索用データセット15の中から、プログラムの仕様(作成者の意図)を記述した自然言語と類似する自然言語で記述された仕様のソースコードを検索した上で、検索されたソースコードに基づいて、全ての入出力例を満たすプログラムが生成されるまで、プログラムの修正(変更)が繰り返される。その結果、従来技術と比較して、所望のプログラム(つまり、構文的に正しく、かつ、所望の入出力例を満たすプログラム)が自動生成される可能性を高めることができる。
 なお、本実施の形態において、類似コードは、第1のプログラムの一例である。類似コード検索部11は、検索部の一例である。プログラム合成部12は、変更部の一例である。対象プログラムは、第2のプログラムの一例である。
 以上、本発明の実施の形態について詳述したが、本発明は斯かる特定の実施形態に限定されるものではなく、請求の範囲に記載された本発明の要旨の範囲内において、種々の変形・変更が可能である。
10     プログラム生成装置
11     類似コード検索部
12     プログラム合成部
13     合成プログラム実行部
14     入出力結果判定部
15     検索用データセット
100    ドライブ装置
101    記録媒体
102    補助記憶装置
103    メモリ装置
104    CPU
105    インタフェース装置
106    表示装置
107    入力装置
B      バス

Claims (7)

  1.  プログラムの仕様を記述した自然言語と、プログラミング言語の構文を満たす前記プログラムとの対応付けの集合の中から、生成対象のプログラムの仕様を記述した自然言語と類似する自然言語で記述された仕様に対応する第1のプログラムを検索する検索部と、
     前記第1のプログラムを変更して、1以上の入力値及び出力値の組を満たす第2のプログラムを生成する変更部と、
    を有することを特徴とするプログラム生成装置。
  2.  前記変更部は、前記第2のプログラムが生成されるまで、前記第1のプログラムの一部の変更を累積的に繰り返す、
    ことを特徴とする請求項1記載のプログラム生成装置。
  3.  前記変更部は、複数のプログラム部品を用いて前記第1のプログラムの一部を変更する、
    ことを特徴とする請求項2記載のプログラム生成装置。
  4.  プログラムの仕様を記述した自然言語と、プログラミング言語の構文を満たす前記プログラムとの対応付けの集合の中から、生成対象のプログラムの仕様を記述した自然言語と類似する自然言語で記述された仕様に対応する第1のプログラムを検索する検索手順と、
     前記第1のプログラムを変更して、1以上の入力値及び出力値の組を満たす第2のプログラムを生成する変更手順と、
    をコンピュータが実行することを特徴とするプログラム生成方法。
  5.  前記変更手順は、前記第2のプログラムが生成されるまで、前記第1のプログラムの一部の変更を累積的に繰り返す、
    ことを特徴とする請求項4記載のプログラム生成方法。
  6.  前記変更手順は、複数のプログラム部品を用いて前記第1のプログラムの一部を変更する、
    ことを特徴とする請求項5記載のプログラム生成方法。
  7.  請求項4乃至6いずれか一項記載のプログラム生成方法をコンピュータに実行させることを特徴とするプログラム。
PCT/JP2020/005388 2020-02-12 2020-02-12 プログラム生成装置、プログラム生成方法及びプログラム WO2021161428A1 (ja)

Priority Applications (3)

Application Number Priority Date Filing Date Title
US17/798,550 US20230342117A1 (en) 2020-02-12 2020-02-12 Program generation apparatus, program generation method and program
PCT/JP2020/005388 WO2021161428A1 (ja) 2020-02-12 2020-02-12 プログラム生成装置、プログラム生成方法及びプログラム
JP2021577770A JP7375835B2 (ja) 2020-02-12 2020-02-12 プログラム生成装置、プログラム生成方法及びプログラム

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2020/005388 WO2021161428A1 (ja) 2020-02-12 2020-02-12 プログラム生成装置、プログラム生成方法及びプログラム

Publications (1)

Publication Number Publication Date
WO2021161428A1 true WO2021161428A1 (ja) 2021-08-19

Family

ID=77291457

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2020/005388 WO2021161428A1 (ja) 2020-02-12 2020-02-12 プログラム生成装置、プログラム生成方法及びプログラム

Country Status (3)

Country Link
US (1) US20230342117A1 (ja)
JP (1) JP7375835B2 (ja)
WO (1) WO2021161428A1 (ja)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH08234975A (ja) * 1995-02-28 1996-09-13 Fujitsu Ltd プログラム生成装置および方法

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7412388B2 (en) * 2003-12-12 2008-08-12 International Business Machines Corporation Language-enhanced programming tools
US8504354B2 (en) * 2008-06-02 2013-08-06 Microsoft Corporation Parallel fragment extraction from noisy parallel corpora
US9606990B2 (en) * 2015-08-04 2017-03-28 International Business Machines Corporation Cognitive system with ingestion of natural language documents with embedded code
US10095691B2 (en) * 2016-03-22 2018-10-09 Wolfram Research, Inc. Method and apparatus for converting natural language to machine actions
US10732965B2 (en) * 2016-10-13 2020-08-04 Tata Consultancy Services Limited Systems and methods for dynamic generation of questionnaires on programming concepts
JP6663873B2 (ja) * 2017-02-22 2020-03-13 株式会社日立製作所 プログラム自動生成システム及びプログラム自動生成方法
US11144810B2 (en) * 2017-06-27 2021-10-12 International Business Machines Corporation Enhanced visual dialog system for intelligent tutors
US10664472B2 (en) * 2018-06-27 2020-05-26 Bitdefender IPR Management Ltd. Systems and methods for translating natural language sentences into database queries
US11669332B1 (en) * 2020-10-07 2023-06-06 Appsfreedom, Inc. Systems and methods for modernizing legacy applications

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH08234975A (ja) * 1995-02-28 1996-09-13 Fujitsu Ltd プログラム生成装置および方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
JUNNOSUKE MATSUMOTO; YOSHIKI HIGO; KENTO SHIMONAKA; SHINJI KUSUMOTO: "Automatic programming by reusing/working existing methods", PROCEEDINGS OF 2018 IPSJ/SIGSE SOFTWARE ENGINEERING SYMPOSIUM; SEPTEMBER 5 - 7, 2018, 29 August 2018 (2018-08-29) - 7 September 2018 (2018-09-07), JP, pages 54 - 63, XP009530449 *

Also Published As

Publication number Publication date
JPWO2021161428A1 (ja) 2021-08-19
JP7375835B2 (ja) 2023-11-08
US20230342117A1 (en) 2023-10-26

Similar Documents

Publication Publication Date Title
JP7351352B2 (ja) プログラム生成装置、プログラム生成方法及びプログラム
US20140156282A1 (en) Method and system for controlling target applications based upon a natural language command string
JP5005510B2 (ja) ソフトウェアの設計支援方法、設計支援装置及び設計支援プログラム
EP2510433B1 (en) Canonicalized versions of reuse candidates in graphical state diagrams
JP6663873B2 (ja) プログラム自動生成システム及びプログラム自動生成方法
WO2021161429A1 (ja) プログラム生成装置、プログラム生成方法及びプログラム
CN112379917A (zh) 浏览器兼容性提升方法、装置、设备及存储介质
Sargsyan et al. ISP-Fuzzer: Extendable fuzzing framework
Kessentini et al. Automated co-evolution of metamodels and transformation rules: A search-based approach
US6832214B1 (en) Method, system, and program for converting code to executable code using neural networks implemented in a software program
JP2020060919A (ja) システム移行支援装置、システム移行支援方法及びプログラム
US20230107200A1 (en) Program generation apparatus, program generation method and program
JP4959784B2 (ja) 生成装置、生成方法、および、生成プログラム
JP6651974B2 (ja) 情報処理装置、コンパイル方法及びコンパイラプログラム
WO2021161428A1 (ja) プログラム生成装置、プログラム生成方法及びプログラム
JP5275087B2 (ja) プログラム生成装置およびブロック線図生成装置
CN114691151A (zh) 一种基于深度学习的优化代码反编译方法和系统
JP6364332B2 (ja) 仕様生成方法、仕様生成装置、及びプログラム
WO2022230190A1 (ja) プログラム生成装置、プログラム生成方法及びプログラム
WO2022249255A1 (ja) プログラム生成装置、プログラム生成方法及びプログラム
WO2021161427A1 (ja) プログラム生成装置、プログラム生成方法及びプログラム
WO2022239179A1 (ja) プログラム生成装置、プログラム生成方法及びプログラム
US11775293B1 (en) Deploying a static code analyzer based on program synthesis from input-output examples
JP7269244B2 (ja) サービス管理アプリケーションインターフェースにおいてグローバリゼーション機能を提供するためのシステムおよび方法
WO2022249422A1 (ja) コードマッピング装置、コードマッピング方法、及びプログラム

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20918866

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2021577770

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20918866

Country of ref document: EP

Kind code of ref document: A1