• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

J4 ›› 2010, Vol. 32 ›› Issue (3): 119-123.doi: 10.3969/j.issn.1007130X.2010.

• 论文 • 上一篇    下一篇

后序遍历二叉树非递归算法的推导及形式化证明

左正康, 游珍, 薛锦云   

  1. ( 江西师范大学省高性能计算技术重点实验室,江西 南昌 330022)
  • 收稿日期:2008-03-24 修回日期:2009-07-06 出版日期:2010-03-10 发布日期:2010-03-10
  • 通讯作者: 左正康 E-mail:kerrykaren@126.com
  • 作者简介:左正康(1980),男,江西临川人,博士生,讲师,CCF学生会员(E20009770G),研究方向为软件形式化;游珍,硕士生;薛锦云,教授,博士生导师。

Derivation and Formal Proof of NonRecursive Postorder BinaryTree Traversal Algorithm

ZUO Zheng-Kang, LIU Zhen, XUE Jin-Yun   

  1. (Key Laboratory for HighPerformance Computing Technology,Jiangxi Normal University,Nanchang 330022)
  • Received:2008-03-24 Revised:2009-07-06 Online:2010-03-10 Published:2010-03-10
  • Contact: ZUO Zheng-Kang E-mail:kerrykaren@126.com

摘要: 开发涉及非线性数据结构算法程序的循环不变式一直是形式化方法的难点。本文使用PAR方法开发循环不变式的新策略,对后序遍历二叉树问题循环不变式的开发使用递归定义技术,得到了该问题循环不变式的简单精确的表达形式,简化了算法程序的推导和证明过程;利用PAR平台提供的抽象程序设计语言Ap1a中的数据抽象机制,使所得的算法程序结构简洁清晰且易于证明;最后,使用DijkstraGries标准程序证明法形式证明了该问题的核心算法程序(只有4行代码),并使用PAR平台将Apla程序转换成正确的C++代码。实例的成功进一步说明PAR方法提供的循环不变式的开发技术对推导和证明非线性数据结构算法程序的有效性。

关键词: 后序遍历二叉树, 循环不变式, PAR方法, 非线性数据结构, DijkstraGries标准程序证明法

Abstract: Developing loop invariants of algorithms containing nonlinear data structure is generally regarded as a difficult problem. In this paper, new strategies for developing loop invariant are introduced, and an exact and simple loop invariant of the nonrecursive postorder binarytree traversal algorithm is worked out by adopting the recursive definition technique of loop invariants and ideas of partitionandrecur. The approach considerably simplifies the process of derivation and proof of the nonrecursive algorithm and avoids the blindness of developing the loop invariant. Using datatype abstraction of Apla language, which is a part of PAR, the result algorithmic program is pretty concise and easy to be proved. Finally, the core algorithm (just 4 lines in Apla) is successfully proved by DijkstraGries standard proving technique, and the abstract program is transformed into C++ program by PAR platform. It is demonstrated that the recursive definition technique of loop invariant is feasible and effective for deriving and proving nonlinear data structure algorithms.

Key words: postorder binarytree traversal;loop invariant;PAR method;nonlinear data structure;DijkstraGries standard proving technique

中图分类号: