Synchronous data stream language trusted compiling method based on formalization method

The Luster language is grammatically recognized and transformed through formal methods and pushdown automata models, combined with semantic verification, which solves the problem that the correctness of Luster compilation results cannot be guaranteed, achieves transparency and automation of the compilation process, and reduces the complexity of verification. , meeting the high security requirements of safety-critical systems.

CN118734320APending Publication Date: 2024-10-01BEIHANG UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410832881.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

In the existing technology, the correctness of the compilation results of the synchronous data flow language Luster cannot be guaranteed, and the verification process is too complicated to ensure that no errors are generated in the compilation.

Method used

Using a compilation method based on formal methods, the Luster language is grammatically recognized and converted by building a pushdown automaton model, and the semantic verification method is used to verify the consistency between the Luster language and the target C code, achieving transparency and automation of the compilation process.

Benefits of technology

It realizes the transparency of the Luster compilation process, can identify and locate grammatical errors, reduces the verification complexity, ensures the correctness of the compilation results, and meets the high security requirements of safety-critical systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118734320A_ABST
    Figure CN118734320A_ABST
Patent Text Reader

Abstract

The invention provides a synchronous data stream language credible compiling method based on a formalization method, and relates to the field of synchronous data stream language credible compilation, the method can perform lexical analysis, syntactic analysis and semantic analysis on an input Lustre program, and then a push-down automaton model is used to generate a target C code; in addition to realizing basic functions of the compiler, translation correctness is verified for semantic equivalence of an input grammar unit and a corresponding target C code grammar unit by using a grammar-based formalization method. The verification process is simplified, the correctness of the compiler is ensured, and the technical problems that the correctness of the compiling result cannot be ensured and the verification process is complex in the prior art are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of trusted compilation of synchronous data flow languages, and in particular to a trusted compilation method of synchronous data flow languages ​​based on a formal method. Background Art

[0002] In the past fifty years, electronic computer technology has developed rapidly, and the integration of industry and computers has become increasingly close. Computers have played a leading role in the development of industrial technology. With the vigorous development of computers in industry, the research of safety-critical systems has become a major topic in the field of industrial control and embedded systems. Safety-critical systems refer to systems whose failure will cause personal danger, huge property losses or social harm. Such systems are widely used in industrial fields, such as aerospace, railways, and automobiles. Safety-critical systems are also widely used in the medical field, such as radiotherapy machines, infusion pumps, medical ventilation systems, etc. In the nuclear power field, which has extremely high requirements for safety, safety-critical systems also play a vital role in the control of nuclear facilities.

[0003] Among them, the compiler, as an important part of system development, builds a bridge between high-level programming languages ​​and machine-readable machine languages, providing codes that can be interpreted by the processor. For example, GCC, one of the most famous open source compilation tools, supports the compilation of multiple languages ​​such as C, C++, Ada, Fortran, etc. Specifically, the compiler is one of the important system software in the entire computer system. All software written in high-level languages ​​must be compiled by the compiler to become executable programs on the computing platform. Some embedded systems, especially those related to safety-critical fields, and even Class A (safety10-9) systems have always been the focus of attention in the design and implementation of software engineering projects in the fields of nuclear industry, aerospace, etc. A Class A safety-critical software must be executable code generated by a Class A compilation system. Therefore, safety-critical compilation is an important guarantee for safety-critical systems.

[0004] Many fields where safety-critical systems are used have high requirements for the response speed of electronic systems. They need to be able to respond to the environment in real time. Such systems can receive input at any time and calculate in real time to obtain output results so as to continuously interact with the environment. The programming language used in such scenarios is mainly synchronous data flow language. Since the programs generated by such languages ​​have high requirements for real-time and reliability, they also have high requirements for compilers, especially in safety-critical systems. SCADE, a commonly used modeling software for embedded systems and control systems, uses a Lustre-like language, which is a typical synchronous data flow modeling language.

