Method and system for checking and verifying side-oriented static semantics based on translation confirmation

By using a translation confirmation-based method in a trusted compiler, the translation confirmation program is constructed and attached to the translation process, the problem of lack of universality and scalability of the correctness verification of the static semantic analysis/checking process in the prior art is solved, and more efficient static semantic property checking and correctness verification are achieved.

CN120234010APending Publication Date: 2025-07-01TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510384582.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-28
Publication Date
2025-07-01

AI Technical Summary

Technical Problem

The verification of the correctness of static semantic analysis/checking processes in existing trusted compilers lacks the general situation to consider, as well as the problem of large-scale modification of front-end translation and its proof process that may be caused by handling the newly added static semantic characteristics.

Method used

Using a translation confirmation method, by determining the front-end intermediate languages ​​L and M, setting the static semantic goodness predicate corresponding to the preset side A, obtaining the shadow language M' and matching maps, constructing a translation and performing static semantic properties checking checks, generating a translation confirmation program that meets the static semantic properties checking needs of side A, and appending it to the translation process to perform static semantics checking and correctness verification towards side A.

Benefits of technology

This method can better consider common cases, reduce front-end translation and proof process modification caused by newly added static semantic characteristics, and improve the scalability and reliability of static semantic analysis/checking processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120234010A_ABST
    Figure CN120234010A_ABST
Patent Text Reader

Abstract

The invention relates to a side-oriented static semantic check and verification method and system based on translation confirmation, and the method comprises the steps: determining two front-end intermediate languages L and M, and respectively setting a static semantic good predicate of a side A; obtaining a shadow language M'corresponding to the M, determining matching mapping from the M 'to the M, and constructing a checking function for translating from L to the M' and performing static semantic property checking; and sequentially combining the check function and the matching mapping together to generate a translation confirmation program meeting the static semantic property check requirement of the side A, and adding the translation confirmation program after the translation process from L to M so as to carry out static semantic check and correctness verification facing the side A. Therefore, the problems that the correctness verification of the static semantic analysis / check process in the existing trusted compiler is lack of consideration of general situations, and large-area modification of front-end translation and the proving process of the front-end translation is possibly caused by processing newly-added static semantic characteristics are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of front - end static semantic checking, and particularly relates to a method and system for side - oriented static semantic checking and verification based on translation confirmation. Background Art

[0002] Regarding the "miscompilation" problem of code generators or compilers, for safety - critical systems, it is necessary to consider the errors introduced by code generators or compilers. Otherwise, the verification work done at great effort at the source program level may fail at the target program level.

[0003] Figure 1 Depicts the typical application development process in the safety - critical embedded control field, aiming to emphasize the crucial importance of the code generation link. In recent years, along with the upsurge of MBSE (Model - Based Systems Engineering), model - based / model - driven development has gradually emerged and become the mainstream in the industry. The proportion of code automatically generated from models has taken the dominant position.

[0004] To increase the safety and trustworthiness of code generators or compilers, simply relying on testing and strict process management is not enough. Verifying the correctness of code generators or compilers, rather than just testing, is the fundamental way to solve the problem. The most rigorous verification method is to adopt formal methods.

[0005] In recent years, significant progress has been made in the research on the formal verification of code generators or compilers. The CompCert compiler is an outstanding representative of a trustworthy compiler verified formally. It is the first commercially available trustworthy C - language compiler verified formally. This compiler translates an important subset of C into assembly code. Its compilation process is divided into multiple stages. After lexical analysis and some pre - processing processes, the translation correctness of each subsequent stage is proved with the help of the proof assistant Coq, and these proofs can be checked by an independent proof checker. This is the strongest formal verification method to date, reaching the highest level of trustworthiness that people can expect.

[0006] Figure 2 Is a schematic diagram of the overall design architecture of the trustworthy compiler CompCert. After front - end pre - processing, the source language CompCert C is transformed into a simplified intermediate representation Clight, which has eliminated the side - effects of expressions and satisfies semantic determinacy. See Figure 2 The right - hand part of. Starting from Clight, the compiler goes through another 8 intermediate representations and more than 10 transformation passes. The translation correctness of these translation stages has been proved in Coq, and finally, the target assembly code is generated.

[0007] The formal verification of the translation process from Clight to assembly represents the most prominent achievement of the CompCert trustworthy compiler. To provide a more complete chain of trustworthy evidence, since version 2.3 (May 2014), CompCert has also implemented the verification of the correctness of the parsing process, and since version 2.5 (June 2015), CompCert has added the verification of the type checker. The latter mainly verifies its correctness by confirming that it meets the type system definition, specifically referring to the soundness of the type checker. Consider the following functions:

[0008] wt_program(p): p is a well-typed program (AST),

[0009] typecheck_program(p): The type-checking function that returns the resulting program (AST)

[0010] Then the correctness of the type checker can be described as:

[0011]

[0012] Among them, if typecheck_program is only responsible for type checking and does not accompany any translation function, then p = p'.

[0013] However, when the source language features are particularly rich, it may be necessary to perform front-end static semantic checks in multiple stages, and the static check work in some aspects may be delayed until later to be completed. In such cases, the above single typecheck_program function is difficult to meet the development and verification requirements of actual trustworthy compilers or code generator fronts. For example, if a highly trustworthy code generator from the Scade modeling language to the C language is constructed based on formal verification as Figure 1 shown, then such problems will be encountered.

[0014] The Scade modeling language is a synchronous language extended from Lustre. Currently, the long-term projects of formal verification of Lustre-like trustworthy compilers adopting a technical route similar to CompCert at home and abroad mainly include the L2C trustworthy compiler project and the Vélus trustworthy compiler. Currently, the main achievements of L2C and Vélus are still in the translation stage, and the verification work directly targeting front-end static semantic checks lags behind relatively. Although various necessary static check functions are also accompanied in the construction and verification of the translation stage, for the development and verification of highly trustworthy code generators or compilers in engineering applications, complete source-level static semantic checks and their verification are essential.

[0015] The existing translation confirmation methods do not directly verify the translation program. Instead, they use a unified semantic framework to model the source and target codes of the translation process, define a specific semantic equivalence relationship / simulation equivalence relationship between the two models, and design a confirmation program that can automatically prove their equivalence. According to different semantic models, the confirmation program can achieve the equivalence confirmation between models through methods such as automatic solving or proof, symbolic calculation, model checking, static analysis, etc., as Figure 3 shown.

[0016] Figure 3 In the translation confirmation process shown, when the semantic non-equivalence of the front and back intermediate representations is found, the compiler will stop. The two intermediate languages can be the same language. For example, if the translation program is an optimization on a certain intermediate language, in such cases, if the semantic non-equivalence of the front and back intermediate representations is found, it is not necessary to stop the compiler, and this optimization can be abandoned,

[0017] Ideally, the correctness of the confirmation program can be verified. Figure 2 In the register allocation process from RTL to LTL in, an improved graph coloring register allocation algorithm is adopted, and its correctness verification is implemented in the current open-source version of CompCert by using translation confirmation and simultaneously proving the correctness of this confirmation program.

[0018] Let S and C represent the source and target programs of the current translation process respectively, and Comp be the translation function. Then the translation function Comp′ with the confirmation program Validate can be defined as:

[0019]

[0020]

[0021] Therefore, the correctness of the confirmation program Validate can be described as

[0022]

[0023] where

[0024] Translation confirmation is easy to implement the confirmation for a specific property, and the confirmation programs for various properties can be independent of each other. This advantage actually has little presence in the verification of the translation process because the correctness of the translation process generally boils down to semantic preservation, and other properties to be verified are all defined and verified around semantic preservation. On the other hand, the translation confirmation method generally has a potential false alarm problem. Due to these two reasons, the method based on translation confirmation seems to have a lower presence compared to the method that directly verifies the translation process itself.

[0025] Let L and M be the front-end intermediate languages, and assume that the static semantic analysis / checking process of a certain aspect A (i.e., a certain aspect of static semantic properties) is included in the translation process trans from L to M. For aspect A, define the following static semantic goodness predicate:

[0026] w A _L(p): p is an L program with good properties on the side A

[0027] w A _M(p): p is an M program with good properties on the side A

[0028] The correctness of this static semantic analysis / checking process can be described as:

[0029]

