Formal verification is crucial in software engineering to ensure program correctness through mathematical proof. One widely used technique for this purpose is bounded model checking (BMC), which involves verifying the correctness of a program within specified bounds. Python, a programming language favored for its simplicity and extensive libraries, particularly in fields like web development, image processing, and artificial intelligence, presents unique challenges for formal verification. This is largely due to its dynamic nature and the lack of explicit type information, which is essential for traditional verification tools.
Verifying Python programs is inherently difficult because Python determines type information at runtime. This dynamic typing makes it hard for traditional static analysis tools to ascertain program correctness. Without explicit type annotations, ensuring the safety and correctness of Python programs, especially those in systems with critical security requirements, becomes a formidable task. This problem is exacerbated in large codebases or applications where security and reliability are paramount.
Traditional methods for verifying statically typed languages typically involve converting code into an intermediate representation that verification tools can analyze. For Python, some researchers have explored converting Python code into C to take advantage of existing C verification tools. However, this approach is often inefficient and impractical due to the fundamental differences between Python and C, such as Python’s dynamic features and C’s static typing requirements.
Researchers from the University of Manchester and TPV Technology have introduced ESBMC-Python, a novel tool designed to verify Python programs. ESBMC-Python utilizes the ESBMC framework, an efficient SMT-based bounded model checker, to formally verify Python code. This tool converts Python programs into abstract syntax trees (ASTs), then type-annotated and formatted to fit into the BMC pipeline. This transformation allows the verification of Python programs by overcoming the difficulties posed by Python’s dynamic typing.
The process employed by ESBMC-Python begins with parsing the Python source code to generate an AST. This AST is then annotated with type information, which is crucial for the subsequent steps. The annotated AST is translated into an intermediate representation that the ESBMC framework can process. This conversion involves translating Python expressions and statements into symbols that fit within the ESBMC’s model-checking structure. The tool effectively handles Python’s dynamic features by converting them into a format suitable for the BMC pipeline, enabling the verification of properties such as type correctness and logical consistency.
ESBMC-Python’s performance was rigorously evaluated using a benchmark suite comprising 85 Python programs. These programs covered many features in real-world Python applications, including arithmetic operations, conditionals, loops, user assertions, bitwise operations, classes, inheritance, and polymorphism. The evaluation results were impressive, with average verification times ranging from 24.5 milliseconds to 49.1 milliseconds and memory usage between 14.5 and 26.4 megabytes. These figures indicate that ESBMC-Python is efficient and can handle large codebases and extensive program sets in relatively short periods.
One of the standout achievements of ESBMC-Python was its ability to identify a critical division-by-zero error in the Ethereum consensus specification. This specification controls the Ethereum blockchain’s node inclusion, validation, and validator penalty processes. The error involved an unsigned integer overflowing to zero and subsequently being used as a divisor, which could have led to significant service interruptions and potential security vulnerabilities in the blockchain network. The successful identification and subsequent correction of this error by ESBMC-Python underscore its practical utility and effectiveness in real-world applications.
In conclusion, ESBMC-Python’s ability to identify critical errors, such as the division-by-zero issue in the Ethereum consensus specification, highlights its practical relevance and reliability. This tool ensures the safety and correctness of Python programs and provides a valuable benchmark for future verification tools. The research team plans to extend ESBMC-Python’s capabilities by including more features and enhancing the type inference algorithm to handle complex program flows.
Check out the Paper. All credit for this research goes to the researchers of this project. Also, don’t forget to follow us on Twitter.
Join our Telegram Channel and LinkedIn Group.
If you like our work, you will love our newsletter..
Don’t Forget to join our 46k+ ML SubReddit
The post Researchers at the University of Manchester Proposes ESBMC-Python: The First BMC-based Python-code Verifier for Formal Verification of Python Programs appeared first on MarkTechPost.