计算机科学 ›› 2023, Vol. 50 ›› Issue (9): 108-116.doi: 10.11896/jsjkx.220700214

• 计算机软件 • 上一篇    下一篇

基于迭代轨迹划分的单分支循环程序终止性分析

王垚1,2, 李轶1   

  1. 1 中国科学院重庆绿色智能技术研究院自动推理与认知重庆市重点实验室 重庆 400714
    2 中国科学院大学重庆学院 重庆 400714
  • 收稿日期:2022-07-24 修回日期:2022-11-30 出版日期:2023-09-15 发布日期:2023-09-01
  • 通讯作者: 李轶(zm_liyi@163.com)
  • 作者简介:(wangyao@cigit.ac.cn)
  • 基金资助:
    国家自然科学基金(61572024,11771421,61103110);重庆市自然科学基金(cstc2019jcyj-msxmX0638);重庆市院士专项(cstc2018jcyj-yszxX0002,cstc2019yszx-jcyjX0003);国家重点研发计划(2020YFA07123000);中国科学院“西部之光”

Termination Analysis of Single Path Loop Programs Based on Iterative Trajectory Division

WANG Yao1,2, LI Yi1   

  1. 1 Chongqing Key Laboratory of Automated Reasoning and Cognition,CIGIT,CAS,Chongqing 400714,China
    2 Chongqing School,University of Chinese Academy of Sciences,Chongqing 400714,China
  • Received:2022-07-24 Revised:2022-11-30 Online:2023-09-15 Published:2023-09-01
  • About author:WANG Yao,born in 1997,postgra-duate.Her main research interest is program verification.
    LI Yi,born in 1980,Ph.D,associate professor.His main research interests include program verification and symbolic computation.
  • Supported by:
    National Natural Science Foundation of China(61572024,11771421,61103110),National Science Foundation of Chongqing,China(cstc2019jcyj-msxmX0638),Chongqing Science and Technology Innovation Guidance Special Project(cstc2018jcyj-yszxX0002,cstc2019yszx-jcyjX0003),National Key Research and Development Program of China(2020YFA07123000) and Chinese Academy of Sciences “Light of West China” program.

摘要: 秩函数作为循环程序终止性分析的重要方法已得到广泛研究。文中着重研究了单分支循环的终止性。首先提出了双向迭代循环概念,将单分支循环分为双向迭代循环和非双向迭代循环。其次,针对双向迭代循环程序,建立了一种划分思路,提出了三段式秩函数的概念,并证明了若该双向迭代循环存在三段式秩函数,则其是终止的。而对非双向迭代循环,引用增函数的划分思路,即利用增函数将原程序空间划分为更小的空间,并通过计算更小空间上的秩函数来证明原程序的终止性。最后,将三段式秩函数的计算问题归结为SVM分类问题,并利用工具Z3或bottema对由SVM所得的候选秩函数进行验证。

关键词: 程序验证, 秩函数, 机器学习, 程序终止性

Abstract: The ranking function has been extensively studied as an important method of program termination analysis.In this paper,we focus on the termination of single-path loops.Firstly,the concept of two-way iterative loops is proposed,and the single-path loops are divided into bidirectional iterative loops and non-bidirectional iterative loops.Secondly,for the bidirectional iterative loop program,a division method and concept of trivial ranking function are proposed,and it is proved that if a bidirectional iterative loop exists a trivial rank function,it is terminated.As for the non-bidirectional iterative loop,we use incremental function as the division method,i.e.,the original program space is divided into smaller spaces by using incremental function,and the termination of the original program is proved by computing the ranking function on the smaller space.Finally,the problem of computing the trivial ranking function comes down to the SVM classification problem,and we verifies candidate ran-king functions using the tools Z3 or bottema.

Key words: Program verification, Ranking functions, Machine learning, Program termination

中图分类号: 

  • TP311