[0005] In software development, the process from domain thinking to design model and then to source code is too complicated and prone to various errors. Therefore, domain-specific modeling language (DSML) has been rapidly developed for this situation. This language can safely and efficiently complete software development in specific fields, reducing the complex development process of traditional programming languages. Lustre, as a domain modeling language used in embedded control and signal processing systems, has produced the corresponding industrial software Scade suite. The Scade suite can compile a sublanguage of Simulink / Stateflow into executable code and can be used to develop safety-critical applications such as fly-by-wire controllers and power plant supervision software systems. As the language used by Scade, some features make Lustre suitable for many of the above tasks. Lustre's data flow-based operation mode gives it good semantics and can be used to construct real-time controllers. It also has good traceability and can provide modular programming solutions, which are highly practical in automatic program verification and industrial fields. However, while Scade has high availability as a commercial software, its black box compilation process also makes it impossible to conduct in-depth research on Lustre compilation and ensure that Lustre compilation is error-free.

[0006] Ensuring the correctness and security of software through testing cannot fundamentally solve the security problem and cannot meet the requirements of software systems with high security requirements. Regarding the correctness of the compilation process, it is generally believed that only formal development has the highest correctness and security. In the prior art, there are two main ways to verify the compilation. One is the formal verification of the compiler itself. This method requires proof verification of each step of the entire compilation process of the compiler. It is generally based on high-order logic and uses axioms and derivation rules in the axiom system for derivation verification. It is currently not fully automated and requires professional personnel to intervene in verification. The other is a translation confirmation method, which verifies the source program whether the target code is correctly implemented for the target code produced by each separate compilation process. Translation confirmation can be performed automatically. In order to enable the translation confirmation process to be automatically implemented, it is necessary to establish a general semantic framework for representing the source code and the target point code, describe the semantics of the program through the framework, and formalize the correctness of the program. Finally, the equivalence relationship between the source program and the target program is proved based on semantics. The above two verification schemes cannot guarantee the correctness of the compilation results and the verification process is too complicated. Summary of the invention

[0007] In view of this, an embodiment of the present invention provides a trusted compilation method for synchronous data flow language based on formal methods to solve the technical problems in the prior art that the correctness of the compilation result cannot be guaranteed and the verification process is complicated. The method includes:

[0008] Constructing a push-down automaton model, wherein the push-down automaton model performs grammar recognition on the Lustre language through an automaton recognition algorithm, wherein the grammar recognition process includes recognition, parsing and detection of expressions and statements in the Lustre language, and locating grammar error positions of the Lustre language to obtain the Lustre grammar corresponding to the Lustre language;

[0009] According to a preset template correspondence table between the Lustre grammar and the target C code, converting the Lustre grammar into the target C code;

[0010] A semantics-based formal verification method is used to verify the consistency of the semantics of the Lustre language and the target C code, and a proof sequence for verification is obtained.

[0011] Furthermore, the push-down automaton model performs grammar recognition on the Lustre language through an automaton recognition algorithm, including:

[0012] Performing standardization processing on the Lustre language to obtain a grammar unit of the Lustre language, wherein the standardization processing includes eliminating left recursion, simplifying the EBNF paradigm, and formatting terminal symbols and non-terminal symbols;

[0013] Based on the grammar unit after the standardization process, the push-down automaton model is generated. The push-down automaton model performs grammar recognition on the Lustre language through the automaton recognition algorithm to obtain the Lustre grammar. The Lustre grammar includes a grammar unit sequence of the Lustre language. The grammar unit sequence is used to generate the target C code.

[0014] Furthermore, based on the grammar unit after standardization, a push-down automaton generation algorithm is used to generate the push-down automaton model, wherein the input of the push-down automaton generation algorithm is the production sequence and start state symbol of the context-free grammar, wherein the grammar unit is the basic unit constituting the context-free method.

[0015] Furthermore, the operation logic of the target C code includes simulation sampling, node operation, node output and update data flow.

[0016] Furthermore, converting the Lustre grammar into the target C code according to a preset template correspondence table between the Lustre grammar and the target C code includes:

[0017] Based on the Lustre grammar, the intermediate data and the template correspondence table, the target C code corresponding to each grammar unit of the Lustre grammar is generated, wherein the intermediate data includes a symbol table, a Node table and an auxiliary function table, and the Lustre grammar includes a plurality of the grammar units.