[0030] When trans is only used as an analysis / checking process (without any translation function), that is, L and M are the same front-end intermediate language, this is the case in most current trusted compiler front-end designs. For example, in the aforementioned CompCert trusted compiler, its typecheck_program is only responsible for type checking and is not accompanied by any translation function (at this time p'=p), so its correctness can be described as:

[0031]

[0032] Regardless of whether the translation process trans includes a translation function or is merely a static semantic analysis / checking process, in the solutions adopted in the prior art, the translation process trans needs to be reflected in the correctness proof process of the static semantic analysis / checking process.

[0033] In summary, the existing technology for verifying the correctness of the static semantic analysis / checking process in a trusted compiler has the following two shortcomings:

[0034] (1) Lack of consideration of the common situation where static semantic analysis / checking is integrated into the translation process;

[0035] (2) The translation process needs to be reflected in the correctness proof process of the static semantic analysis / checking process, which will lead to poor scalability and cause large-scale modifications to the front-end translation and its proof process when adding new static semantic features.

[0036] In summary, the correctness verification of the static semantic analysis / checking process in the existing trusted compiler lacks consideration of common situations, and the large-scale modification of the front-end translation and its proof process that may be caused by processing the newly added static semantic features needs to be urgently addressed. Summary of the invention

[0037] This application provides a method and system for side-oriented static semantic checking and verification based on translation confirmation to solve the problems that the correctness verification in the existing static semantic analysis / checking process of a trusted compiler lacks consideration of general cases, and large-scale modifications to the front-end translation and its proof process may be caused by handling newly added static semantic features.

[0038] An embodiment of the first aspect of this application provides a method for side-oriented static semantic checking and verification based on translation confirmation, including the following steps: determining a front-end intermediate language L and a front-end intermediate language M, and respectively setting static semantic goodness predicates corresponding to a preset side A through the front-end intermediate language L and the front-end intermediate language M; obtaining a shadow language M' corresponding to the front-end intermediate language M, determining a matching mapping from the shadow language M' to the front-end intermediate language M, and constructing a checking function for translating from the front-end intermediate language L to the shadow language M' and performing static semantic property checking; sequentially combining the checking function and the matching mapping to generate a translation confirmation program that meets the static semantic property checking requirements of the side A, and attaching the translation confirmation program after the translation process from the front-end intermediate language L to the front-end intermediate language M to perform side A-oriented static semantic checking and correctness verification.

[0039] Optionally, in an embodiment of this application, the static semantic goodness predicate corresponding to the side A is:

[0040] w A _L(p): p is an L program with good properties of side A

[0041] w A _M(p): p is an M program with good properties of side A where, w A _L(p) and w A _M(p) respectively represent the static semantic goodness predicates corresponding to the side A set for the front-end intermediate language L and the front-end intermediate language M.

[0042] Optionally, in an embodiment of this application, the checking function satisfies the following logical formula:

[0043]

[0044] where trans_checker represents the checking function; p0 represents any front-end intermediate language L program; p represents any front-end intermediate language M program; OK(p) represents that the checking function ends normally and returns p.

[0045] Optionally, in an embodiment of this application, the matching mapping satisfies the following logical formula:

[0046]

[0047] Among them, matched(p0, p) represents the matching mapping; p0 represents any shadow language M' program; p represents any front-end intermediate language M program; w A _M(p0) represents that p0 satisfies the static semantic well-formedness predicate corresponding to aspect A set for the front-end intermediate language M; w A _M(p) represents that p satisfies the static semantic well-formedness predicate corresponding to aspect A set for the front-end intermediate language M.

[0048] An embodiment of the second aspect of the present application provides a side-oriented static semantic checking and verification system based on translation confirmation, including: a predicate setting module, configured to determine a front-end intermediate language L and a front-end intermediate language M, and respectively set static semantic well-formedness predicates corresponding to a preset aspect A through the front-end intermediate language L and the front-end intermediate language M; a function construction module, configured to obtain a shadow language M' corresponding to the front-end intermediate language M, determine a matching mapping from the shadow language M' to the front-end intermediate language M, and construct a checking function for performing static semantic property checking on a translation from the front-end intermediate language L to the shadow language M'; a correctness verification module, configured to combine the checking function and the matching mapping in sequence to generate a translation confirmation program that meets the static semantic property checking requirements of aspect A, and append the translation confirmation program after the translation process from the front-end intermediate language L to the front-end intermediate language M to perform static semantic checking and correctness verification for aspect A.

[0049] Optionally, in an embodiment of the present application, the static semantic well-formedness predicate corresponding to aspect A is:

[0050] w A _L(p): p is an L program with good properties of aspect A

[0051] w A _M(p): p is an M program with good properties of aspect A where, w A _L(p) and w A _M(p) respectively represent the static semantic well-formedness predicates corresponding to aspect A set for the front-end intermediate language L and the front-end intermediate language M.

[0052] Optionally, in an embodiment of the present application, the checking function satisfies the following logical formula:

[0053]

[0054] Among them, trans_checker represents the said checking function; p0 represents any front-end intermediate language L program; p represents any front-end intermediate language M program; OK(p) means that the said checking function ends normally and returns p.

[0055] Optionally, in an embodiment of the present application, the matching mapping satisfies the following logical formula:

[0056]

[0057] Among them, matched(p0,p) represents the said matching mapping; p0 represents any shadow language M' program; p represents any front-end intermediate language M program; w A _M(p0) means that p0 satisfies the static semantic goodness predicate corresponding to aspect A set for the front-end intermediate language M; w A _M(p) means that p satisfies the static semantic goodness predicate corresponding to aspect A set for the front-end intermediate language M.

[0058] An embodiment of the third aspect of the present application provides a computer-readable storage medium, which stores a computer program. When the program is executed by a processor, it implements the above-mentioned aspect-oriented static semantic checking and verification method based on translation confirmation.

[0059] An embodiment of the fourth aspect of the present application provides a computer program product, including a computer program, and the computer program is executed to implement the above-mentioned aspect-oriented static semantic checking and verification method based on translation confirmation.

[0060] Thus, the embodiments of the present application have the following beneficial effects:

[0061] Embodiments of the present application can determine a front - end intermediate language L and a front - end intermediate language M, and respectively set static semantic well - formedness predicates corresponding to a preset aspect A through the front - end intermediate language L and the front - end intermediate language M; obtain a shadow language M' corresponding to the front - end intermediate language M, determine a matching mapping from the shadow language M' to the front - end intermediate language M, and construct a checking function for performing static semantic property checking on a translation from the front - end intermediate language L to the shadow language M'; combine the checking function and the matching mapping in sequence to generate a translation confirmation program that meets the static semantic property checking requirements of aspect A, and append the translation confirmation program after the translation process from the front - end intermediate language L to the front - end intermediate language M to perform static semantic checking and correctness verification for aspect A. The present application can be used for aspect - oriented static semantic analysis / checking and its correctness verification in the design of trusted compilers, and its universality can better assist in the design and planning of the compilation front - end part in the development of trusted compilers. Thus, it solves the problems that in existing trusted compilers, static semantic analysis / checking and its correctness verification lack consideration of general cases, and large - scale modifications to the front - end translation and its proof process may be caused by handling newly added static semantic features.

[0062] Additional aspects and advantages of the present application will be given in part in the following description, become apparent in part from the following description, or be learned through the practice of the present application. Brief Description of the Drawings

[0063] The above - mentioned and / or additional aspects and advantages of the present application will become apparent and be easily understood from the following description of the embodiments in conjunction with the drawings, where:

[0064] Figure 1 is a schematic diagram of a typical application development process in the field of embedded control;

[0065] Figure 2 is a schematic diagram of the architecture of a formally verified trusted compiler CompCert;

[0066] Figure 3 is a schematic diagram of a translation confirmation process;

[0067] Figure 4 is a flowchart of a method for aspect - oriented static semantic checking and verification based on translation confirmation according to an embodiment of the present application;

[0068] Figure 5 is a schematic diagram of a translation confirmation process for static semantic analysis / checking of a certain aspect according to an embodiment of the present application;

[0069] Figure 6 is an example diagram of a system for aspect - oriented static semantic checking and verification based on translation confirmation according to an embodiment of the present application;

[0070] Among them, 10 - Side - oriented Static Semantic Inspection and Verification System Based on Translation Confirmation; 100 - Predicate Setting Module, 200 - Function Construction Module, 300 - Correctness Verification Module. Detailed implementation manners

[0071] The embodiments of the present application will be described in detail below. Examples of the embodiments are shown in the drawings, where the same or similar reference numerals indicate the same or similar elements or elements with the same or similar functions throughout. The embodiments described below by referring to the drawings are exemplary and are intended to explain the present application and should not be construed as limiting the present application.

[0072] The side - oriented static semantic inspection and verification method and system based on translation confirmation according to the embodiments of the present application will be described below with reference to the drawings. In view of the problems mentioned in the above - mentioned background art, the present application provides a side - oriented static semantic inspection and verification method based on translation confirmation. In this method, by determining the front - end intermediate language L and the front - end intermediate language M, and respectively setting static semantic goodness predicates corresponding to a preset side A through the front - end intermediate language L and the front - end intermediate language M; obtaining the shadow language M' corresponding to the front - end intermediate language M, determining the matching mapping from the shadow language M' to the front - end intermediate language M, and constructing an inspection function for performing static semantic property inspection on the translation from the front - end intermediate language L to the shadow language M'; combining the inspection function and the matching mapping in sequence to generate a translation confirmation program that meets the static semantic property inspection requirements of side A, and attaching the translation confirmation program after the translation process from the front - end intermediate language L to the front - end intermediate language M to perform side - oriented static semantic inspection and correctness verification. The present application can be used for side - oriented static semantic analysis / inspection and its correctness verification in the design of trusted compilers, and its universality can better assist in the design and planning of the compilation front - end part in the development of trusted compilers. Thus, the problems that the correctness verification in the existing static semantic analysis / inspection process of trusted compilers lacks consideration of general cases and that large - scale modifications may be caused to the front - end translation and its proof process due to handling newly added static semantic features are solved.

[0073] Specifically, Figure 4 is a flowchart of a side - oriented static semantic inspection and verification method based on translation confirmation provided by the embodiments of the present application.

[0074] As Figure 4 shown, the side - oriented static semantic inspection and verification method based on translation confirmation includes the following steps:

[0075] In step S401, the front-end intermediate language L and the front-end intermediate language M are determined, and the static semantic well-formedness predicates corresponding to the preset side A are set through the front-end intermediate language L and the front-end intermediate language M respectively.

[0076] In an embodiment of the present application, L and M can be first set as the front-end intermediate languages. Assume that the static semantic analysis / checking process of a certain side A (i.e., a certain aspect of static semantic properties) is included in the translation process trans from L to M, and at the same time, the static semantic well-formedness predicate corresponding to side A is determined.

[0077] Optionally, in an embodiment of the present application, the static semantic well-formedness predicate corresponding to side A is:

[0078] w A _L(p): p is an L program with good properties of side A

[0079] w A _M(p): p is an M program with good properties of side A, where w A _L(p) and w A _M(p) respectively represent the static semantic well-formedness predicates corresponding to side A set for the front-end intermediate language L and the front-end intermediate language M.

[0080] It should be noted that for side A, the embodiments of the present application can define the following static semantic well-formedness predicates:

[0081] w A _L(p): p is an L program with good properties of side A

[0082] w A _M(p): p is an M program with good properties of side A, where w A _L(p) and w A _M(p) respectively represent the static semantic well-formedness predicates corresponding to side A set for the front-end intermediate language L and the front-end intermediate language M.

[0083] Thus, the embodiments of the present application provide reliable data guidance and basis for the subsequent matching mapping and the construction of corresponding functions by determining the static semantic well-formedness predicates corresponding to side A.

[0084] In step S402, the shadow language M' corresponding to the front-end intermediate language M is obtained, the matching mapping from the shadow language M' to the front-end intermediate language M is determined, and a checking function for translating from the front-end intermediate language L to the shadow language M' and performing static semantic property checking is constructed.

[0085] In step S403, the checking function and the matching mapping are combined in sequence to generate a translation confirmation program that meets the requirements for checking the static semantic properties of aspect A, and the translation confirmation program is appended after the translation process from the front-end intermediate language L to the front-end intermediate language M to perform static semantic checking and correctness verification for aspect A.

[0086] Furthermore, an embodiment of the present application also needs to introduce a shadow language M' of M, and there is a matching mapping matched from M' to M; then, as Figure 5 shown, the embodiment of the present application needs to find a translation from L to M' and a checking function trans_checker for performing static semantic property checking of aspect A.

[0087] During the actual execution process, the embodiment of the present application usually defaults that trans_checker is more simplified than trans and is conducive to the correctness verification of the static semantic property checking of aspect A.

[0088] Thus, in the embodiment of the present application, the functions trans_checker and matched are combined in sequence to form a translation confirmation program that meets the requirements for checking the static semantic properties of aspect A. This translation confirmation program is appended after trans, and its correctness can be guaranteed by the matching mapping matched and the function trans_checker. In the construction of a specific trusted compiler, these proofs are usually completed based on formal verification methods and tools.

[0089] Optionally, in an embodiment of the present application, the matching mapping satisfies the following logical formula:

[0090]

[0091] where matched(p0, p) represents the matching mapping; p0 represents any shadow language M' program; p represents any front-end intermediate language M program; w A _M(p0) represents that p0 satisfies the static semantic well-formedness predicate corresponding to aspect A set for the front-end intermediate language M; w A _M(p) represents that p satisfies the static semantic well-formedness predicate corresponding to aspect A set for the front-end intermediate language M.

[0092] In the specific implementation process, the embodiment of the present application introduces a shadow language M' of M, and there is a matching mapping matched from M' to M, satisfying: for any p0, p,

[0093]

[0094] Among them, matched(p0, p) represents a matching mapping; p0 represents any shadow language M' program; p represents any front-end intermediate language M program; w A _M(p0) means that p0 satisfies the static semantic well-formedness predicate corresponding to aspect A set for the front-end intermediate language M; w A _M(p) means that p satisfies the static semantic well-formedness predicate corresponding to aspect A set for the front-end intermediate language M.

[0095] Optionally, in an embodiment of the present application, the check function satisfies the following logical formula:

[0096]

[0097] Among them, trans_checker represents the check function; p0 represents any front-end intermediate language L program; p represents any front-end intermediate language M program; OK(p) means that the check function ends normally and returns p.

[0098] Furthermore, in the embodiment of the present application, a function trans_checker that needs to find a translation from L to M' and perform static semantic property checking for aspect A is required. Then, the embodiment of the present application can prove that for any p0, p, there is:

[0099]

[0100] Among them, trans_checker represents the check function; p0 represents any front-end intermediate language L program; p represents any front-end intermediate language M program; OK(p) means that the check function ends normally and returns p.

[0101] It should be noted that the embodiment of the present application is a general method. The following are two special cases:

[0102] (1) When trans has no substantial impact on the static semantic property check for aspect A, then there is no need to newly introduce the shadow language M' of M, that is, the shadow language can be M itself. At this time, matched can be defined as the identity function, and thus:

[0103]

[0104] naturally holds. It only needs to prove that for any p0, p,

[0105]

[0106] Of course, trans_checker needs to complete translation work similar to trans, plus the static semantic property check for aspect A. Since the latter has no substantial impact on the former, this proof generally does not encounter difficulties.

[0107] (2) When trans degenerates to not perform any translation work (at this time L = M), trans_checker is only responsible for checking the static semantic properties of side A, and only needs to prove that for any p,

[0108]

[0109] This degenerate case corresponds to the current technical status of front-end part verification in the construction of trusted compilers, such as the verification of the typecheck_program in the CompCert trusted compiler.

[0110] In summary, the embodiments of the present application provide a general framework for static semantic analysis / checking based on translation confirmation, which is used for side-oriented static semantic analysis / checking and its correctness verification in the design of trusted compilers. Compared with the prior art, its generality can better assist in the design and planning of the compilation front-end part in the development of trusted compilers, especially when the source language features are particularly rich, it has significant guiding significance for the implementation and verification of multi-stage and multi-side static semantic checking tasks.

[0111] For example, in the L2C trusted compiler project, in the face of numerous new extended features, the embodiments of the present application propose a design scheme for the compilation front-end part, and complete the static semantic checking and its correctness verification work for the important side of "initialization analysis", providing a solid theoretical support for subsequent related work for other multiple sides.

[0112] According to the side-oriented static semantic checking and verification method based on translation confirmation proposed by the embodiments of the present application, by determining the front-end intermediate language L and the front-end intermediate language M, and respectively setting the static semantic goodness predicates corresponding to the preset side A through the front-end intermediate language L and the front-end intermediate language M; obtaining the shadow language M' corresponding to the front-end intermediate language M, and determining the matching mapping from the shadow language M' to the front-end intermediate language M, and constructing a checking function for translating from the front-end intermediate language L to the shadow language M' and performing static semantic property checking; combining the checking function and the matching mapping in sequence to generate a translation confirmation program that meets the static semantic property checking requirements of side A, and attaching the translation confirmation program after the translation process from the front-end intermediate language L to the front-end intermediate language M to perform side-oriented static semantic checking and correctness verification. The present application can be used for side-oriented static semantic analysis / checking and its correctness verification in the design of trusted compilers, and its generality can better assist in the design and planning of the compilation front-end part in the development of trusted compilers.

[0113] Secondly, a side-oriented static semantic checking and verification system based on translation confirmation proposed according to the embodiments of the present application is described with reference to the accompanying drawings.

[0114] Figure 6 It is a block diagram of the side - oriented static semantic checking and verification system based on translation confirmation according to an embodiment of the present application.

[0115] As Figure 6 shown, the side - oriented static semantic checking and verification system 10 based on translation confirmation includes: a predicate setting module 100, a function construction module 200, and a correctness verification module 300.

[0116] Among them, the predicate setting module 100 is used to determine the front - end intermediate language L and the front - end intermediate language M, and respectively set the static semantic goodness predicates corresponding to the preset side A through the front - end intermediate language L and the front - end intermediate language M.

[0117] The function construction module 200 is used to obtain the shadow language M' corresponding to the front - end intermediate language M, determine the matching mapping from the shadow language M' to the front - end intermediate language M, and construct a checking function for translating from the front - end intermediate language L to the shadow language M' and performing static semantic property checking.

[0118] The correctness verification module 300 is used to sequentially combine the checking function and the matching mapping to generate a translation confirmation program that meets the requirements of static semantic property checking for side A, and attach the translation confirmation program after the translation process from the front - end intermediate language L to the front - end intermediate language M to perform side - A - oriented static semantic checking and correctness verification.

[0119] Optionally, in an embodiment of the present application, the static semantic goodness predicate corresponding to side A is:

[0120] w A _L(p): p is an L - program with good properties of side A

[0121] w A _M(p): p is an M - program with good properties of side A. Among them, w A _L(p) and w A _M(p) respectively represent the static semantic goodness predicates corresponding to side A set for the front - end intermediate language L and the front - end intermediate language M.

[0122] Optionally, in an embodiment of the present application, the checking function satisfies the following logical formula:

[0123]

[0124] Among them, trans_checker represents the checking function; p0 represents any front - end intermediate language L - program; p represents any front - end intermediate language M - program; OK(p) means that the checking function ends normally and returns p.

[0125] Optionally, in an embodiment of the present application, the expression for matching mapping is as follows:

[0126]

[0127] where matched(p0, p) represents the matching mapping; p0 represents any shadow language M' program; p represents any front-end intermediate language M program; w A _M(p0) represents that p0 satisfies the static semantic well-formedness predicate corresponding to aspect A set for the front-end intermediate language M; w A _M(p) represents that p satisfies the static semantic well-formedness predicate corresponding to aspect A set for the front-end intermediate language M.

[0128] It should be noted that the foregoing explanation of the embodiments of the aspect-oriented static semantic checking and verification method based on translation confirmation also applies to the aspect-oriented static semantic checking and verification system based on translation confirmation in this embodiment, and will not be elaborated here.

[0129] The aspect-oriented static semantic checking and verification system based on translation confirmation proposed according to the embodiments of the present application includes a predicate setting module 100, configured to determine the front-end intermediate language L and the front-end intermediate language M, and respectively set the static semantic well-formedness predicates corresponding to the preset aspect A through the front-end intermediate language L and the front-end intermediate language M; a function construction module 200, configured to obtain the shadow language M' corresponding to the front-end intermediate language M, determine the matching mapping from the shadow language M' to the front-end intermediate language M, and construct a checking function for performing static semantic property checking on the translation from the front-end intermediate language L to the shadow language M'; a correctness verification module 300, configured to combine the checking function and the matching mapping in sequence to generate a translation confirmation program that meets the static semantic property checking requirements of aspect A, and attach the translation confirmation program after the translation process from the front-end intermediate language L to the front-end intermediate language M to perform aspect-oriented A static semantic checking and correctness verification. The present application can be used for aspect-oriented static semantic analysis / checking and its correctness verification in the design of trusted compilers, and its universality can better assist in the design and planning of the compilation front-end part in the development of trusted compilers.

[0130] The embodiments of the present application further provide a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the above-mentioned aspect-oriented static semantic checking and verification method based on translation confirmation.

[0131] The embodiments of the present application further provide a computer program product, including a computer program, and when the computer program is executed, it is used to implement the above-mentioned aspect-oriented static semantic checking and verification method based on translation confirmation.

[0132] In the description of this specification, the descriptions with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples", etc., mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of this application. In this specification, the schematic representations of the above terms are not necessarily directed to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, without contradiction, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.

[0133] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one of such features. In the description of this application, the meaning of "N" is at least two, such as two, three, etc., unless otherwise specifically defined.

[0134] Any process or method description shown in the flowchart or described in other ways herein may be understood to represent a module, segment, or portion of code including one or N executable instructions for implementing a customized logic function or process, and the scope of the preferred embodiments of this application includes additional implementations, where the functions may be executed in a substantially simultaneous manner or in a reverse order according to the functions involved, rather than in the order shown or discussed, which should be understood by those skilled in the art to which the embodiments of this application pertain.

[0135] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a definite sequence list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or in conjunction with these instruction execution systems, apparatuses, or devices. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection part (electronic device) having one or N wirings, a portable computer disk cartridge (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically by optically scanning the paper or other media, followed by editing, interpretation, or other suitable processing as necessary, and then stored in a computer memory.

[0136] It should be understood that various parts of the present application can be implemented by hardware, software, firmware, or a combination thereof. In the above-described embodiments, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits having logic gate circuits for implementing logical functions on data signals, application-specific integrated circuits having suitable combinational logic gate circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), and the like.

[0137] Those of ordinary skill in the art of this technology can understand that all or part of the steps carried by the methods of the above-described embodiments can be completed by a program instructing relevant hardware, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.

[0138] In addition, each functional unit in various embodiments of the present application may be integrated into a processing module, may exist separately physically for each unit, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. When the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0139] The above-mentioned storage medium may be a read-only memory, a magnetic disk, an optical disc, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present application. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present application.

