Biological sequence analysis algorithm recursive relation conversion method, tool and system

Through the automated recursive relationship conversion method, the recursive relationship of the biological sequence analysis algorithm is converted into an Isabelle function, which solves the problem of inefficiency of traditional methods and improves the efficiency and convenience of verification of biological sequence analysis algorithms.

CN118963760AInactive Publication Date: 2024-11-15JIANGXI NORMAL UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410969721.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2024-11-15
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional methods cannot automate the recursive conversion of biological sequence analysis algorithms, which is related to the transformation of Isabelle functions, resulting in inefficiency and needs to be completed manually, affecting the efficiency and correctness of algorithm verification.

Method used

Design a biological sequence analysis algorithm recursive relationship conversion method, and convert recursive relationships into Isabelle functions through lexical analysis, grammatical analysis and semantic analysis, including lexical analysis, grammatical tree construction, semantic analysis and code conversion to generate a complete Isabelle Theoretical document, automate the process.

Benefits of technology

It improves the efficiency and convenience of biological sequence analysis algorithm verification, reduces users' cumbersome tasks in low-level language conversion, improves the efficiency of proof work, and allows users to focus more on theoretical proof.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118963760A_ABST
    Figure CN118963760A_ABST
Patent Text Reader

Abstract

The invention discloses a biological sequence analysis algorithm recursive relationship conversion method, tool and system, and the method comprises the steps: carrying out the lexical analysis and grammatical analysis of recursive relationships needing to be converted, and carrying out the semantic analysis of a syntax tree of each recursive relationship; code conversion is carried out according to the number loop of the recursion relation, and Isable functions with the equivalent number are obtained based on simplified grammar and related information in each loop; and supplementing necessary heads and tails of the Isable function to form a complete Isable theory, and finally outputting an Isable theory file. The method can be used for completing automatic conversion from a biological sequence analysis algorithm recursion relation to an Isable function, and the efficiency and convenience of certification work are greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology and relates to a method, tool and system for converting recursive relations of biological sequence analysis algorithms. Background Art

[0002] As the core of the software system, the reliability of the algorithm is particularly critical, and it is of great significance to ensure the correctness of the algorithm. Traditional software testing and other methods can only prove that there are errors in the algorithm, but cannot completely eliminate the errors. In contrast, formal verification can ensure the correctness of development by proving the logical relationship between different formal specifications. Therefore, mathematical proof is required to construct a correct algorithm, and credibility is ensured by formal verification of the constructed algorithm.

[0003] Isabelle is a general system for implementing logic. The key to using Isabelle is to create theories. After formally constructing an algorithm, you need to define related functions in Isabelle to verify the correctness of the constructed algorithm. The main body of the algorithm is obtained based on the recursive relationship. The correctness of the main body of the algorithm can be guaranteed by verifying the recursive relationship, which requires converting the recursive relationship into a function in Isabelle. This part of the work is often done manually, with a low degree of automation, which greatly reduces the efficiency of formal verification of the algorithm. Summary of the invention

[0004] In view of the shortcomings of existing research, the conversion from recursive relations to Isabelle theory still needs manual conversion, which is inefficient. The present invention proposes a biological sequence analysis algorithm recursive relation conversion method, tool and system, which are used to complete the automatic conversion from the biological sequence analysis algorithm recursive relation to the Isabelle function, expand the biological sequence component BioSeq to the Isabelle type library, and improve the convenience of biological sequence analysis algorithm verification. The present invention can free users from the tedious task of completing low-level language conversion, allowing them to focus on the proof of the theory, thereby greatly improving the efficiency and convenience of the proof work.

[0005] The present invention is implemented by the following technical solutions: A biological sequence analysis algorithm recursive relationship conversion method, comprising the following steps:

[0006] S1. The recursive relation to be converted is subjected to lexical analysis and grammatical analysis to determine whether it conforms to the lexical and grammatical rules written based on the grammatical analysis generation tool (antrl). If it conforms, a grammatical tree of the recursive relation is obtained; if it does not conform, an error message is transmitted and error handling is performed;

[0007] S2. Perform semantic analysis on the syntax tree of each recursive relation to determine whether it complies with the semantics, that is, whether the type of the declaration part is consistent with the recursive relation part and whether it satisfies the operation rules of the expression. If so, unnecessary branches are cut off to obtain a simplified syntax tree and related information such as variable declarations; if not, an error message is transmitted and error handling is performed;

[0008] S3, code conversion is performed according to the number of recursive relations, and an equivalent number of Isabelle functions are obtained based on simplified syntax and related information in each loop;

[0009] S4. Supplement the necessary header and tail of the Isabelle function to form a complete Isabelle theory, and finally output the Isabelle theory file.

[0010] Further preferably, in step S1, the input recursive relationship character sequence is scanned by a lexical analyzer, and the characters are marked and classified according to predefined lexical rules. If an unrecognizable mark is encountered, it is regarded as a lexical error and error handling is performed; if no unrecognizable mark is encountered, the input recursive relationship character sequence is converted into a mark sequence.

[0011] Further preferably, the lexical analyzer is automatically generated by a syntax analysis generation tool (antrl) according to the written lexical analysis.

[0012] Further preferably, the grammar is a grammatical form of a recursive relation, which is divided into two parts: a declaration and a recursive relation expression, wherein the declaration part is in the following form:

[0013] |[in: variable declaration; out: function declaration]|

[0014] Here, in and out are keywords, followed by variable declarations, which specify all variable names mentioned in the recursive relation and their corresponding variable types, and function declarations, which specify the function name and the type of its calculation result.

[0015] Further preferably, the recursive relation part has the following two forms:

[0016] Function name (input variable): = expression, only one expression;

[0017] Function name (input variable): = expression {condition} | ... | expression {condition}, there are multiple expressions;

