Method, system and medium for converting JPSL to PPTL property specification
By defining the Java property description language JPSL and designing the conversion method from JPSL to PPTL, the problem of high requirements for timing logic in Java program model detection and verification is solved, and a simple description and verification of properties in Java programs is realized, which meets the context-related time State properties verification requirements.
Patent Information
- Application Number
- CN202111425598.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-26
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2041-11-26
AI Technical Summary
When using Java programs for model detection and verification, verification personnel need to be proficient in timing logic formulas, which makes it difficult for engineering and technicians to conduct model detection and verification, and existing tools cannot meet the context-related tidal properties verification requirements in Java programs.
Define the Java property description language JPSL, mark the property characteristics in the Java source program through annotation, design the conversion method of JPSL to PPTL property specifications, automatically convert the JPSL statements into semantic equivalent PPTL formulas, and realize the description and verification of the properties of Java programs. .
It provides a simple and easy-to-use Java property description technology, which reduces the dependence on timing logic, and allows engineering and technical personnel to conduct model detection and verification without mastering mathematical logic knowledge to meet the context-related situations in Java programs. State properties verification requirements.
Smart Images

Figure CN114281314B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of system formal modeling and verification, and in particular relates to a method, system and medium for converting JPSL to PPTL property specification. Background Art
[0002] At present, Java, as an object-oriented programming language designed for Internet software development, has developed software with good understandability, extensibility, reusability and platform independence, and is widely used in the development of various software systems such as communications, network services, and the Internet of Things. Faced with a large number of software systems developed using the Java language, how to ensure the correctness, security, and reliability of the system is a huge challenge.
[0003] As a traditional means of software system verification, software testing can only prove that there are errors in the system but cannot prove that there are no errors, which is inherently insufficient. Formal verification uses mathematical methods to model and describe the properties of the system to be verified, and proves that the system meets the expected properties under the support of rigorous mathematical theories, providing an effective verification method to ensure the correctness, security and reliability of the software system.
[0004] Model checking is an important formal verification technology. Based on the finite state migration model and the properties to be verified of a given software system, it can automatically exhaustively traverse the execution path of the system through an algorithm with the support of model checking tools to detect whether the properties hold. If the properties do not hold, it can provide a counterexample path to help engineering technicians locate and troubleshoot errors.
[0005] The main methods for using model checking technology to verify Java source programs include: (1) using classic tools such as SPIN and NuSMV to describe the properties to be verified as LTL (Linear-time Temporal Logic) formulas or CTL (Computation Tree Logic). It is generally necessary to manually build an abstract model of the system to be verified based on the program code and describe it using the verification tool's dedicated modeling language (such as SPIN's Promela). The modeling process is very inefficient and prone to errors. (2) using tools such as Java Pathfinder to directly verify Java source code, but it can only verify properties such as security and assertions, and cannot verify context-related temporal properties in the program, which cannot meet the needs of Java programs.
[0006] In addition, using MSVL (Modeling, Simulation and Validation Language) to perform model checking on Java programs is also an important verification method. MSVL is an executable logic programming language defined based on PTL (Projection Temporal Logic). During verification, the Java program can be converted into a semantically equivalent MSVL program model through an algorithm, and the properties to be verified are described using PPTL (Propositional Projection Temporal Logic) formulas. Then, the system model detection verification is completed through the dedicated model checking platform MSV. PPTL is a propositional subset of PTL, which has the expression ability of a completely regular language and can verify more complex system properties than LTL and CTL (such as the closure property of repeated execution). Compared with SPIN and NuMSV, MSVL can accurately describe the model of the system to be verified, and has been applied to the verification of typical software systems such as communication protocols and memory management.
[0007] At present, no matter what method is used to perform model checking and verification on Java programs, the verification personnel are required to directly use temporal logic formulas (LTL, CTL or PPTL, etc.) to describe the properties of the system to be verified. This requires the verification personnel to be proficient in the syntax and semantics of the corresponding temporal logic, and to correctly define the system properties described by the temporal logic formula in combination with the established abstract model of the system to be verified. For general engineering and technical personnel engaged in software system development, although they can easily know the properties and characteristics that the system should have by combining the analysis, design and implementation scheme of the system, it is difficult to use temporal logic formulas to accurately define it because the professional knowledge of mathematical logic is often weak. On the other hand, although scholars engaged in the research of formal verification technology have good mathematical logic knowledge, they usually lack engineering knowledge and need to spend a lot of time to familiarize themselves with the analysis and design scheme of the software system before they can correctly define the system properties. The above factors seriously restrict the promotion and application of Java model checking technology in the industry.
[0008] Through the above analysis, the problems and defects of the prior art are as follows:
[0009] (1) The existing methods of model checking and verification of Java source programs using classic tools such as SPIN and NuSMV require the use of LTL and CTL formulas to describe the properties of the system to be verified, and their expression ability is not as good as PPTL.
[0010] (2) Existing tools such as Java Pathfinder are used to directly verify Java source code, but they can only verify properties such as security and assertions, and cannot verify the context-related temporal properties in the program, which cannot meet the needs of Java programs.
[0011] (3) Regardless of the method used to perform model checking and verification on Java programs, the verifier is required to directly use temporal logic formulas to describe the system to be verified. However, since the verifier's professional knowledge of mathematical logic is often weak, it is difficult to use temporal logic formulas to accurately define it.
[0012] (4) The current scholars engaged in formal verification technology research usually lack engineering knowledge and need to spend a lot of time to familiarize themselves with the analysis and design of software systems before they can correctly define the properties of the system. This seriously restricts the promotion and application of Java model checking technology in the industry.
[0013] The difficulty of solving the above problems and defects is as follows: (1) It is necessary to design a reasonable JPSL property annotation method based on the Java program verification needs and the expression ability of PPTL, so that engineering technicians can conveniently and quickly describe the properties that the software system needs to meet as JPSL statements associated with the Java program code, and mix them into the source code in the form of comments during programming; (2) It is necessary to extract the mixed JPSL property statements from the Java source program, and design conversion rules to automatically convert the JPSL property statements into semantically equivalent PPTL formulas, and identify the constraint position and range of the system properties described by the PPTL formulas.
[0014] The significance of solving the above problems and defects is as follows: the present invention provides a simple and easy-to-use Java property description technology for engineering and technical personnel by designing a conversion method from JPSL to PPTL property specifications. When the software system is programmed, the property characteristics of the system are annotated in the Java source code in the form of program annotations through JPSL statements, and the JPSL statements in the Java source program are automatically converted into system properties described by PPTL formulas. By using the PPTL property formula obtained after the conversion, combined with the MSVL program model corresponding to the Java source program, the model monitoring and verification of the system can be completed on the MSV platform. Based on the present invention, a model detection tool for Java source programs can be developed, allowing general engineering and technical personnel to perform model detection and verification without having to master mathematical logic knowledge, laying a foundation for promoting the application of Java program model detection technology in the engineering community.
[0015] To solve the above problems, we defined the Java Property Description Language JPSL for model checking. We used the program annotation method familiar to engineers (such as assertions, pre- and post-conditions, etc.) to describe the properties that the software system needs to meet as JPSL statements associated with the software unit and mixed them into the program code. JPSL uses unique keywords to replace complex temporal logic operators, which can easily describe the temporal properties of Java programs such as liveness, security, and fairness.
[0016] The syntax definition of JPSL is shown in Table 1. JPSL statements (JPSL_Stmt) are in the form of Java program comments and are identified by the keyword @JPSL. SEC_BEGIN and SEC_END are used to identify code snippets that need to be annotated and must appear in pairs. The definitions and meanings of JPSL keywords and operators are shown in Tables 2 and 3 respectively.
[0017] Table 1 JPSL definition
[0018]
[0019] Table 2 JPSL keywords
[0020]
[0021] Table 3 JPSL operators
[0022]
[0023] Summary of the invention
[0024] In view of the problems existing in the prior art, the present invention provides a method, system and medium for converting JPSL to PPTL property specifications, and in particular relates to a method and software system for converting JPSL (Java Property Specification Language) to PPTL (Propositional Projection Temporal Logic) property specifications.
[0025] The present invention is achieved by a method for converting JPSL to PPTL property specifications, the method comprising the following steps:
[0026] Step 1: Use JPSL to annotate the properties of classes, functions, code snippets, and program statements in the Java source program according to the marking rules;
[0027] Step 2: Perform lexical and grammatical analysis on the Java program marked with JPSL property statements, and construct an extended object-oriented abstract syntax tree EOOAST to describe the grammatical structure JST of the Java program itself and the JPSL property statements;
[0028] Step 3: Check the integrity and consistency of the JST in EOOAST. The check rules are to determine whether the JST conforms to the JPSL syntax and whether the referenced variable names are correct. Class properties can only reference class-defined attributes or inherited attributes, and the other three can only reference class attributes, method parameters, and defined local variables.
[0029] Step 4: Convert the JST in EOOAST into a PPTL formula with constraint positions that describes the properties of the Java program.
[0030] Furthermore, in step 1, the marking rule includes:
[0031] Rule 1: Describe the properties that all objects of a class need to satisfy during their lifetime as JPSL statements and annotate them before the corresponding class definition, referred to as "class property statements";
[0032] Rule 2: Describe the properties that need to be satisfied when executing a method as a JPSL statement and annotate it before the corresponding method, referred to as a "method property statement";
[0033] Rule 3: Describe the properties that need to be satisfied when executing a code segment as a JPSL statement and mark it before the corresponding code segment, referred to as "code segment property statement";
[0034] Rule 4: After the program is executed until the property that the statement needs to satisfy is described as a JPSL statement, it is marked before the corresponding statement, referred to as an "assertion property statement";
[0035] Further, in step four, the JST in EOOAST is converted into a PPTL formula with a constraint position as a triple (scope, pptl_prop, map), wherein the scope represents the constraint scope of the JPSL property, the pptl_prop represents the PPTL property formula after the JPSL statement is converted, and the map is a set of atomic proposition descriptions of the atomic propositions contained in pptl_prop and the predicate formulas represented by them, including constraint position scope calculation rules, JPSL statement to PPTL property formula pptl_prop and atomic proposition description set map conversion rules.
[0036] Furthermore, the constraint position scope calculation rule includes:
[0037] Rule 1: If JST is a property statement annotated on the class node cls, the constraint location scope is cls;
[0038] Rule 2: If JST is a property statement annotated on the method fun node of class cls, the constraint location scope is cls:fun;
[0039] Rule 3: If JST is a property statement annotated on the code segment from line num0 to line num1 in method fun of class cls, the constraint location scope is cls:fun:num0:num1;
[0040] Rule 4: If JST is an assertion statement annotated on line num in method fun of class cls, the constraint location scope is cls:fun:num.
[0041] Furthermore, the conversion rules from the JPSL statement to the PPTL property formula pptl_prop and the atomic proposition description set map include:
[0042] (1) If JST is a predicate formula e1[<|<=|==|>|>=]e2, the transformed property formula pptl_prop is a new atomic proposition p, and the atomic proposition description set map is {p:e1[<|<=|==|>|>=]e2};
[0043] (2) If JST is a property statement SEQ(Prop1,...,Prop n ), first for each Prop i (1≤i≤n) is converted and the result is pptl_prop i and map i , the final converted property formula pptl_prop is pptl_prop1;...;pptl_prop n , the atomic proposition states that the set map is map1∪...∪map n ;
[0044] (3) If JST is the property statement REPEAT(Prop1), first transform Prop1, and let the result be pptl_prop1 and map1. The final transformed property formula pptl_prop is (pptl_prop1)+, and the atomic proposition description set map is map1;
[0045] (4) If JST is the property statement SOMETIMES(Prop1), first transform Prop1, and let the result be pptl_prop1 and map1. The final transformed property formula pptl_prop is ◇pptl_prop1, and the atomic proposition description set map is map1;
[0046] (5) If JST is the property statement ALWAYS(Prop1), first transform Prop1, and let the results be pptl_prop1 and map1. The final transformed property formula pptl_prop is □pptl_prop1, and the atomic proposition description set map is map1;
[0047] (6) If JST is a property statement PRE(Prop1), first transform Prop1, and let the results be pptl_prop1 and map1. The final transformed property formula pptl_prop is pptl_prop1, and the atomic proposition description set map is map1;
[0048] (7) If JST is the property statement POST(Prop1), first transform Prop1, and let the results be pptl_prop1 and map1. The final transformed property formula pptl_prop is □(ε→pptl_prop1), and the atomic proposition description set map is map1;
[0049] (8) If JST is a property statement! Prop1, first convert Prop1, and let the result be pptl_prop1 and map1. The final converted property formula pptl_prop is The atomic proposition states that the set map is map1;
[0050] (9) If the JST is a property statement Prop1&&Prop2, first transform Prop1 and Prop2 respectively, and let the results be pptl_prop1, map1 and pptl_prop2, map2 respectively. The final transformed property formula pptl_prop is pptl_prop1∧pptl_prop2, and the atomic proposition description set map is map1∪map2;
[0051] (10) If JST is a property statement Prop1||Prop2, first transform Prop1 and Prop2 respectively, and let the results be pptl_prop1, map1 and pptl_prop2, map2 respectively. The final transformed property formula pptl_prop is pptl_prop1∨pptl_prop2, and the atomic proposition description set map is map1∪map2.
[0052] Another object of the present invention is to provide a JPSL to PPTL property specification conversion system using the JPSL to PPTL property specification conversion method, the JPSL to PPTL property specification conversion system comprising:
[0053] (1) Lexical analysis module, used to complete the JPSL lexical analysis process and convert the JPSL character stream into a word sequence according to the lexical rules of JPSL;
[0054] (2) Syntax analysis module, used to complete the JPSL syntax analysis process, process the results of lexical analysis, and complete the construction of the JPSL syntax tree JST;
[0055] (3) A formula conversion module is used to complete the final conversion of the JPSL to PPTL formula according to the JST to PPTL conversion algorithm.
[0056] Another object of the present invention is to provide a computer device, the computer device comprising a memory and a processor, the memory storing a computer program, and when the computer program is executed by the processor, the processor performs the following steps:
[0057] Use JPSL to annotate the properties of classes, functions, code snippets and program statements in Java source programs according to marking rules through annotations; perform lexical and grammatical analysis on Java programs annotated with JPSL property statements, and construct an extended object-oriented abstract syntax tree EOOAST to describe the grammatical structure JST of the Java program itself and JPSL property statements; perform integrity and consistency check on the JST in EOOAST, and convert the JST in EOOAST into a PPTL formula with constraint positions that describes the properties of the Java program.
[0058] Another object of the present invention is to provide a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the following steps:
[0059] Use JPSL to annotate the properties of classes, functions, code snippets and program statements in Java source programs according to marking rules through annotations; perform lexical and grammatical analysis on Java programs annotated with JPSL property statements, and construct an extended object-oriented abstract syntax tree EOOAST to describe the grammatical structure JST of the Java program itself and JPSL property statements; perform integrity and consistency check on the JST in EOOAST, and convert the JST in EOOAST into a PPTL formula with constraint positions that describes the properties of the Java program.
[0060] Another object of the present invention is to provide an information data processing terminal, which is used to implement the conversion system from JPSL to PPTL property specification.
[0061] In combination with all the above technical solutions, the advantages and positive effects of the present invention are as follows: the JPSL to PPTL property specification conversion method provided by the present invention is suitable for developing model detection tools for Java source programs and performing model detection and verification on Java programs. Compared with directly using temporal logic formulas to describe the properties to be verified, the present invention provides engineering and technical personnel with a simple Java property description technology by designing a JPSL statement to PPTL formula conversion method, which allows model detection and verification without the need to master temporal logic, laying a foundation for promoting the application of Java program model detection technology in the engineering community.
[0062] The present invention defines a Java program property description language JPSL, which allows engineers to embed the properties that the system should have into the Java source program in the form of comments using JPSL statements during programming development, and designs a method for extracting and converting JPSL statements to projection temporal logic PPTL formulas, laying the foundation for directly implementing Java program model detection. The JPSL language uses annotation methods similar to assertions and pre / postconditions familiar to developers to replace complex temporal logic, describes the properties that the software system needs to meet as JPSL statements associated with program codes, and mixes them in the Java source program in the form of comments. The implementation of the present invention reduces the difficulty of describing the properties to be verified in actual model detection, and makes up for the expression ability of existing attribute description languages, thereby promoting the promotion and use of model detection technology in the industry.
[0063] The main function of the lexical analysis module of the present invention is to traverse the extracted JPSL language according to the specified JPSL lexical rules, then identify the tokens therein, and convert the JPSL into a word sequence. If the lexical analysis of JPSL is performed manually, it is time-consuming and laborious, and the accuracy cannot be guaranteed.
[0064] The grammatical analysis module of the present invention processes the output results of the lexical analysis module according to the defined grammatical rules to ensure that the various grammatical phrases of the word sequence combination obtained by the lexical analysis conform to the program structure specification, and then converts it into JST, and uses the JST as the input of the conversion module to perform the next step of converting JST to PPTL.
[0065] The JST to PPTL conversion module of the present invention obtains node information in JST, performs conversion processing operations on the obtained information in sequence, and stores the final conversion results in a list set. Compared with the prior art, the present invention can reduce the difficulty of describing the properties to be verified in actual model detection, and make up for the expression ability of the existing attribute description language, thereby promoting the promotion and use of model detection technology in the industry. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0067] Figure 1 It is a flow chart of a method for converting JPSL to PPTL property specification provided by an embodiment of the present invention.
[0068] Figure 2 It is a schematic diagram of a method for converting JPSL to PPTL property specification provided in an embodiment of the present invention.
[0069] Figure 3 It is a structural block diagram of a conversion system from JPSL to PPTL property specification provided by an embodiment of the present invention;
[0070] In the figure: 1. Lexical analysis module; 2. Syntax analysis module; 3. Formula conversion module.
[0071] Figure 4 It is an extended abstract syntax tree structure diagram proposed for a Java program marked with JPSL properties provided by an embodiment of the present invention.
[0072] Figure 5 It is an extended hierarchical syntax diagram for code segments and JPSL statements provided by an embodiment of the present invention.
[0073] Figure 6 It is an extended abstract syntax tree structure diagram of the "3x+1" problem provided by an embodiment of the present invention.
[0074] Figure 7 It is an extended abstract syntax tree structure diagram of the "3x+1" problem provided by an embodiment of the present invention.
[0075] Figure 8 It is JST4 of the extended hierarchical syntax diagram of the "3x+1" problem provided by the embodiment of the present invention. DETAILED DESCRIPTION
[0076] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0077] In view of the problems existing in the prior art, the present invention provides a method, system and medium for converting a JPSL to a PPTL property specification. The present invention is described in detail below in conjunction with the accompanying drawings.
[0078] like Figure 1 As shown, the method for converting JPSL to PPTL property specification provided by the embodiment of the present invention includes the following steps:
[0079] S101, using JPSL to annotate the properties of classes, functions, code snippets, and program statements in a Java source program according to marking rules;
[0080] S102, performing lexical and grammatical analysis on the Java program marked with JPSL property statements, and constructing an extended object-oriented abstract syntax tree EOOAST to describe the grammatical structure JST of the Java program itself and the JPSL property statements;
[0081] S103, perform integrity and consistency check on the JST in EOOAST, and convert the JST in EOOAST into a PPTL formula with constraint positions that describes the properties of the Java program.
[0082] The principle diagram of the conversion method from JPSL to PPTL property specification provided by the embodiment of the present invention is as follows Figure 2 shown.
[0083] like Figure 3 As shown, the JPSL to PPTL property specification conversion system provided by the embodiment of the present invention includes:
[0084] The lexical analysis module 1 is used to complete the JPSL lexical analysis process and convert the JPSL character stream into a word sequence according to the lexical rules of JPSL;
[0085] Syntax analysis module 2 is used to complete the JPSL syntax analysis process, process the results of lexical analysis, and complete the construction of the JPSL syntax tree JST;
[0086] The formula conversion module 3 is used to complete the final conversion of the JPSL to PPTL formula according to the JST to PPTL conversion algorithm.
[0087] The conversion process in the present invention requires the use of a proprietary conversion tool based on the JPSL language to PTL, and the tool runs in the following environment:
[0088] System: Windows 7 and above
[0089] Memory: 2GB
[0090] CPU: Intel Core i3 and above
[0091] Software: JVM, JRE support
[0092] The application principle of the present invention is described in detail below in conjunction with the accompanying drawings.
[0093] The method for converting JPSL language to PPTL formula provided by the embodiment of the present invention comprises the following steps:
[0094] (1) Use JPSL to annotate the properties of classes, functions, code snippets, and program statements in Java source programs according to the marking rules;
[0095] (2) Perform lexical and grammatical analysis on the Java program annotated with JPSL property statements, and construct an extended object-oriented abstract syntax tree (EOOAST) to describe the grammatical structure of the Java program itself and the JPSL property statements;
[0096] (3) Perform integrity and consistency check on the JST in EOOAST. The check rules are to determine whether the JST conforms to the JPSL syntax and whether the referenced variable names are correct. Class property statements can only reference class-defined attributes or inherited attributes; method property statements, code segment property statements, and assertion property statements can only reference the attributes of the class to which they belong, the formal parameters of the method, and the defined local variables;
[0097] (4) Convert the JST in EOOAST into a PPTL formula with constraint positions that describes the properties of the Java program.
[0098] The EOOAST (Extended Abstract Syntax) tree structure diagram for a Java program marked with JPSL properties provided by an embodiment of the present invention is as follows: Figure 4 As shown, the extended hierarchical syntax diagram for method codes and JPSL statements provided by the embodiment of the present invention is as follows Figure 5 shown.
[0099] The application principle of the present invention is further described below.
[0100] The method for converting JPSL language to PPTL formula provided by the embodiment of the present invention comprises the following steps:
[0101] Step 1: Use JPSL to annotate the properties of classes, functions, code snippets, and program statements in the Java source program according to the marking rules;
[0102] Step 2: Perform lexical and grammatical analysis on the Java program marked with JPSL property statements, and construct an extended object-oriented abstract syntax tree EOOAST to describe the grammatical structure JST of the Java program itself and the JPSL property statements;
[0103] Step 3: Check the integrity and consistency of the JST in EOOAST. The check rules are to determine whether the JST complies with the JPSL syntax and whether the referenced variable names are correct. Class property statements can only reference class-defined attributes or inherited attributes; method property statements, code segment property statements, and assertion property statements can only reference the attributes of the class to which they belong, the formal parameters of the method, and the defined local variables;
[0104] Step 4: Convert the JST in EOOAST into a PPTL formula triple (scope, pptl_prop, map) with constraint position and describing the properties of the Java program, wherein the scope represents the constraint scope of the JPSL property, the pptl_prop represents the PPTL property formula after the JPSL statement is converted, and the map is the atomic proposition description set of the atomic proposition contained in pptl_prop and the predicate formula it represents. This includes the constraint position scope calculation rules, the conversion rules from the JPSL statement to the PPTL property formula pptl_prop and the atomic proposition description set map.
[0105] The constraint position scope calculation rule is:
[0106] Rule 1: If JST is a property statement annotated on the class node cls, the constraint location scope is cls;
[0107] Rule 2: If JST is a property statement annotated on the method fun node of class cls, the constraint location scope is cls:fun;
[0108] Rule 3: If JST is a property statement annotated on the code segment from line num0 to line num1 in method fun of class cls, the constraint location scope is cls:fun:num0:num1;
[0109] Rule 4: If JST is an assertion statement annotated on line num in method fun of class cls, the constraint location scope is cls:fun:num.
[0110] The conversion rules of the JPSL statement to the PPTL property formula pptl_prop and the atomic proposition description set map are:
[0111] (1) If JST is a predicate formula e1[<|<=|==|>|>=]e2, the transformed property formula pptl_prop is a new atomic proposition p, and the atomic proposition description set map is {p:e1[<|<=|==|>|>=]e2};
[0112] (2) If JST is a property statement SEQ(Prop1,...,Propn ), first for each Prop i (1≤i≤n) is converted and the result is pptl_prop i and map i , the final converted property formula pptl_prop is pptl_prop1;...;pptl_prop n , the atomic proposition states that the set map is map1∪...∪map n ;
[0113] (3) If JST is the property statement REPEAT(Prop1), first transform Prop1, and let the result be pptl_prop1 and map1. The final transformed property formula pptl_prop is (pptl_prop1)+, and the atomic proposition description set map is map1;
[0114] (4) If JST is the property statement SOMETIMES(Prop1), first transform Prop1, and let the result be pptl_prop1 and map1. The final transformed property formula pptl_prop is ◇pptl_prop1, and the atomic proposition description set map is map1;
[0115] (5) If JST is the property statement ALWAYS(Prop1), first transform Prop1, and let the results be pptl_prop1 and map1. The final transformed property formula pptl_prop is □pptl_prop1, and the atomic proposition description set map is map1;
[0116] (6) If JST is a property statement PRE(Prop1), first transform Prop1, and let the results be pptl_prop1 and map1. The final transformed property formula pptl_prop is pptl_prop1, and the atomic proposition description set map is map1;
[0117] (7) If JST is the property statement POST(Prop1), first transform Prop1, and let the results be pptl_prop1 and map1. The final transformed property formula pptl_prop is □(ε→pptl_prop1), and the atomic proposition description set map is map1;
[0118] (8) If JST is a property statement! Prop1, first convert Prop1, and let the result be pptl_prop1 and map1. The final converted property formula pptl_prop is The atomic proposition states that the set map is map1;
[0119] (9) If the JST is a property statement Prop1&&Prop2, first transform Prop1 and Prop2 respectively, and let the results be pptl_prop1, map1 and pptl_prop2, map2 respectively. The final transformed property formula pptl_prop is pptl_prop1∧pptl_prop2, and the atomic proposition description set map is map1∪map2;
[0120] (10) If JST is a property statement Prop1||Prop2, first transform Prop1 and Prop2 respectively, and let the results be pptl_prop1, map1 and pptl_prop2, map2 respectively. The final transformed property formula pptl_prop is pptl_prop1∨pptl_prop2, and the atomic proposition description set map is map1∪map2.
[0121] The application effects of the present invention are described in detail below with reference to examples.
[0122] The implementation process of the present invention is illustrated and described below through an example. The example is only an explanation of the process of the present invention, and only the core part of the implementation process is given, and other similar processes are no longer given.
[0123] This example is a Java program to verify the "3x+1 problem", as shown in Table 4. The "3x+1 problem" is to input any positive integer x. If x is an odd number, set x=3x+1, otherwise set x=x / 2. Repeat the operation on x according to this rule, and the value of x must be 1 in the end.
[0124] First, JPSL is used to annotate the properties of the system in the Java source program through annotations: the attribute value of the class Quess3X1 is used to store the value of the positive integer x in the "3x+1 problem", which is always greater than 0 during the calculation. It is described by the JPSL property statement " / *@JPSL ALWAYS(value>0)* / " and annotated in front of the class Quess3X1, as shown in the first row of Table 4; before calling the run method to calculate value according to the calculation rules, the value of value must be greater than 0, which is described by the JPSL property statement " / *@JPSL PRE(value>0)* / " and annotated in front of the method run, as shown in the 16th row of Table 4; after executing the while loop statement in run, the value of value is equal to 1, which is described by the JPSL code segment property statement " / *@JPSL SEC_BEGIN POST(value=1)* / … / *@JPSL SEC_END* / ", as shown in rows 16 to 20 of Table 4.
[0125] Then, the Java program marked with JPSL property statements is subjected to lexical and grammatical analysis, and an extended abstract syntax tree (EOOST) is constructed to describe the grammatical structure of the Java program itself and the JPSL property statements. Figure 6 and Figure 7 , JST3 reference for extended hierarchical syntax diagrams Figure 8 .
[0126] Table 4 Java source code for the "3x+1 problem" (with JPSL property statements marked)
[0127]
[0128] Finally, the integrity and consistency of the JPSL syntax tree in EOOAST are checked; the JPSL syntax tree in EOOAST is converted into a PPTL formula with constraint positions. The three JPSL statements in Table 4 use the value variable, which is an attribute of the class Quess3X1 and passes the integrity and consistency check. The JPSL statement in the first line is a class property statement. According to the constraint scope calculation rule 1 and the conversion rules 1 and 5 from the JPSL statement to the PPTL property formula, the final result is (Quess3X1,p1,{p1:value>0}); the JPSL statement in the 16th line is a method property statement. According to the constraint scope calculation rule 2 and the conversion rules 1 and 6 from the JPSL statement to the PPTL property formula, the final result is (Quess3X1:run,p2,{p1:value>0}); the JPSL statements in the 19th and 25th lines are code segment property statements. According to the constraint scope calculation rule 3 and the conversion rules 1 and 7 from the JPSL statement to the PPTL property formula, the final result is (Quess3X1:run:19:25,□(ε→p3),{p3:value=1}).
[0129] The above examples show the basic process of describing the property of Java program model detection and converting it to PPTL property formula. The program property description method based on JPSL is easy to master and intuitive to describe. It is more convenient and accurate than the direct description method using LTL, CTL and PPTL logic formulas. The present invention realizes the organic unity of programming development and property description by engineering and technical personnel, provides support for direct model detection and verification of Java programs, and promotes the promotion of model detection technology in the industry.
[0130] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When the use is implemented in whole or in part in the form of a computer program product, the computer program product includes one or more computer instructions. When the computer program instructions are loaded or executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL) or wireless (e.g., infrared, wireless, microwave, etc.) mode) to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0131] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principle of the present invention should be covered by the protection scope of the present invention.
Claims
1. A method for converting JPSL to PPTL property specification, characterized in that: The method for converting the JPSL to PPTL property specification comprises the following steps: Step 1: Use JPSL to annotate the properties of classes, functions, code snippets, and program statements in the Java source program according to the marking rules; Step 2: Perform lexical and grammatical analysis on the Java program marked with JPSL property statements, and construct an extended object-oriented abstract syntax tree EOOAST to describe the grammatical structure JST of the Java program itself and the JPSL property statements; Step 3: Check the integrity and consistency of the JST in EOOAST; Step 4: Convert the JST in EOOAST into a PPTL formula with constraint positions and describing the properties of the Java program; In step 1, the marking rules include: Rule 1: Describe the properties that all objects of a class need to satisfy during their lifetime as JPSL statements and annotate them before the corresponding class definition, referred to as "class property statements"; Rule 2: Describe the properties that need to be satisfied when executing a method as a JPSL statement and annotate it before the corresponding method, referred to as "method property statement"; Rule 3: Describe the properties that need to be satisfied when executing a code segment as a JPSL statement and mark it before the corresponding code segment, referred to as "code segment property statement"; Rule 4: After the program is executed to the property that the statement needs to satisfy, describe it as a JPSL statement and mark it before the corresponding statement, referred to as "assertion property statement"; In step 4, the JST in EOOAST is converted into a PPTL formula triple (scope, pptl_prop, map) with a constraint position, wherein the scope represents the constraint scope of the JPSL property, the pptl_prop represents the PPTL property formula after the JPSL statement is converted, and the map is a set of atomic propositions contained in pptl_prop and atomic proposition descriptions representing predicate formulas, including constraint position scope calculation rules, JPSL statement to PPTL property formula pptl_prop and atomic proposition description set map conversion rules; The constraint position scope calculation rules include: Rule 1: If JST is a property statement annotated on the class node cls, the constraint location scope is cls; Rule 2: If JST is a property statement annotated on the method fun node of class cls, the constraint location scope is cls:fun; Rule 3: If JST is a property statement annotated on the code segment from line num0 to line num1 in method fun of class cls, the constraint location scope is cls:fun:num0:num1; Rule 4: If JST is an assertion statement annotated on line num in method fun of class cls, the constraint location scope is cls:fun:num; The conversion rules from the JPSL statement to the PPTL property formula pptl_prop and the atomic proposition description set map include: (1) If JST is a predicate formula e1[<|<=|==|>|>=]e2, the transformed property formula pptl_prop is a new atomic proposition p, and the atomic proposition description set map is {p:e1[<|<=|==|>|>=]e2}; (2) If JST is a property statement SEQ(Prop1,...,Prop n ), first for each Prop i (1≤i≤n) is converted and the result is pptl_prop i and map i , the final converted property formula pptl_prop is pptl_prop1;...;pptl_prop n , the atomic proposition states that the set map is map1∪...∪map n ; (3) If JST is the property statement REPEAT(Prop1), first transform Prop1, and let the result be pptl_prop1 and map1. The final transformed property formula pptl_prop is (pptl_prop1)+, and the atomic proposition description set map is map1; (4) If JST is the property statement SOMETIMES(Prop1), first transform Prop1, and let the result be pptl_prop1 and map1. The final transformed property formula pptl_prop is ◇pptl_prop1, and the atomic proposition description set map is map1; (5) If JST is the property statement ALWAYS(Prop1), first convert Prop1 and let the result be pptl_prop1 and map1. The final property formula pptl_prop after conversion is The atomic proposition states that the set map is map1; (6) If JST is a property statement PRE(Prop1), first transform Prop1, and let the results be pptl_prop1 and map1. The final transformed property formula pptl_prop is pptl_prop1, and the atomic proposition description set map is map1; (7) If JST is the property statement POST(Prop1), first transform Prop1 and let the result be pptl_prop1 and map1. The final property formula pptl_prop after transformation is The atomic proposition states that the set map is map1; (8) If JST is a property statement! Prop1, first convert Prop1, and let the result be pptl_prop1 and map1. The final converted property formula pptl_prop is The atomic proposition states that the set map is map1; (9) If the JST is a property statement Prop1&&Prop2, first transform Prop1 and Prop2 respectively, and let the results be pptl_prop1, map1 and pptl_prop2, map2 respectively. The final transformed property formula pptl_prop is pptl_prop1∧pptl_prop2, and the atomic proposition description set map is map1∪map2; (10) If JST is a property statement Prop1||Prop2, first transform Prop1 and Prop2 respectively, and let the results be pptl_prop1, map1 and pptl_prop2, map2 respectively. The final transformed property formula pptl_prop is pptl_prop1∨pptl_prop2, and the atomic proposition description set map is map1∪map2.
2. A JPSL to PPTL property specification conversion system implementing the JPSL to PPTL property specification conversion method of claim 1, characterized in that: The JPSL to PPTL property specification conversion system includes: The lexical analysis module is used to complete the JPSL lexical analysis process and convert the JPSL character stream into a word sequence according to the lexical rules of JPSL; The syntax analysis module is used to complete the JPSL syntax analysis process, process the results of lexical analysis, and complete the construction of the JPSL syntax tree JST; The formula conversion module is used to complete the final conversion of JPSL to PPTL formula according to the JST to PPTL conversion algorithm.
3. A computer device, characterized in that: The computer device includes a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method for converting JPSL to PPTL property specification as claimed in claim 1.
4. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the steps of the method for converting JPSL to PPTL property specification as claimed in claim 1.
5. An information data processing terminal, characterized in that: The information data processing terminal is used to implement the JPSL to PPTL property specification conversion system as described in claim 2.