[0018] Furthermore, the use of a semantics-based formal verification method to verify the consistency of the semantics of the Lustre language and the target C code includes:

[0019] Recognize the Lustre language as the Lustre grammar and convert it into Isabelle format;

[0020] Recognize the target C code as C language grammar and convert it into Isabelle format;

[0021] The precondition of the Lustre language is set to be equal to the precondition of the target C code in the Isabelle target code, and the output result is obtained by running the intermediate code. If the output result is equal, the semantics of the Lustre language and the target C code are consistent, and the Lustre language is compiled correctly.

[0022] Furthermore, the semantics-based formal verification method verifies the semantic consistency of the Lustre language and the target C code by means of segmented verification, and the segmented verification is to verify the semantic consistency of the Lustre language and the target C code at different time points separately.

[0023] Compared with the prior art, the beneficial effects that can be achieved by at least one of the above-mentioned technical solutions adopted in the embodiments of this specification include at least: the Lustre compilation method provided by the present invention can recognize grammar and locate error positions and types, thereby realizing transparency of the compilation process; and the semantic consistency of the Lustre language and the target C code is verified using a formal verification-based method, thereby reducing the complexity of verification. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0025] Figure 1 It is a flow chart of a trusted compilation method of a synchronous data flow language based on a formal method provided by an embodiment of the present invention;

[0026] Figure 2 is an example diagram of a pushdown automaton provided by an embodiment of the present invention;

[0027] Figure 3 It is a diagram of a formal verification architecture provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0028] The embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0029] The following describes the implementation methods of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The present application can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that, in the absence of conflict, the following embodiments and the features in the embodiments can be combined with each other. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work belong to the scope of protection of the present application.

[0030] The present invention proposes a trusted compilation method for Lustre language, and verifies the correctness of the method based on the interactive theorem prover Isabelle. The compiler can perform lexical analysis, syntax analysis and semantic analysis on the input Lustre language, and then generate target C code using a push-down automaton model. In addition to realizing the basic functions of the compiler, the semantic equivalence of the input syntax unit and the corresponding target code syntax unit is formally verified to ensure the correctness of the compiler. The Lustre compilation method provided by the present invention can recognize grammar and locate the error position and type, thereby realizing the transparency of the compilation process; the semantic consistency of the Lustre language and the target C code is verified using a formal verification-based method, thereby reducing the complexity of verification.

[0031] In the embodiment of the present invention, Figure 1 As shown in the figure, the trusted compilation method of synchronous data flow language based on formal method includes:

[0032] Step S100: construct a push-down automaton model, wherein the push-down automaton model performs grammar recognition on the Lustre language through an automaton recognition algorithm. The grammar recognition process includes recognition, parsing and detection of expressions and statements in the Lustre language, and locating grammar error positions of the Lustre language to obtain the Lustre grammar corresponding to the Lustre language;

[0033] Specifically, in step S100, a push-down automaton model is first generated based on the Lustre context-free grammar, and the expressions and statements of each grammar unit of the Lustre language are identified, parsed and detected through the push-down automaton model, and grammar checking is implemented, and the location where the error occurs is located and feedback is given, and the Lustre language (source language) is identified as the corresponding Lustre grammar.

[0034] Furthermore, in step S100, the push-down automaton model performs grammar recognition on the Lustre language through an automaton recognition algorithm, including:

[0035] Step S101: performing standardization processing on the Lustre language to obtain a grammar unit of the Lustre language, wherein the standardization processing includes eliminating left recursion, simplifying the EBNF paradigm, and formatting terminal symbols and non-terminal symbols;

[0036] Step S102: Based on the grammar unit after the standardization process, the push-down automaton model is generated. The push-down automaton model performs grammar recognition on the Lustre language through the automaton recognition algorithm to obtain the Lustre grammar. The Lustre grammar includes a grammar unit sequence of the Lustre language. The grammar unit sequence is used to generate the target C code.