[1]COL'ON M A,SIPMA H B.Synthesis of Linear Ranking Functions[C]//International Conference on Tools and Algorithms for the Construction and Analysis of Systems.Berlin:Springer,2001:67-81.
[2]COL'ON M A,SIPMA H B.Practical Methods for Proving Program Termination[C]//International Conference on Computer Aided Verification.Berlin:Springer,2002:442-454.
[3]PODELSKI A,RYBALCHENKO A.A Complete Method forthe Synthesis of Linear Ranking Functions[C]//International Workshop on Verification,Model Checking,and Abstract Interpretation.Berlin:Springer,2004:239-251.
[4]BRADLEY A R,MANNA Z,SIPMA H B.The PolyrankingPrinciple[C]//International Colloquium on Automata,Languages,and Programming.Berlin:Springer,2005:1349-1361.
[5]BRADLEY A R,MANNA Z,SIPMA H B.Linear Ranking with Reachability[C]//Computer Aided Verification,17th International Conference,CAV 2005.Edinburgh,Scotland:DBLP,2005:491-504.
[6]BEN-AMRAM A M,GENAIM S.Ranking Functions forLinear-Constraint Loops[J].Journal of the ACM,2012,61(4):1-55.
[7]BAGNARA R,ESNARD F,PESCETTI A,et al.A new look at the automatic synthesis of linear ranking functions[J].Information and Computation,2012,215:47-67.
[8]BEN-AMRAM A M,GENAIM S,MASUD A N.On the Termination of Integer Loops[J].ACM Transactions on Programming Languages & Systems,2012,34(4):1-24.
[9]BAGNARA R,MESNARD F.Eventual Linear Ranking Func-tions [C]//Proceedings of the 15th Symposium on Principles and Practice of Declarative Programming.Madrid,Spain:ACM,2013:229-238.
[10]BEN-AMRAM A M,GENAIM S.On the Linear Ranking Pro-blem for Integer Linear-ConstraintLoops[J].ACM Sigplan Notices,2013,48(1):51-62.
[11]LEIKE J,HEIZMANN M,HOENICKE J,et al.Linear Ranking for Linear Lasso Programs.[C]//Automated Technology for Verification and Analysis.Cham:Springer,2013:365-380.
[12]LEIKE J,HEIZMANN M.Ranking Templates for Linear Loops[J].Logical Methods in Computer Science,2015,11(1):1-27.
[13]BEN-AMRAM A M,GENAIM S.On Multiphase-Linear Ran-king Functions[C]//International Conference on Computer Aided Verification.Cham:Springer,2017:601-620.
[14]BEN-AMRAM A M,DOMÉNECH J J,GENAIM S.Multi-phase-Linear Ranking Functions and their Relation to Recurrent Sets[C]//International Static Analysis Symposium.Cham:Springer,2018:459-480.
[15]COUSOT P.Proving Program Invariance and Termination byParametric Abstraction,Lagrangian Relaxation and Semidefinite Programming[C]//Verification,Model Checking,& Abstract Interpretation.Berlin:Springer,2005:1-24.
[16]CHEN Y,XIA B,LU Y,et al.Discovering Non-linear Ranking Functions by Solving Semi-algebraic Systems[C]//Theoretical Aspects of Computing-ICTAC 2007.2007:34-49.
[17]SHEN L,WU M,YANG Z,et al.Generating exact nonlinearranking functions by symbolic-numeric hybrid method[J].Journal of Systems Science and Complexity,2013,26(2):291-301.
[18]LI Y,ZHU G,FENG Y.The L-Depth Eventual Linear Ranking Functions for Single-Path Linear Constraint Loops[C]//The 10th International Symposium on Theoretical Aspects of Software Engineering.IEEE,2016:30-37.
[19]YUAN Y,LI Y.Ranking function detection via SVM:A more general method[J].IEEE Access,2019(7):9971-9979.
[20]LI Y,SUN X C,LI Y,et al.Synthesizing Nested Ranking Functions for Loop Programs via SVM[C]//International Confe-rence on Formal Engineering Methods.Cham:Springer,2019:438-454.
[21]SUN X C.Proving the Termination of Loop Programs based on SVM [D].Beijing:Institute of Software,Chinese Academy of Sciences,2020.
[22]GENAIM S.LoopKiller:website for termination analysis[EB/OL].http://loopkiller.com/irankfinder.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!