Technical Field
The present invention relates generally to information processing and, in particular, to formal specification generation using examples.
Description of the Related Art
It is desirable to obtain a formal specification from requirements written in natural language using input-output examples. As an example, a person can intend to obtain a formal specification from the problem descriptions in a programming contest. It is presumed that the input-output examples are given and that we can check if the examples satisfy the specifications.
However, syntax-based translation to obtain an accurate formal specification is applicable only to very limited standardized documents. For example, the structure of natural language sentences is different from that of mathematical expressions. In general, simple relationships cannot be found between vocabularies in the documents and mathematical expressions.
Thus, there is a need for improved formal specification generation using examples.
According to an aspect of the present invention, a computer-implemented method is provided for generating a formal specification of a function. The method includes extracting a set of words from requirements of the function. The method further includes translating the set of words to a set of specification fragments. The method also includes converting the set of the specification fragments to a set of production rules. The method additionally includes constructing multiple prospective specifications from the set of production rules taking into account a syntax of the formal specification. The method further includes validating each of the multiple prospective specifications using input-output examples. The method also includes generating the formal specification of the function from validated ones of the multiple prospective specifications.
According to another aspect of the present invention, a computer program product is provided for generating a formal specification of a function. The computer program product includes a non-transitory computer readable storage medium having program instructions embodied therewith. The program instructions are executable by a computer to cause the computer to perform a method. The method includes extracting a set of words from requirements of the function. The method further includes translating the set of words to a set of specification fragments. The method also includes converting the set of the specification fragments to a set of production rules. The method additionally includes constructing multiple prospective specifications from the set of production rules taking into account a syntax of the formal specification. The method further includes validating each of the multiple prospective specifications using input-output examples. The method also includes generating the formal specification of the function from validated ones of the multiple prospective specifications.
According to yet another aspect of the present invention, a computing device is provided for generating a formal specification of a function. The computing device includes a processor and a memory operably coupled to the processor. The processor and the memory are configured to extract a set of words from requirements of the function. The processor and the memory are further configured to translate the set of words to a set of specification fragments. The processor and the memory are also configured to convert the set of the specification fragments to a set of production rules. The processor and the memory are additionally configured to construct multiple prospective specifications from the set of production rules taking into account a syntax of the formal specification. The processor and the memory are further configured to validate each of the multiple prospective specifications using input-output examples. The processor and the memory are also configured to generate the formal specification of the function from validated ones of the multiple prospective specifications.
These and other features and advantages will become apparent from the following detailed description of illustrative embodiments thereof, which is to be read in connection with the accompanying drawings.
The following description will provide details of preferred embodiments with reference to the following figures wherein:
The present invention is directed to formal specification generation using examples.
In an embodiment, the present invention uses only local context to extract potential fragments of the formal specification. Without relying on the syntax and semantics of natural language, the present invention can extract key information from a natural language description of a mathematical function, based on only word and idiomatic patterns associated with mathematical components.
In an embodiment, the present invention creates all possible combinations of the extracted specification fragments taking account of constraints on the combinations derived from the syntax of the specification language. For example, a correct specification can be chosen by validating the extracted specification fragments using input-output examples. As used herein, the term “input/output examples” refers to examples of inputs and corresponding outputs of a mathematical function for which a formal specification is generated.
A first storage device 122 and a second storage device 124 are operatively coupled to system bus 102 by the I/O adapter 120. The storage devices 122 and 124 can be any of a disk storage device (e.g., a magnetic or optical disk storage device), a solid state magnetic device, and so forth. The storage devices 122 and 124 can be the same type of storage device or different types of storage devices.
A speaker 132 is operatively coupled to system bus 102 by the sound adapter 130. A transceiver 142 is operatively coupled to system bus 102 by network adapter 140. A display device 162 is operatively coupled to system bus 102 by display adapter 160.
A first user input device 152, a second user input device 154, and a third user input device 156 are operatively coupled to system bus 102 by user interface adapter 150. The user input devices 152, 154, and 156 can be any of a keyboard, a mouse, a keypad, an image capture device, a motion sensing device, a microphone, a device incorporating the functionality of at least two of the preceding devices, and so forth. Of course, other types of input devices can also be used, while maintaining the spirit of the present invention. The user input devices 152, 154, and 156 can be the same type of user input device or different types of user input devices. The user input devices 152, 154, and 156 are used to input and output information to and from system 100.
Of course, the processing system 100 may also include other elements (not shown), as readily contemplated by one of skill in the art, as well as omit certain elements. For example, various other input devices and/or output devices can be included in processing system 100, depending upon the particular implementation of the same, as readily understood by one of ordinary skill in the art. For example, various types of wireless and/or wired input and/or output devices can be used. Moreover, additional processors, controllers, memories, and so forth, in various configurations can also be utilized as readily appreciated by one of ordinary skill in the art. These and other variations of the processing system 100 are readily contemplated by one of ordinary skill in the art given the teachings of the present invention provided herein.
Moreover, it is to be appreciated that environment 200 described below with respect to
Further, it is to be appreciated that processing system 100 may perform at least part of the method described herein including, for example, at least part of method 300 of
The environment 200 includes a computing device 210. The environment 200 further includes a set of computing devices collectively and individually denoted by the figure reference numeral 220.
In the embodiment of
The generation of the formal specification of the function can be based on a request for the same from any of the computing devices 220. The input/output examples can be provided from one or more of the computing devices 220. In an embodiment, one of the computing devices 220 can issue a request for generation of a formal specification of a function to computing device 210 and a different one or more of the computing devices 220 can provide the input/output examples to computing device 210 in support of the request. In another embodiment, computing device 210 implements the present invention without using any of computing devices 220 in any manner. These and other possible scenarios in environment 200 to which the present invention can be applied are readily determined by one of ordinary skill in the art, given the teachings of the present invention provided herein.
It is to be appreciated that the computing device 210 and the computing devices in the set 220 can be any type of computing device. For the sake of illustration, computing device 210 is implemented herein by a server, as well as each of computing devices 220, with each of the devices 210 and 220 interchangeably referred to herein as such (server).
Communications between the computing device 210 and the computing devices 220 can occur over one or more wired communications networks/arrangements and/or one or more wireless networks. For the sake of illustration, in the embodiment of
While certain types of communication technologies are described between the elements of
In the embodiment shown in
A description will now be given of variables relating to a method in accordance with an embodiment of the present invention described with respect to
Specification Generation System=(G, X, W, Cw, M, Cm, R, D, F, Ex), where
Examples of notations, using some of the preceding variables:
At step 310, extract a set of words from requirements of the function and annotate the set of words. In an embodiment, the requirements of the function are written in natural language.
Referring again to
Referring again to
Referring again to
At step 350, perform a validation process on each of the multiple prospective specifications, using input-output examples. The validation process determines whether or not each of the multiple prospective specifications satisfy the formal specification, using input-output examples. The prospective specifications that satisfy the formal specification are considered validated.
At step 360, generate the formal specification of the function from validated ones of the multiple prospective specifications.
In an embodiment, the inputs to method 1100 include: G, namely, a context-free grammar of specification; and R, namely, a set of production rules of a context-free grammar. In an embodiment, the output from method 1100 includes H, namely, a subset of G.
At step 1110, compute a finite-state automaton by computing an approximation of the set of production rules of the context-free grammar of the formal specification. For example, step 1110 can involve performing the approximation by creating a pushdown automaton from R, and ignoring the stack. Of course, other techniques can be used to perform the approximation, while maintaining the spirit of the present invention.
At step 1120, create a finite-state transducer based on the finite-state automaton by introducing output symbols. In an embodiment, for example, step 1120 involves a process of adding an output symbol to every transition rule of the finite-state automaton where the name of the output symbol is the same as the name of the input symbol of the transition rule of the finite-state automaton.
At step 1130, transform the context-free grammar of the formal specification using the finite-state transducer. In an embodiment, for example, step 1130 involves the process of applying the finite-state transducer to the context-free grammar since the finite-state transducer is a function that maps a context-free grammar to another context-free grammar.
It is to be appreciated that the purpose of steps 1120 and 1130 is to compute the intersection of a finite-state automaton and a context-free grammar.
A description will now be given of variables relating to another method in accordance with an embodiment of the present invention described with respect to
Specification Generation System SG=(G, X, W, M, R, D, F, Ex)
At step 1210, extract a set of words from requirements of the function. In an embodiment, the requirements of the function are written in natural language. For example, step 1210 can be applied so as to extract the set of words from the natural language description 410 shown in
Referring again to
Referring again to
Referring again to
At step 1250, perform a validation process on each of the multiple prospective specifications, using input-output examples. The validation process determines whether or not each of the multiple prospective specifications satisfy the formal specification, using input-output examples. The prospective specifications that satisfy the formal specification are considered validated.
At step 1260, generate the formal specification of the function from validated ones of the multiple prospective specifications. For example, step 1260 can generate the formal description 1010 shown in
The present invention may be a system, a method, and/or a computer program product at any possible technical detail level of integration. The computer program product may include a computer readable storage medium (or media) having computer readable program instructions thereon for causing a processor to carry out aspects of the present invention.
The computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.
Computer readable program instructions described herein can be downloaded to respective computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network. The network may comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. A network adapter card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing/processing device.
Computer readable program instructions for carrying out operations of the present invention may be assembler instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like, and conventional procedural programming languages, such as the “C” programming language or similar programming languages. The computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) may execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present invention.
Aspects of the present invention are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer readable program instructions.
These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including instructions which implement aspects of the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable apparatus, or other device implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts or carry out combinations of special purpose hardware and computer instructions.
Reference in the specification to “one embodiment” or “an embodiment” of the present invention, as well as other variations thereof, means that a particular feature, structure, characteristic, and so forth described in connection with the embodiment is included in at least one embodiment of the present invention. Thus, the appearances of the phrase “in one embodiment” or “in an embodiment”, as well any other variations, appearing in various places throughout the specification are not necessarily all referring to the same embodiment.
It is to be appreciated that the use of any of the following “/”, “and/or”, and “at least one of”, for example, in the cases of “A/B”, “A and/or B” and “at least one of A and B”, is intended to encompass the selection of the first listed option (A) only, or the selection of the second listed option (B) only, or the selection of both options (A and B). As a further example, in the cases of “A, B, and/or C” and “at least one of A, B, and C”, such phrasing is intended to encompass the selection of the first listed option (A) only, or the selection of the second listed option (B) only, or the selection of the third listed option (C) only, or the selection of the first and the second listed options (A and B) only, or the selection of the first and third listed options (A and C) only, or the selection of the second and third listed options (B and C) only, or the selection of all three options (A and B and C). This may be extended, as readily apparent by one of ordinary skill in this and related arts, for as many items listed.
Having described preferred embodiments of a system and method (which are intended to be illustrative and not limiting), it is noted that modifications and variations can be made by persons skilled in the art in light of the above teachings. It is therefore to be understood that changes may be made in the particular embodiments disclosed which are within the scope of the invention as outlined by the appended claims. Having thus described aspects of the invention, with the details and particularity required by the patent laws, what is claimed and desired protected by Letters Patent is set forth in the appended claims.
Number | Name | Date | Kind |
---|---|---|---|
7844951 | Chen et al. | Nov 2010 | B2 |
7941438 | Moilina-Moreno et al. | May 2011 | B2 |
8943465 | Broadfoot et al. | Jan 2015 | B2 |
9152385 | Chakrapani Rao et al. | Oct 2015 | B2 |
20020062475 | Iborra | May 2002 | A1 |
20030046061 | Preston | Mar 2003 | A1 |
20070074180 | Hinchey | Mar 2007 | A1 |
20100146491 | Hirano | Jun 2010 | A1 |
20120191833 | Liu | Jul 2012 | A1 |
20170031896 | Dymetman | Feb 2017 | A1 |
20170293276 | Hubauer | Oct 2017 | A1 |
Entry |
---|
Ishihara et al., “A Translation Method from Natural Language Specifications into Formal Specifications Using Contextual Dependencies” (Year: 1992). |
Konrad et al., “Facilitating the Construction of Specification Pattern-based Properties” (Year: 2005). |
Mirovia et al., “Finite-State-Transducers for Natural Language Processing” (Year: 2012). |
Lamsweerde, “Formal Specification: a Roadmap” (Year: 2000). |
Cabral, et al., “Formal Specification Generation from Requirement Documents”, Electronic Notes in Theoretical Computer Science 195 (2008), Jan. 2008, pp. 171-188. |
Fatwanto, et al., “Natural Language Requirements Specification Analysis Using Part-of-Speech Tagging”, IEEE, Nov. 2013, pp. 98-102. |
Ilieva, et al., “Automatic Transition of Natural Language Software Requirements Specification into Formal Presentation”, Springer-Verlag Berlin Heidelberg, Jun. 2005, pp. 392-397. |
Minamide, Yasuhiko, “Static Approximation of Dynamically Generated Web Pages”, WWW 2005, May 2015, pp. 432-441. |
Mohri, et al., “Regular Approximation of Context-Free Grammars Through Transformation”, Robustness in Language and Speech Technology, Chapter 9, 2000, pp. 251-261. |
Dr. Graband, et al., “ETCS Requirements Specification and Validation: The Methodology”, RINA, Jun. 2007, pp. 1-48. |
Number | Date | Country | |
---|---|---|---|
20180129478 A1 | May 2018 | US |