arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.15674cs.PL
收藏

从混合通信顺序进程生成经过形式化验证的C代码

Formally Verified C Code Generation from Hybrid Communicating Sequential Processes

Shuling Wang, Zekun Ji, Bohua Zhan, Xiong Xu, Qiang Gao, Naijun Zhan

AI总结:

本文提出从HCSP到POSIX C的代码生成算法,通过定义形式化语义和近似互模拟关系证明生成代码的正确性,并在自动巡航控制模型上验证了其实用性。

摘要:

混合通信顺序进程(HCSP)是一种用于混合系统的形式化模型,包含沿常微分方程(ODE)演化、通信和并行组合的原语。需要代码生成来将HCSP模型转换为可在实践中执行的代码,而这种转换的正确性对于确保生成的代码准确反映形式化模型至关重要。在本文中,我们提出了一种从HCSP到使用POSIX库实现并发的C代码的代码生成算法。主要困难包括如何弥合HCSP中的同步通信模型与C中使用互斥锁进行同步之间的差距,以及如何离散化沿ODE的演化并支持通过通信中断ODE演化。为了证明代码生成的正确性,我们为POSIX C定义了形式化语义,并为HCSP和C程序构建了迁移系统模型。然后,我们定义了迁移系统轨迹之间的近似互模拟关系,并证明在HCSP满足一定鲁棒性条件下,生成的C程序与原始模型近似互模拟。最后,我们在一个详细的自动巡航控制模型上评估了该代码生成算法,展示了其在现实世界示例中的实用性。

英文摘要:

Hybrid Communicating Sequential Processes (HCSP) is a formal model for hybrid systems, including primitives for evolution along an ordinary differential equation (ODE), communication, and parallel composition. Code generation is needed to convert HCSP models into code that can be executed in practice, and the correctness of this conversion is essential to ensure that the generated code accurately reflects the formal model. In this paper, we propose a code generation algorithm from HCSP to C with POSIX library for concurrency. The main difficulties include how to bridge the gap between the synchronized communication model in HCSP and the use of mutexes for synchronization in C, and how to discretize evolution along ODEs and support interrupt of ODE evolution by communication. To prove the correctness of code generation, we define a formal semantics for POSIX C, and build transition system models for both HCSP and C programs. We then define an approximate bisimulation relation between traces of transition systems, and show that under certain robustness conditions for HCSP, the generated C program is approximately bisimilar to the original model. Finally, we evaluate the code generation algorithm on a detailed model for automatic cruise control, showing its utility on real-world examples.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