arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2503.10416cs.PLcs.DScs.PFcs.SC
收藏

在Prolog中推广运行时重复递归展开以实现超线性加速

Super-Linear Speedup by Generalizing Runtime Repeated Recursion Unfolding in Prolog

Thom Fruehwirth

AI总结:

本文将运行时重复递归展开从CHR中的单一线性直接递归规则推广到Prolog中的多重递归与多重递归规则,并用十个子句实现展开器、元解释器和轮转规则处理器,通过基准测试验证超线性加速的可行性。

摘要:

运行时重复递归展开最近被提出,作为一种即时程序转换策略,能够实现超线性加速。迄今为止,该方法仅限于约束处理规则(CHR)编程语言中的单一线性直接递归规则。在这篇配套论文中,我们将该技术推广到多重递归和多重递归规则,并在逻辑编程语言Prolog中提供了该推广方法的实现。该方法的基本思想如下:当在运行时遇到递归调用时,递归规则与自身进行展开,并且只要展开后的规则适用于当前调用,就对每个生成的展开规则重复这一过程。通过这种方式,越来越多的递归步骤被合并为一个递归步骤。然后,解释器从展开程度最高的规则开始,将这些规则应用于该调用。对于具有充分可简化展开的递归,可以实现超线性加速,即时间复杂度得以降低。我们实现了一个展开器、一个推广的元解释器以及一个新颖的轮转规则处理器,仅用Prolog中的十个子句就完成了对运行时重复递归展开的推广。我们通过最坏情况时间复杂度估计以及一些能够实现超线性加速的基本经典算法的基准测试,展示了该技术的可行性。

英文摘要:

Runtime repeated recursion unfolding was recently introduced as a just-in-time program transformation strategy that can achieve super-linear speedup. So far, the method was restricted to single linear direct recursive rules in the programming language Constraint Handling Rules (CHR). In this companion paper, we generalize the technique to multiple recursion and to multiple recursive rules and provide an implementation of the generalized method in the logic programming language Prolog. The basic idea of the approach is as follows: When a recursive call is encountered at runtime, the recursive rule is unfolded with itself and this process is repeated with each resulting unfolded rule as long as it is applicable to the current call. In this way, more and more recursive steps are combined into one recursive step. Then an interpreter applies these rules to the call starting from the most unfolded rule. For recursions which have sufficiently simplifyable unfoldings, a super-linear can be achieved, i.e. the time complexity is reduced. We implement an unfolder, a generalized meta-interpreter and a novel round-robin rule processor for our generalization of runtime repeated recursion unfolding with just ten clauses in Prolog. We illustrate the feasibility of our technique with worst-case time complexity estimates and benchmarks for some basic classical algorithms that achieve a super-linear speedup.

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

↑