[0018] The whole of the function name (input variable) is called a function, where the input variable includes the set of all input variables; when there is only one expression on the right side of the equation, the corresponding condition can be omitted. When there are multiple expressions, it is required to indicate under what conditions the recursive function takes the value of the expression, corresponding to the two forms of the above recursive relationship respectively; the expression is a Boolean expression or a mathematical expression, and the condition is a Boolean expression. When the Boolean expression is true, the value taken is the calculation value of the expression corresponding to the condition; the expression is the operation between basic data, variables and functions.

[0019] Further preferably, the semantic analysis in step S2 includes:

[0020] S2-1: Scan the syntax tree of the recursive relation from front to back, and store the scanned variables, variable types, functions, and function types into key-value pair data types, with variable names and function names as key data and corresponding types as value data;

[0021] S2-2: Analyze whether the following requirements are met: ① In the current recursive relation, all variables must be variables declared in the variable declaration part of the recursive relation; ② The expression part requires that the data must be of the same type for operation, and numbers and Boolean types cannot be operated; ③ In the right half of the equation of the recursive relation, the function that appears can only be the function on the left side of the equation or the function on the left side of the equation in the previous recursive relation. If it is a function that appears later, it is considered undeclared; similarly, if it does not meet the requirements, an error message will be transmitted, marked as a semantic error, and error handling will be performed to tell the user the error message, quickly locate the code error location and correct it; if it meets the requirements, continue scanning;

[0022] S2-3: During the scanning process, delete separators such as ";" and "|", and determine whether the function on the left side of the equation appears on the right side of the equation. If it appears, mark the recursive relationship as a recursive function; if it does not appear, mark it as a non-recursive function for code conversion, and finally obtain a simplified syntax tree and various related information, including tag information and the key-value pair data type in step S2-1.

[0023] Further preferably, the code conversion in step S3 includes:

[0024] S3-1: According to the relevant information obtained in step S2, the function declaration part in the Isabelle function is obtained. The function declaration includes a declaration keyword, a function name, a function parameter type, and a function return value type. The declaration keyword is determined from the tag information obtained in step S2 to be a non-recursive function keyword or a recursive function keyword. If it is a non-recursive function, the non-recursive function keyword is obtained. If it is a recursive function, the recursive function keyword is obtained. The function name, function parameter type, and return value type are all obtained from the key-value pair data type in step S2, wherein the function name does not need to be converted, and the function parameter type and return value type need to be converted to the Isabelle type according to the variable type conversion rules;

[0025] S3-2: According to the tag information obtained in step S2 and the simplified syntax tree, the function body part of the Isabelle function is obtained. First, determine whether the tag information is a non-recursive function or a recursive function:

[0026] ① If the tag is a non-recursive function, the left and right brackets of the recursive relation are removed, a space is added after the function name, and the comma separators between all input variables are replaced with spaces. The input variables are converted into Isabelle variables according to the variable conversion rules; the equal sign is replaced by ":="; if there is only one expression on the right side of the equation, it is directly converted into an expression in Isabelle according to the expression conversion rules in the expression conversion rule table. If there are two expressions, "expression 1 {condition 1} | expression 2 {condition 2}" is converted into "if (condition 1) expression 1 else expression 2", and each expression and condition must be converted into an expression and condition in Isabelle according to the expression rules in Table 1. If there are more than two expressions, "expression 1 {condition 1} | expression 2 {condition 2} | ... | expression k {condition k}" is converted into "if (condition 1) expression 1 else if (condition 2) expression 2 else if ... else if (condition k-1) expression k-1 else expression k", and similarly, each expression and condition must be converted into an expression and condition in Isabelle according to the expression conversion rules in Table 1;

[0027] ② If the tag is a recursive function, then "function name (input variable): = expression 1 {condition 1} | expression 2 {condition 2} | ... | expression k {condition k}" is converted to "function name input variable 1 = expression 1 | ... | function name input variable k-1 = expression k-1 | function name input variable = expression k", where input variable 1 to input variable k-1 are all obtained by replacing the input variables according to the conditions corresponding to the expressions, and expression k is a general case, and the input variable does not need to be replaced. In addition, all input variables and expressions are converted into Isabelle variables and expressions according to the variable conversion rules and expression conversion rules respectively;

[0028] S3-3: Concatenate the function declaration part in step S3-1 and the function body part in step S3-2, separated by a carriage return, to obtain a complete Isabelle function.

[0029] The present invention provides a recursive relation conversion tool for a biological sequence analysis algorithm, comprising: a recursive relation module, the purpose of which is to convert a single recursive relation input into a corresponding Isabelle function, and to determine whether to call a non-recursive function module or a recursive function module according to grammatical structure information obtained by semantic analysis; if the non-recursive function module is called, the conversion result is the conversion result of the non-recursive function module; if the recursive function module is called, the conversion result is the conversion result of the recursive function module;

[0030] The non-recursive function module is used to convert recursive relations marked as non-recursive functions in semantic analysis into non-recursive functions in Isabelle;

[0031] The recursive function module is used to convert recursive relations marked as recursive functions in semantic analysis into recursive functions in Isabelle;

[0032] Function declaration module is used to convert the function declaration part. The uncertain part is the definition / fun keyword, parameter type and return value type. The keyword part can be determined by the semantic analysis mark to determine whether it is converted into definition or fun. The parameter type and return value type of the recursive relationship are obtained through the variable name list and function name in the key-value pair type. Here, the variable type module needs to be called to obtain the Isabelle type, and finally the various results are spliced ​​into the above function declaration form;

[0033] The recursive function body module is divided into two parts: the left side of the equation and the right side of the equation. The left side of the equation temporarily calls the function module, and then replaces the function parameters according to the conditions of each expression. Else indicates the general situation, the function parameters remain unchanged, and the expression module is called on the right side of the equation. The recursive function body module conversion rules are as follows:

[0034] f(c)=e1{c1}|e2{c2}|…|e k {else}=>f C1=E1|f C2=E2|...|f C=e k

