arXiv:2602.19743cs.FLcs.CL2026-02

用自然语言描述形式语言,能自动判断对错并解释原因。

NILE: Formalizing Natural-Language Descriptions of Formal Languages

  • 设计语法贴近自然语言的表达语言Nile,支持精准匹配描述与形式化表达
  • 大模型将自然语言描述转为近似结构的Nile表达式,准确率达高
  • 适合教育场景中自动评估学生对形式语言的理解并给出可读解释

本文研究自然语言对形式语言的描述如何与形式化表示对比,并解释语义差异。动机源于教育场景:学习者用自然语言描述由有限状态自动机、正则表达式、下推自动机、上下文无关文法或集合记号呈现的形式语言时,教育系统需判断描述是否准确,并解释错误原因。为此,我们提出一种形式语言表达语言Nile,其语法结构可映射自然语言描述。Nile足够强大,可覆盖所有正则语言及教育中常见的上下文无关语言片段。生成与自然语言描述在句法上相近的Nile表达式后,可算法化地提供不准确描述的解释。在教育数据集上的实验表明,大模型能以高准确率将自然语言描述转化为等价且句法接近的Nile表达式,从而实现自动化解释。相比之下,虽可将描述转为正则表达式(但无法处理上下文无关文法),但结果句法差异大,不适合作解释。

原文摘要 · Abstract (English)

This paper explores how natural-language descriptions of formal languages can be compared to their formal representations and how semantic differences can be explained. This is motivated from educational scenarios where learners describe a formal language (presented, e.g., by a finite state automaton, regular expression, pushdown automaton, context-free grammar or in set notation) in natural language, and an educational support system has to (1) judge whether the natural-language description accurately describes the formal language, and to (2) provide explanations why descriptions are not accurate. To address this question, we introduce a representation language for formal languages, Nile, which is designed so that Nile expressions can mirror the syntactic structure of natural-language descriptions of formal languages. Nile is sufficiently expressive to cover a broad variety of formal languages, including all regular languages and fragments of context-free languages typically used in educational contexts. Generating Nile expressions that are syntactically close to natural-language descriptions then allows to provide explanations for inaccuracies in the descriptions algorithmically. In experiments on an educational data set, we show that LLMs can translate natural-language descriptions into equivalent, syntactically close Nile expressions with high accuracy - allowing to algorithmically provide explanations for incorrect natural-language descriptions. Our experiments also show that while natural-language descriptions can also be translated into regular expressions (but not context-free grammars), the expressions are often not syntactically close and thus not suitable for providing explanations.

形式语言自然语言教育AI语义解释

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