Claims

1. A side-oriented static semantic checking and verification method based on translation confirmation, characterized in that: The following steps are involved: Determine a front-end intermediate language L and a front-end intermediate language M, and set a static semantic goodness predicate corresponding to a preset aspect A through the front-end intermediate language L and the front-end intermediate language M respectively; Obtain the shadow language M' corresponding to the front-end intermediate language M, determine the matching mapping of the shadow language M' to the front-end intermediate language M, and construct a check function for translating from the front-end intermediate language L to the shadow language M' and performing static semantic property check; The check function and the matching mapping are combined in sequence to generate a translation confirmation program that meets the static semantic property check requirements of the aspect A, and the translation confirmation program is attached to the translation process from the front-end intermediate language L to the front-end intermediate language M to perform static semantic checking and correctness verification for the aspect A.

2. The method according to claim 1, characterized in that The static semantic goodness predicate corresponding to the aspect A is: w A _L(p): p is an L program with good properties on the side A w A _M(p): p is an M program with good properties on the side A Among them, w A _L(p) and w A _M(p) represents the static semantic goodness predicates corresponding to the aspect A set for the front-end intermediate language L and the front-end intermediate language M respectively.

3. The method according to claim 1, characterized in that The check function satisfies the following logical formula: Among them, trans_checker represents the checking function; p0 represents any front-end intermediate language L program; p represents any front-end intermediate language M program; OK(p) represents that the checking function ends normally and returns p.

