Regular expressions are pervasive in modern systems. Many real-world regular expressions are inefficient, sometimes to the extent that they are vulnerable to complexity-based attacks, and while much research has focused on detecting inefficient regular expressions or accelerating regular expression matching at the hardware level, we investigate automatically transforming regular expressions to remove inefficiencies. We reduce this problem to general expression optimization, an important task necessary in a variety of domains even beyond compilers, e.g., digital logic design, etc. Syntax-guided synthesis (SyGuS) with a cost function can be used for this purpose, but ordered enumeration through a large space of candidate expressions can be prohibitively expensive. Equality saturation is an alternative approach which allows efficient construction and maintenance of expression equivalence classes generated by rewrite rules, but the procedure may not reach saturation, meaning global minimality cannot be confirmed. We present a new approach called rewrite-guided synthesis (ReGiS), in which a unique interplay between SyGuS and equality saturation-based rewriting helps to overcome these problems, resulting in an efficient, scalable framework for expression optimization.
翻译:许多现实世界的常规表达方式效率低下,有时甚至容易受到复杂的攻击,而且尽管许多研究侧重于发现效率低下的常规表达方式或加快硬件一级的常规表达方式匹配,但我们调查了常规表达方式的自动转换以消除效率低下;我们将此问题降低为一般表达优化,这是甚至汇编者以外的各个领域中的一项重要任务,例如数字逻辑设计等。 具有成本功能的语法引导合成(SyGuS)可以用于此目的,但通过大量候选表达方式按顺序进行查点可能费用极高。 平等饱和是一种替代方法,允许高效地构建和维护由重写规则产生的表达等同类,但程序可能达不到饱和度,这意味着全球最低程度无法确认。 我们提出了一个叫做重写制指导合成(ReGiS)的新方法,其中SyGuS与平等饱和度重写(Sygues)之间独特的相互作用有助于克服这些问题,导致一个高效、可伸缩的表达优化框架。