[0035] Among them, e1, e2, …, e k are the 1st, 2nd, ..., kth expressions, E1, E2, ..., E k are the results of calling the expression module respectively; c, c1 and c2 are the conditions of the expression, and C, C1 and C2 are the results of calling the conditional module; else is a special conditional statement defined, indicating other situations of all conditional disjunctions;

[0036] The non-recursive function body module is also divided into the conversion of the left side of the equation and the right side of the equation. The left side of the equation can call the function module. If the right side of the equation is only an expression, the mathematical expression module or the Boolean expression module is directly called. If there are multiple expressions, the conversion rules are as follows:

[0037] e1{c1}|e2{else}=>if C1 E1 else E2

[0038] e1{c1}|e2{c2}|…|e k {else}=>if C1 E1 else if C2 E2…else E k

[0039] Among them, the else in the conversion result is a keyword, which means otherwise in Isabelle;

[0040] The conditional module is used to convert the condition corresponding to each expression into Isabelle's logical statement and extract the condition in the brackets {}, that is, the Boolean expression. The output result of the conditional module is the output result of calling the Boolean expression module.

[0041] The mathematical expression module is used to convert the mathematical expression in the recursive relation into the corresponding expression in Isabelle; the Boolean expression module is used to convert the Boolean expression in the recursive relation into the corresponding expression in Isabelle; the mathematical expression module and the Boolean expression module are collectively referred to as the expression module; the expression module conversion rules are unified as follows:

[0042] e=>E, if e is an expression;

[0043] e=>F, if e is a function;

[0044] e=>V, if e is a variable;

[0045] e=>N, if e is a number;

[0046] max(e1,e2)=>(max E1 E2), maximum value operation expression;

[0047] min(e1,e2)=>(min E1 E2), minimum value operation expression;

[0048] e1 op e2=>(E1 op E2), general operation expression;

[0049] Among them, max means taking the maximum value between the two, and min means taking the minimum value between the two; op is a numeric operator including +, -, ×, ÷, etc. and a logical operator including ∧, ∨, and, or, etc., and the data must be of the corresponding type; F, V and N are the conversion results of the corresponding modules of function, variable and number call respectively;

[0050] Function module is used to convert the function in the recursive relation into the corresponding function in Isabelle. The function module conversion rules are as follows:

[0051] f(v1,v2,…,v k )=>f V1 V2…V k ;

[0052] Where f is the function name; v1, v2, …, v k are variable parameters, V1, V2, …, V k The result of the conversion for which the variable module is called;

[0053] The variable module is used to implement variable conversion. It chooses to call a single variable submodule or a compound variable submodule according to the syntax tree. The conversion rules of the variable module are as follows:

[0054] sv=>SV, single variable;

[0055] cv(v)=>V CV, composite variable;

[0056] Wherein, v represents a set of single variables and composite variables, sv represents a single variable, cv represents a composite variable, and V, SV, and CV are the results of their conversion according to the conversion rules in the conversion rule table.

[0057] The variable type module is used to convert the variable type in the recursive relationship into the equivalent Isabelle theory type. The conversion is performed according to the variable type conversion rules. The data in the variable type conversion rule table is stored in the key-value pair data type in the form of a string. When a variable type is encountered, the variable type module is called to obtain the corresponding Isabelle theory type data according to the variable type key-value pair data of the recursive relationship.

[0058] The present invention provides a non-volatile computer storage medium, which stores computer executable instructions. The computer executable instructions can execute a biological sequence analysis algorithm recursive relationship conversion method in the above embodiment.

[0059] The present invention provides a biological sequence analysis algorithm recursive relationship conversion system, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned biological sequence analysis algorithm recursive relationship conversion method.

[0060] In order to automate some manual operations in the formal verification of biological sequence analysis algorithm programs, the present invention designs a simple recursive relationship description grammar, analyzes the structural characteristics between the problem-solving recursive relationship and the Isabelle function described by the grammar, designs corresponding conversion rules, and obtains a conversion method from the recursive relationship of the biological sequence analysis algorithm to the Isabelle theory, and develops a conversion tool that supports this method. The main functions of the conversion tool are: input one or more recursive relationships from the keyboard or file; perform lexical, grammatical and semantic analysis on all recursive relationships, and prompt error messages; convert the recursive relationship with correct form and grammar into the corresponding Isabelle function.

[0061] The new types expanded by the present invention can facilitate the verification of bioinformatics algorithms, without the need to redefine some commonly used bioinformatics types and functions, thereby improving the efficiency of bioinformatics algorithm verification work to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Figure 1 It is a flow chart of the present invention.

[0063] Figure 2 Schematic diagram of the recursive relationship conversion tool for biological sequence analysis algorithms. DETAILED DESCRIPTION

[0064] The present invention will be further described in detail below with reference to the accompanying drawings.

[0065] Reference Figure 1 , a biological sequence analysis algorithm recursive relationship conversion method, comprising the following steps:

[0066] S1. The recursive relation to be converted is subjected to lexical analysis and grammatical analysis to determine whether it conforms to the lexical and grammatical rules written based on the grammatical analysis generation tool (antrl). If it conforms, a grammatical tree of the recursive relation is obtained; if it does not conform, error information (error type and error position) is transmitted for error handling;

[0067] S2. Perform semantic analysis on the syntax tree of each recursive relation to determine whether it complies with the semantics, that is, whether the type of the declaration part is consistent with the recursive relation part and whether it satisfies the operation rules of the expression (only the same type can be operated). If it complies, unnecessary branches are cut off to obtain a simplified syntax tree and related information such as variable declaration; if it does not comply, error information (error type and error position) is transmitted and error handling is performed;

[0068] S3, code conversion is performed according to the number of recursive relations, and an equivalent number of Isabelle functions are obtained based on simplified syntax and related information in each loop;

[0069] S4. Supplement the necessary header and tail of the Isabelle function, including necessary keywords and statements for importing sub-theories, etc., to form a complete Isabelle theory, and finally output the Isabelle theory file.

