摘要
回溯机制是逻辑程序设计的重要设施。回溯本身是一种获得目标所有可能解的良好方法。在考察VisualProlog回溯机制作用原理的基础上,通过若干实例,详细阐述了回溯机制所遵循的4个基本原则,即自顶向下逐层搜索原则、从左到右顺序扫描原则、规则匹配原则、事实匹配原则,给出了回溯机制的循环实现方法,深入分析了回溯过程可能发生的各种情况,从而揭示出回溯机制的本质特性和应用机理。结论指出回溯机制具有副作用,需要利用截断机制、失败谓词等对搜索过程进行仔细控制。
The backtracking mechanism is an important facility for logic programming. The backtracking itself is a good approach to obtaining all the possible solutions to a goal. On the basis of observing and studying the operating elements of backtracking mechanism in Visual Prolog with a group of instances, the four fundamental principles, i.e. those of bottom - up, right - left sequencing, rule matching and fact matching, are expatiated in detail. A backtracking approach implemented by means of repetition is explored. All kinds of possible cases in the course of backtracking are deeply analyzed and investigated, thus the essential characteristics and the applied fundamentals of the backtracking mechanism are revealed. Finally, the conclusion indicates that the backtracking mechanism has side - effects, and it is necessary to control carefully the searching courses by using a cut mechanism, a fail predicate and otherwise.
出处
《空军工程大学学报(自然科学版)》
CSCD
2004年第5期80-84,共5页
Journal of Air Force Engineering University(Natural Science Edition)
基金
国家教育部高等学校骨干教师资助计划项目(GG-810-90039-1003)