[0037] Specifically, in step S101, a push-down automaton model is constructed, and a push-down automaton model with a state callback mechanism and an automaton recognition algorithm are proposed, so as to realize the recognition and analysis of the security features of complex programs. The construction method includes: standardizing the Lustre language; constructing a push-down automaton model; and using a push-down automaton recognition algorithm to perform grammar recognition. In step S101, context-free grammars have the characteristics of being independent of each other, and the union of context-free grammars is still a context-free grammar. The safe Lustre subset is also described by a variety of context-free grammars, and the sentence structure generated by each context-free grammar can be recognized by the corresponding automaton. The Lustre language expression of this sentence structure is the Lustre grammar unit. In order to realize the automatic generation of push-down automata, it is necessary to standardize the grammar units of the Lustre language, mainly including: eliminating left recursion, simplifying the EBNF paradigm, and formatting terminal symbols and non-terminal symbols. The purpose of eliminating left recursion is to prevent infinite loops in the subsequent push-down automaton recognition process; the purpose of simplifying the EBNF paradigm is to convert some symbols representing optional and repeated groupings into equivalent forms that can be recognized by the push-down automaton generation algorithm; the purpose of formatting terminal and non-terminal symbols is to facilitate the push-down automaton to judge the grammar units.

[0038] The grammar units of Lustre before and after partial standardization are shown in Table 1.

[0039] Table 1: Lustre grammar units before and after normalization

[0040]

[0041] Furthermore, in step S102, based on the grammar unit after standardization processing, the push-down automaton model is generated using a push-down automaton generation algorithm, and the input of the push-down automaton generation algorithm is the production sequence and start state symbol of the context-free grammar, wherein the grammar unit is the basic unit constituting the context-free method.

[0042] Each context-free grammar has a corresponding push-down automaton, so the corresponding push-down automaton can be generated based on the standardized grammar units, and then applied to the semantic analysis of the corresponding grammar units. The pseudocode of the push-down automaton generation algorithm is shown in Table 2 below. In the pseudocode of Table 2, the input of the push-down automaton generation algorithm is the production sequence and start state symbol of the context-free grammar. The context-free grammar is input in the form of A→B|C, which means that the non-terminal symbol on the left is replaced by one of the production bodies separated by "|" on the right. The implementation of the push-down automaton generation algorithm includes the following steps:

[0043] 1. The algorithm traverses all productions, and combines the nonterminals that appear on the left side of the production into a nonterminal symbol set nonterminals, and the symbols that do not appear on the left side of the production, that is, the terminals, into a terminal symbol set terminals. In addition, the mapping from all production heads to production bodies needs to be stored in the productions hash table. When there is a "|" in the production body, each production body separated by the "|" needs to be added to the mapping with the same production head as the key;

[0044] 2. Establish the basic states of the push-down automaton, Start, Q, Q_loop and End states, where Start represents the start state of the push-down automaton and End represents the end state. Each step of the push-down automaton requires judging the current state, the read-in element and the top state of the stack. First, you need to set the transitions between the 4 basic states, add a transition from the Start to the Q state, and at the same time, in order to facilitate the judgment of whether there are elements in the stack, add a sentinel symbol Δ to the stack. When the push-down automaton recognizes, if the sentinel symbol is popped out of the stack, the push-down automaton is considered to have successfully recognized; add a transition from the Q to the Q_loop state, and push the starting element (non-terminal symbol) into the stack; add a transition from the Q_loop to the End state, and judge whether the top of the stack is the sentinel symbol Δ. If so, pop out the sentinel symbol Δ, otherwise report an error;

[0045] 3. Based on the previous state transition relationship, traverse each terminal symbol in terminals, add a self-transition from Q_loop state to Q_loop state, and push the terminal symbol into the stack. Each self-transition means that when the current state is Q_loop and the read element is the terminal symbol, add the terminal symbol to the stack and continue to transition back to Q_loop state.

