arXiv:2511.13942cs.AIcs.DS2025-11

提出CORGI算法,解决规则匹配中的指数开销问题。

CORGI: Efficient Pattern Matching With Quadratic Guarantees

  • 采用图结构正向构建关系,反向迭代生成匹配结果
  • 在组合匹配任务中性能优于SOAR和OPS5的RETE实现
  • 支持流式输出后续匹配,内存占用仅为二次方

基于规则的系统需在实时应用中快速完成复杂匹配,如智能体规划与低延迟数据库查询。传统模式匹配系统在变量约束不足或产生组合型中间匹配时,可能出现指数级时间与空间消耗。当在线AI系统通过示例归纳生成规则时,易产生导致程序崩溃的最坏情况匹配模式。为此,本文提出CORGI(Collection-Oriented Relational Graph Iteration)算法,不同于RETE的β-内存机制,其通过前向构建接地关系图、后向迭代生成匹配的方式,实现单个满足解的二次时间与空间保证,并可无需将完整冲突集存入内存即流式输出后续匹配。性能评估显示,在简单组合匹配任务上,CORGI显著优于SOAR和OPS5的RETE实现。

原文摘要 · Abstract (English)

Rule-based systems must solve complex matching problems within tight time constraints to be effective in real-time applications, such as planning and reactive control for AI agents, as well as low-latency relational database querying. Pattern-matching systems can encounter issues where exponential time and space are required to find matches for rules with many underconstrained variables, or which produce combinatorial intermediate partial matches (but are otherwise well-constrained). When online AI systems automatically generate rules from example-driven induction or code synthesis, they can easily produce worst-case matching patterns that slow or halt program execution by exceeding available memory. In our own work with cognitive systems that learn from example, we've found that aggressive forms of anti-unification-based generalization can easily produce these circumstances. To make these systems practical without hand-engineering constraints or succumbing to unpredictable failure modes, we introduce a new matching algorithm called CORGI (Collection-Oriented Relational Graph Iteration). Unlike RETE-based approaches, CORGI offers quadratic time and space guarantees for finding single satisficing matches, and the ability to iteratively stream subsequent matches without committing entire conflict sets to memory. CORGI differs from RETE in that it does not have a traditional $β$-memory for collecting partial matches. Instead, CORGI takes a two-step approach: a graph of grounded relations is built/maintained in a forward pass, and an iterator generates matches as needed by working backward through the graph. This approach eliminates the high-latency delays and memory overflows that can result from populating full conflict sets. In a performance evaluation, we demonstrate that CORGI significantly outperforms RETE implementations from SOAR and OPS5 on a simple combinatorial matching task.

规则系统模式匹配算法优化内存效率

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。