4. The method according to claim 1, characterized in that: The matching mapping satisfies the following logical formula: Wherein, matched(p0,p) represents the matching mapping; p0 represents any shadow language M' program; p represents any front-end intermediate language M program; w A _M(p0) means that p0 satisfies the static semantic goodness predicate corresponding to the facet A set for the front-end intermediate language M; w A _M(p) indicates that p satisfies the static semantic well-being predicate corresponding to the facet A set for the front-end intermediate language M.

5. A side-oriented static semantic checking and verification system based on translation confirmation, characterized in that: include: A predicate setting module, used to determine a front-end intermediate language L and a front-end intermediate language M, and to set a static semantic goodness predicate corresponding to a preset aspect A through the front-end intermediate language L and the front-end intermediate language M respectively; A function construction module, used to obtain the shadow language M' corresponding to the front-end intermediate language M, determine the matching mapping of the shadow language M' to the front-end intermediate language M, and construct a check function for translating from the front-end intermediate language L to the shadow language M' and performing static semantic property check; A correctness verification module is used to combine the check function and the matching mapping in sequence to generate a translation confirmation program that meets the static semantic property check requirements of the aspect A, and attach the translation confirmation program to the translation process from the front-end intermediate language L to the front-end intermediate language M to perform static semantic checking and correctness verification for the aspect A.