[0046] 4. Traverse each key-value pair in the productions hash table, that is, traverse all production heads and corresponding production bodies, first push the production head into the stack, then start from the Q_loop state, and add the elements of the production body to the state transition diagram in reverse. For example, for production A→BC, first add the transition from Q_loop to state A and push A into the stack, then add the transition from state A to state C and push state C into the stack, then add the transition from state C to state B and push state B into the stack, finally add the transition from state B to state Q_loop, and pop the production head A. After these steps, the required push-down automaton can be generated.

[0047] Table 2: Pseudocode of pushdown automaton generation algorithm

[0048]

[0049]

[0050]

[0051] Furthermore, after all the push-down automata are generated by traversing all the grammar units of the Lustre language, the push-down automaton recognition process can begin. The recognition of the push-down automaton is based on the previous lexical analysis and push-down automaton data. The lexical analysis will obtain the lexical unit stream of the source program. The push-down automaton recognition program will match and run the lexical unit stream and the push-down automaton elements, and finally construct a grammar unit sequence for subsequent target code generation. The push-down automaton recognition algorithm can automatically convert the grammar units of Lustre v6 into corresponding push-down automata. The push-down automaton model example is shown in the figure below. Figure 2As shown in the figure, after the lexical analysis outputs the lexical unit stream, the program first enters the Start state, at which time the sentinel Δ is pushed into the empty stack and the program enters the Q state, and then the IfExpression state is pushed into the Q_loop state. The Q_loop state has two paths to choose from at this time. The first is to process the reserved word terminal, that is, the three self-conversions related to if, then, and else in Q_loop. Although if matches the input element in this path, the top of the stack does not match if and cannot be selected. The other path is to choose to reach the IfExpression1 state. If matches the current input element and the top of the stack also matches IfExpression, so this path is selected. After that, it will go through IfExpression1, IfExpression2, IfExpression3, IfExpression4, IfExpression4 states in turn and finally return to the Q_loop state. During each conversion process, Expression2, else, Expression1, then, and LogicExpression will be pushed into the stack. Among them, Expression2, Expression1, and LogicExpression will be used as non-terminal symbols and enter the push-down automaton corresponding to the grammar unit for further processing, while the terminal symbol will be processed in O_loop. The push-down automaton recognition algorithm is shown in Table 3 below.

[0052] Table 3: Pushdown automaton recognition algorithm

[0053]

[0054]

[0055] Step S200: converting the Lustre grammar into the target C code according to a preset template correspondence table between the Lustre grammar and the target C code;

[0056] Specifically, after the Lustre grammar recognition is completed, the Lustre grammar is converted into the corresponding C language grammar according to the template correspondence table between the constructed Lustre grammar unit and the target C code, and the C language grammar is converted into the corresponding target C code according to the semantics carried by the context. The logical framework of the target C code running corresponding to the Lustre grammar unit is as follows: Figure 3 shown.

[0057] Furthermore, the target code operation logic is divided into four steps, namely, simulation sampling, node operation, node output, and updating data flow. Simulation sampling is used to simulate the process of sampling data from the external environment and introducing it into the system by the control / embedded system. In the target code mode, standard input is used to read data. Node operation is the main logic part of Lustre. Each Lustre program needs to select the main node to run before compilation. The main node is the entry point for program operation. The main node includes parameter and variable declarations and equation operations. The control logic and operation logic of the Lustre program are completed by equations and expressions. The target code of the main node corresponds to the main function of the C program. The target code of the declaration and equation parts needs to be represented independently. The result output is the part used by Lustre to feedback the operation results. The target code uses standard output to output the results to the console. The last step is to update the data flow, that is, to update the value of each clock variable. The target code of the clock variable is represented by a C language structure, in which a variable is used to record the value of the clock in the previous cycle, and the value of the clock is updated after each operation.

[0058] Table 4 below shows the target code patterns corresponding to some Lustre grammar units.

[0059] Table 4: Target code patterns corresponding to some Lustre grammar units

[0060]

[0061] The target code mode provides a template of the target C code after compiling different grammar units. Based on the Lustre grammar, the intermediate data and the template correspondence table, the target C code corresponding to each grammar unit of the Lustre grammar is generated, wherein the intermediate data includes a symbol table, a Node table and an auxiliary function table, and the Lustre grammar includes multiple grammar units.