[0070] In step S1, the input recursive relationship character sequence is scanned by a lexical analyzer, and the characters are marked and classified according to predefined lexical rules, such as keywords, identifiers, symbols, operators, etc. If an unrecognizable tag is encountered, it is regarded as a lexical error and error processing is performed; if not encountered, the input recursive relationship character sequence is converted into a tag sequence. The lexical analyzer is automatically generated by the syntax analysis generation tool (antrl) according to the written lexical. The lexical is mainly the lexical rules of separators, keywords, operators and identifiers. In simple terms, it explains what kind of character arrangement and combination each tag should be, such as the identifier must be a combination of letters or numbers, and the first one must be a letter.

[0071] In step S1, the syntax analyzer recognizes the tag sequence as a meaningful sentence according to predefined syntax rules, and checks the grammatical correctness of the tags. If the syntax is correct, a syntax tree is constructed according to the syntax rules (the number of recursive relations input is the number of recursive relation sub-syntax trees); if not, it is regarded as a syntax error and error handling is performed.

[0072] The parser is automatically generated by the grammar analysis generation tool (antrl) according to the written grammar. The grammar is the grammatical form of recursive relations, which is divided into two parts: declaration and recursive relation. The declaration part is as follows:

[0073] |[in: variable declaration; out: function declaration]|

[0074] Here, in and out are keywords, followed by variable declarations, which specify all variable names mentioned in the recursive relation and their corresponding variable types, and function declarations, which specify the function name and the type of its calculation result.

[0075] The recursive relation part has the following two forms:

[0076] Function name (input variable): = expression, only one expression;

[0077] Function name (input variable): = expression {condition} | ... | expression {condition}, there are multiple expressions;

[0078] The function name (input variable) as a whole is called a function, where the input variable includes the set of all input variables; when there is only one expression on the right side of the equation, the corresponding condition can be omitted. When there are multiple expressions, it is required to indicate under what conditions the recursive function takes the value of the expression, corresponding to the two forms of the above recursive relationship respectively; the expression can be a Boolean expression or a mathematical expression, and the condition is a Boolean expression. When the Boolean expression is true, the value taken is the calculation value of the expression corresponding to the condition; the expression can be an operation between basic data (numbers or true or false), variables (number variables or Boolean variables) and functions (functions with calculation result types of numbers or Boolean types).

[0079] After lexical and grammatical analysis, it can be ensured that the recursive relation conforms to lexical and grammatical rules, but it cannot be guaranteed to conform to the current semantics and the syntax tree still has some redundant nodes. Therefore, the semantic analysis described in step S2 of the present invention includes:

[0080] S2-1: Scan the syntax tree of the recursive relation from front to back, and store the scanned variables, variable types, functions, and function types into key-value pair data types, with variable names and function names as key data and corresponding types as value data;

[0081] S2-2: Analyze whether the following requirements are met: ① In the current recursive relation, all variables must be variables declared in the variable declaration part of the recursive relation; ② The expression part requires that the data must be of the same type for operation, and numbers and Boolean types cannot be operated; ③ In the right half of the equation of the recursive relation, the function that appears can only be the function on the left side of the equation or the function on the left side of the equation in the previous recursive relation. If it is a function that appears later, it is considered undeclared. Similarly, if it does not meet the requirements, the error information (error type and error location) will be transmitted, marked as a semantic error, and error handling will be performed to tell the user the error information, quickly locate the error location of the code and then correct it; if it meets the requirements, continue scanning;

[0082] S2-3: During the scanning process, delete separators such as ";" and "|", and determine whether the function on the left side of the equation appears on the right side of the equation. If it appears, mark the recursive relationship as a recursive function; if it does not appear, mark it as a non-recursive function for code conversion, and finally obtain a simplified syntax tree and various related information, including tag information and the key-value pair data type in step S2-1.

[0083] With the simplified syntax tree, and the key-value pairs and list data storing the relevant information, code conversion can be performed based on these data. The code conversion in step S3 includes:

[0084] S3-1: According to the relevant information obtained in step S2, the function declaration part in the Isabelle function is obtained. The function declaration includes a declaration keyword (non-recursive function keyword or recursive function keyword), a function name, a function parameter type, and a function return value type. The declaration keyword can be determined from the tag information obtained in step S2 to determine whether it is a non-recursive function keyword or a recursive function keyword. If it is a non-recursive function, the non-recursive function keyword is obtained. If it is a recursive function, the recursive function keyword is obtained. The function name, function parameter type, and return value type can all be obtained from the key-value pair data type in step S2, wherein the function name does not need to be converted, and the function parameter type and return value type need to be converted to Isabelle type according to the variable type conversion rules in Table 3.

[0085] S3-2: According to the tag information obtained in step S2 and the simplified syntax tree, the function body part of the Isabelle function is obtained. First, determine whether the tag information is a non-recursive function or a recursive function:

[0086] ① If the tag is a non-recursive function, the left and right brackets are removed from the left side of the recursive relation, a space is added after the function name, all comma separators between input variables are replaced with spaces, and the input variables are converted into Isabelle variables according to the variable conversion rules in Table 2; the equal sign is replaced by ":="; if there is only one expression on the right side of the equation, it is directly converted into an expression in Isabelle according to the expression conversion rules in Table 1. If there are two expressions, "expression 1 {condition 1} | expression 2 {condition 2}" is converted into "if (condition 1) expression 1 else expression 2", and each expression and condition must be converted into an expression and condition in Isabelle according to the expression rules in Table 1. If there are more than two expressions, "expression 1 {condition 1} | expression 2 {condition 2} | ... | expression k {condition k}" is converted into "if (condition 1) expression 1 else if (condition 2) expression 2 else if ... else If (condition k-1) expression k-1 else expression k", similarly, each expression and condition should be converted into an expression and condition in Isabelle according to the expression conversion rules in Table 1.

