首页> 外文会议>Proceedings of the ASIAN symposium on Partial evaluation and semantics-based program manipulation >On obtaining Knuth, Morris, and Pratt's string matcher by partial evaluation
【24h】

On obtaining Knuth, Morris, and Pratt's string matcher by partial evaluation

机译:通过部分评估获得Knuth,Morris和Pratt的字符串匹配器

获取原文
获取原文并翻译 | 示例

摘要

We present the first formal proof that partial evaluation of a quadratic string matcher can yield the precise behaviour of Knuth, Morris, and Pratt's linear string matcher.Obtaining a KMP-like string matcher is a canonical example of partial evaluation: starting from the naive, quadratic program checking whether a pattern occurs in a text, one ensures that backtracking can be performed at partial-evaluation time (a binding-time shift that yields a staged string matcher); specializing the resulting staged program yields residual programs that do not back up on the text, a la KMP. We are not aware, however, of any formal proof that partial evaluation of a staged string matcher precisely yields the KMP string matcher, or in fact any other specific string matcher.In this article, we present a staged string matcher and we formally prove that it performs the same sequence of comparisons between pattern and text as the KMP string matcher. To this end, we operationally specify each of the programming languages in which the matchers are written, and we formalize each sequence of comparisons with a trace semantics. We also state the (mild) conditions under which specializing the staged string matcher with respect to a pattern string provably yields a specialized string matcher whose size is proportional to the length of this pattern string and whose time complexity is proportional to the length of the text string. Finally, we show how tabulating one of the functions in this staged string matcher gives rise to the 'next' table of the original KMP algorithm.The method scales for obtaining other linear string matchers, be they known or new.
机译:我们提供了第一个形式证明,即对二次字符串匹配器进行部分评估可以得出Knuth,Morris和Pratt的线性字符串匹配器的精确行为。获得类似KMP的字符串匹配器是部分评估的典型示例:从天真的开始,二次程序检查文本中是否出现模式,以确保可以在部分求值时间(绑定时间偏移产生分段的字符串匹配器)执行回溯;对生成的分阶段程序进行专业化处理会产生残余程序,这些程序不会在文本上备份,例如KMP。但是,我们不知道有任何形式上的证明可以证明,对分阶段字符串匹配器的部分评估可以精确地产生KMP字符串匹配器,或者实际上是任何其他特定的字符串匹配器。在本文中,我们介绍了一个分阶段字符串匹配器,我们正式证明了它在模式和文本之间执行与KMP字符串匹配器相同的比较序列。为此,我们在操作上指定编写匹配器的每种编程语言,并使用跟踪语义对每个比较序列进行形式化。我们还陈述了(温和)条件,在这种条件下,相对于模式字符串专门化分级字符串匹配器可证明产生了一个专门的字符串匹配器,其大小与该模式字符串的长度成比例,并且时间复杂度与文本的长度成比例串。最后,我们展示了如何在此阶段化的字符串匹配器中列表函数之一如何产生原始KMP算法的``下一个''表。该方法可扩展以获得其他线性字符串匹配器(无论它们是已知的还是新的)。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号