6. The system according to claim 5, characterized in that The static semantic goodness predicate corresponding to the aspect A is: w A _L(p): p is an L program with good properties on the side A w A _M(p): p is an M program with good properties on the side A Among them, w A _L(p) and w A _M(p) represents the static semantic goodness predicates corresponding to the aspect A set for the front-end intermediate language L and the front-end intermediate language M respectively.

7. The system according to claim 5, characterized in that The check function satisfies the following logical formula: Among them, trans_checker represents the checking function; p0 represents any front-end intermediate language L program; p represents any front-end intermediate language M program; OK(p) represents that the checking function ends normally and returns p.

8. The system according to claim 5, characterized in that The matching mapping satisfies the following logical formula: Wherein, matched(p0,p) represents the matching mapping; p0 represents any shadow language M' program; p represents any front-end intermediate language M program; w A _M(p0) means that p0 satisfies the static semantic goodness predicate corresponding to the facet A set for the front-end intermediate language M; w A _M(p) indicates that p satisfies the static semantic well-being predicate corresponding to the facet A set for the front-end intermediate language M.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: The program is executed by a processor to implement the side-oriented static semantic checking and verification method based on translation confirmation as described in any one of claims 1 to 4.

10. A computer program product, comprising a computer program, characterized in that The computer program is executed to implement the side-oriented static semantic checking and verification method based on translation confirmation as described in any one of claims 1 to 4.