[0087] ② If the tag is a recursive function, it is converted from "function name (input variable): = expression 1 {condition 1} | expression 2 {condition 2} | ... | expression k {condition k}" to "function name input variable 1 = expression 1 | ... | function name input variable k-1 = expression k-1 | function name input variable = expression k", where input variable 1 to input variable k-1 are all obtained by replacing the input variables according to the conditions corresponding to the expressions, expression k is a general case, and the input variable does not need to be replaced. In addition, all input variables and expressions are converted into Isabelle variables and expressions according to the variable conversion rules in Table 2 and the expression conversion rules in Table 1 respectively.

[0088] S3-3: Concatenate the function declaration part in step S3-1 and the function body part in step S3-2, separated by a carriage return, to obtain a complete Isabelle function.

[0089] Table 1 Expression conversion rules table

[0090]

[0091] Among them, the data may be an expression, a function, a variable, or a number. If the data is an expression, it is converted from the left side to the right side according to the conversion rules of Table 1. If the data is a function, it is converted by the conversion method of the function on the left side of the equation described in step ① of step S3-2. If the data is a variable, it is converted according to the conversion rules of Table 2. If the data is a number, no conversion is required.

[0092] Table 2 Variable conversion rules

[0093]

[0094] Among them, variables include single variables and compound variables. Compound variables can be nested, that is, the compound variable can be "list(list(list n))", then the conversion result according to the conversion rule is "(list(list(list n)))".

[0095] Table 3 Variable type conversion rules

[0096]

[0097] Isabelle's data type library already contains some commonly used data types, such as nat, int, float, set, list, and map, but there is no biological type data (DNA sequence, RNA sequence, etc.) and some basic operations. The converted results cannot run normally and are not enough to support the verification of biological sequence analysis algorithms. Therefore, the Isabelle theory converted from the recursive relationship still needs the support of the corresponding type library. Therefore, in order for the converted Isabelle theory to be used normally for algorithm verification, the present invention uses the ML language to define the biological sequence type, and then uses the RFGT tool to convert the BioSeq component into the Isabelle type, thereby realizing the conversion support from the recursive relationship of the biological sequence analysis algorithm to the Isabelle theory. The steps are as follows:

[0098] (1) First, define the base types of three biological sequences - DNA base DB, RNA base RB and protein base PB as follows:

[0099] DB=A|C|G|T

[0100] RB=A|C|G|T

[0101] PB=A|R|N|D|C|E|Q|G|H|I|L|K|M|F|P|S|T|W|Y|V|U|O|X

[0102] The right side of the equation is the base type, such as the bases of DNA are adenine A, cytosine C, guanine G, and thymine T.

[0103] (2) The designed unified recursive relation grammar is used to express the recursive formula of the three functions in the component BioSeq. The functions of the three functions are as follows: ① Penalty rule function. When the two paired bases are vacant, the score is 0; when one of the bases is vacant, the score is -2; when both bases are not vacant and are the same, the score is 1; when both bases are not vacant and are different, the score is -1; ② Single column alignment score function. The bases of the three sequences are paired, and the penalty rule function is called to calculate the sum of the scores; ③ Subproblem computability function. If the subproblem is computable, the score is the score of the current subproblem. If the subproblem is not computable, the score is the lowest score. Here, -100 is used to represent the lowest score.

[0104] (3) The recursive relationship of the three functions in the BioSeq component is used as input, and the Isabelle function is generated using the RFGT tool. The file is exported as the RecurType.thy theory file and saved in the Isabelle installation root directory. For subsequent verification, it only needs to reference RecurType as the parent theory in the header and it can be used directly.

[0105] In order to make the tool more practical and easy to use, the present invention designs a simple, intuitive and easy-to-use user interface. Non-essential elements are removed, leaving only the most important input, conversion and output functions in the tool, and the input and output are placed in the same interface, allowing users to understand the conversion effect between the recursive relationship and Isabelle's theory more quickly and intuitively, and to modify and optimize more efficiently when necessary.

[0106] Compared with completely manual verification, using the RFGT tool saves the time of manually converting recursive relations into Isabelle functions, allowing verifiers to start writing verification code directly and focus their energy on algorithm verification rather than low-level code conversion.

[0107] Reference Figure 2 , a recursive relation conversion tool for biological sequence analysis algorithm, including: a recursive relation module, the purpose of which is to convert a single recursive relation input into a corresponding Isabelle function, and to determine whether to call a non-recursive function module or a recursive function module according to the grammatical structure information obtained by semantic analysis. If a non-recursive function module is called, the conversion result is the conversion result of the non-recursive function module; if a recursive function module is called, the conversion result is the conversion result of the recursive function module. If the conversion result of a submodule is to be used in the splicing process below, it means that there is a calling relationship, and each item will not be explained one by one.

[0108] The non-recursive function module is used to convert the recursive relations marked as non-recursive functions in semantic analysis into non-recursive functions in Isabelle. The non-recursive function in Isabelle is as follows:

[0109] <Function declaration>

[0110] definitionFunction name::"Parameter type=>...=>Parameter type=>Return value type"where

[0111] <Non-recursive function body>

[0112] "Function name input variable...input variable = return value"

[0113] Among them, definition and where are keywords, and the conversion result of the non-recursive function module is the conversion result of the function declaration module concatenated with the conversion result of the non-recursive function body module.

[0114] The recursive function module is used to convert the recursive relation marked as a recursive function in semantic analysis into a recursive function in Isabelle. The recursive function in Isabelle is as follows:

[0115] <Function declaration>

[0116] fun function name:: "parameter type=>...=>parameter type=>return value type" where

[0117] <Recursive function body>

[0118] "Function name basic case 1 variable value = basic case 1 return value" |

[0119] ...|

[0120] "Function name basic case k variable value = basic case k return value" |

[0121] "Function name input variable...input variable = recursive case return value" |