[0062] Step S300: Use a semantics-based formal verification method to verify the consistency of the semantics of the Lustre language and the target C code, and obtain a proof sequence for verification.

[0063] Furthermore, in step S300, the semantics-based formal verification method is used to verify the consistency of the Lustre language and the target C code, including:

[0064] Step S301, identifying the Lustre language as the Lustre grammar and then converting it into the Isabelle format;

[0065] Step S302, identifying the target C code as C language grammar and then converting it into Isabelle format;

[0066] Step S303: Set the precondition of the Lustre language to be equal to the precondition of the target C code in the Isabelle target code, and obtain the output result by running the intermediate code. If the output result is equal, the semantics of the Lustre language and the target C code are consistent, and the Lustre language is compiled correctly.

[0067] Specifically, in order to verify the correctness of the above compilation method, Isabelle-assisted formal verification of compilation is used. The formal verification module verifies the semantic consistency of the source Lustre language segment and the corresponding target C language in grammar units, and gives a proof sequence of verification to complete the verification of the compiler. The proof sequence is generated by the consistency of the preconditions of the source grammar and the target grammar, and the preconditions and postconditions of the target grammar are deduced to finally obtain the postconditions of the original grammar, which ensures the correctness and reliability of the formal verification. The semantic-based formal verification method needs to be deduced based on the semantics of the source language and the target language, and then the semantic consistency is judged to derive the correctness of the compilation. In this application, the semantics of some grammar units of Lustre are shown in Table 5, and the semantics of the target C language grammar units are shown in Table 6.

[0068] Table 5: Lustre grammar unit semantics

[0069]

[0070]

[0071] Table 6: Objective C language core grammar unit semantics

[0072]

[0073] Furthermore, the process of using a semantics-based formal verification method to verify the consistency of the semantics of the Lustre language and the target C code includes: identifying the Lustre language as a corresponding Lustre grammar and then converting it into the Isabelle format; identifying the target C code as a grammar and then converting it into the Isabelle format; in the Isabelle target code, the preconditions of the Lustre code and the corresponding C code are made equal, for example, the input parameter values ​​of the node nodes are made equal, and the outputs are equal after the intermediate code to prove the semantic consistency of the two, that is, the correctness of the compilation, such as Figure 3 Formal verification architecture diagram.

[0074] Furthermore, the semantics-based formal verification method verifies the semantic consistency of the Lustre language and the target C code by means of segmented verification, and the segmented verification is to verify the semantic consistency of the Lustre language and the target C code at different time points separately.

[0075] Preferably, since Lustre is a data flow language and contains many operators with different values ​​in the first cycle and subsequent cycles, such as the arrow operator, expression1 arrow expression2 means that the value of expression1 is taken in the first cycle, otherwise the value of expression2 is taken, etc., so the verification is carried out in a segmented verification manner: each time only verifies the correctness of the compilation at a certain time point. Taking the first cycle as the starting cycle, the precondition is that the input parameter values ​​are equal, and the postcondition is that the output parameter values ​​are equal; for all cycles except the first cycle, the precondition needs to add the output parameter values ​​of the previous cycle Lustre and C are equal, and then prove that the output is equal. In general, a recursive verification method is adopted, that is, the postcondition of the first cycle is brought into the precondition of the second cycle, and after verifying that the postcondition of the second cycle is equal, it is brought into the precondition of the third cycle, and so on, and then the data of each cycle of the Lustre data flow and the C data flow obtained by the compilation conversion are equal. The proof sequence example is shown in Table 7.

[0076] Table 7: Example of proof sequence

[0077]

[0078]

[0079] In summary, the embodiments of the present invention achieve the following technical effects:

[0080] 1. The Lustre compiler development process in this application complies with the DO-178C standard to ensure safety and reliability. For Lustre code, a single grammar can be identified and printed, and the error location and type can be quickly located, making the compilation process transparent;

[0081] 2. The correctness of existing compilation results cannot be guaranteed or the verification process is too complicated. For example, SCADE's KCG is a commercial software based on Lustre, and the compilation process is black box, and the correctness of the compilation cannot be guaranteed. In addition, most of the verification of Lustre compilation is achieved by verifying the compiler itself. The process is relatively complicated and has poor scalability. Any modification to the compiler will require re-verification of the entire compiler. This application uses a systematic and automated method based on formal verification, which reduces the complexity of verification. At the same time, it can realize the automatic generation of Isabelle proof sequences, greatly reducing the development cost of verification;

[0082] 3. This application checks whether the program is well-clocked while checking the grammatical correctness of the Lustre program; a translation method based on templates and push-down automata is used.

[0083] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A trusted compilation method for synchronous data flow language based on formal methods, characterized in that: The method comprises: Constructing a push-down automaton model, wherein the push-down automaton model performs grammar recognition on the Lustre language through an automaton recognition algorithm, wherein the grammar recognition process includes recognition, parsing and detection of expressions and statements in the Lustre language, and locating grammar error positions of the Lustre language to obtain the Lustre grammar corresponding to the Lustre language; According to a preset template correspondence table between Lustre grammar and target C code, converting the Lustre grammar into the target C code; A semantics-based formal verification method is used to verify the consistency of the semantics of the Lustre language and the target C code, and a proof sequence for verification is obtained.

2. The method for trusted compilation of synchronous data flow language based on formal method according to claim 1, characterized in that: The push-down automaton model performs grammar recognition on the Lustre language through an automaton recognition algorithm, including: Performing standardization processing on the Lustre language to obtain a grammar unit of the Lustre language, wherein the standardization processing includes eliminating left recursion, simplifying the EBNF paradigm, and formatting terminal symbols and non-terminal symbols; Based on the grammar unit after the standardization process, the push-down automaton model is generated. The push-down automaton model performs grammar recognition on the Lustre language through the automaton recognition algorithm to obtain the Lustre grammar. The Lustre grammar includes a grammar unit sequence of the Lustre language. The grammar unit sequence is used to generate the target C code.

3. The method for trusted compilation of synchronous data flow language based on formal method according to claim 2, characterized in that: Based on the grammar unit after standardization, the push-down automaton model is generated using a push-down automaton generation algorithm, the input of the push-down automaton generation algorithm is a production sequence and a start state symbol of a context-free grammar, wherein the grammar unit is a basic unit constituting the context-free grammar.

4. The method for trusted compilation of synchronous data flow language based on formal method according to claim 1, characterized in that: The operation logic of the target C code includes simulation sampling, node operation, node output and update data flow.

5. The method for trusted compilation of synchronous data flow language based on formal method according to claim 1, characterized in that: The converting the Lustre grammar into the target C code according to a preset template correspondence table between the Lustre grammar and the target C code includes: Based on the Lustre grammar, the intermediate data and the template correspondence table, the target C code corresponding to each grammar unit of the Lustre grammar is generated, wherein the intermediate data includes a symbol table, a Node table and an auxiliary function table, and the Lustre grammar includes a plurality of the grammar units.

6. The method for trusted compilation of synchronous data flow language based on formal method according to claim 1, characterized in that: The using of a semantics-based formal verification method to verify the consistency of the semantics of the Lustre language and the target C code includes: Recognize the Lustre language as the Lustre grammar and convert it into Isabelle format; Recognize the target C code as C language grammar and convert it into Isabelle format; The precondition of the Lustre language is set to be equal to the precondition of the target C code in the Isabelle target code, and the output result is obtained by running the intermediate code. If the output result is equal, the semantics of the Lustre language and the target C code are consistent, and the Lustre language is compiled correctly.

7. The method for trusted compilation of synchronous data flow language based on formal method according to claim 6, characterized in that: The semantics-based formal verification method verifies the semantic consistency of the Lustre language and the target C code by means of segmented verification, and the segmented verification is to verify the semantic consistency of the Lustre language and the target C code at different time points separately.

Citation Information

Cited By

  • Synchronous data stream language trusted translation method combined with 8114 criterion

    CN119597276A

  • A Reliable Translation Method for Synchronous Data Stream Languages ​​Based on the 8114 Criterion

    CN119597276B