基于Frama-C的希尔排序形式化验证
Formal Verification of Shell Sort Based on Frama-C
摘要: 希尔排序是一种基于间隔递减的经典排序算法,其正确性对软件可靠性至关重要。本文采用形式化方法,借助Frama-C平台及其ACSL规范语言,对希尔排序程序进行源代码级别的正确性验证。验证过程中的主要难点在于构造嵌套循环的循环不变式,以描述数组的有序性和元素排列性质。通过设计合适的循环不变式,并借助Alt-Ergo、CVC4、Z3等定理证明器进行验证,最终证明了希尔排序程序的功能正确性与内存安全性。
Abstract: Shell sort is a classic sorting algorithm based on decreasing intervals. Its correctness is crucial for software reliability. This paper uses a formal method and based on the Frama-C platform and its ACSL specification language, conducts source code-level correctness verification of the Shell sort program. The main difficulty in the verification process lies in constructing the loop invariants of nested loops to describe the order of the array and the arrangement properties of elements. By designing appropriate loop invariants and using theorem provers such as Alt-Ergo, CVC4, and Z3 for verification, the functional correctness and memory safety of the Shell sort program are ultimately proved.
参考文献
|
[1]
|
翟娟, 汤震浩, 李彬, 等. 常用循环摘要的自动生成方法及其应用[J]. 软件学报, 2017, 28(5): 1051-1069.
|
|
[2]
|
de Gouw, S. (2019) Verifying OpenJDK’s Sort Method for Generic Collections. Journal of Automated Reasoning, 62, 93-162.
|
|
[3]
|
Petrovic, D. (2014) Verification of Selection and Heap Sort Using Locales. Archive of Formal Proofs.
|
|
[4]
|
Drămnesc, I., Jebelean, T. and Stratulat, S. (2024) Certification of Sorting Algorithms Using Theorema and Coq. In: Lecture Notes in Computer Science, Springer, 38-56. [Google Scholar] [CrossRef]
|
|
[5]
|
Hoare, C.A.R. (1969) An Axiomatic Basis for Computer Programming. Program Verification: Fundamental Issues in Computer Science, 14, 83-96.
|
|
[6]
|
Correnson, L., Dargaye, Z. and Pacalet, A. (2015) Frama-C’s WP Plug in Manual. https://www.frama-c.com/download/frama-c-wp-manual.pdf
|
|
[7]
|
Baudin, P., Cuoq, P., Filliâtre, J.C., et al. (2020) ANSI/ISO C Specification Language. Version 1.16.
|