[0122] Among them, definition and where are keywords. The basic case variable values ​​are the values ​​of the variables at the recursive function exit. For example, the variable i at the recursive function exit of the Fibonacci number fib(i) has values ​​of 1 and 2. The recursive case is the general case, and the return value is the result of the recursive expression. The conversion result of the recursive function module is the conversion result of the function declaration module concatenated with the conversion result of the recursive function body module.

[0123] The function declaration module is used to convert the function declaration part. The uncertain parts are the definition / fun keywords, parameter types and return value types. The keyword part can be determined by the semantic analysis mark to determine whether it is converted into definition or fun. The parameter type and return value type of the recursive relationship can be obtained through the variable name list and function name in the key-value pair type. Here, the variable type module needs to be called to obtain the Isabelle type, and finally the various results are spliced ​​into the form of the above function declaration.

[0124] The recursive function body module is divided into two parts: the left side of the equation and the right side of the equation. The left side of the equation temporarily calls the function module, and then replaces the function parameters according to the conditions of each expression. Else indicates the general situation, the function parameters remain unchanged, and the expression module is called on the right side of the equation. The recursive function body module conversion rules are as follows:

[0125] f(c)=e1{c1}|e2{c2}|…|e k {else}=>f C1=E1|f C2=E2|...|f C=e k

[0126] Among them, e1, e2, …, e k are the 1st, 2nd, ..., kth expressions, E1, E2, ..., E k are the results of calling the expression module respectively; c, c1 and c2 are the conditions of the expression, and C, C1 and C2 are the results of calling the conditional module; else is a special conditional statement defined, which represents other situations of all conditional disjunctions.

[0127] The non-recursive function body module is also divided into the conversion of the left side of the equation and the right side of the equation. The left side of the equation can call the function module. If the right side of the equation is only an expression, the mathematical expression module or the Boolean expression module is directly called. If there are multiple expressions, the conversion rules are as follows:

[0128] e1{c1}|e2{else}=>if C1 E1 else E2

[0129] e1{c1}|e2{c2}|…|e k {else}=>if C1 E1 else if C2 E2…else E k

[0130] The else in the conversion result is a keyword, which means otherwise in Isabelle.

[0131] The conditional module is used to convert the condition corresponding to each expression into Isabelle's logical statement, extract the condition in the brackets {}, that is, the Boolean expression, and the output result of the conditional module is the output result of calling the Boolean expression module.

[0132] The mathematical expression module is used to convert the mathematical expression in the recursive relation into the corresponding expression in Isabelle; the Boolean expression module is used to convert the Boolean expression in the recursive relation into the corresponding expression in Isabelle; the mathematical expression module and the Boolean expression module are collectively referred to as the expression module. In the conversion process, the priority of operators and the difference in the writing order of functions are taken into consideration. The conversion rules of the expression module are unified as follows:

[0133] e=>E, if e is an expression;

[0134] e=>F, if e is a function;

[0135] e=>V, if e is a variable;

[0136] e=>N, if e is a number;

[0137] max(e1,e2)=>(max E1 E2), maximum value operation expression;

[0138] min(e1,e2)=>(min E1 E2), minimum value operation expression;

[0139] e1 op e2=>(E1 op E2), general operation expression;

[0140] Among them, max means taking the maximum value between the two, and min means taking the minimum value between the two; op is a number operator including +, -, ×, ÷, etc. and a logic operator including ∧, ∨, and, or, etc., and the data must be of the corresponding type; F, V, and N are the conversion results of the function, variable, and number calling the corresponding module respectively. Because an expression may be an operation of another expression and other data, the mathematical expression module and the Boolean expression module are set to be callable themselves.

[0141] Function module is used to convert the function in the recursive relation to the corresponding function in Isabelle. During the conversion process, it is necessary to consider the function parameters, return value type, and function call method. The function module conversion rules are as follows:

[0142] f(v1,v2,…,v k )=>f V1 V2…V k ;

[0143] Where f is the function name; v1, v2, …, v k are variable parameters, V1, V2, …, V k The result of the transformation for which the variable module was called.

[0144] The variable module is used to implement variable conversion. It chooses to call a single variable submodule or a compound variable submodule according to the syntax tree. The conversion rules of the variable module are as follows:

[0145] sv=>SV, single variable;

[0146] cv(v)=>V CV, composite variable;

[0147] Among them, v represents a set of single variables and compound variables, sv represents a single variable, cv represents a compound variable, and V, SV and CV are the results of their conversion according to the conversion rules in the conversion rule table.

[0148] The variable type module is used to convert the variable type in the recursive relationship into the equivalent Isabelle theory type. The conversion is performed according to the variable type conversion rules. The data in the variable type conversion rule table is stored in the key-value pair data type in the form of a string. When a variable type is encountered, the variable type module is called to obtain the corresponding Isabelle theory type data according to the variable type key-value pair data of the recursive relationship.

[0149] In another embodiment, a non-volatile computer storage medium is provided, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions can execute a biological sequence analysis algorithm recursive relationship conversion method in the above embodiment.

[0150] This embodiment provides a biological sequence analysis algorithm recursive relationship conversion system, including: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above-mentioned biological sequence analysis algorithm recursive relationship conversion method.

[0151] The specific implementation scheme described above further illustrates the purpose, technical scheme and technical effect of the present invention in detail. It should be understood that the above description is only a specific implementation scheme of the present invention and is not intended to limit the scope of the present invention. Any equivalent changes and modifications made by any technician in the field without departing from the ideas and principles of the present invention should fall within the scope of protection of the present invention.

Claims

1. A biological sequence analysis algorithm recursive relationship conversion method, characterized in that: The following steps are involved: S1. The recursive relation to be converted is subjected to lexical analysis and grammatical analysis to determine whether it conforms to the lexical and grammatical rules written based on the grammatical analysis generation tool. If it conforms, a grammatical tree of the recursive relation is obtained; If it does not meet the requirements, an error message is transmitted and error handling is performed; S2. Perform semantic analysis on the syntax tree of each recursive relation to determine whether it complies with the semantics, that is, whether the type of the declaration part is consistent with the recursive relation part and whether it satisfies the operation rules of the expression. If so, cut off unnecessary branches to obtain a simplified syntax tree and related information such as variable declaration; If it does not meet the requirements, an error message is transmitted and error handling is performed; S3, code conversion is performed according to the number of recursive relations, and an equivalent number of Isabelle functions are obtained based on simplified syntax and related information in each loop; S4. Supplement the necessary header and tail of the Isabelle function to form a complete Isabelle theory, and finally output the Isabelle theory file.

2. The biological sequence analysis algorithm recursive relationship conversion method according to claim 1, characterized in that: In step S1, the input recursive relationship character sequence is scanned by a lexical analyzer, and the characters are marked and classified according to predefined lexical rules. If an unrecognizable mark is encountered, it is regarded as a lexical error and error processing is performed; If not encountered, the input recursive relation character sequence is converted into a tag sequence.

3. The biological sequence analysis algorithm recursive relationship conversion method according to claim 1, characterized in that: The lexical analyzer is automatically generated by the syntax analysis generation tool according to the written lexical.

4. The biological sequence analysis algorithm recursive relationship conversion method according to claim 1, characterized in that: The grammar is the grammatical form of a recursive relation, which is divided into two parts: declaration and recursive relation. The declaration part is as follows: |[in: variable declaration; out: function declaration]| Among them, in and out are keywords, the variable declaration specifies all the variable names mentioned in the recursive relationship and their corresponding variable types, and the function declaration specifies the function name and the type of its calculation result.

5. The biological sequence analysis algorithm recursive relationship conversion method according to claim 4, characterized in that: The recursive relation part has the following two forms: Function name (input variable): = expression, only one expression; Function name (input variable): = expression {condition} | ... | expression {condition}, there are multiple expressions; The whole of function name (input variables) is called a function, where input variables include the set of all input variables; When there is only one expression on the right side of the equation, the corresponding condition is omitted. When there are multiple expressions, it is required to indicate the conditions under which the recursive function takes the value of the expression, corresponding to the two forms of the recursive relation respectively; The expression is a Boolean expression or a mathematical expression. The condition is a Boolean expression. When the Boolean expression is true, the result is the operation value of the expression corresponding to the condition. Expressions are operations between basic data, variables, and functions.

6. The biological sequence analysis algorithm recursive relationship conversion method according to claim 5, characterized in that: The semantic analysis in step S2 includes: S2-1: Scan the syntax tree of the recursive relation from front to back, and store the scanned variables, variable types, functions, and function types into key-value pair data types, with variable names and function names as key data and corresponding types as value data; S2-2: Analyze whether the following requirements are met: ① In the current recursive relation, all variables must be variables declared in the variable declaration part of the recursive relation; ② The expression part requires that the data must be of the same type for operation, and numbers and Boolean types cannot be operated; ③ In the right half of the equation of the recursive relation, the function that appears can only be the function on the left side of the equation or the function on the left side of the equation in the previous recursive relation. If it is a function that appears later, it is considered undeclared; similarly, if it does not meet the requirements, an error message will be transmitted, marked as a semantic error, and error handling will be performed to tell the user the error message, quickly locate the code error location and correct it; if it meets the requirements, continue scanning; S2-3: During the scanning process, delete separators such as ";" and "|", and determine whether the function on the left side of the equation appears on the right side of the equation. If it appears, mark the recursive relationship as a recursive function; if it does not appear, mark it as a non-recursive function for code conversion, and finally obtain a simplified syntax tree and various related information, including tag information and the key-value pair data type in step S2-1.

7. The biological sequence analysis algorithm recursive relationship conversion method according to claim 6, characterized in that: The code conversion in step S3 includes: S3-1: According to the relevant information obtained in step S2, the function declaration part in the Isabelle function is obtained. The function declaration includes a declaration keyword, a function name, a function parameter type, and a function return value type. The declaration keyword is determined from the tag information obtained in step S2 to be a non-recursive function keyword or a recursive function keyword. If it is a non-recursive function, the non-recursive function keyword is obtained. If it is a recursive function, the recursive function keyword is obtained. The function name, function parameter type, and return value type are all obtained from the key-value pair data type in step S2, wherein the function name does not need to be converted, and the function parameter type and return value type need to be converted to the Isabelle type according to the variable type conversion rules; S3-2: According to the tag information obtained in step S2 and the simplified syntax tree, the function body part of the Isabelle function is obtained. First, determine whether the tag information is a non-recursive function or a recursive function: ① If the tag is a non-recursive function, the left and right brackets of the recursive relation are removed, a space is added after the function name, and the comma separators between all input variables are replaced with spaces. The input variables are converted into Isabelle variables according to the variable conversion rules; the equal sign is replaced by ":="; if there is only one expression on the right side of the equation, it is directly converted into an expression in Isabelle according to the expression conversion rules in the expression conversion rule table. If there are two expressions, "expression 1{condition 1}|expression 2{condition 2}" is converted into "if(condition 1)expression 1elseexpression 2", and each expression and condition must be converted into an expression and condition in Isabelle according to the expression rules in Table 1. If there are more than two expressions, "expression 1{condition 1}|expression 2{condition 2}|…|expression k{condition k}" is converted into "if(condition 1)expression 1else if(condition 2)expression 2else if…else if(condition k-1)expression k-1elseexpression k", and similarly, each expression and condition must be converted into an expression and condition in Isabelle according to the expression conversion rules in Table 1; ② If the tag is a recursive function, then "function name (input variable): = expression 1 {condition 1} | expression 2 {condition 2} | ... | expression k {condition k}" is converted to "function name input variable 1 = expression 1 | ... | function name input variable k-1 = expression k-1 | function name input variable = expression k", where input variable 1 to input variable k-1 are all obtained by replacing the input variables according to the conditions corresponding to the expressions, and expression k is a general case, and the input variable does not need to be replaced. In addition, all input variables and expressions are converted into Isabelle variables and expressions according to the variable conversion rules and expression conversion rules respectively; S3-3: Concatenate the function declaration part in step S3-1 and the function body part in step S3-2, separated by a carriage return, to obtain a complete Isabelle function.

8. A biological sequence analysis algorithm recursive relationship conversion tool, characterized in that: include: The recursive relation module is used to convert a single recursive relation input into a corresponding Isabelle function. It determines whether to call a non-recursive function module or a recursive function module based on the grammatical structure information obtained from the semantic analysis. If a non-recursive function module is called, the conversion result is the conversion result of the non-recursive function module; if a recursive function module is called, the conversion result is the conversion result of the recursive function module. The non-recursive function module is used to convert recursive relations marked as non-recursive functions in semantic analysis into non-recursive functions in Isabelle; The recursive function module is used to convert recursive relations marked as recursive functions in semantic analysis into recursive functions in Isabelle; Function declaration module is used to convert the function declaration part. The uncertain part is the definition / fun keyword, parameter type and return value type. The keyword part can be determined by the semantic analysis mark to determine whether it is converted into definition or fun. The parameter type and return value type of the recursive relationship are obtained through the variable name list and function name in the key-value pair type. Here, the variable type module needs to be called to obtain the Isabelle type, and finally the various results are spliced ​​into the above function declaration form; The recursive function body module is divided into two parts: the left side of the equation and the right side of the equation. The left side of the equation temporarily calls the function module, and then replaces the function parameters according to the conditions of each expression. Else indicates the general situation, the function parameters remain unchanged, and the expression module is called on the right side of the equation. The recursive function body module conversion rules are as follows: f(c)=e1{c1}|e2{c2}|…|e k {else}=>f C1=E1|f C2=E2|...|f C=e k Among them, e1, e2, …, e k are the 1st, 2nd, ..., kth expressions, E1, E2, ..., E k are the results of calling the expression module respectively; c, c1 and c2 are the conditions of the expression, and C, C1 and C2 are the results of calling the conditional module; else is a special conditional statement defined, indicating other situations of all conditional disjunctions; The non-recursive function body module is also divided into the conversion of the left side of the equation and the right side of the equation. The left side of the equation can call the function module. If the right side of the equation is only an expression, the mathematical expression module or the Boolean expression module is directly called. If there are multiple expressions, the conversion rules are as follows: e1{c1}|e2{else}=>if C1 E1 else E2 e1{c1}|e2{c2}|…|e k {else}=>if C1 E1 else if C2 E2…else E k Among them, the else in the conversion result is a keyword, which means otherwise in Isabelle; The conditional module is used to convert the condition corresponding to each expression into Isabelle's logical statement and extract the condition in the brackets {}, that is, the Boolean expression. The output result of the conditional module is the output result of calling the Boolean expression module. The mathematical expression module is used to convert the mathematical expression in the recursive relation into the corresponding expression in Isabelle; the Boolean expression module is used to convert the Boolean expression in the recursive relation into the corresponding expression in Isabelle; the mathematical expression module and the Boolean expression module are collectively referred to as the expression module; the expression module conversion rules are unified as follows: e=>E, if e is an expression; e=>F, if e is a function; e=>V, if e is a variable; e=>N, if e is a number; max(e1,e2)=>(max E1 E2), maximum value operation expression; min(e1,e2)=>(min E1 E2), minimum value operation expression; e1 op e2=>(E1 op E2), general operation expression; Among them, max means taking the maximum value between the two, and min means taking the minimum value between the two; op is a numeric operator including +, -, ×, ÷, etc. and a logical operator including ∧, ∨, and, or, etc., and the data must be of the corresponding type; F, V and N are the conversion results of the corresponding modules of function, variable and number call respectively; Function module is used to convert the function in the recursive relation into the corresponding function in Isabelle. The function module conversion rules are as follows: <h2 style=";text-align:left;direction:ltr">f(v1,v2,…,v<h2 style=";text-align:left;direction:ltr"> k <h2 style=";text-align:left;direction:ltr"> )=>f V1 V2…V<h2 style=";text-align:left;direction:ltr"> k <h2 style=";text-align:left;direction:ltr"> ; Where f is the function name; v1, v2, …, v k are variable parameters, V1, V2, …, V k The result of the conversion for which the variable module is called; The variable module is used to implement variable conversion. It chooses to call a single variable submodule or a compound variable submodule according to the syntax tree. The conversion rules of the variable module are as follows: sv=>SV, single variable; cv(v)=>V CV, composite variable; Wherein, v represents a set of single variables and composite variables, sv represents a single variable, cv represents a composite variable, and V, SV, and CV are the results of their conversion according to the conversion rules in the conversion rule table. The variable type module is used to convert the variable type in the recursive relationship into the equivalent Isabelle theory type. The conversion is performed according to the variable type conversion rules. The data in the variable type conversion rule table is stored in the key-value pair data type in the form of a string. When a variable type is encountered, the variable type module is called to obtain the corresponding Isabelle theory type data according to the variable type key-value pair data of the recursive relationship.

9. A non-volatile computer storage medium, characterized in that: The computer storage medium stores computer executable instructions, which execute the biological sequence analysis algorithm recursive relationship conversion method described in any one of claims 1 to 7.

10. A biological sequence analysis algorithm recursive relationship conversion system, comprising: At least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, characterized in that the instructions are executed by the at least one processor so that the at least one processor executes a recursive relationship conversion method for a biological sequence analysis algorithm as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Intelligent contract compiling method suitable for formal verification

    CN109753288A

  • Large-scale code data feature extraction method and system

    CN117113347A

  • Method for implementing compiled embedded python

    US20230075927A1

  • Method for parsing programming languages and structured data

    US9684496B1